|
@@ -1,15 +1,16 @@
|
|
|
<?php
|
|
|
-namespace refill\dixin;
|
|
|
+namespace refill\dixin_normal;
|
|
|
|
|
|
require_once(BASE_HELPER_RAPI_PATH . '/dixin/config.php');
|
|
|
use refill;
|
|
|
+
|
|
|
class RefillCallBack implements refill\IRefillCallBack
|
|
|
{
|
|
|
public function verify($params): bool
|
|
|
{
|
|
|
$input = $params;
|
|
|
unset($input['sign']);
|
|
|
- $sign = $this->sign($input);
|
|
|
+ $sign = config::sign($input);
|
|
|
if ($params['sign'] == $sign) {
|
|
|
return true;
|
|
|
} else {
|
|
@@ -17,56 +18,29 @@ class RefillCallBack implements refill\IRefillCallBack
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected function check_empty($value): bool
|
|
|
- {
|
|
|
- if (!isset($value))
|
|
|
- return true;
|
|
|
- if (trim($value) === "")
|
|
|
- return true;
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- private function sign($params): string
|
|
|
- {
|
|
|
- ksort($params);
|
|
|
-
|
|
|
- $body = "";
|
|
|
- $i = 0;
|
|
|
- foreach ($params as $k => $v) {
|
|
|
- if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
|
|
|
- if ($i == 0) {
|
|
|
- $body .= "{$k}" . "=" . urlencode($v);
|
|
|
- } else {
|
|
|
- $body .= "&" . "{$k}" . "=" . urlencode($v);
|
|
|
- }
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $body .= "&key=".config::KEY;
|
|
|
- return md5($body);
|
|
|
- }
|
|
|
-
|
|
|
+ //[$order_id, $success, $can_try, $need_handle, $official_sn]
|
|
|
public function notify($params): array
|
|
|
{
|
|
|
- $status = $params['state'];
|
|
|
- $order_sn = $params['order_sn'];
|
|
|
+
|
|
|
+ $order_sn = $params['merchant_no'];
|
|
|
$order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
|
|
|
+
|
|
|
if (empty($order_info)) {
|
|
|
return [false, false, false, false, ''];
|
|
|
}
|
|
|
- $official_sn = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
|
|
|
|
|
|
+ $official_sn = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
|
|
|
$order_id = $order_info['order_id'];
|
|
|
- if ($status === 'SUCCESS') {
|
|
|
- $data['ch_trade_no'] = $params['trade_no'];
|
|
|
+
|
|
|
+ $status = intval($params['recharge_status']);
|
|
|
+ if ($status === 3) {
|
|
|
+ $data['ch_trade_no'] = $params['order_no'];
|
|
|
$data['official_sn'] = $official_sn;
|
|
|
Model('refill_order')->edit($order_id, $data);
|
|
|
return [$order_id, true, false, true, $official_sn];
|
|
|
}
|
|
|
- elseif ($status === 'CANCEL') {
|
|
|
- Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['trade_no']]);
|
|
|
+ elseif (in_array($status,[4,5])) {
|
|
|
+ Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['order_no']]);
|
|
|
return [$order_id, false, true, true, ''];
|
|
|
}
|
|
|
else {
|