Created
March 11, 2022 11:47
-
-
Save guillaumeduhan/d977b264bcec2ef2b2a7f73a5d1d5f48 to your computer and use it in GitHub Desktop.
Stripe get payment intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async getPaymentIntent () { // get the payment intent from API | |
const data = { | |
amount: this.formatStripePrice(this.getCurrentCoaching.price), | |
currency: 'eur' | |
} | |
this.isLoading = true | |
await this.$api.payment.getPaymentIntent(data, process.env.NODE_ENV) // call API, env is to switch dev/staging/prod | |
.then(({ client_secret }) => { | |
this.clientSecret = client_secret | |
this.buildCard() // build front module payment | |
}) | |
.catch(() => {}) | |
}, | |
async sendPayment () { | |
const { paymentIntent } = await this.$stripe.confirmCardPayment(this.clientSecret, { | |
payment_method: { | |
card: this.card, | |
billing_details: { | |
address: { | |
line1: '', | |
line2: '' | |
}, | |
name: '', | |
email:'' | |
} | |
}, | |
receipt_email: '' | |
}) | |
if (!paymentIntent) { | |
.... | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment