#loeffel_api

1 messages ยท Page 1 of 1 (latest)

viscid micaBOT
#

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

silent cloudBOT
#

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.

uneven elm
#

pm_card_visa is just a token for payments, not an actual Payment Method object that can be attached to a Customer

versed garnet
#

But why is this working for NewCustomer? Only on Update this is a problem

uneven elm
#

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?

versed garnet
#

Based on this site this is a "payment method", no "token"

Yeah its just for testing rn

  1. 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

uneven elm
#

Again, can you share an example where 1 worked

versed garnet
#

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)

uneven elm
#

Yeah I guess this just an edge case/quirk with the API

versed garnet
#

here the info about the missing payment_method param: req_J6d2zPbN7JMYwc

uneven elm
#

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

versed garnet
#

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?

uneven elm
#

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

silent cloudBOT
versed garnet
#

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?

velvet prairie
#

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

versed garnet
#
  1. 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

  2. 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)

velvet prairie
#
  1. 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's invoice_settings.default_payment_method it wont be used for subscriptions
versed garnet
#
  1. so i need to create a customer -> create a setup intent with customer -> update the customer invoice_settings.default_payment_method?
velvet prairie
#
  1. 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 the invoice_settings.default_payment_method then you don't need to collect another payment method for future subscriptions
versed garnet
#

but what when the customer want to change his payment method for subscriptions?

velvet prairie
#

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 the invoice_settings.default_payment_method

versed garnet
#

got it

#

so setup intent with customer ALWAYS attaches the payment method for me, correct?

velvet prairie
#

yes

versed garnet
#

ok i think the last question:

  1. imagine i create a customer without any payment method information

  2. and then i create a setup intent with customer which attaches the payment method automatically

  3. i dont update the default payment method for the customer

  4. 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)

velvet prairie
#

no, the subscription would still need to have a payment method in that case

versed garnet
#

and it wouldnt if i update the default payment method for the customer before creating the subscription correct?

velvet prairie
#

it wouldn't what?

#

need a PM?

versed garnet
#

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.

velvet prairie
#

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

versed garnet
#

but what about the first subscription and first payment method?

velvet prairie
#

I'm not sure I understand the question

versed garnet
#

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?

velvet prairie
#

neither

#

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

versed garnet
#

what do you mean by "you don't need to create a SetupIntent first"

velvet prairie
#

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

versed garnet
#

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?

uneven elm
#

You don't need an initial intent upfront, that will be created by the subscription

#
  1. Create Customer
  2. Create Subscription
  3. Load Elements and collect payment info
  4. Confirm the intent generated by 2 using payment info from 3
versed garnet
#

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?