Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. processStripePayment() {
  2. window['stripe'].confirmCardPayment(this.clientSecret, {
  3. payment_method: {
  4. card: this.card,
  5. billing_details: {
  6. name: this.customerName
  7. }
  8. }
  9. }).then((result) => {
  10. console.log(':: RESULT', result);
  11. if (result.error) {
  12. // Show error to your customer (e.g., insufficient funds)
  13. console.log(result.error.message);
  14. this.isError = true;
  15. this.errorMessage = result.error.message;
  16. this.sendingRequest = false;
  17. if (result.error && result.error.payment_intent && result.error.payment_intent.status === 'canceled') {
  18. this.clientSecret = null;
  19. }
  20. } else {
  21. // The payment has been processed!
  22. if (result.paymentIntent.status === 'succeeded') {
  23. this.paymentStatus = WidgetStatus.SUCCESS;
  24. this.openPage('success');
  25. this.isError = false;
  26. this.errorMessage = '';
  27. this.sendingRequest = false;
  28. // Show a success message to your customer
  29. // There's a risk of the customer closing the window before callback
  30. // execution. Set up a webhook or plugin to listen for the
  31. // payment_intent.succeeded event that handles any business critical
  32. // post-payment actions.
  33. }
  34. }
  35. });
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement