beam-community / stripity-stripe

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

Stripe.Converter.convert_result not returning struct #793

Closed sb8244 closed 1 year ago

sb8244 commented 1 year ago

I ran into an issue in my test suite where Stripe.WebhookHandler handle_event receives an object that isn't a struct. I tracked this down in the code to the check known_struct?/1

I believe the issue here is that in some envs (not sure how prod vs dev vs test works here), the build modules aren't preloaded. So if you check function_exported? before the module is loaded, it will always return false.

https://github.com/sb8244/stripity-stripe/blame/main/lib/stripe/converter.ex#L118

I may be wrong here, so I didn't PR a fix yet. My fix for now will be to manually ensure the necessary stripe files are loaded using Code.ensure_loaded!