#Corjan-setupintent
1 messages ยท Page 1 of 1 (latest)
seti_1K4LqPGzhgXG0QoU3Z2mqxmN
This object has been created with all defaults. Only added the payment_method_types field to support the ones I want
After doing something like this: $this->stripeClient->setupIntents->update($id, ['customer' => $customerID]); I get an exception:
The customer ... cannot be updated without also passing the payment method
Creating the setupintent with the same payment_method_types field and customer does work. eg:
$this->stripeClient->setupIntents->create([
'payment_method_types' => [...],
'customer' => $customerID
]);
Thanks for the ID, I am able to see the request
the purpose of the setupIntent is to collect the payment info from the customer so that you can use this info the charge the customer later.
so that is why, as the error suggests, you need to update the payment_method and then customer
But I am able to create a setupintent for a customer directly when I not know the payment_method yet. This is an example of that: https://dashboard.stripe.com/test/setup_intents/seti_1K4Lv6GzhgXG0QoULeb1edLv
The payment_method will be collected by the js payments element (https://stripe.com/docs/js/setup_intents/payment_method)
Complete reference documentation for the Stripe JavaScript SDK.
Or can you tell me a use case where you want to create a setupIntent without payment_method attached to a user?
Yes, I can do that
The scenario is as follows:
User visits our website and want to register an account which requires immediate payment. This is done in a single form.
So the details for the account is entered and a payment method is selected. At this point I created a setupintent without a customer related to it (as the user does not exist). After submitting the form, I create the customer in Stripe, want to link that customer to the setupintent and then confirm the setupintent with the js sdk (payments element).
This worked fine before as the client secret was used on confirmation rather than create time (https://stripe.com/docs/payments/payment-element/migration?integration-path=future#recurring-update-method)
But now I need the client secret when building the payments element so I am not sure yet if there is a customer to which the setupintent can be linked
Therefore I need to do one of two options:
- Update the setupintent with the customer ID (exception as mentioned)
- Update the payments element with a new client secret (not supported according to js sdk docs https://stripe.com/docs/js/elements_object/update)
How about creating the customer first, then use the customer ID when creating the setup intent?
Yes, but that is not possible when I want to complete everything in the same step. If I move the registration to a separate place and do the payment method collection in a next step - all would be good
The only issue is that this scenario drops conversion rates. Collecting everything in one go is better
But it is strange that for the setupintent endpoint, you can create using limited fields but not update with the same fields
it does seem a bit odd! But it looks like that is just how it it is(I checked and the API has worked this way since SetupIntents were introduced in 2019) and a Customer can't be passed without also passing a PaymentMethod.
Thanks! That is a good remark
Do you understand my scenario and have any recommendations?
To me it sounds like something that needs to be changed in the docs or is a bug ๐
The update description for a setupintent implies that what I want is possible and it does work for the create
I would just create a new SetupIntent with the customer ID instead of updating an existing one I think. That's pretty much the only option since you can't do the update!
Cool! Unfortunately I cannot update the payments elements with that new secret
So then I would need to render the payments element after the user creation
or you could keep using the separate Elements instead of PaymentElement