#RiderFx3
1 messages ยท Page 1 of 1 (latest)
Hi
๐ happy to help
could you elaborate a bit more?
and could you please share the request id? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
The context :
The client create a cart with a subscription and products, so I need to subscribe him to a plan, then charge hjm for the product in a one-time payment.
For example : pi_3M3Gh2DY4NUh1pUi0E7GmSn2
"message": "Your card was declined. This transaction requires authentication."
"type": "card_error"
But I already did the auth before with a SetupIntent
Here is the flow I want to do :
- Cart validation
- Create SetupItent
- 3DS Auth
- Subscribe to a plan
- Then, charge the card immediately for one-time payment
But I got rejected when trying to charge the payment intent off_session
a couple of things to note here
first you can add a one-time payment product to the first invoice when creating a Subscription by using https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
wow !
another thing, is that you don't need to create a SetupIntent
The problem is I don't have the items products stored in stripe dashboard
instead you can use the latest_invoice.payment_intent from the created Subscription to pass the client_secret to the front-end
even though
if it's a custom price, you can create that with price_data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
the product though should be created ahead of time https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items-price_data-product
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I needed to create a SetupIntent to authenticate the card before creating the subscription
Because of 3DS2
This was the only solution the support give to me ...
I'm giving you another ๐
yes sorry, just give me a moment please
basically when you create the Subscription you can expand on latest_invoice.payment_intent this would give you a client_secret that you would then use with the Payment Element on the frontend to collect the payment details
when creating the Subscription make sure to also use payment_settings: {save_default_payment_method: 'on_subscription'},
I don't need to return on the frontend at this step because the customer alrteady give his card number ...
All the script is actually in PHP
So before creating the subscription I already have a customer_id and a valid payment_method
I'm saying don't do your workflow
I'm suggesting a different flow all together
you start by creating the Subscription
and then you collect the payment details and at the same time pay the first invoice
Is there a way to do all this things only in backend ?
Maybe creating the subscription without charge, add the products in the invoice, then charge ?
I do understand that it is hard to change your workflow, especially if you have been working on it for a while
but I can give at least a couple of reasons why this flow is better
I don't understand why it will works like that and not if I get the payment_method before ...
Maybe the key is here ?
"On the backend, create the subscription with status incomplete using payment_behavior=default_incomplete."
let me double down on why it's better to use the workflow I described to you earlier
when you create a SetupIntent the user would be prompted with a 0 (zero) authentication and wouldn't know about the actual price of the subscription
2- even when setting up a payment method for off_session future usage, the issuing bank could still ask for 3DS (upon their discretion) which means that your customer might have to do 2 authentication back-to-back
which is not really a good experience for your user
Yes this was my original problem
But this problem seems to be solved if I edit the invoice before the first charge right ?
no not really
- create setupintent
- create a sub but dont finish it
- edit invoice to add items
- complete the sub
?
this is really an overkill for the 2 steps that I'm giving you
- create a subscription with add_invoice_items
- send the client_secret to the frontend
Yes but it means really lot of work in my javascript flow
not at all it's way easier
by confirming the PaymentIntent on the frontend you would be doing:
1- collecting a valid Payment Method(PM)
2- attaching the PM to the Subscription
3- paying your 1st invoice including the one-off payment
It also means that the customer have to click a first time on a button, then after that you prompt to him a popup for enetering his card ?
4- validating 3DS if needed
yes they would choose their Subscription, then they would be asked to enter their payment details
Okay thanks for your help I will try
please read through this document https://stripe.com/docs/billing/subscriptions/build-subscriptions
it's really well explained
Yes I understand the problem is that I build all my logic in backend wich is really easier for me because I have a lot of checks to do
As I do only one call to my backend in my flow
it is still in the backend
the only difference would be instead of using a SetupIntent you would use a PaymentIntent
Yes but I have 2 calls instead of 1
why do you need 2 calls?
First call : creating the sub, retrieve client secret and send it to front
Second call : get Payment Method and re-send it to backend
no you don't do the second call
when the customer enters their Payment Details using the PaymentElement, we (Stripe) will send the payment details and do all of the list I sent you earlier about creating the PM, attaching it to the customer/subscription, paying the invoice etc...
Yes but I have logic to do in the backend if payment fail etc..
So it's not so simple because I already have a huge system implemented
Seems simple with the little examples on the docs lol
But not simple at all with a lot of logic and checks I have to do in the backend
I understand your frustration, and I know that it's not easy, but you will thank us on the long run, this is the best approach and we don't take this statement lightly
The problem with Stripe is you best approach is changing every 2 month and honestly it's very frustrating to change logic all the time ๐ฆ
Anyway thanks for your helps now I have to do a lot of testings lol
I hear you, and that might be the case if you started working on something before a release of a new feature, but AFAIK the Subscription approach has been around for quite sometime now, I'm sorry that you have been maybe mislead previously, but I assure you that we're here to support you in the best way possible and that's exactly what I'm trying to do here
please do come back for any and every Q you have along the way, I might not be around, but my colleagues will do as good as a job if not better than myself ๐
Thanks a lot