Class: Webhooks::Incoming::Oauth::StripeAccountWebhooksController
- Inherits:
-
WebhooksController
- Object
- WebhooksController
- Webhooks::Incoming::Oauth::StripeAccountWebhooksController
- Defined in:
- app/controllers/webhooks/incoming/oauth/stripe_account_webhooks_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/webhooks/incoming/oauth/stripe_account_webhooks_controller.rb', line 2 def create # we have to validate stripe webhooks based on the text content of their payload, # so we have to do it before we convert it to json in the database. payload = request.body.read # this throws an exception if the signature is invalid. Stripe::Webhook.construct_event( payload, request.env["HTTP_STRIPE_SIGNATURE"], ENV["STRIPE_WEBHOOKS_ACCOUNTS_ENDPOINT_SECRET"] ) Webhooks::Incoming::Oauth::StripeAccountWebhook.create( data: JSON.parse(payload), # we can mark this webhook as verified because we authenticated it earlier in this controller. verified_at: Time.zone.now ).process_async render json: {status: "OK"}, status: :created end |