12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace refill\yifa;
- require_once(BASE_HELPER_PATH . '/refill/yifa/config.php');
- use refill;
- class RefillCallBack implements refill\IRefillCallBack
- {
- public function verify($params): bool
- {
- $sign = $this->sign($params);
- if ($params['sgn'] == $sign) {
- return true;
- } else {
- return false;
- }
- }
- private function check_empty($value)
- {
- if (!isset($value))
- return true;
- if ($value === null)
- return true;
- if (trim($value) === "")
- return true;
- return false;
- }
- private function sign($params)
- {
- ksort($params);
- $app_secret = config::APP_SECRET;
- $body = $app_secret;
- foreach ($params as $k => $v) {
- if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
- $body .= "{$k}{$v}";
- }
- }
- $body .= "&key=" . $app_secret;
- return strtoupper(md5($body));
- }
- public function notify($params)
- {
- $status = intval($params['status']);
- $order_sn = $params['coder_order_sn'];
- $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'];
- $data['official_sn'] = $params['isp_order_sn'];
- $data['ch_trade_no'] = $params['order_sn'];
- Model('refill_order')->edit($order_id, $data);
- if ($status === 'success') {
- return [$order_id, true, false,true,true];
- } elseif ($status === 2) {
- return [$order_id, false, true,true,true];
- }
- }
- }
|