简体   繁体   中英

How to redirect user after to another page using PayPal smart buttons

onApprove: function(data, actions) {
      return actions.order.capture().then(function(details) {
        alert('Transaction completed by ' + details.payer.name.given_name + '!');
        location.href="mywebsite";
      });
    },

I have been trying to find out how to do this for awhile, I have tried "location.replace()" as well, but it still didn't work. I want to redirect a user after payment is accepted. The alert feature does work, but only in sandboxes, when I try and use it on my real site the alert, and the redirect does not work. I am using Google Sites, could that be an issue? This is just the basic code that you get when you create a PayPal smart button, all I added was "location.href", but it won't redirect me. I will try my best to answer any questions! Any help on this matter is appreciated!

Within your .then() function, use actions.redirect() or set window.location.href

I found out what was wrong with it, It was trying to turn the PayPal window into the website, but the window would shut down before I could catch the error!

I know this is an old post, but this is what worked for me:

window.location.replace('https://website.com');

Setting Up Auto Return Using PayPal

To set up Auto Return:

Log in to paypal and click Profile. Click the Website Payment Preferences link under Selling Preferences. Click the On radio button to enable Auto Return. Enter the Return URL. Note: You must meet the Return URL requirements in order to set up Auto Return. Learn more about Return URL.

Sendbox Form Multiple Return Request URL's: If you are using different URL's for success/failure

It will automatically overwrite paypal specified URL.

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