#stan_api
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
🔗 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/1212672421266591744
📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.
⏲️ 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. Thank you for your patience!
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
Can you share the request ID (req_xxx) which you retrieve the Subscription with expanding those two fields and its response returned from Stripe? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
subscriptionId: sub_1Op4ozGogiQBpoccUCxP2crW
reqId: req_jlN0tZgTlq4N6c
this is how I create the schedule
{
customer: customerId,
start_date: 'now',
end_behavior: 'release',
phases: [
{
items: [
{
price: price?.id,
quantity,
},
],
trial: true,
end_date: subscriptionStartPeriod.utc().unix(),
},
{
items: [
{
price: price?.id,
quantity,
},
],
end_date: subscriptionStartPeriod.add(1, 'month').startOf('month').add(12, 'hours').utc().unix(),
},
{
items: [
{
price: price?.id,
quantity,
},
],
iterations: 100,
},
],
expand: ['subscription.pending_setup_intent', 'subscription', 'subscription.latest_invoice'],
}
When a subscription is created immediately via Subscription Schedule, the first invoice is in draft status that the Payment Intent hasn't been created yet: https://dashboard.stripe.com/test/invoices/in_1Op4ozGogiQBpoccUSpmZJ6p
The first invoice should be finalised to generate the Payment Intent.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Your invoice is not finalised, so it's expected that Payment Intent is null: https://dashboard.stripe.com/test/invoices/in_1Op4ozGogiQBpoccUSpmZJ6p
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
so how do I verify the payment using schedule
You should finalise the latest_invoice to get the Payment Intent: https://docs.stripe.com/api/invoices/finalize
Alternatively, I'd recommend following:
- Create a subscription directly with the guide here: https://docs.stripe.com/billing/subscriptions/build-subscriptions?ui=elements
- Only when the payment is made successfully, then you create a subscription schedule: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#changing-subscriptions
when I finalize it, payment_intent is again null on the invoice itself
The invoice is still shown as draft: https://dashboard.stripe.com/test/invoices/in_1Op4ozGogiQBpoccUSpmZJ6p
How do you finalise the invoice? Can you share the request ID (req_xxx) which you finalised the invoice?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
const invoice = await this.stripeClient.invoices.finalizeInvoice(
(subscription.latest_invoice as Stripe.Invoice).id,
);
const s = await this.stripeClient.subscriptions.retrieve(subscription.id, {
expand: ['pending_setup_intent', 'latest_invoice'],
});
Can you share the request ID (req_xxx) which you finalise the invoice? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
I don't see in_1Op4ozGogiQBpoccUSpmZJ6p being finalised
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_FuzCoGuuHCZEeX
after finilizing, do I need to retrieve the subscription again with expand: ['latest_invoice']
and look for the intent there ?
This is a zero dollar invoice. It's expected that Payment Intent will not be present even after you finalise it
yeah my first item is trial
When you retrieve the Subscription again for zero dollar in first invoice, pending_setup_intent should be present
but it is null
await this.stripeClient.invoices.finalizeInvoice((subscription.latest_invoice as Stripe.Invoice).id);
const s = await this.stripeClient.subscriptions.retrieve(subscription.id, {
expand: ['pending_setup_intent', 'latest_invoice'],
});
console.log(s.pending_setup_intent);
Can you share the request ID (req_xxx) of your subscription retrieval and the full response from Stripe?
req_4fj2A4L1oCQ8Ph
this is finilize
then I do GET of the subscription, there is no log for the get
Stripe doesn't store the GET response. Sharing the GET response from your request will help us to understand the problem
ok
for request: req_mQ1p6En7Q0OYGR
and this is how I get this response after finalizeInvoice
const s = await this.stripeClient.subscriptions.retrieve(subscription.id, {
expand: ['pending_setup_intent', 'latest_invoice'],
});
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
ok
We just checked and it seems to be a known bug. What you can do instead is create a Subscription with trial normally, and when the trial ends/customer adds a Payment Method, turn it into a Subscription Schedule.
this means that I have to create subscription and after 14 days to cancel it with crone and create a new one ?
what I need to achieve is to create a subscription with 14 days free trial and the billing of the subscription should happen on 1st of each month
you college pointed me to go to schedules
now you are saying that I have to build the subscription on my self with crone ?
No, I didn't mention cron.
Sorry, the second link shouldn've been this: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#existing-subscription
You can turn any regular Stripe Subscription into a Subscription Schedule. You should create one regular Subscription with trial, and then turn it into a Subscription Schedule (as you do now), with from_subscription parameter.
so what you mean is to create subscription and then create schedule with that subscription
when I create it from subscription, I can't set phases ?
as I said I need it to start now, to have 14 days trial and then to start normal billing from 1st of the month
if the user subscribe today it should have trial till 14 of march
So the trial is not 14 days? What if I start on the 20th, for example?
on 14 it should bill for 14-31 march
and then full billing on 1st of aprial
it is for 14 days
Oh, got it. billing_cycle_anchor should be on the 1st of the month.
this is what I am trying to build
Yes, that's correct.
exactly
You need to first create the Schedule and then update it with additional phases.
but then I am missing payment_intent
I can't get it when I create schedule
- create subscription with 14 days trial
- create schedule from that subscription
- update it some how and add more items ?
- You will get the
pending_setup_intentwhen you create a regular Subscription with a trial. - Then you listen to
setup_intent.succeeded(meaning customer added a Payment Method) and turn Subscription into a Subscription Schedule. - Immediately after add more phases to your S.Schedule.
ok, can you give me example of how to turn it to schedule
first I create schedule from the subscription and then how to add items ?
Here's an example of turning a Subscription into a S.Schedule: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#existing-subscription
yes this is how to create schedule from subscription
but then I need to add more items
is there example for it
You have to update the Subscription Schedule with phases, just as you do when you create it right now: https://docs.stripe.com/api/subscription_schedules/update#update_subscription_schedule-phases
do I need again to add trial phase ?
Yes, I think so. You need to specify the currently running phase too.