#Hazim
1 messages · Page 1 of 1 (latest)
Can you share an example request ID that errors?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
lkike req_123
or what is the error message you get back?
The request generally looks fine to me, but it's possible that eg customerId or priceId are invalid
oh its not that , the problem is that the response does not give me back a client secret so that I can give it to the the front that I have built with React so that the user can enter the payment
My goal is that the user needs to put his card info and needs to be valid so that I can activate the sub
I do not want to activate the sub or launch the trial if the guy does not have a valid payment method
oh
That's different than what you asked, which was about getting 400 responses
But now i understand
it's because you added a trial
Yeah my bad, I just saw in stripe that the client indeed has a sub with a trial
There's no payment in that case, the initial invoice will be a trial mode invoice for $0
So what you need to look at instead is the subscription's pending_setup_intent and expand that
that setup intent will have a client_secret and you need to use that when using eg confirmSetup or similar
in the subscription response
it'll be an ID like seti_123 unless you expand it, which you should do
expand: ['pending_setup_intent'],
to get the full setup intent object and be able to grab the client_secret
okay so in that case the sub and trial won't start unless the client has a payment method?
The trial is active right away, the pending setup intent is how you'd get a PM on file to pay later
and you can optionally configure behaviour to handle not having a PM:
https://stripe.com/docs/billing/subscriptions/trials#create-free-trials-without-payment
So that eg the subscription will cancel or pause if no PM is set up for it before the trial ends
what happens at the end of the trial if the payment didnt succeed?
and is it possible to activate a trial with a payment method instead ?
as in you successfully set up a PM using the setup intent, but then the actual payment fails?
It depends on what you've configured for handling payment failure & recovery: https://stripe.com/docs/billing/subscriptions/overview#settings
I mean that would be great if I can activate a trial when I get the payment method becuse in your documentation , it says trials without a payment methods
That's within your control -- you can use the pending setup intent to collect a payment method from the customer and cancel the subscription if they fails to set up promptly, that's up to you
Or you could use a setup intent without a subscription to collect the PM details up front, before you even create the subscription
Again, up to you
Or you could eg use Checkout subscription mode to start subscriptions, which I highly recommend, which handles logic like this for you