Paypal Checkout.js does not call onAuthorize ()

I have the following code from https://developer.paypal.com/demo/checkout/#/pattern/confirm

The code works when the Paypal verification page is displayed, and I can enter all my information. The problem I am facing is that onAuthorize () does NOT receive the call at all. Even when I complete the transaction, the only one that is called is the onCancel () function.

NOTE. I use test credit cards 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 answer when I print a data object from onCancel () is this:

 { 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" } 
+5
source share

Source: https://habr.com/ru/post/1268556/


All Articles