#scmitton

1 messages · Page 1 of 1 (latest)

feral rockBOT
slate stag
#

Hi, can you share which integration document you're following here?

haughty sleet
slate stag
#

Can you confirm what 'I couldn't expand latest_invoice.payment_intent ' means?

haughty sleet
#

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

slate stag
#

Yeap

haughty sleet
#

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.

slate stag
#

I see.. Let me look on my end

#

Trying to reproduce this on my end.

haughty sleet
#

Should there still be a client secret even though I've specified a trial length?

slate stag
#

That.. I'm trying to confirm on my end...

haughty sleet
#

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.

slate stag
#

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.

haughty sleet
#

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

slate stag
#

You do not need a work around here... Let me find out document on this.

haughty sleet
#

Glad to hear

slate stag
haughty sleet
#

Thanks so much! I'll try this out!

#

Gotta jet though, appreciate all your help.

slate stag
#

No problem!