123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace refill\huiyuan;
- require_once(BASE_HELPER_RAPI_PATH . '/huiyuan/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)
- {
- $agent_id = config::AGENT_ID;
- $key = config::KEY;
- $content = "agent_id={$agent_id}&bill_id={$params['bill_id']}&jnet_bill_no={$params['jnet_bill_no']}&par_price={$params['par_price']}&purchase_amt={$params['purchase_amt']}";
- $content .= "&bill_charge_time={$params['bill_charge_time']}&bill_status={$params['bill_status']}|||{$key}";
- return md5($content);
- }
- public function notify($params)
- {
- $status = $params['bill_status'];
- $order_sn = $params['bill_id'];
- $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 === '成功') {
- return [$order_id, true, false,true];
- }
- elseif ($status === '失败') {
- return [$order_id, false, true,true];
- }
- else {
- return [$order_id, false, false,false];
- }
- }
- }
|