laravel5.5 easywechat 小程序支付

    public function mpPay()
    {
        $options = [
            'app_id' => '',
            'mch_id' => '',
            'key' => '',
            'notify_url' => '',
            'sandbox' => true,
        ];

        $payment = Factory::payment($options);
        $jssdk = $payment->jssdk;


        $attributes = [
            'trade_type' => 'JSAPI',
            'body' => 'ceshi',
            'out_trade_no' => 'ceshi074392473921',
            'total_fee' => 1.01*100,
            'openid' => ''
        ];

        $result = $payment->order->unify($attributes);
        if ($result['return_code'] == 'FAIL') {
            return apiBack(400, $result['return_msg']);
        }
        if ($result['return_code'] == 'SUCCESS') {

            $prepayId = $result['prepay_id'];
            $config = $jssdk->sdkConfig($prepayId);

            return apiBack(200, 'success', [
                'wx_res' => $config
            ]);
        }

        if ($result['return_code'] == 'FAIL' && array_key_exists('return_msg', $result)) {

            return apiBack(400, $result['return_msg']);
        }
    }

 

上一篇:29 典型的时序电路模块2


下一篇:php生成微信jssdk wx.config参数,调用js接口