lokielse / omnipay-wechatpay

(微信支付)WeChatPay driver for the Omnipay PHP payment processing library
MIT License
317 stars 103 forks source link

js支付页面直接空白,PHP错误也是打开的。没有具体错误说明 。 #97

Closed ghost closed 5 years ago

ghost commented 5 years ago

            $gateway    = Omnipay::create('WechatPay_Js');
    $config = Config::get('payment.wx'); 
    $gateway->setAppId($config['app_id']);
    $gateway->setMchId($config['mch_id']);
    $gateway->setApiKey($config['api_key']); 
    $gateway->setNotifyUrl($config['notify_url']);
    $openid = 'oTDe15LhjPyWpSYUoRzSkhuwkFjg';
    $order = [
        'body'              => 'The test order',
        'out_trade_no'      => date('YmdHis').mt_rand(1000, 9999),
        'total_fee'         => 1, //=0.01
        'spbill_create_ip'  => Base::ip(),
        'fee_type'          => 'CNY',
        'open_id'           => $openid
    ];

    $request  = $gateway->purchase($order);
    $response = $request->send();

    $data['status'] = $response->isSuccessful();
    $data['order'] = $response->getJsOrderData();
    echo json_encode($data);

返回

{"status":false,"order":null}

ghost commented 5 years ago

一定要用 $response->getData(); 才有错误信息。