为什么 Paypal 需要 DoExpressCheckoutPayment?
我正在尝试构建一个非常简单的贝宝支持的购物车,以便用户可以购买多个商品。我希望贝宝处理所有付款详细信息。我什至不需要订单确认。我将手动检查 PayPal 上的订单确认。
起初我想使用“网站支付标准”,因为创建一个将发布到贝宝并让贝宝从那里处理它的表单似乎很容易。但是不,这不起作用,因为“网站付款标准”按钮/表单不支持提交多个项目。我在表单中尝试了各种键/值,但它从未起作用。
然后我按照此处<的说明尝试了快速结账/a>.它基本上有效,但据我了解,发送 SetExpressCheckout 后,您必须侦听来自 paypal 的请求并执行 DoExpressCheckoutPayment 才能完成交易。 SO参考。
我觉得这有点麻烦,因为如果我的服务器无法接收来自 paypal 的请求并且我从不发送 DoExpressCheckoutPayment 怎么办?因此,客户认为他们已经完成提交订单,但从未收到订单。
有谁知道如何跳过这个“确认”步骤?我觉得没有必要,也不知道为什么 paypal 需要它。
I am trying to build a very simple paypal-backed shopping cart so users can purchase multiple items. I want paypal to handle all the payment details. I don't even want an order confirmation. I will manually check for order confirmation on paypal.
At first I wanted to use "Website Payments Standard" because it seemed easy to create a form that will post to paypal and let paypal handle it from there. But no, this did not work because the "Website Payments Standard" buttons/form do not support submitting multiple items. I tried all sorts of key/value in my form, and it never worked.
Then I tried Express Checkout using the instructions found here. It largely worked, but as I understand it, after sending a SetExpressCheckout, you have to listen for a request from paypal and do a DoExpressCheckoutPayment to complete the transaction. SO reference.
I find this a bit troublesome, because what if my server fails to receive the request from paypal and I never send a DoExpressCheckoutPayment? So a customer THINKS they have finished submitting an order, but the order was never received.
Does anyone know of a way to skip this "confirmation" step? I find it unnecessary, and not sure why paypal requires it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为快速结账和网站支付标准是根本不同的产品。
要使用 Express Checkout,您需要调用 SetExpressCheckout API。在 API 调用中,您指定产品、金额和 RETURNURL 的详细信息。
一旦您将此数据发布到 PayPal 的 API 端点,您就会收到一个令牌作为回报。
然后,您可以重定向买家,并将令牌附加到以下 URL:https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXXX
一旦买家同意您的购买,他就会被重定向返回到您在 RETURNURL 中指定的 URL。
您现在应该显示订单确认信息,并调用 GetExpressCheckoutDetails API**。
调用 GetExpressCheckoutDetails 时,提供令牌。在 GetExpressCheckoutDetails API 响应中,您将找到 PayerID。
现在您已准备好致电 DoExpressCheckoutPayment 并向买家收费。请记住在调用 DoExpressCheckoutPayment 时同时包含令牌和 payerID。
注意:如果您想通过立即调用 GetExpressCheckoutDetails 和 DoExpressCheckoutPayment 立即向买家收费,请将买家重定向到 https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXXX&useraction=commit。
useraction=commit
会将 PayPal“查看您的付款”页面上的“继续”按钮更改为“立即付款”按钮。--
Express Checkout 和 Website Payments Standard 之间存在如此显着差异的原因是,Website Payments Standard 旨在成为 PayPal 处理整个交易流程的即用型工作解决方案。快速结帐是一种更灵活的解决方案,可让您将其与网站/购物车的现有结帐流程深度集成。
对于您的用例;使用 PayPal 的“购物车上传”按钮查看。
请参阅示例 https://cms。 paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_cart_upload
但请注意,默认情况下这是不安全的,因为您要收取的金额将在 HTML 中清晰可见。
** PayerID 也附加在您的 RETURNURL 的 GET 中。因此,如果您愿意,可以跳过调用 GetExpressCheckoutDetails。
That's because Express Checkout and Website Payments Standard are fundamentally different products.
To use Express Checkout, you would call the SetExpressCheckout API. In the API call, you specify the details of the products, amounts, and the RETURNURL.
Once you post this data to PayPal's API endpoint, you receive a token in return.
You would then redirect the buyer, and append the token to the following URL: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXXX
Once the buyer has agreed to your purchase, he is redirected back to the URL you specified in the RETURNURL.
You should now show the order confirmation, and call the GetExpressCheckoutDetails API**.
When calling GetExpressCheckoutDetails, supply the token. In the GetExpressCheckoutDetails API response you'll find a PayerID.
Now you're ready to call DoExpressCheckoutPayment, and charge the buyer. Remember to include both the token and the payerID when calling DoExpressCheckoutPayment.
Note: If you want to charge the buyer immediately by calling GetExpressCheckoutDetails and DoExpressCheckoutPayment immediately, redirect the buyer to https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXXX&useraction=commit.
The
useraction=commit
will change the "Continue" button on the PayPal 'Review your payment' page to a "Pay now" button.--
The reason there's such a significant difference between Express Checkout and Website Payments Standard, is that Website Payments Standard is intended to be a drop-in working solution where PayPal handles the whole transaction flow. Express Checkout is a more flexible solution which allows you to integrate it deeply with an existing checkout flow of a website / shopping cart.
For your use case; lookat using PayPal 'cart upload' buttons.
See for an example https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_cart_upload
Note however, that this is insecure by default, as the amounts you're going to charge will be plainly visible in the HTML.
** The PayerID is appended in the GET of your RETURNURL as well. So you could skip calling GetExpressCheckoutDetails if you wanted to.
就本网站而言,PayPal Express Checkout API 只需要
DoExpressCheckoutPayment
操作。您说得对,PayPal 不需要处理付款,但在某些情况下需要进行第二次操作。此类场景的一个示例是用户(您网站的客户)在 PayPal 付款确认期间选择送货地址。根据您的运输提供商的不同,您可能需要在用户在 PayPal 确认页面上选择送货地址后计算实际运费。
For the purposes of this site, the
DoExpressCheckoutPayment
operation simply is required by the PayPal Express Checkout API.You're correct that it's not required for PayPal to process a payment, but there are scenarios that would require a second operation. An example of such a scenario would be one where the user (your site's customer) is choosing a shipping address during the PayPal payment confirmation. Depending on your shipping provider(s), you may need to calculate actual shipping amounts after the user has chosen a shipping address on the PayPal confirmation pages.