#dannnnnnnnnnnnnnnnnnnnnn_best-practices

1 messages ยท Page 1 of 1 (latest)

cunning basaltBOT
#

๐Ÿ‘‹ 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.

rose hornet
#

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

cunning basaltBOT
dire juniper
rose hornet
#

Ok perfect, I'll give that a go thank you

knotty fern
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

rose hornet
#

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?

knotty fern
#

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

rose hornet
#

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,
          },
        }
knotty fern
#

I would change only this part

stripe.confirmPayment({
          elements: elements,
          clientSecret: page_data.intent_client_secret,
          confirmParams: {
            return_url: page_data.return_url,
          },
        }```
rose hornet
#

What would you change about it and why just out of curiosity?

knotty fern
#
 const {error} = await stripe.confirmPayment({
      clientSecret,
      confirmParams: {
        confirmation_token: '{{CONFIRMATION_TOKEN_ID}}',
        return_url: 'https://example.com/order/123/complete',
      },
    });```
rose hornet
#

ahh yeah of course using the confirmation token... thanks for all the help with this, managed to get it all working!

#

have a good day!