hmunoz-stripe

PaymentRequest Button confirmation

Jul 28th, 2020 (edited)
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // Confirm the PaymentIntent without handling potential next actions (yet).
  2.     stripe.confirmCardPayment(
  3.       clientSecret,
  4.       {payment_method: ev.paymentMethod.id},
  5.       {handleActions: false}
  6.     ).then(function(confirmResult) {
  7.       console.log(confirmResult);
  8.       if (confirmResult.error) {
  9.         // Report to the browser that the payment failed, prompting it to
  10.         // re-show the payment interface, or show an error message and close
  11.         // the payment interface.
  12.         ev.complete('fail');
  13.       } else {
  14.         // Report to the browser that the confirmation was successful, prompting
  15.         // it to close the browser payment method collection interface.
  16.         ev.complete('success');
  17.         // Let Stripe.js handle the rest of the payment flow.
  18.         console.log(confirmResult.paymentIntent.status);
  19.  
  20.         // if authentication is required on this payment, confirm again
  21.         if (confirmResult.paymentIntent.status == "requires_action") {
  22.           stripe.confirmCardPayment(clientSecret).then(function(result) {
  23.             console.log(result);
  24.             if (result.error) {
  25.               // The payment failed -- ask your customer for a new payment method.
  26.             } else {
  27.               // The payment has succeeded.
  28.             }
  29.           });
  30.         }
  31.       }
  32.     });
Add Comment
Please, Sign In to add comment