Ich versuche Paypal Checkout zu implementieren. Ich fand dieses Stück Code, die für mich nahezu perfekt ist, aber nicht ganz:Paypal Checkout mit Umleitung?
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';
});
});
});
}
Ich möchte den Benutzer auf einem anderen PHP-Seite umgeleitet werden, wenn die Zahlung autorisiert ist. Kann ich weiterhin die Funktionen actions.payment.get() und actions.payment.execute() aufrufen? Wenn ja, wie soll ich fortfahren, sie anzurufen? Wenn nicht, warum?