#ssbjsb_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/1353838902972252243
๐ 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.
- ssbjsb_api, 9 minutes ago, 13 messages
- ssbjsb_api, 3 days ago, 35 messages
Customer in question: cus_S0IoPwNAyEoCSq
I'm advancing the clock 60 days to test bank transfer payments using the apply_customer_balance endpoint on invoices past due for than 30 days.
When I fund the cash balance after advancing the clock, the invoice is automatically getting paid since the request is happening in current time and not in the future time.
And hence getting this error from the from the apply_customer_balance endpoint
{"error"=>
{"message"=>"Invoice is already paid",
"request_log_url"=>"https://dashboard.stripe.com/test/logs/req_JY91fR3hnagQBp?t=1742850423",
"type"=>"invalid_request_error"}}
How do I simulate this in my test so that the funding happens in the future on Stripe and the apply_customer_balance call also happens in the future
Hi there
Hello ๐
Hm, there are no customers associated with this test clock
If/when a customer is managed by a test clock, you should see a bright banner when looking at the customer in the Dashboard: https://dashboard.stripe.com/test/customers/cus_S0IoPwNAyEoCSq
You could also retrieve the Customer and see if their test_clock property is not null/empty: https://docs.stripe.com/api/customers/object#customer_object-test_clock
Okay I see that.
I just made a change in my test associating the customer with the clock.
Still getting the same error.
Here is the customer: cus_S0J3eHlm4hm66I
The invoice is getting paid immediately as soon as the cash balance is funded (This does not happen in production when the time is really in the future).
clock: clock_0R6IRE5QM0nABsUHEO33q1d6
Do I need to associate the invoice with the test clock too?
No, the Invoice should inherit the test clock time from the Customer
Let me take a step back. Can you provide a 1-2 sentence summary of the scenario you're trying to test so we're on the same page?
Invoice is past due for more than 30 days.
The customer then transfers enough cash to cover the invoice amount (For eg. after 60 days of invoice creation).
Stripe does not automatically reconcile the invoice in production.
We have to handle that in our code.
Using the apply_customer_balance endpoint on the PaymentIntent to pay the invoice on the customer's behalf.
Trying to simulate that using test clocks.
But the requests after advancing the test clocks are happening in current time and not in the simulated future time. Hence the apply_customer_balance endpoint is getting an error instead of properly applying the payment.
When I fund the customer cash balance through my test it happens in current time instead of the simulated future time and the invoice is automatically getting paid which I am trying to avoid.
Let's see, I'm taking a look at in_0R6IRH5QM0nABsUHjjmtdYiJ
Shouldn't the events in the red box be happening in the simulated future time? I am advancing the clock before any of those calls are made
Screenshot is from invoice: in_0R6Ie15QM0nABsUHR90UvW8L
Any ideas?
Yeah, I see you advanced the test clock time after finalizing the Invoice and before funding the Customer's balance
Yes
I am advancing the time in my RSpec too
{:current_time_while_funding=>Fri, 23 May 2025 22:04:33.000000000 UTC +00:00}
But stripe is logging the request in current time.
Okay, I think this is a rough edge with Events and test clocks. The Event object's created at timestamp will be the real time, not the test clock time
That said, the data in the payload should match up with the test clock. So, for example, if you look at https://dashboard.stripe.com/test/events/evt_0R6IeY5QM0nABsUHpOoJnUep
status_transitions.paid_at is 1753220098, which lines up with your test clock time (July 22, 2025)
Is there a way to turn off automatic reconciliation on the invoice when I fund the cash balance through my test?
That would avoid the automatic invoice payment and would depend on my API call to apply the customer balance to the payment intent.
hi! i'm taking nover for roadrunner, catching up on the thread now
Hi!
Thank you
of course! ๐
just double checking - is this the only outstanding question at this point?
Is there a way to turn off automatic reconciliation on the invoice when I fund the cash balance through my test?
Yes