#beard_checkout-defaultpm

1 messages ยท Page 1 of 1 (latest)

thorn willowBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

lapis glade
#

@astral hedge I don't really understand what you are asking sorry. Can you reword? What do you mean by "attach" what is happening or not happening that is confusing you?

astral hedge
#

so when I create a checkout session with customer id(customer pre created). the customer goes to checkout and fill in payment info. now I want to attach this payment method to that customer for which the checkout session was created

#

like in future if I want to get payment info. its not available through customer and instead I have to go find it through subscription

lapis glade
#

What does "go find it through the subscription" mean?

astral hedge
#

like the payment method is not available via customer query. I have to query subscription to get the payment method id

lapis glade
#

Gotcha, so that's the whole misunderstanding!

#

A Customer can have 0, 1 or N PaymentMethods. You can use the List Customer PaymentMethods API to find the whole list https://docs.stripe.com/api/payment_methods/customer_list

After the Checkout Session is completed, we make the PaymentMethod that was collected the default on the Subscription in the default_payment_method property.

So you can access that and then store it in your own database for example. Or use the List PaymentMethods API I mentioned to show a list of saved card/PaymentMethods

Does that make sense?

#

beard_checkout-defaultpm

astral hedge
#

but that is the is the issue. list payment method for customer is empty after the checkout

#

the payment method is only available on subscription

#

nvm

#

you are right

#

sorry, I was looking at the wrong customer

lapis glade
#

All good, I made the same mistake this morning debugging another issue and kept saying "where the heck is that card" ๐Ÿ˜‚

astral hedge
#

also list payment method does not mention the default method ?

lapis glade
#

correct that's entirely expected. It's a list of PaymentMethods and none are the default automatically
you can set a specific default globally on the Customer yourself using invoice_settings[default_payment_method] if you want

astral hedge
#

the problem i have is that when a customer subscribe with checkout session. the payment method is what the customer entered. I can query subscription to get that payment method. all good to this point.
then when a customer updates a payment method (we use billing portal session for this). so the updated method is now default for that customer and this will used for the future subscription payment. but that is not a subscription payment method and subscription payment method is empty. so to display current method, I have to check subscription endpoint and then fallback to customer endpoint

lapis glade
#

correct you do. See the link I shared just above since I knew you'd ask that

astral hedge
#

ok, thanks. going over it now