#jackyang_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1297861681094987809
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! can you share the full code of the on("confirm") function?
expressCheckoutElement.on('confirm', async e => {
const { error: submitError } = await this.btnGoogleElements.submit()
if (submitError) {
this.global.toast(submitError.message, 5000)
return
}
const { error, paymentMethod } = await this.stripe.createPaymentMethod({
elements: this.btnGoogleElements
})
if (error) {
this.global.toast(error.message, 5000)
return
}
const res = await $api.creditRent({
scanUrl: this.params.sno,
source: 2,
paymentMethodId: paymentMethod.id,
rentType: 2
})
this.$store.commit('startLoading')
try {
const { error: payEroor } = await this.stripe.confirmPayment({
elements: this.btnGoogleElements,
clientSecret: JSON.parse(res.data.resp).clientSecret,
redirect: 'if_required'
})
if (payEroor) {
console.log(payEroor)
this.global.toast(payEroor.message)
} else {
this.showPopup = false
this.showMask = true
}
this.$store.commit('endLoading')
} catch (e) {
// console.log(e)
if (e) {
this.global.toast(e)
}
this.$store.commit('endLoading')
}
})
},
I see. Unfortunately this is a known bug and the ExpressCheckoutElement doesn't work with using createPaymentMethod
you can either just call confirmPayment directly without that extra step, or I think using a ConfirmationToken : https://docs.stripe.com/payments/build-a-two-step-confirmation#create-ct might work and let you continue to do things like inspect the payment method details before charging
But I need to use "createPaymentMethod" to get "paymentMethod.id" and go to the background interface to get "clientSecret". How can I solve this problem?
you can use ConfirmtionTokens for the same flow(you can send a ConfirmationToken to the backend instead).