#cyril_paymentmethod-save

1 messages ยท Page 1 of 1 (latest)

zenith heathBOT
#

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

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

devout pecan
#

The card used ends in 1117 but it is not saved to the customer payment method. I want to save the card for future auto payment for the auto extended booking.

flint tulipBOT
jovial ocean
devout pecan
#

why the ID saved is pm_1Q03DmRudNHJ72xw7KTygo3m

#

it should be in this format card_1Q01XQRudNHJ72xwTz5mPeVn

jovial ocean
#

No it shouldn't be. You're creating a Payment Method object and those have a pm_ prefix for their ID.

devout pecan
#

But is there a way to save the card id?

jovial ocean
#

No, you're creating Payment Method objects, there is no card ID to be saved.

devout pecan
#

But the problem here when I set the a card to default for those cards that has pm_ prefix for their ID, I got an error.

jovial ocean
#

It's hard to say for sure since that is a UI provided by Bubble that I'm not familiar with, but it looks like you're updating the wrong field on the Customer object. Seems like you're updating default_source instead of invoice_settings.default_payment_method:
https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-default_payment_method

invoice_settings.default_payment_method takes priority over default_source, so you don't have to worry about clearing out default_source when using a Payment Method instead.

devout pecan
#

how to save a card that the id will have a prefix of pm_

jovial ocean
#

Sorry, not sure I'm following. Isn't that exactly what is happening? It's what you're already doing. You're creating a Payment Method with a type of card.

zenith heathBOT
somber otter
#

cyril_paymentmethod-save

devout pecan
#

Right now I have 2 options to save the payment method. First option is to save it just by adding a card which has a card_ prefix saved. The second is saving the method after the payment which has a pm_ prefix. But when I try to set default card that has card_ prefix, it doesn't work. So I need to have all the cards to have a prefix of pm_

somber otter
#

@devout pecan The "prefix" as you say is based on how you wrote your entire integration. So the first step is to understand that as the developer building this.

devout pecan
#

I got it now, I should use invoice_settings.default_payment_method not the default_source when setting a default card.

somber otter
#

correct

devout pecan
#

Thanks @jovial ocean and @somber otter for the help.