#ssbjsb_api

1 messages ยท Page 1 of 1 (latest)

wind oracleBOT
#

๐Ÿ‘‹ 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.

little urchin
#

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

dusty fjord
#

Hi there

little urchin
#

Hello ๐Ÿ‘‹

dusty fjord
#

Hm, there are no customers associated with this test clock

little urchin
#

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?

dusty fjord
#

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?

little urchin
#

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.

dusty fjord
#

Let's see, I'm taking a look at in_0R6IRH5QM0nABsUHjjmtdYiJ

little urchin
#

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?

dusty fjord
#

Yeah, I see you advanced the test clock time after finalizing the Invoice and before funding the Customer's balance

little urchin
#

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.

dusty fjord
#

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

little urchin
#

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.

wind oracleBOT
oblique anvil
#

hi! i'm taking nover for roadrunner, catching up on the thread now

little urchin
#

Hi!
Thank you

oblique anvil
#

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?

little urchin
#

Yes

oblique anvil
#

ok cool! looking into that now

#

ok i'm not seeing a way to do that... i'm still digesting the thread, do you mind if i ask you to summarize why this would be needed in your case?

little urchin
#

I figured it out and made the test pass and successfully simulate the situation

#

Had to set the cash_balance settings on the customer with the reconciliation_mode as manual