Skip to content

Instantly share code, notes, and snippets.

@guillaumeduhan
Created March 11, 2022 11:47
Show Gist options
  • Save guillaumeduhan/d977b264bcec2ef2b2a7f73a5d1d5f48 to your computer and use it in GitHub Desktop.
Save guillaumeduhan/d977b264bcec2ef2b2a7f73a5d1d5f48 to your computer and use it in GitHub Desktop.
Stripe get payment intent
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