#やまだ えしら
1 messages · Page 1 of 1 (latest)
Hi, thanks for everything.
I'm trying to test with a test clock in a staging environment.
Okay but why do you need to list invoices?
For example, if the following Invoice is created using the test clock
- \4000 4/4 1:30 (timestamp: 1680625800)
- \4000 4/1 0:00 (timestamp: 1680274800)
3.\4000 3/32 19:30 (timestamp: 1679568835)
(The amount is not important, the time is important)
Stripe::Invoice.list({ customer: "xxx", created { gte: 1680274800 } }) should return 1 and 2 invoices, but actually nothing is returned
Yeah this is not expected to work with test clocks
You would need to create non-test clock invoices or mock data if you want to test listing
But why do you actually need to test listing?
Like what are you really trying to do?
Yeah this is not expected to work with test clocks
Yes, I think so too.
I have implemented a system for booking downgrades and automatically billing for upgrades (and the difference) in my application. However, currently I am running Stripe from the dashboard and there is a potential for data conflicts. Therefore, we attempted to investigate carefully using a test clock.
Gotcha. So yeah if you want to test something over time then test clocks are great. But to test data ingestion behavior using something like a list request that won't really work with test clocks.
What you could do is isolate the invoices you wan to list to a Customer and then list by that Customer ID instead of created
That may be able to accomplish the same thing you are trying to do
I see. Can you tell us how to do that?
Invoice.list and created are used to get the "amount paid during the month
Well you just isolate the Invoices you are creating to one Customer object. Then use https://stripe.com/docs/api/invoices/list#list_invoices-customer
It looks like the same API I just wrote, what's the difference?
It is the same API but you are filtering your Invoices based on the Customer ID instead of relying on the created timestamp
This should work fine with test clocks
Create all your invoices within one month on one Customer
To simulate the same idea of using created
I understand!
If you don't specify created, the data will be returned normally (because it doesn't use the internal created).
Thank you.
I will try to get all of them first and check if the date is the current month on the code side.
Anyway, I’m sure he’s trying to do something weird, and if I can be certain that he can’t do it, that’s all that matters.
👍
Thanks for always getting back to me quickly and with the right answers.