ectoflow / vue-stripe-elements

A Vue 2 component collection for Stripe.js
MIT License
530 stars 124 forks source link

confirmCardPayment method needs to be made available. #93

Closed mattcookdev closed 3 years ago

mattcookdev commented 5 years ago

https://stripe.com/docs/payments/accept-a-payment#web-submit-payment

confirmPaymentIntent got deprecated and now confirmCardPayment has replaced it.

crgeary commented 4 years ago

For anyone stuck on this, you can access it from the Stripe instance returned from the package while you're waiting for this to be made available directly.

import { instance as StripeInstance } from "vue-stripe-elements-plus";

StripeInstance.confirmCardPayment();
iamkhalidbashir commented 4 years ago

This is working currently

import { instance as StripeInstance } from "vue-stripe-elements-plus";
.....
.....
StripeInstance.confirmCardPayment(paymentIntent.client_secret, {
            payment_method: {
              card: this.$refs.stripeCard.$refs.element._element,
              billing_details: {
                name: paymentIntent.user_name,
                email: paymentIntent.user_email_address
              }
            }
          }).then(result => {
            console.log(result);
            if (result.error) {
              // Show error to your customer (e.g., insufficient funds)
              console.log(result.error.message);
            } else {
              // The payment has been processed!
              if (result.paymentIntent.status === "succeeded") {
                // Show a success message to your customer
                // There's a risk of the customer closing the window before callback
                // execution. Set up a webhook or plugin to listen for the
                // payment_intent.succeeded event that handles any business critical
                // post-payment actions.
              }
            }
          });
        }
softbeehive commented 3 years ago

For v1.0.0:

const StripeElements = this.$refs.elms // vue component instance
StripeElements.instance.confirmCardPayment()