#splue_code

1 messages ¡ Page 1 of 1 (latest)

quartz topazBOT
#

👋 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/1313970066257084427

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

fleet marten
#

thank you in advance!

cunning swift
#

Good question, checking our docs for what might be missing here

fleet marten
#

well for this customer i

  • created them in the dashboard
  • manually added their payment method
  • set their payment method to default

i thought adding a card manually in teh dashboard would properly save hteir card?

#

if i go thorugh the normal flow in my app, it would the original checkout session which saves the card looks like this

export const createCheckoutSession = async ( email: string, request: Request) => {
  return stripe.checkout.sessions.create({
    currency: 'usd',
    ui_mode: 'embedded',
    customer_email: email,
    payment_method_types: ['card'],
    mode: 'setup',
    customer_creation: 'always',
    billing_address_collection: 'required',
    return_url: '{{urll}}',
  });
};

and then i also have a webhook listener which listens for checkout session compeltion events to set the customer's saved payment as the default payment

    const paymentMethods = await this.stripe.customers.listPaymentMethods(
      customerId,
      {
        limit: 1,
      },
    )

    if (paymentMethods.data.length <= 0) {
      console.error(`Customer missing payment data ${customerId}`)
      return null
    }

    const customer = await this.stripe.customers.update(customerId, {
      invoice_settings: {
        default_payment_method: paymentMethods.data[0].id,
      },
    })

cunning swift
#

Ah gotcha, in that case you need to make an API call to update the payment method and set allow_redisplay to true

#

The dashboard saves the PM properly for re-use but it doesn't save it in the way that Checkout needs it to to display it when the customer returns

fleet marten
#

ok so if i manually add a card in the dashboard, i still need to update the allow_redisplay field to true?

#

why does the allow_redisplay method return true here?

stripe customers retrieve_payment_method cus_RKsHoq3BqPRDMO  pm_1QSCWwRwZsexd3LvkUORArwi 


{
"id": "pm_1QSCWwRwZsexd3LvkUORArwi",
"object": "payment_method",
"allow_redisplay": "always"
...
}
cunning swift
#

Oh whoops, I forgot it is an enum rather than a boolean. So you are saying that was already set for that PM but it still isn't showing up in Checkout?

fleet marten
#

im saying that

  1. i created the card in the stripe dashboard
  2. when creating the card int eh dashboard, there is no option to set allow_redisplay
  3. so i checked what allow_redisplay for this newly created payment method using the stripe cli
  4. when i get back the payment method object, it shows allow_redisplay set as always

so if it's already set to "always" why is it not appearing in my checkout session?

cunning swift
#

That I am unsure of, can you create another Checkout Session for that customer and send me the ID here?

fleet marten
#

sure thing

#

1 sec

#

cs_test_a11WN2cM5OehbdpQRq5tu27vS7yY6WnPFlLhKo7dZ39NtMit3dBI60er3a

cunning swift
#

Thank you, checking in to that

fleet marten
#

thanks pompey

#

so you inspired me to try my regular flow, instead of using the dashboard to add a card...

thank you so much because that worked!

when i use my regular flow, i see my presaved credit card

when i use the dashboard, i don't.

not sure why but im okay with that

cunning swift
#

Sounds good! Glad we could get this working in some way or another. I will still look in to this in case anything needs fixing and will escalate to my colleagues if necessary. Have a nice rest of your day!

fleet marten
#

i think part of the confusion is that when I add a card from the dashboard and set it as the customer's default payment method, i expect it to show in checkout sessions