#harshil-ahir_code

1 messages · Page 1 of 1 (latest)

rotund nacelleBOT
#

👋 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/1397074503317717052

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

winged horizon
#

Hi there, is there a specific error you're seeing in your test?

whole needle
#

no i am not seeing any error i am created a client secret key in my local of a customer and product which is created in stripe test mode and i am sending these to FE team and they are paying that amount in my dev server so that i am able to see the logs of payment done and event hit in first time but after there is nothing when the event is hit from webhooks ,also in my webhook i am added every event which is necessary

#

But once the payment is made by FE side i am calling these function in my local will it work
public TestClock advanceTestClock(String testClockId, Long seconds) throws StripeException {
Stripe.apiKey = stripeSecretyKeyTest;
TestClock testClock = TestClock.retrieve(testClockId);

    TestClockAdvanceParams advanceParams = TestClockAdvanceParams.builder()
        .setFrozenTime(testClock.getFrozenTime() + seconds)
        .build();

    return testClock.advance(advanceParams);
}

which will help me to call my recuring payment early

winged horizon
#

Are you testing recurring payments like Subscriptions or normal one-time payments like PaymentIntents?

whole needle
#

Subscriptions

winged horizon
#

Test clocks should work with subscriptions

whole needle
#

Yes i know and i am working on subscriptions as i have explained whole scenario to you

winged horizon
#

yes but I'm sorry, I'm having a hard time grasping the question or the unexpected behaviour. What do you mean by "call my recuring payment early?"

#

to clarify, once a customer or subscription is created inside a Test Clock, the Test Clock needs to be advanced in order to progress along the subscription's billing cycle

whole needle
#

like the product i have purchase its recuring on daily basic i want to test that automatic payment is working or not on next bill so i have used the advanceTestClock method from which my next billing date will occur today only

winged horizon
#

Yes

whole needle
#

in which i am failing to do so

winged horizon
#

What is the error you're seeing?

#

or could you share with me the Subscription ID so that I can have a better look at your integration ?

whole needle
#

i havent stored subscription id but maybe these event logs help you to check the scenario

#

in these you can get subscription id also easily

#

sub_1RnJExEO9jafft5P1mJbhwaB

winged horizon
#

your subscription's second invoice is still in Draft mode

whole needle
#

Means ??

#

sub_1RnIqeEO9jafft5PNleZpFOY
sub_1RnIQOEO9jafft5PB2ghBONR

before that i have created these subscription also

winged horizon
#

I believe this is the webhook endpoint you've set up - we_1QtSq5EO9jafft5PjBMVeQxP — this webhook endpoint is not set to listen to invoice.created or invoice.finalized events, this is likely the reason your webhook didn't receive events when your test clock advanced.

Invoice being in Draft means that Stripe hasn't initiate payment: https://docs.stripe.com/invoicing/integration/workflow-transitions
For subscriptions' invoices, Stripe takes an hour to finalize the invoice from the invoice creation time: https://docs.stripe.com/billing/invoices/subscription

#

it is shown in the Dashboard that payment will be collected at 7/22/25, 7:21 PM

whole needle
#

i have just used invoice.paid for payment in which i am updating the data for my database which come in my first payment these event is trigger and i am updating my data should i need to add other event also for recuring payments not the first one

whole needle
# winged horizon

yes thats what i want to check that it will automatically deducting the payment or not

whole needle
winged horizon
#

It should automatically deduct the payment. You can advance your test clock to July 22, 2025 | 7:30 PM GMT+5:30 to check

#

Could you clarify what you meant by "checking it now before the billing date"? The subscription charges automatically so the customer will be billed when the invoice finalized on 7/22/25, 7.21PM.

whole needle
winged horizon
winged horizon
whole needle
whole needle
winged horizon
#

No, the subscription will follow Test Clock's time. Your test clock time is currently at 6:21PM and the invoice is set to finalize at 7:21PM. It is not possible to trigger the payment sooner

whole needle
#

i want to test the trigger event is working properly or not by automatic deduction

whole needle
whole needle
winged horizon
# whole needle i want to test the trigger event is working properly or not by automatic deducti...

It is not possible to trigger payment events sooner than expected with Subscriptions. Subscriptions follows a billing cycle and each subscription has a billing cycle anchor [0] that determined when recurring payments are collected.

Using Test Clocks will not help trigger payment events sooner than expected. If the invoice finalized at 7:21PM but the Test Clock's time is set at 6:21PM, you have to advance your test clock past 7:21PM to verify that the subscription's invoice has collected payment.

It shouldn't matter whether you advance 24hours or with an additional 5 minutes as long as the new test clock time takes into consideration the one hour invoice finalization time. Therefore, if your test clock time is at 6:21PM but your invoice finalized at 7:21PM the next day, you need to advance your testclock 25 hours ahead, plus ~few minutes ahead to be sure your test clock passed the invoice finalization time.

[0] https://docs.stripe.com/api/subscriptions/object#subscription_object-billing_cycle_anchor

whole needle
#

Okay can you just let the chat opened so i can test the code withthese logic

winged horizon
#

we close idle threads on Discord but you can always start a new thread if you have another question.

whole needle
#

will these new threads will continue these chats

winged horizon
#

nope it will not be a continuation. You will be prompted to post a new question

whole needle
#

sub_1RnaSREO9jafft5PgicWHS7k

can you check for these subscription whats the next payment time as i have already added advanced clock time for 25 hours

#

@winged horizon you there ??

winged horizon
#

@whole needle your subscription's next payment is set to invoice on Jul 24, but your test clock time is currently at Jul 23

#

I would recommend advancing the test clock in the Dashboard so that you can very its current time to avoid any confusion

whole needle
winged horizon
#

You can click on the Advance time button at the top right of the purple banner

whole needle
#

Okay thank for the info after advancing the time my event didnt trigger invoice.paid event it just only triggered invoice.created,dont my invoice automatically should be paid in subscription ???as i suscribe it

rotund nacelleBOT
delicate burrow
#

Hey! Taking over for my colleague. Could you please share the invoice Id you are referring to ?

whole needle
#

in_1RnarjEO9jafft5PNRICAPCy

#

i get event of invoice created but i am using subscription and automatic payment will be done and i have added invoice.paid for recuring payment in my webhooks

delicate burrow
#

THis invoice in still in draft mode, try advancing the test clock by 1 hour and it should be finalized and paid

whole needle
#

It worked thanks for you support @delicate burrow & @winged horizon

rotund nacelleBOT