【发布时间】: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