1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00

fix: Plaid webhook verification (#1824)

* Fix Plaid webhook verification

* Fix client creation in webhook controller
This commit is contained in:
Zach Gollwitzer 2025-02-07 10:35:42 -05:00 committed by GitHub
parent 331de2f997
commit 5eb5ec7aef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 87 additions and 62 deletions

View file

@ -6,8 +6,25 @@ class WebhooksController < ApplicationController
webhook_body = request.body.read
plaid_verification_header = request.headers["Plaid-Verification"]
Provider::Plaid.validate_webhook!(plaid_verification_header, webhook_body)
Provider::Plaid.process_webhook(webhook_body)
client = Provider::Plaid.new(Rails.application.config.plaid, region: :us)
client.validate_webhook!(plaid_verification_header, webhook_body)
client.process_webhook(webhook_body)
render json: { received: true }, status: :ok
rescue => error
Sentry.capture_exception(error)
render json: { error: "Invalid webhook: #{error.message}" }, status: :bad_request
end
def plaid_eu
webhook_body = request.body.read
plaid_verification_header = request.headers["Plaid-Verification"]
client = Provider::Plaid.new(Rails.application.config.plaid_eu, region: :eu)
client.validate_webhook!(plaid_verification_header, webhook_body)
client.process_webhook(webhook_body)
render json: { received: true }, status: :ok
rescue => error