Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe.Webhook fails to process message for "financial_connections.account.created" #817

Closed
1 task done
tmaszk opened this issue Oct 9, 2023 · 5 comments
Closed
1 task done

Comments

@tmaszk
Copy link

tmaszk commented Oct 9, 2023

Package Version

3.0.0

Are you using the latest version?

  • Yes, I verified the issue is still present in the latest version.

Steps to Reproduce

  1. Create a CheckoutSession and display to user
  2. User enter a financial institution in the stripe UI
  3. Receive webhook for "financial_connections.account.created" and see error

I haven't spent a lot of time analyzing it, but I think the problem is Stripe.Webhook.convert_stripe_object/1 converting the incoming object "financial_connections.accout" into the module FinancialConnections.account where is should be FinancialConnections.Account

gist of the code for step 1:

params = %{
  success_url: "http://localhost:4000/success",
  cancel_url: "http://localhost:4000/cancel",
  mode: :payment,
  payment_method_types: [:us_bank_account],
  payment_method_options: %{
    us_bank_account: %{
      financial_connections: %{permissions: [:payment_method, :balances]}
    }
  }
 payment_intent_data: %{
    setup_future_usage: :off_session,
    capture_method: :automatic
  }
}

Stripe.Checkout.Session.create(params)

Expected Result

expected Stripe.WebhookHandler to successfully parse message for "financial_connections.accout"

Actual Result

Using the stripe cli, received the following messages (sensitive info omitted)

[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG websocket.Client.readPump: Incoming message message={"type":"webhook_event","endpoint":{"api_version":null},"event_payload":"{
  \"id\": \"evt_...\",
  \"object\": \"event\",
  \"api_version\": \"2020-08-27\",
  \"created\": 1696873216,
  \"data\": {
    \"object\": {
      \"id\": \"fca_...\",
      \"object\": \"financial_connections.account\",
      \"account_holder\": null,
      \"balance\": null,
      \"balance_refresh\": null,
      \"category\": \"cash\",
      \"created\": 1696873211,
      \"display_name\": \"Success\",
      \"institution_name\": \"StripeBank\",
      \"last4\": \"7777\",
      \"livemode\": false,
      \"ownership\": null,
      \"ownership_refresh\": null,
      \"permissions\": [
        \"balances\",
        \"payment_method\"
      ],
      \"status\": \"active\",
      \"subcategory\": \"checking\",
      \"supported_payment_method_types\": [
        \"us_bank_account\"
      ]
    }
  },
  \"livemode\": false,
  \"pending_webhooks\": 2,
  \"request\": {
    \"id\": null,
    \"idempotency_key\": null
  },
  \"type\": \"financial_connections.account.created\"
}","http_headers":{"Accept":"*/*; q=0.5, application/xml","Cache-Control":"no-cache","Content-Type":"application/json; charset=utf-8","Stripe-Signature":"t=1...","User-Agent":"Stripe/1.0 (+https://stripe.com/docs/webhooks)"},"webhook_conversation_id":"...,"webhook_id":"..."}
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG proxy.WebhookEventProcessor.ProcessEvent: Processing webhook event webhook_converesation_id=... webhook_id=...
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG proxy.WebhookEventProcessor.filterWebhookEvent: Received event with non-default API version, ignoring api_version=2023-08-16
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG Setting read deadline:
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG websocket.Client.writePump: Sending text message
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG proxy.WebhookEventProcessor.ProcessEvent: Processing webhook event webhook_converesation_id=... webhook_id=...
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG websocket.Client.writePump: Sending text message
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG proxy.EndpointClient.Post: Forwarding event to local endpoint
2023-10-09 13:40:16   --> financial_connections.account.created [evt_...]
[Mon, 09 Oct 2023 13:40:16 EDT] DEBUG websocket.Client.writePump: Sending text message
2023-10-09 13:40:16  <--  [500] POST http://localhost:4000/webhook/stripe [evt_...]

In the terminal, elixir logged the error and trace:

13:40:16.598 [error] Loading of .../_build/dev/lib/stripity_stripe/ebin/Elixir.Stripe.FinancialConnections.account.beam failed: :baffle

13:40:16.598 [error] beam/beam_load.c(180): Error loading module 'Elixir.Stripe.FinancialConnections.account':
  module name in object code is 'Elixir.Stripe.FinancialConnections.Account'

13:40:16.614 [error] beam/beam_load.c(180): Error loading module 'Elixir.Stripe.FinancialConnections.account':
  module name in object code is 'Elixir.Stripe.FinancialConnections.Account'

13:40:16.614 [error] Loading of .../_build/dev/lib/stripity_stripe/ebin/Elixir.Stripe.FinancialConnections.account.beam failed: :badfile

13:40:16.652 [error] Loading of .../_build/dev/lib/stripity_stripe/ebin/Elixir.Stripe.FinancialConnections.account.beam failed: :baffle

13:40:16.652 [error] beam/beam_load.c(180): Error loading module 'Elixir.Stripe.FinancialConnections.account':
  module name in object code is 'Elixir.Stripe.FinancialConnections.Account'

13:40:16.673 [error] #PID<0.9726.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.9613.0>, stream id 2) terminated
Server: localhost:4000 (http)
Request: POST /webhook/stripe
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function :"Elixir.Stripe.FinancialConnections.account".__struct__/0 is undefined (module :"Elixir.Stripe.FinancialConnections.account" is not available)
        :"Elixir.Stripe.FinancialConnections.account".__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 4.3.1.1) maps.erl:411: :maps.fold_1/3
        (stripity_stripe 3.0.0) lib/stripe/converter.ex:52: anonymous fn/3 in Stripe.Converter.convert_stripe_object/1
        (elixir 1.14.5) lib/enum.ex:2468: 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
        ...
@tmaszk
Copy link
Author

tmaszk commented Oct 9, 2023

Seems like it may be addressed by #792

Copy link

github-actions bot commented Nov 9, 2023

This issue has been automatically marked as "stale:discard". If this issue still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment.

@tmaszk
Copy link
Author

tmaszk commented Nov 12, 2023

bump

Copy link

This issue has been automatically marked as "stale:discard". If this issue still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment.

@yordis
Copy link
Member

yordis commented Dec 22, 2023

@tmaszk are you still facing this issue?

@yordis yordis closed this as completed Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants