#sahil_api
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/1229863457151520778
๐ 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.
- sahil_card-verification, 5 days ago, 25 messages
- sahil_best-practices, 5 days ago, 25 messages
Hello! You should be able to modify your code to set the Payment Method as the Customer's default for Invoices: https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-default_payment_method
The reason they work differently is that they're different products with different features and use cases. The Payment Element is designed to be used and implemented by a developer who writes code to get the exact behavior they want. The Customer Portal can be implemented without code and has a closer relationship to things like Subscriptions than the Payment Element does, thus it has different features, functionality, and defaults.
Can I do that while creating a customer?
oh that needs the exact ID of the payment method, right?
I won't have that when creating the customer
In our product, the customer is created much before a subscription is created
Yep, you need the ID of the Payment Method you want to be the default.
ok, I see this option won't work for me then
Besides, I see that the subscription.default_payment_method is set when adding the card
So can I be certain that either one of customer.invoice_settings.default_payment_method or subscription.default_payment_method will be set ?
to be clear, what I see is PaymentElement sets subscription.default_payment_method
and BillingPortal sets customer.invoice_settings.default_payment_method
When you say Payment Element does that, what do you mean exactly?
the PaymentElement from @stripe/react-stripe-js
Yeah, I mean, what does your code look like? I think your code is setting it, not the Payment Element itself?
What I meant is when our users are adding their card through PaymentElement, the subscription object has subscription.default_payment_method but customer.invoice_settings.default_payment_method is nil
But when they add their card through the BillingPortal it's vice versa
๐ As Rubeus mentioned earlier, they're different products with different features and use cases
Yeah so can I be certain that atleast one of the fields will always be set regardless of how the card was added?
I am sorry to let you know that my laptop's battery is soon gonna drain, I don't have a power source at the moment
I see that the subscription.default_payment_method is set when adding the card
The payment method is added on the subscription when you confirm the PaymentIntent/SetupIntent associated with the subscription invoice.