Smart Button Redirect Code?

NatePerry
New Community Member

Hi there!

Not sure if this is the correct place to post this, so would appreciate a mod moving this to the right place if not.

 

I have integrated a Smart Button on my checkout page, and have entered the client ID in the code. I've also set up the app in the developer tools, and almost everything is working perfectly...

 

Anyone checking out with a paypal account will be redirected to the payment confirmed page, where they receive details on how to access their purchase.

 

Unfortunately, people choosing the "credit/debit card" option do not get redirected upon successful payment... they simply receive the following message that is inside the code of the smart button below:

 

image.png

 

My question to you is: what code to I enter there to replace the alert with a redirect to my payment confirmed page?

 

TLDR: Instead of having a simple message displayed when someone purchases using credit/debit card, I want them to instead be redirected to another page on my website - what code do I need to enter in the smart button widget in order to make this happen?

Thanks in advance! 🙏

Login to Me Too
1 REPLY 1

flyingkei
Contributor
Contributor

It depends on if you're using a framework with your Javascript. If you are, you'll likely want to use whatever router is provided with it. If not, you may want to directly access the window object and set the location to your new page. Make sure to include the order id or some kind of identifier in that url so that you can load the correct order from the backend when you land on the new page. 

https://developer.mozilla.org/en-US/docs/Web/API/Window/location

 

Also for security purposes, make sure that the authenticated user is authorized to load that order. Otherwise, it will be a security hole if any user can land on that page and checkout so long as they have the correct order id.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.