贝宝 Laravel Integrarion CheckOutStatus = PayentActionNotIntiated

PayPal Laravel Integrarion CheckOutStatus = PayentActionNotIntiated

我正在从事需要集成 PayPal 进行支付的项目。 我在 Laravel 8 的帮助下集成了 PayPal: https://devnote.in/how-to-integrate-paypal-payment-gateway-with-laravel/

一切正常。但是我无法在我的沙箱 activity 选项卡中看到交易,所以我调试了我在响应中发现的代码

"CHECKOUTSTATUS" => "PaymentActionNotInitiated"

我觉得不对的是这个

$response = $provider->setExpressCheckout($data);
$response = $provider->setExpressCheckout($data, true);

这是我付款后的回复

"TOKEN" => "EC-2X484972KX015750V"
"BILLINGAGREEMENTACCEPTEDSTATUS" => "1"
"CHECKOUTSTATUS" => "PaymentActionNotInitiated"
"TIMESTAMP" => "2021-08-25T08:46:25Z"
"CORRELATIONID" => "45064f9f5ee81"
"ACK" => "Success"
"VERSION" => "123"
"BUILD" => "55938276"
"EMAIL" => "sb-8dekq7353673@personal.example.com"
"PAYERID" => "9U9985S7EREYQ"
"PAYERSTATUS" => "verified"
"FIRSTNAME" => "John"
"LASTNAME" => "Doe"
"COUNTRYCODE" => "US"
"ADDRESSSTATUS" => "Confirmed"
"CURRENCYCODE" => "USD"
"AMT" => "30.00"
"ITEMAMT" => "30.00"
"SHIPPINGAMT" => "0.00"
"HANDLINGAMT" => "0.00"
"TAXAMT" => "0.00"
"DESC" => "Your order #EL/21-22/7 Invoice"
"INVNUM" => "EL/21-22/7"
"INSURANCEAMT" => "0.00"
"SHIPDISCAMT" => "0.00"
"INSURANCEOPTIONOFFERED" => "false"
"L_NAME0" => "Prem"
"L_QTY0" => "1"
"L_TAXAMT0" => "0.00"
"L_AMT0" => "30.00"
"L_DESC0" => "Order No: EL/21-22/7 ORDER SUMMARY- aosdno"
"PAYMENTREQUEST_0_CURRENCYCODE" => "USD"
"PAYMENTREQUEST_0_AMT" => "30.00"
"PAYMENTREQUEST_0_ITEMAMT" => "30.00"
"PAYMENTREQUEST_0_SHIPPINGAMT" => "0.00"
"PAYMENTREQUEST_0_HANDLINGAMT" => "0.00"
"PAYMENTREQUEST_0_TAXAMT" => "0.00"
"PAYMENTREQUEST_0_DESC" => "Your order #EL/21-22/7 Invoice"
"PAYMENTREQUEST_0_INVNUM" => "EL/21-22/7"
"PAYMENTREQUEST_0_INSURANCEAMT" => "0.00"
"PAYMENTREQUEST_0_SHIPDISCAMT" => "0.00"
"PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID" => "sb-nicfx7337505@business.example.com"
"PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED" => "false"
"L_PAYMENTREQUEST_0_NAME0" => "Prem"
"L_PAYMENTREQUEST_0_QTY0" => "1"
"L_PAYMENTREQUEST_0_TAXAMT0" => "0.00"
"L_PAYMENTREQUEST_0_AMT0" => "30.00"
"L_PAYMENTREQUEST_0_DESC0" => "Order No: EL/21-22/7 ORDER SUMMARY- aosdno"
"PAYMENTREQUESTINFO_0_ERRORCODE" => "0"

使用该 EC API,当买家 return 访问您的网站时,您应该显示最终订单审核页面,最终批准操作将触发 DoExpressCheckoutPayment API 调用(使用来自 url 查询字符串的 EC 令牌和 PayerID,return 是用 return 编辑的)创建一个 PayPal 交易。根据响应,您将显示一条感谢 you/success 消息——或有关无法处理付款的错误消息。在您调用 DoExpressCheckoutPayment.

之前不会创建交易

无论如何,您正在尝试的这种集成是与经典 EC API 的集成,它已有几代人的历史(大约 15 岁)。您不应该将这个旧的 API 用于任何新的集成,您正在遵循的指南已经很旧了,应该被忽略。


相反,遵循当前 Set up standard payments guide and make 2 routes on your server, one for 'Create Order' and one for 'Capture Order', documented here。两条路线都应该 return 只有 JSON 数据(没有 HTML 或文本)。在第二条路线中,当捕获 API 成功时,您应该将其生成的付款详细信息存储在您的数据库中(特别是 purchase_units[0].payments.captures[0].id,这是 PayPal 交易 ID)并执行任何必要的业务逻辑(例如发送确认电子邮件或预订产品)立即 将您的 return JSON 转发给前端呼叫者之前。

将这 2 条路线与前端批准流程配对:https://developer.paypal.com/demo/checkout/#/pattern/server