贝宝交易后重定向到页面

时间:2020-04-15 20:38:11

标签: javascript paypal

我做了以下示例:

https://developer.paypal.com/docs/checkout/integrate/#2-add-the-paypal-javascript-sdk-to-your-web-page

<script>
  paypal.Buttons({
    createOrder: function(data, actions) {
      // This function sets up the details of the transaction, including the amount and line item details.
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '1.00'
          }
        }]
      });
    },

    onApprove: function(data, actions) {
      // This function captures the funds from the transaction.
      //actions.redirect();

      return actions.order.capture().then(function(details) {
        // This function shows a transaction success message to your buyer.

      });
    }




  }).render('#paypal-button-container');
  //This function displays Smart Payment Buttons on your web page.
</script>

但是我想在交易批准后将用户转到其他页面。

我尝试使用:

onApprove: function(data, actions) {
      // This function captures the funds from the transaction.


      return actions.order.capture().then(function(details) {
        // This function shows a transaction success message to your buyer.
        actions.redirect("<url>");
      });
    }

没有成功。

关于如何设置重定向网址的任何想法?

1 个答案:

答案 0 :(得分:2)

您尝试过使用此功能吗?

document.location.href = "www.your-redirect-page.com"