Closed xuyudong closed 4 years ago
` public function demo() { $qrCode = new QrCode();
// 请求参数,完整参数见具体表格 $tradeNo = time() . rand(1000, 9999); $payData = [ 'body' => 'ali qr pay', 'subject' => '测试支付宝扫码支付', 'trade_no' => $tradeNo, 'time_expire' => time() + 1000, // 表示必须 1000s 内付款 'amount' => '0.01', // 单位为元 ,最小为0.01 'return_param' => '123123', // 'client_ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1',// 客户地址 'goods_type' => '1', // 0—虚拟类商品,1—实物类商品 'store_id' => '', 'operator_id' => '', 'terminal_id' => '', // 终端设备号(门店号或收银设备ID) 默认值 web ]; // 使用 try { $client = new \Payment\Client(\Payment\Client::ALIPAY, self::$pay_config); $res = $client->pay(\Payment\Client::ALI_CHANNEL_QR, $payData); } catch (InvalidArgumentException $e) { echo $e->getMessage(); exit; } catch (\Payment\Exceptions\GatewayException $e) { echo $e->getMessage(); var_dump($e->getRaw()); exit; } catch (\Payment\Exceptions\ClassNotFoundException $e) { echo $e->getMessage(); exit; } catch (Exception $e) { echo $e->getMessage(); exit; } $qrCode ->setText($res['qr_code']) ->setExtension('png') ->setSize(300) ->setPadding(10) ->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]) ->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]) ->setErrorCorrection(QrCode::LEVEL_MEDIUM); header('Content-Type: ' . $qrCode->getContentType()); $qrCode->render(); die; }
`
` public function alinotify() { $callback = new AlipayNotify();
try { $client = new \Payment\Client(\Payment\Client::ALIPAY, self::$pay_config); $xml = $client->notify($callback); Log::info($xml); } catch (InvalidArgumentException $e) { Log::info($e->getMessage()); exit; } catch (\Payment\Exceptions\GatewayException $e) { Log::info($e->getMessage()); exit; } catch (\Payment\Exceptions\ClassNotFoundException $e) { Log::info($e->getMessage()); exit; } catch (\Exception $e) { Log::info($e->getMessage()); exit; } }
日志记录为 [ info ] [ PARAM ] array ( 'gmt_create' => '2020-07-29 17:12:56', 'charset' => 'utf-8', 'seller_email' => 'xx@sandbox.com', 'subject' => '测试支付宝扫码支付', 'sign' => 'V2esy0sevNl4MIgXjKU7Zxx, 'body' => 'ali qr pay', 'buyer_id' => 'xx', 'invoice_amount' => '0.01', 'notify_id' => 'xx', 'fund_bill_list' => '[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]', 'notify_type' => 'trade_status_sync', 'trade_status' => 'TRADE_SUCCESS', 'receipt_amount' => '0.01', 'buyer_pay_amount' => '0.01', 'app_id' => '2021000116660473', 'sign_type' => 'RSA2', 'seller_id' => '2088621954740738', 'gmt_payment' => '2020-07-29 17:13:06', 'notify_time' => '2020-07-29 17:13:06', 'version' => '1.0', 'out_trade_no' => 'xx', 'total_amount' => '0.01', 'trade_no' => '20200729220014xx18443', 'auth_app_id' => 'xx', 'buyer_logon_id' => 'nod***@sandbox.com', 'point_amount' => '0.00', ) 试过几个通道都没有自定义信息返回。。。
[ info ] [ PARAM ] array ( 'gmt_create' => '2020-07-29 17:12:56', 'charset' => 'utf-8', 'seller_email' => 'xx@sandbox.com', 'subject' => '测试支付宝扫码支付', 'sign' => 'V2esy0sevNl4MIgXjKU7Zxx, 'body' => 'ali qr pay', 'buyer_id' => 'xx', 'invoice_amount' => '0.01', 'notify_id' => 'xx', 'fund_bill_list' => '[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]', 'notify_type' => 'trade_status_sync', 'trade_status' => 'TRADE_SUCCESS', 'receipt_amount' => '0.01', 'buyer_pay_amount' => '0.01', 'app_id' => '2021000116660473', 'sign_type' => 'RSA2', 'seller_id' => '2088621954740738', 'gmt_payment' => '2020-07-29 17:13:06', 'notify_time' => '2020-07-29 17:13:06', 'version' => '1.0', 'out_trade_no' => 'xx', 'total_amount' => '0.01', 'trade_no' => '20200729220014xx18443', 'auth_app_id' => 'xx', 'buyer_logon_id' => 'nod***@sandbox.com', 'point_amount' => '0.00', )
发现用的是return_params,解决
` public function demo() { $qrCode = new QrCode();
`
` public function alinotify() { $callback = new AlipayNotify();
`
日志记录为
[ info ] [ PARAM ] array ( 'gmt_create' => '2020-07-29 17:12:56', 'charset' => 'utf-8', 'seller_email' => 'xx@sandbox.com', 'subject' => '测试支付宝扫码支付', 'sign' => 'V2esy0sevNl4MIgXjKU7Zxx, 'body' => 'ali qr pay', 'buyer_id' => 'xx', 'invoice_amount' => '0.01', 'notify_id' => 'xx', 'fund_bill_list' => '[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]', 'notify_type' => 'trade_status_sync', 'trade_status' => 'TRADE_SUCCESS', 'receipt_amount' => '0.01', 'buyer_pay_amount' => '0.01', 'app_id' => '2021000116660473', 'sign_type' => 'RSA2', 'seller_id' => '2088621954740738', 'gmt_payment' => '2020-07-29 17:13:06', 'notify_time' => '2020-07-29 17:13:06', 'version' => '1.0', 'out_trade_no' => 'xx', 'total_amount' => '0.01', 'trade_no' => '20200729220014xx18443', 'auth_app_id' => 'xx', 'buyer_logon_id' => 'nod***@sandbox.com', 'point_amount' => '0.00', )
试过几个通道都没有自定义信息返回。。。