12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace refill\sctongqian;
- require_once(BASE_HELPER_RAPI_PATH . '/sctongqian/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)
- {
- $content = config::APP_KEY . $params['TimesTamp'] . $params['MOrderID'] . $params['OrderID'] . $params['State'] . $params['ChargeAccount'];
- $content .= $params['BuyCount'] . config::App_Secret;
- return strtoupper(md5($content));
- }
- public function notify($params)
- {
- $status = intval($params['State']);
- $order_sn = $params['MOrderID'];
- $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) {
- //卡密信息,需返回
- $CardInfo = $this->rsa_decode($params['CardInfo']);
- return [$order_id, true, false,true];
- }
- elseif ($status === 3) {
- return [$order_id, false, true,true];
- }
- else {
- return [$order_id, false, false,false];
- }
- }
- private function rsa_decode($encrypted)
- {
- $private_key = config::PRIVATE_KEY;
- //使用私钥解密数据
- openssl_private_decrypt(base64_decode($encrypted), $decrypted,$private_key);
- return $decrypted;
- }
- }
|