Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Payment Methods API #47

Open
1hakr opened this issue Dec 1, 2019 · 3 comments
Open

Support for Payment Methods API #47

1hakr opened this issue Dec 1, 2019 · 3 comments

Comments

@1hakr
Copy link

1hakr commented Dec 1, 2019

Any plans on supporting Payment Methods API which is now the recommended way and also support 3D Secure option?

https://stripe.com/docs/payments/payment-intents/migration/automatic-confirmation

@Wazabiii
Copy link

Hi!
In fact you can use the payment API with 3D Secure:

  1. Charge a customer with a payment intent
    => you receive an object with 'client_secret'

  2. Use v-stripe-card:

    <v-stripe-card
      v-model="token"
      :api-key="apiKey"
      create="token"
    ></v-stripe-card>
  1. You receive a token and use confirmCardPayment to attach your customer payment intent and the card. You can save the card for future payment with save_payment_method: true
stripe.confirmCardPayment(
  '**client_secret**',
  {
    payment_method: {
      card: {
        token: this.token.id
      }
    },
    save_payment_method: false
  }
).then(function(result) {
  // Handle result.error or result.paymentIntent
});

I hope this will help ;)

@1hakr
Copy link
Author

1hakr commented Dec 10, 2019

Thanks @Wazabiii , i dont want to use tokens as they will be deprecated soon. I ended up cloning it and adding the functionality.

@Wazabiii
Copy link

Yes you're right!
As an other workaround if you don't wan't to use token (even if a token is created behind during the process):

  1. Use a ref
    <v-stripe-card
      v-model="token"
      :api-key="apiKey"
      ref="stripeCard"
    ></v-stripe-card>
  1. Use the Stripe instance of the component to securely accept the payment (according to the Stripe documentation: https://stripe.com/docs/payments/accept-a-payment#web-submit-payment)
      this.$refs.stripeCard.stripe
        .confirmCardPayment('**client_secret**', {
          payment_method: {
            card: this.$refs.stripeCard.card
          },
          save_payment_method: false
        })
        .then(function(result) {
          if (result.error) {
            console.error(result.error.message);
          }
        });

@morphatic do you have specific rules for PR to implement this features in the prop "create"?

Maybe it could be the value create="card" ?
And I think this option should only return the card object and the Stripe instance (without using confirmCardPayment inside the processCard() function)
Maybe like this?:

    if (this.create === 'card') {
        this.$emit('input', {
            card: this.card,
            stripe: this.stripe
        });
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants