#khris-subscription-setupintent
1 messages ยท Page 1 of 1 (latest)
Hi ๐ can you share the ID of a Subscription from your testing where you saw this behavior?
I can try... it's currently just in test code, and I'm stepping through it line by line in my server-side code
sub_1NLpanBRcLdcM5pSv3JqeGyx
I havent got to the line where it tries to access the PendingSetupIntent and hence its clientsecret
it appears to have a PendingSetupIntentId of
seti_1NLpaoBRcLdcM5pShkzlNs2Q
but the object itself is null
Hm, from my end it looks like a pending setup intent was created when the Subscription was created.
What do you mean the object is null? How are you trying to access the client secret?
What request is providing the subscription that you're referencing?
What I think is happening is you aren't expanding the pending_setup_intent field so it is providing a string with the ID of a Setup Intent instead of a nested object, so when you try to drill in to get the client secret you are trying to access fields that don't exist and get a null value instead.
not sure what you mean by expanding the pending_setup_intent field
this is using stripe.net in backend ASP.NET
Can you show me the code that you're using to populate your subscription variable?
sure one sec
it's in VB I'm afraid
Dim subsService As New SubscriptionService()
Dim subsOptions As New SubscriptionCreateOptions()
subsOptions.Customer = cust.Id
subsOptions.PaymentBehavior = "default_incomplete"
subsOptions.TrialEnd = DateTimeOffset.FromUnixTimeSeconds(unixTime).UtcDateTime
subsOptions.ProrationBehavior = "none"
subsOptions.PaymentSettings = paymentSettings
subsOptions.Items = New List(Of SubscriptionItemOptions)
Dim subItem As New SubscriptionItemOptions()
subItem.Price = Price.Id
subsOptions.Items.Add(subItem)
Dim subscription As Subscription = subsService.Create(subsOptions)
Thank you! Yeah, I think what I described is what is happening.
By default the pending_setup_intent field on a Subscription only provides you with the ID of the Setup Intent. In order to instead have the Setup Intent object returned in line with the Subscription object you will need to use our expand feature:
https://stripe.com/docs/api/expanding_objects?lang=dotnet
You will want to expand pending_setup_intent when making the request to create the Subscription, then I believe you'll be able to reference the client secret as you're trying.
The sample code provided in this section includes that use of expand, and can be used as a reference:
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription
Ok thank you, I'll give that a go. Appreciate your time.
Any time, happy to help!
So options.AddExpand("subscription")?
khris-subscription-setupintent
no that would expand a subscription property on a Subscription object which doesn't make sense
apols.
you set the name of what you want to expand, in this case you want to turn the pending_setup_intent: 'seti_123' in the full SetupIntent object
options.AddExpand("pending_setup_intent") or something like that?
so you want our API to return pending_setup_intent: { id:'seti_123', object: 'setup_intent', ...., client_secret: 'xxxx', .... } does that make sense?
yep try that it should work!
ok thanks
@median bay did it work?
Seems to, yes. The AddExpand results in the property not being null, and it has a clientsecret
Just trying to sort out mounting the payments element now
yay
specifically the options parameter
the client secret has the customer product and price all baked in, presumably, so I don't need to explicitly set amount?
correct
Ok, well thanks for you help. My brain is fried now, so I'm giving up for today.
One day at a time ๐