123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace refill\dinghui;
- require_once(BASE_HELPER_RAPI_PATH . '/dinghui/config.php');
- use refill;
- class RefillCallBack implements refill\IRefillCallBack
- {
- public function verify($params): bool
- {
- $res = $this->decrypt($params);
- if ($res == 1) {
- return true;
- } else {
- return false;
- }
- }
- private function decrypt($params)
- {
- $sign = $params['sign'];
- unset($params['sign']);
- $content = '';
- ksort($params);
- foreach ($params as $key => $val){
- $content .= "{$key}={$val}&";
- }
- $content = rtrim($content,'&');
- return openssl_verify($content, hex2bin($sign), config::PUBLIC_KEY);
- }
- private function message_decrypt($message)
- {
- return json_decode(openssl_decrypt($message, 'AES-256-ECB', config::AES_KEY, 0, ''));
- }
- public function notify($params)
- {
- $data = $this->message_decrypt($params['message']);
- $status = $data->charge_result;
- $order_sn = $data->app_order_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 === 'SUCCESS') {
- return [$order_id, true, false,true];
- }
- elseif ($status === 'FAILED') {
- return [$order_id, false, true,true];
- }
- else {
- return [$order_id, false, false,false];
- }
- }
- }
|