1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace refill\masheng;
- require_once(BASE_HELPER_RAPI_PATH . '/masheng/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): string
- {
- $userid = config::USER_ID;
- $key = config::KEY;
- $content = "agent_id=$userid&amount={$params['amount']}&batch_no={$params['batch_no']}&key=$key&order_id={$params['order_id']}&pay_at={$params['pay_at']}&status={$params['status']}";
- return md5($content);
- }
- public function notify($params): array
- {
- $status = intval($params['status']);
- $order_sn = $params['batch_no'];
- $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'];
- if ($status === 2) {
- Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['order_id']]);
- return [$order_id, true, false, true];
- } elseif ($status === 4) {
- Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['order_id']]);
- return [$order_id, false, true, true];
- } else {
- return [$order_id, false, false, false];
- }
- }
- }
|