code-lives / baidu-pay
百度小程序支付、订单查询、退款、支付回调、获取token
dev-main
2021-11-02 08:13 UTC
This package is auto-updated.
Last update: 2024-12-01 00:07:38 UTC
README
说明(重要)
支付回调一定要保存userId 退款需要。
Config 参数
安装
composer require code-lives/baidu-pay
Demo
$config = [ 'appid'=>'abcdef', 'appkey' => 'abcdef', 'payappKey' => "MMMMMMMM", 'appSecret' => 'ABCDEF', 'dealId' => 123456, 'rsaPriKeyStr' => "ABCDEF", 'rsaPubKeyStr' => 'ABCDEF', ];
初始化
//use Baidu\Pay\Pays; $Baidu = new Pays($config);
获取token
$Baidu = new Pays($config); $result = $Baidu->getToken();
支付参数配置
Demo
$result = $Baidu->getOrderParm($order, $money, $desc);
订单查询参数配置
$order = [ 'access_token' => 'abcde', 'tpOrderId' => '123456', ]; $result = $Baidu->findOrder($order);
退款参数配置
Demo
$data = [ 'token' => 'abcd', 'bizRefundBatchId' => 123456,//百度平台订单号 'isSkipAudit' => 1, 'orderId' => 123456, 'refundReason' => '测试退款', 'refundType' => 2,// 'tpOrderId' => '123',//自己平台订单号 'userId' => 123, ]; $result = $Baidu->applyOrderRefund($data);
支付异步通知
$Baidu->notifyCheck($_POST); //返回 true false