#やまだ えしら

1 messages · Page 1 of 1 (latest)

fair cloakBOT
paper crown
#

Hi there

#

Yeah that won't really work

#

What are you trying to do?

wicked saddle
#

Hi, thanks for everything.
I'm trying to test with a test clock in a staging environment.

paper crown
#

Okay but why do you need to list invoices?

wicked saddle
#

For example, if the following Invoice is created using the test clock

  1. \4000 4/4 1:30 (timestamp: 1680625800)
  2. \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

paper crown
#

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?

fair cloakBOT
wicked saddle
#

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.

paper crown
#

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

wicked saddle
#

I see. Can you tell us how to do that?

#

Invoice.list and created are used to get the "amount paid during the month

paper crown
wicked saddle
#

It looks like the same API I just wrote, what's the difference?

paper crown
#

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

wicked saddle
#

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.

paper crown
#

👍

wicked saddle
#

Thanks for always getting back to me quickly and with the right answers.