stripe/stripe-java

Allow Webhook class instance to be configured with java.time.Clock

lnhrdt opened this issue · 2 comments

lnhrdt commented

Is your feature request related to a problem? Please describe.

In our application every piece of code that references the current time uses a instance of java.time.Clock. This technique has allowed us to create a suite of reliable tests (aka not flakey tests) in a consistent way across our codebase.

com.stripe.net.Webhook makes a direct reference to java.lang.System.currentTimeMillis() which prevents us from using this technique when testing our Stripe webhook integration. I wish it were possible to create a configured instance of Webhook (perhaps in a similar way to the new StripeClient builder) passing in an instance of Clock so that we could test our Stripe webhook integration in the same way as the rest of our application.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Hello @lnhrdt, thanks for the feedback. This seems like a reasonable request to me. I'm marking this as future as we won't be able to prioritize this right away.

Today we updated our webhook configuration and tests to take advantage of the clock configuration option introduce in #1739. It worked great and we're happy to have this improvement.

Thank you @WilliamChang80!