#loeffel_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. Thank you for your patience!
โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.
๐ 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/1213071351779430482
๐ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
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.
- _loeffel, 3 days ago, 3 messages
pm_card_visa is just a token for payments, not an actual Payment Method object that can be attached to a Customer
But why is this working for NewCustomer? Only on Update this is a problem
Got an example?
Not sure why this is so important anyway, not like you can actually use these pm_card_x tokens in live mode?
And in any case, you shouldn't be calling the /attach method really. You should be using Setup Intents to collect and save payment info: https://docs.stripe.com/payments/save-and-reuse
Based on this site this is a "payment method", no "token"
Yeah its just for testing rn
-
For create i just set the default_payment_method param to the customer params with the value "pm_card_visa" - This works without any problems (later there will be a setup intent which generates the payment method id)
When i want to update the customer default payment method i can't use the "pm_card_visa" directly - i need to attach a new payment method to the customer and then set this new generated (?) payment method id to the customer params - which makes sense but i just try to understand why this is working for 1) without any issues
Again, can you share an example where 1 worked
sure, sorry: req_uHIyBzk1JMpJhd
i think this belongs to the "payment_method" req param which somehow translate the "pm_card_visa" to the correct payment_method_id
(because this param is not available for update customer params)
Yeah I guess this just an edge case/quirk with the API
here the info about the missing payment_method param: req_J6d2zPbN7JMYwc
When you create the Customer it must create and attach the PM object, then set it as the default
When you update, it seems to skip the attach part which is a requirement before you can set it as the default
yes
alright, then i understand, thank you! โค๏ธ
just for understanding:
when i send a setup intent generated payment_method_id - does this generate a new payment method id with the attach call or is this only for the test cards?
Well you won't need to (and shouldn't) do an attach call with a Setup Intent
You pass the cus_xxx on creation of the intent, and that handles the 'attachment' when confirmed
But to answer your question, no that wouldn't generate a new pm_xxx ID
my flow is currently setup intent without customer -> create customer with payment id
maybe it make more sense to go create customer -> create setup intent with customer
would the second flow set the setup intent generated payment method as default payment method for the customer?
๐ taking over for my colleague. Let me catch up.
in all cases, even if you create the customer then generate a SetupIntent, for a Payment Method to be used by default you need to update the customer and set invoice_settings.default_payment_method with the new PM ID
but this default payment method is only used for billing invoices
and is not directly used with simple PaymentIntents
-
so imagine i create a customer, then i create a setup intent with the customer => this results in the customer with a auto attachted payment method which will be used for the future generated subscription
-
imagine the subscription expires and the customer want to create a new subscription - i create a new setup intent with the customer which generates a new payment method for the customer
will this new payment method be used for the new subscription automatically?
(because the customer want to have a new payment method)
- so imagine i create a customer, then i create a setup intent with the customer => this results in the customer with a auto attachted payment method which will be used for the future generated subscription
attached payment method yes, but unless you update the customer'sinvoice_settings.default_payment_methodit wont be used for subscriptions
- so i need to create a customer -> create a setup intent with customer -> update the customer
invoice_settings.default_payment_method?
- imagine the subscription expires and the customer want to create a new subscription - i create a new setup intent with the customer which generates a new payment method for the customer
once you set theinvoice_settings.default_payment_methodthen you don't need to collect another payment method for future subscriptions
but what when the customer want to change his payment method for subscriptions?
will this new payment method be used for the new subscription automatically?
(because the customer want to have a new payment method)
if the customer wants to change their default payment method you need to replace theinvoice_settings.default_payment_method
got it
so setup intent with customer ALWAYS attaches the payment method for me, correct?
yes
ok i think the last question:
-
imagine i create a customer without any payment method information
-
and then i create a setup intent with customer which attaches the payment method automatically
-
i dont update the default payment method for the customer
-
i create a subscription for the customer without any payment method information - would this work without ever setting the default_payment_method before? (would the subscription pick the payment method automatically from the earlier created setup intent)
no, the subscription would still need to have a payment method in that case
and it wouldnt if i update the default payment method for the customer before creating the subscription correct?
sorry, it would work to create the subscription without any payment information when i set the default payment method before
chatgpt is telling me this:
Setting as Default PaymentMethod
To have the PaymentMethod set as the default for invoice payments (e.g., for subscriptions), you need to explicitly set the setup_future_usage parameter to off_session when creating the SetupIntent. This parameter indicates that the PaymentMethod will be used for future payments that are not customer-initiated. For subscriptions and other recurring payments, setting setup_future_usage to off_session is a common practice.
that's not enough
unless the PM is set as the customer's invoice_settings.default_payment_method it won't be used by default
but what about the first subscription and first payment method?
I'm not sure I understand the question
ok no problem, all in all there are 2 ways in my specific google aip way:
-
- create a setup intent without customer -> create a customer with payment method -> create subscription
-
- create a customer without payment method
- create a setup intent with customer
- update the customer default payment method
- create a subscription
which flow would you pick?
neither
if the intent is subscriptions, then you should look at this guide https://docs.stripe.com/billing/subscriptions/build-subscriptions?ui=elements
you don't need to create a SetupIntent first
and once the first invoice is paid, you can then update the customer's default payment method as explained before
what do you mean by "you don't need to create a SetupIntent first"
you can start by creating the customer, then you create the Subscription
and use the latest_invoice.payment_intent (if there's a first payment) or the pending_setup_intent (if the subscription is in trial or the first invoice is 0 because of a discount or something) and confirming that intent will automatically attach the PM to the customer and save it as the default payment method on the subscription (if you use payment_settings: { save_default_payment_method: 'on_subscription' }, as shown in the doc I shared)
once the first invoice is paid, you can then update the customer's invoice_settings.default_payment_method so that in the future it would be used with any newly created subscription
i am super confused
i talk about the first subscription with the payment element - but maybe you talk about the stripe checkout link or something?
Nope, not Checkout specific. This URL is the recommended Payment Element flow
You don't need an initial intent upfront, that will be created by the subscription
- Create Customer
- Create Subscription
- Load Elements and collect payment info
- Confirm the intent generated by 2 using payment info from 3
Alright, sorry for my confusion - i implemented stripe a few years ago with another stripe flow
now i get the create process completly! ๐
no to the update process:
imagine the subscription expired and the customer want to create a new subscription but maybe want to create a new payment method
how would you handle this flow?