简体   繁体   English

如何使用 PayPal v2 和 JavaScript 检测付款?

[英]How do I detect payments using PayPal v2 and JavaScript?

I'm developing a server that will detect PayPal payments to a specific PayPal account.我正在开发一个服务器,它将检测到特定 PayPal 帐户的 PayPal 付款。 I've started looking into the PayPal SDK and got lost... I saw that V1 is deprecated, so I probably should use V2.我已经开始研究 PayPal SDK 并迷路了......我看到 V1 已被弃用,所以我可能应该使用 V2。

The only thing that I need is that PayPal will call my server webhook once the account receives money.我唯一需要的是,一旦帐户收到钱,PayPal 就会调用我的服务器 webhook。

How should I do this?我该怎么做?

The only thing that I need is that PayPal will call my server webhook我唯一需要的是 PayPal 会调用我的服务器 webhook

Don't do that.不要那样做。 Use a proper server integration.使用适当的服务器集成。

You need two routes on your server, one for 'Set Up Transaction' and one for 'Capture Transaction', documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/您的服务器上需要两条路线,一条用于“设置交易”,一条用于“捕获交易”,记录在此处: https : //developer.paypal.com/docs/checkout/reference/server-integration/

The best approval flow for the customer to go through is: https://developer.paypal.com/demo/checkout/#/pattern/server , as your site stays loaded in the background, and it does not redirect away from your page.客户要经历的最佳审批流程是: https://developer.paypal.com/demo/checkout/#/pattern/server ,因为您的网站在后台保持加载状态,并且不会从您的页面重定向.


When your capture transaction API call runs successfully and completes the order, you will have an immediate response with a payment object and transaction details.当您的捕获交易 API 调用成功运行并完成订单时,您将立即收到付款对象和交易详细信息的响应。 Thus, there is no need for the extra asynchronous step of waiting for a separate webhook call (which is prone to errors or exceptions), and your integration will be more robust.因此,不需要额外的异步步骤来等待单独的 webhook 调用(这很容易出现错误或异常),并且您的集成将更加健壮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM