1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace refill\sohan_fast;
- require_once(BASE_HELPER_RAPI_PATH . '/sohan_fast/config.php');
- use refill;
- class RefillCallBack implements refill\IRefillCallBack
- {
- private function sign($params) : string
- {
- //MD5(Orderid=SH2009_05150001&Chargeid=2893131209&Orderstatu_int=16&Errorcode=0000&Password=0FE8E43F53BB5848)
- $keys = ['Orderid','Chargeid','Orderstatu_int','Errorcode','Password'];
- $body = '';
- foreach ($keys as $key)
- {
- if($key == 'Password') {
- $body .= "$key=" . config::appSecret;
- }
- else{
- $body .= "$key=$params[$key]&";
- }
- }
- return md5($body);
- }
- public function verify($params): bool
- {
- $sign = $this->sign($params);
- if ($params['Sign'] == $sign) {
- return true;
- } else {
- return false;
- }
- }
- //[$order_id, $success, $can_try, $need_handle, $official_sn]
- public function notify($params): array
- {
- $order_sn = $params['Orderid'];
- $ch_trade_no = $params['Chargeid'];
- $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
- if (empty($order_info)) {
- return [false, false, false, false, ''];
- }
- $order_id = $order_info['order_id'];
- $status = intval($params['Orderstatu_int']);
- if (in_array($status, [11, 16])) {
- $official_sn = config::get_osn($params['Orderstatu_text']);
- Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no, 'official_sn' => $official_sn]);
- return [$order_id, true, false, true, $official_sn];
- }
- elseif (in_array($status, [20, 21, 26])) {
- Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
- return [$order_id, false, true, true, ''];
- }
- else {
- return [$order_id, false, false, false, ''];
- }
- }
- }
|