From 51c88dfc9cb2689561a3210ca4f67b4ff52b1c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwanyongkang=E2=80=9D?= <“937888580@qq.com”> Date: Thu, 16 Nov 2023 13:24:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E8=B7=AF=E7=94=B1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E4=BB=98=E5=AE=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/Alipay.php | 2 +- app/ros/controller/Order.php | 2 +- extends/alipay/Alipay.php | 77 +++++++++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/app/common/controller/Alipay.php b/app/common/controller/Alipay.php index 414035b..c52dc17 100644 --- a/app/common/controller/Alipay.php +++ b/app/common/controller/Alipay.php @@ -17,7 +17,7 @@ class Alipay { $ali = new AlipaySdk(); - $flag = $ali->payVerify($_POST); + $flag = $ali->payVerify2($_POST); if($flag){ diff --git a/app/ros/controller/Order.php b/app/ros/controller/Order.php index 73725eb..9084779 100644 --- a/app/ros/controller/Order.php +++ b/app/ros/controller/Order.php @@ -116,7 +116,7 @@ class Order extends Controller ]; - $pay_html = Alipay::pay($param); + $pay_html = Alipay::pay2($param); $info = [ 'code'=>2, diff --git a/extends/alipay/Alipay.php b/extends/alipay/Alipay.php index 8cfa776..2db76a4 100644 --- a/extends/alipay/Alipay.php +++ b/extends/alipay/Alipay.php @@ -2,8 +2,8 @@ /* * @Author: 万永康 * @Date: 2020-10-11 12:32:50 - * @LastEditTime: 2022-03-22 14:52:50 - * @LastEditors: Please set LastEditors + * @LastEditTime: 2023-11-11 14:15:28 + * @LastEditors: “wanyongkang” “937888580@qq.com” * @Description: In User Settings Edit * @FilePath: /phptest/alipay/Alipay.php */ @@ -65,6 +65,50 @@ class Alipay + $param = json_encode($param); + + $request->setReturnUrl('http://www.juip.com/product/routeros'); + + $notifyUrl="http://php-api.juip.com/common/alipay/alipayverify"; + $request->setNotifyUrl($notifyUrl); + + $request->setBizContent($param); + $result = $aop->pageExecute ( $request); + + return $result; + + } + /** + * + * web 付款 + * $param = [ + * 'body' => '123', + * 'subject' => 'test', + * 'total_amount' => '0.01', + * 'out_trade_no' => '1231313123123', + * 'product_code' => "FAST_INSTANT_TRADE_PAY",//QUICK_WAP_PAY + * 'timeout_express'=>"15m" + *]; + * + * + */ + public static function pay2($param) + { + global $config; + $aop = new \AopClient (); + $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do'; + $aop->appId = $config['alipay2']['app_id'];; + $aop->rsaPrivateKey = $config['alipay2']['private_key'] ; + $aop->apiVersion = '1.0'; + $aop->signType = 'RSA2'; + $aop->postCharset='utf-8'; + $aop->format='json'; + $aop->alipayrsaPublicKey = $config['alipay2']['public_key']; + + $request = new \AlipayTradePagePayRequest(); + + + $param = json_encode($param); $request->setReturnUrl('http://www.juip.com/product/routeros'); @@ -108,6 +152,35 @@ class Alipay return false; } } + /** + * @description: 获取支付返回参数 + * @param {*} $post + * @return {*} + */ + public static function payVerify2($post) { + global $config; + $aop = new \AopClient (); + $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do'; + $aop->appId = $config['alipay2']['app_id'];; + $aop->rsaPrivateKey = $config['alipay2']['private_key'] ; + $aop->apiVersion = '1.0'; + $aop->signType = 'RSA2'; + $aop->postCharset='utf-8'; + //签名方式 + $sign_type="RSA2"; + //输出拆分后的数据数据 + //验签代码 + $flag = $aop->rsaCheckV1($post, null, $sign_type); + + if ($flag) + { + return true; + } + else + { + return false; + } + } /** * @description: 转帐到支付宝账户 * @param {type}$param