#fabian_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1268225819462078484
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
const subscriptionSchedule = await stripe.subscriptionSchedules.create({
customer: customerId,
end_behavior: 'release',
phases: [
{
items: [
{
price: testProduct,
},
],
iterations: amountTestMonths ?? 1,
currency: 'eur',
},
{
items: [
{
price: mainProduct,
},
],
currency: 'eur',
},
],
});
That looks like it should properly create a schedule that creates a subscription. What is happening instead?
It seems like it doesnt have the same properties as a "real" subscription. eg:
payment_settings: {save_default_payment_method: 'on_subscription'},
expand: ['latest_invoice.payment_intent'],
Also I cant figure out how to get the clientSecret
With a normal subscription I could access it like the following:
clientSecret: (
(subscription?.latest_invoice as Stripe.Invoice)
.payment_intent as Stripe.PaymentIntent
).client_secret,
At the moment I need the client secret to complete the transaction on the client side
Are those the payment behavior and settings that you do want or don't want?
Those setting should properly be reflected on the subscription. Once you do know the settings that you want, you can pass them to the phase settings
Can you tell me more about what you are trying to figure out with what you want these settings to be?
I think my main focus at the moment is the client secret to complete the transaction
I just cant figure out the interaction between a subscription and a subscription schedule.
I need a way to achieve the following but with two phases:
const subscription = await stripe.subscriptions.create({
customer: customerId,
currency: 'eur',
items: [{price: mainProduct}],
payment_behavior: 'default_incomplete',
payment_settings: {save_default_payment_method: 'on_subscription'},
expand: ['latest_invoice.payment_intent'],
});
return {
status: 'success',
message: 'Stripe Subscription created',
subscriptionId: subscription.id,
customerId,
clientSecret: (
(subscription?.latest_invoice as Stripe.Invoice)
.payment_intent as Stripe.PaymentIntent
).client_secret,
};
The schedule create that you have now should work. Is there not a payment intent on the latest invoice when you create it?
If I do the same with subscriptionSchedules