12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace refill\yanhao;
- require_once(BASE_HELPER_RAPI_PATH . '/yanhao/config.php');
- use refill;
- class RefillCallBack implements refill\IRefillCallBack
- {
- public function verify($params): bool
- {
- $sign = $this->sign($params);
- if ($params['Sign'] == $sign) {
- return true;
- } else {
- return false;
- }
- }
- private function sign($params)
- {
- $user_id = config::USER_ID;
- $key = config::Key;
- $content = "{$user_id}{$params['TimesTamp']}{$params['OutOrderID']}{$params['UserOrderId']}{$params['Status']}{$key}";
- return strtoupper(md5($content));
- }
- //[$order_id, $success, $can_try, $need_handle]
- public function notify($params)
- {
- $status = intval($params['Status']);
- $order_sn = $params['UserOrderId'];
- $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
- if (empty($order_info)) {
- return [false, false, false,false];
- }
- $order_id = $order_info['order_id'];
- if ($status === 2) {
- return [$order_id, true, false, true];
- } elseif ($status === 3) {
- return [$order_id, false, true, true];
- } else {
- return [$order_id, false, false, false];
- }
- }
- }
|