#dannnnnnnnnnnnnnnnnnnnnn_best-practices
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/1371440165020766290
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- dannnnnnnnnnnnnnnnnnnnnn_best-practices, 4 days ago, 9 messages
Just to clarify as well, this isn't in all cases this is for a select few payment intents as well still want other ones to be able to be paid by those card brands if that makes sense
You'd need to check the brand before payment confirmation and handle accordingly. Bets way to do that is with a Confirmation Token: https://docs.stripe.com/payments/finalize-payments-on-the-server
Ok perfect, I'll give that a go thank you
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
Ok so I had a quick read of that doc, so our current workflow is that we create a payment intent and pass that intent secret along with a customer session secret to the elements object. Is it still possible to use the confirmation token to get the card brand doing it this way?
cause my assumption is that the create-confirm-intent endpoint will create a new payment intent and confirm that right?
yes
not necessarily
you can create a confirmationToken and validate either on the frontend or the backend whatever you need and then also you can confirm on the frontend or the backend the PI with the ConfirmationToken
Ok so I've got it working but want to hear your opinion on how I've gone about it/if theres any possible issues with my method. I create the payment element like so:
const elements = stripe.elements({
clientSecret: page_data.intent_client_secret,
customerSessionClientSecret: page_data.customer_session_client_secret,
appearance: appearance,
})
const paymentOptions = {
layout: {
type: 'accordion',
radios: true,
spacedAccordionItems: false,
},
}
const paymentElement = elements.create('payment', paymentOptions)
paymentElement.mount('#payment-element')
and then on submit I do the following:
stripe.createConfirmationToken({
elements: elements,
}).then(function (result) {
const token = result.confirmationToken
const brand = token.payment_method_preview.card.brand
const disallowedBrands = ['diners', 'jcb', 'unionpay', 'amex']
if (disallowedBrands.includes(brand)) {
// handle my error
}
stripe.confirmPayment({
elements: elements,
clientSecret: page_data.intent_client_secret,
confirmParams: {
return_url: page_data.return_url,
},
}
I would change only this part
stripe.confirmPayment({
elements: elements,
clientSecret: page_data.intent_client_secret,
confirmParams: {
return_url: page_data.return_url,
},
}```
What would you change about it and why just out of curiosity?