#yuichi-hamamoto_docs
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/1381844888731127839
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- yuichi-hamamoto_api, 5 days ago, 22 messages
⛔️ Stripe developers have stepped away for a short while
Please leave your questions here, and we’ll respond as soon as we're back! If you need help urgently, you can contact Stripe support for help.
Hi! Looking into your question!
Can I get the Subscription object you are looking at?
How?
I was going paste the object I retrived but it was too big to paste
Sorry it's screenshot. Could be hard to read
But I am not asking about something specific
I just need the object ID which starts with sub_. I see it in your screenshot. Can you paste that here?
sub_1RW7E1R3ZSJy0f3V6sg9lJ8d
So let's say when the user subscribes and pays the invoice, it will receive invoice.paid hook. But invoice is invoice, I only know the payment was successfully completed for the subscription, and now it's active.
But I would like to know what the invoice was for or at least how long the user is provisioned
like was it for 1/1-31? 2/1-28?
If you look at the invoice.paid event (e.g. https://dashboard.stripe.com/test/events/evt_1RWBoKR3ZSJy0f3VGtjDNf5s) you can see
-
The subscription period:
"period": {
"end": 1780631309,
"start": 1749095309
}, -
Under plan you can see the interval: "interval": "year",
-
You can also see what subscription it is for:
"subscription": "sub_1RW7E1R3ZSJy0f3V6sg9lJ8d"
I see period in object.lines.data: {period:{end,start}}[]
Why is it array?
I was aware interval exists but it only tell me interval but not exact day
As far as I read https://docs.stripe.com/api/subscriptions/object subscription does have the infomation
Where are you seeing this? In the same event I provided?
yea
It only has one object in the array so easy to miss that's an array tho
The period you gave to me belong there
wait not it's just feld
it says there are 28 in the line
Sorry I am a little confused. What is the exact question here?
User subscribe
Pay the incoice
Then receive invoice.paid
but it doesnt have the infomation about for what period
When I receive the hook, I want to provision but with period, from when to when
e.g. start monthly subscription on 1/1
pay on 1/5, then the subscription becomes active. I want to provision for 1/5-2/4 and inform the user
Like "we received payment for 1/5-2/4 so you can use for the period"
The period_start and period_end are the indicators for the start and end of a subscription.
- https://docs.stripe.com/api/invoices/object#invoice_object-period_start
- https://docs.stripe.com/api/invoices/object#invoice_object-period_end
These fields are a timestamp. So you can convert them. Looking at evt_1RWBoKR3ZSJy0f3VGtjDNf5s, below are the conversions:
- period_start: Friday, 5 June 2026 03:48:29 (UTC)
- period_end: Thursday, 5 June 2025 03:48:29 (UTC)
"period_end": 1749095309,
"period_start": 1749095309,
So the reason why period_end and period_start are the same is because it's on the test mode?
I checked some events but they are all same
I am still looking into it. Can you provide these events where you saw they were the same?
evt_1RYKDjR3ZSJy0f3VrDG1ln9B
Thank you for waiting!
Lets focus on sub_1RW7E1R3ZSJy0f3V6sg9lJ8d first.
- You first created this subscription for Jun 4, 2025 - Jun 4, 2026 (https://dashboard.stripe.com/test/invoices/in_1RW7E1R3ZSJy0f3VyO6VuDBq).
- Then you changed the billing cycle anchor to now via this request: https://dashboard.stripe.com/test/logs/req_Eb59xPhH8d9bzT.
- This created a new invoice: https://dashboard.stripe.com/test/invoices/in_1RWBjGR3ZSJy0f3V7ZG56Djr.
- Then you updated the billing cycle anchor again: https://dashboard.stripe.com/test/logs/req_aS8BbskXZQ344y
- This created a new invoice: https://dashboard.stripe.com/test/invoices/in_1RWBmUR3ZSJy0f3VcCxO6BJE
Now for all of these, each invoice is created as the "first" invoice for that new cycle. For first Invoices, since there is no "past" for the invoice, period_start and period_end will be equal in that situation and correspond to the date the Subscription was created. In this cases these invoices all have the same start and end date.
Now moving to sub_1RYKCQR3ZSJy0f3VHanuVtDB:
- Event
evt_1RYKDjR3ZSJy0f3VrDG1ln9Bis forin_1RYKCQR3ZSJy0f3VpQ1QCasj in_1RYKCQR3ZSJy0f3VpQ1QCasjis the first invoice and it follows the same principal as what I mentioned above: For first Invoices, since there is no "past" for the invoice, period_start and period_end will be equal in that situation and correspond to the date the Subscription was created. In this cases these invoices all have the same start and end date.
So in any case, there's no way I know what the invoice/payment was for, for the first payment of subscription?
But for 2-n th cycle of subscription, I can refer period_start and period_end
You can see the reason for the Invoice via the billing_reason for the invoice: https://docs.stripe.com/api/invoices/object#invoice_object-billing_reason
I meant for the first payment, I dont know when the first cycle will ends right
You should use the subscription's line item's period.
period: {
end: 1780631309,
start: 1749095309
},
Why do you say that?
So it's safe to search the array of line items for subscription if the billing_reason is related to subscription?
and the number of subscription exists in lines is 1
Becasue invoice.period_end and period_start is not usable for first payment and need to search in lines to find currect period
Yes you should get the start and end dates from the subscription line items.
ok I get it