Closed ghost closed 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}
一定要用 $response->getData(); 才有错误信息。
返回
{"status":false,"order":null}