#scmitton
1 messages · Page 1 of 1 (latest)
Hi, can you share which integration document you're following here?
I'm trying to follow this: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#collect-payment But in my scenario I passed a trial_period_days parameter to createSubscription. I found that I couldn't expand latest_invoice.payment_intent but instead I could expand pending_setup_intent to find the client secret. But apparently that client secret doesn't work for some reason?
Can you confirm what 'I couldn't expand latest_invoice.payment_intent ' means?
This is how I create a subscription: subscription = stripe.Subscription.create(
'customer': customer_id,
'items': [{'price': price_id}],
'payment_behavior': 'default_incomplete',
'payment_settings': {
'save_default_payment_method': 'on_subscription'
},
'expand': ['pending_setup_intent'],
'trial_period_days': trial_period_days,
)
But this is what the docs have: subscription = stripe.Subscription.create(
'customer': customer_id,
'items': [{'price': price_id}],
'payment_behavior': 'default_incomplete',
'payment_settings': {
'save_default_payment_method': 'on_subscription'
},
'expand': ['latest_invoice.payment_intent'],
'trial_period_days': trial_period_days,
)
Notice the 'expand' field
Yeap
If I look at the subscription, there is no client secret anywhere in it
When expand is this: 'expand': ['latest_invoice.payment_intent'] there's no client secret anywhere, but when expand is this: 'expand': ['pending_setup_intent'], there is a field called client_secret, but when I pass it to the front end to use in confirmPayment, it gives an error like I originally mentioned.
Should there still be a client secret even though I've specified a trial length?
That.. I'm trying to confirm on my end...
Well for starters it looks like pending_setup_intent is not meant for confirming payment like I was trying to do, just found that out from the docs. But the question still remains as to why I can't get the client secret from the latest_invoice.
That is correct, the Setup client secret and the Payment intent client secret are different. One is used to collect payment details for future use. One is set up for a payment that is currently occurring. What I'm trying to do is what I get from my end if I add a trial period on a subscription. That is what you're doing, right?
I think the issue is that since there is a trial, no amount to be paid, you're seeing this behavior.
Yeah, so I'm trying to checkout the user, and collect their card info for payment after the trial ends. What I assumed to be a pretty basic scenario. When I create the subscription on the server side the way I've described it doesn't send me any client secret to give me to the front end, which I will need in order to use the stripe.confirmPayment api. Here's a the stripe api call to create the subscription that returns no client secret: stripe.Subscription.create(
'customer': <customer_id>,
'items': [{'price': <price_id>}],
'payment_behavior': 'default_incomplete',
payment_settings={
'save_default_payment_method': 'on_subscription'
},
'expand': ['latest_invoice'],
'trial_end': <unix timestamp>,
'proration_behavior': 'none',
)
I suppose a way I might be able to get this to work, is to create a normal subscription without a free trial, then after the user's payment info is confirmed, update the subscription to have a free trial.
Seems kinda hacky though to me
You do not need a work around here... Let me find out document on this.
Glad to hear
I can't find that document now... but what you're seeing is expected. And with the Setup intent client secret you received, instead of confirm PaymentIntent call, you'd use this https://stripe.com/docs/js/setup_intents/confirm_setup
No problem!