1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace refill\yuke_dx;
- require_once(BASE_HELPER_RAPI_PATH . '/yuke_dx/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)
- {
- $params['rechargeAmount'] = number_format($params['rechargeAmount'], 3);
- $key = config::SECRET_KEY;
- $content = "tPfChannelId={$params['tPfChannelId']}&rechargeAccount={$params['rechargeAccount']}&rechargeAmount={$params['rechargeAmount']}&orderType={$params['orderType']}";
- $content .= "&orderStatus={$params['orderStatus']}&orderSn={$params['orderSn']}&outOrderId={$params['outOrderId']}&createTime={$params['createTime']}";
- $content .= "&updatedTime={$params['updatedTime']}&secret_key={$key}";
- return strtoupper(md5($content));
- }
- //[$order_id, $success, $can_try, $need_handle]
- public function notify($params)
- {
- $status = intval($params['orderStatus']);
- $order_sn = $params['outOrderId'];
- $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) {
- $data['official_sn'] = $params['callbackOtherAttr']['cert_no'];
- Model('refill_order')->edit($order_id, $data);
- return [$order_id, true, false,true];
- }
- elseif ($status === 3 || $status === 4) {
- return [$order_id, false, true,true];
- }
- else {
- return [$order_id, false, false,false];
- }
- }
- }
|