This commit is contained in:
szdot 2024-06-05 19:34:20 +08:00
commit d05e47701e

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()));