redirect after onApprove
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I leave the payment page after onApprove function has posted to my validation page? I tried redirecting within the validation page which did not work, I tried adding a .then(window.location.replace("the page that called the payment page")); chained to the onApprove function but it seems to bypass my validation page call (return fetch("validation page"...)
<script>
paypal.Buttons(
{
createOrder: function(data, actions)
{
// Set up the transaction
return actions.order.create(
{
purchase_units:
[
{
reference_id: document.getElementById("<%= HiddenLicenseID.ClientID %>").value,
amount:
{
currency: "CAD",
value: document.getElementById("<%= HiddenPrice.ClientID %>").value,
}
}
]
});
},
onApprove: function (data, actions)
{
return actions.order.capture().then(function (details) {
// Call your server to save the transaction
return fetch('/pp_transaction_result.aspx?' + document.getElementById("<%= HiddenLicenseID.ClientID %>").value,
{
method: 'post',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ orderID: data.orderID, })
});
});
}
}).render('#paypal-button-container');
</script>
- Labels:
-
Payments REST APIs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorted.
Use .then (function() {window.location.assign("...")}) instead of window.location.replace() chained from onApprove.
Not a javaScript developer.
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.