简体   繁体   中英

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. I've started looking into the PayPal SDK and got lost... I saw that V1 is deprecated, so I probably should use V2.

The only thing that I need is that PayPal will call my server webhook once the account receives money.

How should I do this?

The only thing that I need is that PayPal will call my server 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/

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.


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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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