I created Smart paypal button and got this code
<div id="paypal-button-container"></div> <script src="https://www.paypal.com/sdk/js?client-id=sb¤cy=EUR" data-sdk-integration-source="button-factory"></script> <script> paypal.Buttons({ style: { shape: 'pill', color: 'gold', layout: 'vertical', label: 'buynow', }, createOrder: function(data, actions) { return actions.order.create({ purchase_units: [{ amount: { value: '13.88' } }] }); }, onApprove: function(data, actions) { return actions.order.capture().then(function(details) { alert('Transaction completed by ' + details.payer.name.given_name + '!'); }); } }).render('#paypal-button-container'); </script>
I am wondering, is there function to open specific url after successful payment to add in onApprove function after alert? Will it work like that?
Will window.open() work in this case?
Advertisement
Answer
You want to use location.assign. The syntax:
location.assign(url);