#nerder-subscription-setupintent
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Do you have an example request ID I can look at?
should be this one: https://dashboard.stripe.com/acct_1FuM5ALAVB3C1lDI/test/logs/req_JcPYkQPurnGPJK
this is my code
const stripeSub: Stripe.Subscription = await this.stripe.subscriptions.create(
{
customer: customerId,
items: [
{
price: priceId,
},
],
cancel_at_period_end: isOneOff,
application_fee_percent: gym.transactionFee.percent,
trial_period_days: trialDays,
payment_behavior: 'default_incomplete',
expand: ['latest_invoice.payment_intent', 'pending_setup_intent'],
},
{
stripeAccount: gym.accountId.value,
},
);
let clientSecret = ((stripeSub.latest_invoice as Stripe.Invoice).payment_intent as Stripe.PaymentIntent)
?.client_secret;
// https://stripe.com/docs/billing/subscriptions/overview#non-payment
if (clientSecret === undefined) {
clientSecret = (stripeSub.pending_setup_intent as Stripe.SetupIntent).client_secret;
}
if (clientSecret === undefined) {
throw new Error(`Could not extract client secret from subscription ${stripeSub.id}`);
}
return ClientSecret.of(clientSecret);
basically, i was taking into consideration that a subscription might not have a latest_invoice so I was looking for the client_secret inside the pending_setup_intent that i was previously expanding
Oh I wonder if it has something to do with the customer having a default payment method already
Can you try with a fresh customer object?
ok, let me try real quick
๐
Interesting, can you run a quick test without setting the payment_behavior?
NP!
I can confirm that pending_setup_intent is only present if the Customer/Subscription doesn't already have a properly set up PaymentMethod object