0
我試圖實施PayPal結帳。我發現這段代碼是近乎完美的我,但並不完全:帶重定向的PayPal結帳?
onAuthorize: function(data, actions) {
// Get the payment details
return actions.payment.get().then(function(data) {
// Display the payment details and a confirmation button
var shipping = data.payer.payer_info.shipping_address;
document.querySelector('#recipient').innerText = shipping.recipient_name;
document.querySelector('#line1').innerText = shipping.line1;
document.querySelector('#city').innerText = shipping.city;
document.querySelector('#state').innerText = shipping.state;
document.querySelector('#zip').innerText = shipping.postal_code;
document.querySelector('#country').innerText = shipping.country_code;
document.querySelector('#paypal-button-container').style.display = 'none';
document.querySelector('#confirm').style.display = 'block';
// Listen for click on confirm button
document.querySelector('#confirmButton').addEventListener('click', function() {
// Disable the button and show a loading message
document.querySelector('#confirm').innerText = 'Loading...';
document.querySelector('#confirm').disabled = true;
// Execute the payment
return actions.payment.execute().then(function() {
// Show a thank-you note
document.querySelector('#thanksname').innerText = shipping.recipient_name;
document.querySelector('#confirm').style.display = 'none';
document.querySelector('#thanks').style.display = 'block';
});
});
});
}
我想將用戶重定向的其他PHP頁面時,付款授權。我仍然可以調用函數actions.payment.get()和actions.payment.execute()嗎?如果是,我應該如何繼續打電話給他們?如果不是,爲什麼?