javascript - Paypal 交易后重定向至页面

标签 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>");
      });
    }

没有成功。

知道如何设置重定向网址吗?

最佳答案

你尝试过使用这个吗?

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

关于javascript - Paypal 交易后重定向至页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61238196/

相关文章:

javascript - 尝试访问弹出元素时,在 magnificPopup 打开的弹出窗口中使用 getElementById 失败

paypal - Mass Pay操作中如何查看每笔付款?

PayPal webhook 没有收到任何事件

php - Paypal 错误400

paypal - 如何只允许 Paypal 请求我的 notify_url?

javascript - 如何将具有重复值的数组映射到 Javascript 中的唯一数组?

javascript - 动态创建 html 内容时移动设备上没有滚动条

javascript - 使用 gulp 并行运行多个 qunit 测试

paypal - Sandbox api curl (5) SSL 连接错误

从自定义功能区按钮调用时,Javascript 的行为与 onSave 不同