【类 型】:test

【主	题】:拿订单信息 提交到微信支付接口  换取签名
【描	述】:
	[原因]:测试支付
	[过程]:拿订单信息 提交到微信支付接口  换取签名
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-06-05 19:33:35 +08:00
parent 166bd88d5c
commit 857f95b507

View File

@ -51,12 +51,16 @@ class PayController extends PublicController
*/ */
public function pay() public function pay()
{ {
$order_sn = $_REQUEST['order_sn']; //获取订单信息
$order = [ $where['order_sn'] = $_REQUEST['order_sn'];
'out_trade_no' => $order_sn, $orderDb = D('order');
'description' => 'subject-测试', $order = $orderDb->where($where)->find();
//设置获取签名的订单参数
$orderParameter = [
'out_trade_no' => $order['order_sn'],
'description' => $order['shop_id'],
'amount' => [ 'amount' => [
'total' => 1, 'total' => $order['total_price'] / 100, //单位:分
'currency' => 'CNY', 'currency' => 'CNY',
], ],
'payer' => [ 'payer' => [
@ -65,7 +69,7 @@ class PayController extends PublicController
]; ];
try { try {
$pay = Pay::wechat($this->config)->mini($order); $pay = Pay::wechat($this->config)->mini($orderParameter);
echo json_encode(array('status' => 1, 'payMsg' => $pay)); echo json_encode(array('status' => 1, 'payMsg' => $pay));
} catch (\Exception $e) { } catch (\Exception $e) {
echo json_encode(array('status' => 0, 'msg' => 'Error: ' . $e->getMessage())); echo json_encode(array('status' => 0, 'msg' => 'Error: ' . $e->getMessage()));