beam-community / stripity-stripe

An Elixir Library for Stripe
Other
965 stars 344 forks source link

Stripe.TestClock is undefined #810

Closed PJUllrich closed 11 months ago

PJUllrich commented 11 months ago

Hey folks 👋

when I test my subscription flow locally using Stripe's TestClock simulation, I receive the following error whenever an event with the object name test_helpers.test_clock comes in:

Request: POST /webhooks/stripe
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function Stripe.TestClock.__struct__/0 is undefined (module Stripe.TestClock is not available)
        Stripe.TestClock.__struct__()
        (stripity_stripe 3.0.0) lib/stripe/converter.ex:41: Stripe.Converter.convert_stripe_object/1
        (stripity_stripe 3.0.0) lib/stripe/converter.ex:34: anonymous fn/2 in Stripe.Converter.convert_map/1
        (stdlib 5.0.1) maps.erl:416: :maps.fold_1/4
        (stripity_stripe 3.0.0) lib/stripe/converter.ex:52: anonymous fn/3 in Stripe.Converter.convert_stripe_object/1
        (elixir 1.15.3) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
        (stripity_stripe 3.0.0) lib/stripe/converter.ex:46: Stripe.Converter.convert_stripe_object/1
        (stripity_stripe 3.0.0) lib/stripe/webhook.ex:45: Stripe.Webhook.construct_event/4
        (stripity_stripe 3.0.0) lib/stripe/webhook_plug.ex:136: Stripe.WebhookPlug.call/2

It seems that the Stripe.TestClock struct, which was introduced in PR #723 was somehow removed. I think it was renamed to Stripe.TestHelpers.TestClock, but maybe the struct name in this function here was not renamed.

PJUllrich commented 11 months ago

I created a PR that potentially fixes this. https://github.com/beam-community/stripity-stripe/pull/811