diff --git a/app/Services/Gateway/TrimePay.php b/app/Services/Gateway/TrimePay.php deleted file mode 100644 index 4814a1b6..00000000 --- a/app/Services/Gateway/TrimePay.php +++ /dev/null @@ -1,211 +0,0 @@ -appSecret = $appSecret; - $this->gatewayUri = 'https://api.Trimepay.com/gateway/'; - } - - - /** - * @name 准备签名/验签字符串 - */ - public function prepareSign($data) - { - ksort($data); - return http_build_query($data); - } - - /** - * @name 生成签名 - * @param sourceData - * @return 签名数据 - */ - public function sign($data) - { - return strtolower(md5(md5($data) . $this->appSecret)); - } - - /* - * @name 验证签名 - * @param signData 签名数据 - * @param sourceData 原数据 - * @return - */ - public function verify($data, $signature) - { - $mySign = $this->sign($data); - return $mySign === $signature; - } - - public function post($data, $type = 'pay') - { - if ($type == 'pay') { - $this->gatewayUri .= 'pay/go'; - } elseif ($type == 'refund') { - $this->gatewayUri .= 'refund/go'; - } elseif ($type == 'pre') { - $this->gatewayUri .= 'pay/pre'; - } else { - $this->gatewayUri .= 'query/go'; - } - - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $this->gatewayUri); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data); - $data = curl_exec($curl); - curl_close($curl); - return $data; - } - - - public function purchase($request, $response, $args) - { - $price = $request->getParam('price'); - $type = $request->getParam('type'); - - - if ($price <= 0) { - return json_encode(['code' => -1, 'errmsg' => '非法的金额.']); - } - $user = Auth::getUser(); - $pl = new Paylist(); - $pl->userid = $user->id; - $pl->total = $price; - $pl->tradeno = self::generateGuid(); - $pl->save(); - - - $data['appId'] = Config::get('trimepay_appid'); - $data['payType'] = $type; - $data['merchantTradeNo'] = $pl->tradeno; - $data['totalFee'] = (float)$price * 100; - $data['notifyUrl'] = Config::get('baseUrl') . '/payment/notify'; - $data['returnUrl'] = Config::get('baseUrl') . '/user/payment/return'; - $params = $this->prepareSign($data); - $data['sign'] = $this->sign($params); - switch ($type) { - case ('WEPAY_JSAPI'): - $result = json_decode($this->post($data, $type = 'pre'), true); - break; - default: - $result = json_decode($this->post($data), true); - } - $result['pid'] = $pl->tradeno; - return json_encode($result); - } - - public function query($tradeNo) - { - $data['appId'] = Config::get('trimepay_appid'); - $data['merchantTradeNo'] = $tradeNo; - $params = $this->prepareSign($data); - $data['sign'] = $this->sign($params); - return json_decode($this->post($data, $type = 'query'), true); - } - - public function notify($request, $response, $args) - { - $data = array(); - $data['payStatus'] = $request->getParam('payStatus'); - $data['payFee'] = $request->getParam('payFee'); - $data['callbackTradeNo'] = $request->getParam('callbackTradeNo'); - $data['payType'] = $request->getParam('payType'); - $data['merchantTradeNo'] = $request->getParam('merchantTradeNo'); - - //file_put_contents(BASE_PATH.'/storage/trimepay_notify.log', json_encode($data)."\r\n", FILE_APPEND); - // 准备待签名数据 - $str_to_sign = $this->prepareSign($data); - // 验证签名 - $resultVerify = $this->verify($str_to_sign, $request->getParam('sign')); - if ($resultVerify) { - //file_put_contents('./trimepay_notify_success.log', json_encode($data)."\r\n", FILE_APPEND); - $this->postPayment($data['merchantTradeNo'], 'TrimePay'); - echo 'SUCCESS'; - } else { - echo 'FAIL'; - } - } - - public function refund($merchantTradeNo) - { - $data['appId'] = Config::get('trimepay_appid'); - $data['merchantTradeNo'] = $merchantTradeNo; - $params = $this->prepareSign($data); - $data['sign'] = $this->sign($params); - - return $this->post($data, 'refund'); - } - - - public function getPurchaseHTML() - { - return View::getSmarty()->fetch('user/trimepay.tpl'); - } - - public function getReturnHTML($request, $response, $args) - { - $pid = $_GET['merchantTradeNo']; - $p = Paylist::where('tradeno', '=', $pid)->first(); - $money = $p->total; - if ($p->status == 1) { - $success = 1; - } else { - $data = array(); - $data['payStatus'] = $request->getParam('payStatus'); - $data['payFee'] = $request->getParam('payFee'); - $data['callbackTradeNo'] = $request->getParam('callbackTradeNo'); - $data['payType'] = $request->getParam('payType'); - $data['merchantTradeNo'] = $request->getParam('merchantTradeNo'); - // 准备待签名数据 - $str_to_sign = $this->prepareSign($data); - // 验证签名 - $resultVerify = $this->verify($str_to_sign, $request->getParam('sign')); - if ($resultVerify) { - $this->postPayment($data['merchantTradeNo'], 'TrimePay'); - $success = 1; - } else { - $success = 0; - } - } - return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl'); - } - - public function getStatus($request, $response, $args) - { - $return = []; - $p = Paylist::where('tradeno', $_POST['pid'])->first(); - $return['ret'] = 1; - $return['result'] = $p->status; - return json_encode($return); - } -} diff --git a/app/Services/Payment.php b/app/Services/Payment.php index 68672914..e5df0627 100644 --- a/app/Services/Payment.php +++ b/app/Services/Payment.php @@ -9,7 +9,7 @@ namespace App\Services; use App\Services\Gateway\{ - AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, PAYJS, YftPay + AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, PAYJS, YftPay }; class Payment @@ -30,8 +30,6 @@ class Payment return new AopF2F(); case ('chenAlipay'): return new ChenPay(); - case ('trimepay'): - return new TrimePay(Config::get('trimepay_secret')); case ('payjs'): return new PAYJS(Config::get('payjs_key')); case ('yftpay'): diff --git a/config/.config.example.php b/config/.config.example.php index 49c8c8f1..60e37260 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -177,7 +177,7 @@ $_ENV['enable_checkin_captcha'] = 'false'; //启用签到验证码 //支付系统设置---------------------------------------------------------------------------------------- -#取值 none | codepay | trimepay | f2fpay | chenAlipay | paymentwall | spay |tomatopay | payjs | yftpay +#取值 none | codepay | f2fpay | chenAlipay | paymentwall | spay |tomatopay | payjs | yftpay $_ENV['payment_system']='none'; #yft支付设置 @@ -212,10 +212,6 @@ $_ENV['zfbjk_pid']=''; $_ENV['zfbjk_key']=''; $_ENV['zfbjk_qrcodeurl']=''; -#Trimepay https://portal.trimepay.com/#/auth/register/134 -$_ENV['trimepay_appid']=''; //AppID -$_ENV['trimepay_secret']=''; //AppSecret - # BitPay 数字货币支付(比特币、以太坊、EOS等) 商户后台获取授权码 https://merchants.mugglepay.com/ # 客服和技术 24x7 在线支持: https://t.me/joinchat/GLKSKhUnE4GvEAPgqtChAQ $_ENV['bitpay_secret']='';