#TheUchi007
1 messages · Page 1 of 1 (latest)
Hello! Yes, you can set whatever trial period you want using trial_period_days when creating the Subscription: https://stripe.com/docs/api/subscriptions/create#create_subscription-trial_period_days
Amazing, exactly what I was searching for. Thank you!
Hello, May I ask another question in this thread?
It is still in regards to this setup
Yep, what's up?
Awesome, thanks
Ok, so I was able to create the subscription with the trial, which is great. However, I cannot seem to attach a payment method to it. So, on my current flow:
-
User chooses a membership(subscription)
-
User gets redirected to checkout page
-
The Backend creates a new subscription, and I get the latest payment invoice with the payment intent
-
This gets me the client secret so I can have a user pay
The flow above works great to make a payment. However, with the trial, I get no client secret, so I can't embed the form to add a card. How can I go about it?
I want a user to be able to attach a card, even though they are not being charged at this moment
The Subscription should have a pending_setup_intent you can use to collect payment info: https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
Ok, then I use that to create a payment intent? Or how do I implement it?
👋 Hopping in since Rubeus has to head out soon
You'd use that pending_setup_intent to collect payment information that can be used for future payments (https://stripe.com/docs/payments/save-and-reuse). Setup intents work similarly to payment intents, but the main difference is that there is no charge/payment being made.
Ah ok. So let me know if this is how I can implement:
-
App creates the subscription with trial
-
I gather the newly created subscription data via API
-
I then check for
pending_setup_intent, and if it is present, I retrieve that payment intent -
According to API docs, this should get me a client secret, so then I can use this to add the credit card info
Would this work?
Yup, that's almost correct - but with a small change to step 3:
3. I then check for pending_setup_intent , and if it is present, I retrieve that~~ payment intent~~ setup intent