#sveba-subscription-schedule

1 messages ยท Page 1 of 1 (latest)

rocky cobalt
#

Hello ๐Ÿ‘‹
Just so that I'm clear, are you trying to migrate existing subscriptions to a schedule or just trying to create a new subscription that is attached to a schedule?

blazing panther
#

my project is still in development, there is no existing subscriptions. I'm just trying to change my code so it works with subscription schedules

rocky cobalt
#

Gotcha. How are you creating the SubscriptionSchedules exactly? There wouldn't be a subscription ID until the schedule kicks in

blazing panther
#

const schedule = await stripe.subscriptionSchedules.create(
{
customer: customer.id,
start_date: "now",
end_behavior: "release",
phases: _initialPrice
? [
{
items: [{ price: _initialPrice }],
iterations: 1,
},
{
items: [{ price: _recurringPrice }],
},
]
: [
{
items: [{ price: _recurringPrice }],
},
],
},
{
stripeAccount: stripeAccountId,
}
);

#

I was getting a subscription id by calling schedule.subscription

#

I thought if I maybe expand the subscription schedule with "latest_invoice.payment_intent" then I could use the subscription id to get the subscription which would allowed me to get the client secret, but it throw an error "This property cannot be expanded (latest_invoice)."

rocky cobalt
#

you'd also likely need to expand the subscription too

#

can you share the code that you're currently using to expand?

blazing panther
#

here's how I expand it

#

const schedule = await stripe.subscriptionSchedules.create(
{
customer: customer.id,
start_date: "now",
end_behavior: "release",
expand: ["latest_invoice.payment_intent"],
phases: _initialPrice
? [
{
items: [{ price: _initialPrice }],
iterations: 1,
},
{
items: [{ price: _recurringPrice }],
},
]
: [
{
items: [{ price: _recurringPrice }],
},
],
},
{
stripeAccount: stripeAccountId,
}
);

blazing panther
rocky cobalt
#

ah okay, mostly need to change this to expand: ["subscription.latest_invoice.payment_intent"]

blazing panther
#

ohh I can I'll try it right now and will let you know, thanks

#

I did what you said, but subscription.latest_invoice.payment_intent is null right now

rocky cobalt
#

can you share the invoice id?

blazing panther
#

in_1LXmhrPqGmcXJ4PgywR5EFYs

rocky cobalt
#

seems like the invoice is still in draft state

#

that's why there isn't a payment intent there

blazing panther
#

how could i then get a client secret to send over to frontend?

rocky cobalt
blazing panther
#

Thank you