【问题标题】:PayPal Smart Button - How To Edit Redirect UrlPayPal 智能按钮 - 如何编辑重定向 URL
【发布时间】:2021-12-13 10:16:16
【问题描述】:

我正在尝试在我的 PayPal 智能按钮生成的代码中输入重定向 url 链接,但不知道该怎么做。我希望我能在这里得到帮助。

我希望能够在成功付款后将客户重定向到例如 (https://www.example.com/request/)。

以下是 Paypal 的智能按钮代码:

function initPayPalButton() { paypal.Buttons({ style: { shape: 'rect', color: 'gold', layout: 'vertical', label: 'paypal',
},

createOrder: function(data, actions) {
  return actions.order.create({
    purchase_units: [{"description":"Digital Service","amount":{"currency_code":"USD","value":1}}]
  });
},

onApprove: function(data, actions) {
  return actions.order.capture().then(function(orderData) {

    // Full available details
    console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));

    // Show a success message within this page, e.g.
    const element = document.getElementById('paypal-button-container');
    element.innerHTML = '';
    element.innerHTML = '<h3>Thank you for your payment!</h3>';

    // Or go to another URL:  actions.redirect('thank_you.html');

  });
},

onError: function(err) {
  console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();

【问题讨论】:

    标签: javascript php url paypal payment-gateway


    【解决方案1】:

    // Or go to another URL: actions.redirect('thank_you.html');

    您的问题的答案在代码示例中,就在这里。

    【讨论】:

      【解决方案2】:
      function redirect(url){
        window.setTimeout(function(){
            window.location.href = url;
        }, 300);
      }
      
      <button onclick="redirect("https://www.google.com")">Redirect</button>
      

      【讨论】:

        猜你喜欢
        • 2021-07-21
        • 2020-10-19
        • 2020-06-28
        • 2021-02-09
        • 2020-03-23
        • 2021-04-27
        • 2021-10-31
        • 2020-07-13
        • 2021-04-16
        相关资源
        最近更新 更多