我正在嘗試在我的 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();
uj5u.com熱心網友回復:
// Or go to another URL: actions.redirect('thank_you.html');
您的問題的答案在代碼示例中,就在此處。
uj5u.com熱心網友回復:
function redirect(url){
window.setTimeout(function(){
window.location.href = url;
}, 300);
}
<button onclick="redirect("https://www.google.com")">Redirect</button>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/343385.html
標籤:javascript php 网址 贝宝 支付网关
