I have the following code from https://developer.paypal.com/demo/checkout/#/pattern/confirm
The code is working as the Paypal checkout page shows and I'm able to enter all of my information. The issue that I'm having is that the onAuthorize() does NOT get called at all. Even when I complete a transaction, the only thing that gets called is the onCancel() function.
NOTE: I'm using the test credit cards from here https://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm
paypal.Button.render({
// Set your environment
env: 'sandbox', // sandbox | production
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'AY2UxZoOkoWQ0-******',
production: '' // This is not set
},
commit: true, // Set to 'Pay Now'
payment: function() { // Wait for the PayPal button to be clicked
// 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.00', currency: 'USD' }
}
]
});
},
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions) {
console.log('onAuthorize');
},
onCancel: function(data, actions) {
console.log('onCancel');
console.log(data);
}
}, '#paypal-button-container');
The response when I print the data object from onCancel() is the following:
{
cancelUrl: "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&xo_node_fallback=true&force_sa=true&fallback=1&token=EC-90M952801L841090P",
intent: "sale",
paymentToken: "EC-90M952801L841090P"
}