123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace refill\guochuang_nation_trd;
- require_once(BASE_HELPER_RAPI_PATH . '/guochuang_nation_trd/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)
- {
- $key = config::ApiKey;
- $content = "{$params['body']}&ts={$params['ts']}&key={$key}";
- return strtoupper(md5($content));
- }
- public function notify($params)
- {
- $params = json_decode($params['body'], true);
- $status = $params['status'];
- $order_sn = $params['outerId'];
- $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 === 'SUCCESS') {
- $official_sn = strtolower($params['evidence']) == 'null' ? '' : $params['evidence'];
- $data['official_sn'] = $official_sn;
- Model('refill_order')->edit($order_id, $data);
- return [$order_id, true, false, true, $official_sn];
- } elseif ($status === 'FAIL') {
- return [$order_id, false, true, true, ''];
- } else {
- return [$order_id, false, false, false, ''];
- }
- }
- }
|