Search code examples
reactjspaypalcartcheckout

React PayPal Payment process checkout


I'm new to the react web app, I trying to create cart payment checkout process. All the modules PayPal button open in same page with POPUP. I want to redirect from my site to the PayPal site and return back to my site. Currently i'm using the below example. Is there any module to create order and redirect.

https://www.npmjs.com/package/react-paypal-button-v2


Solution

  • Why do you want to redirect away from your site? That's how things were done 5+ years ago.

    It's much better to keep your site loaded and present in the background and show payers an in-context approval experience, instead of redirecting them over to a new and possibly unfamiliar login page.

    You are asking for how to do something you shouldn't even be trying to do, and which will result in an inferior buyer experience and fewer completed checkouts, which is the opposite of what you should want.

    But since you ask, the way to do it is not not use the PayPal JavaScript SDK button. Just use the /v2/checkout/orders REST API to create an order and receive an approval_url, which you can redirect to with a static "Checkout with PayPal" button from, say, https://www.paypal.com/us/webapps/mpp/logos-buttons

    Again, full page redirects are an old integration method that give a poor buyer experience and you shouldn't use this method.