I have paypals simple express checkout javascript and I have a problem while testing it, I can not seem to fiqure out how to add a return url to the code below.
under the paypal developer sites apps & credentials, I have created a REST API app and added a return url there, but this does not seem to work with the simple javascript Express Checkout integration as listed below.
Can I simply pass in return and cancel urls or does the Basic client intergration not allow this??
sorry to ask a stupid question , it just palpays docs are not that good at all and looking threw google there lots of different options to do the same basic things
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<div id="paypal-button-container"></div>
<script>
// Render the PayPal button
paypal.Button.render({
// Set your environment
env: 'sandbox', // sandbox | production
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'sandbox',
production: 'production'
},
// Wait for the PayPal button to be clicked
payment: function () {
// Make a client-side call to the REST api to create the payment
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: {total: '10.99', currency: 'USD'}
}
]
});
},
// Wait for the payment to be authorized by the customer
commit: true, // Optional: show a 'Pay Now' button in the checkout flow
onAuthorize: function (data, actions) {
// Execute the payment
return actions.payment.execute().then(function () {
// Show a success page to the buyer
});
}
}, '#paypal-button-container');
I gave up on this widget as it is limited and hell lot buggy. But I think you would redirect by doing it within the onAuthorize
callback handler.
paypal.Button.render({
// etc...
onAuthorize: function (data, actions) {
return actions.payment.execute().then(function () {
// redirect to success page
}).catch(function(err) {
// redirect to error page
});
}
}, '#paypal-button-container');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.