cancel
Showing results for 
Search instead for 
Did you mean: 

redirect after onApprove

Contributor

redirect after onApprove

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>

1 REPLY 1
Contributor

Re: redirect after onApprove

Sorted.

    Use .then (function() {window.location.assign("...")}) instead of window.location.replace() chained from onApprove.

 

Not a javaScript developer.