Class: PaymentKit::WebhookController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- PaymentKit::WebhookController
- Defined in:
- app/controllers/payment_kit/webhook_controller.rb
Overview
HTTP entrypoint: verify signature(s) → dedupe → instrument → 200 OK.
PaymentKit treats 4xx as a permanent failure (no retry) and retries 5xx or timeouts five times over roughly 27 hours, so failure mapping matters:
- bad/missing signature → 401, never retried
- verified but unparseable → 400, never retried
- subscriber raised → 500 by default (retried), or 200 when
PaymentKit.error_handleris configured
Endpoints must answer within 30 seconds, so subscribers should enqueue work rather than perform it inline.
Instance Method Summary collapse
-
#event ⇒ Object
Handles one webhook delivery: verify, deduplicate, dispatch, answer.
Instance Method Details
#event ⇒ Object
Handles one webhook delivery: verify, deduplicate, dispatch, answer.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/payment_kit/webhook_controller.rb', line 24 def event # raw_post (not body.read) so verification still sees the exact bytes # after middleware or param parsing has consumed the request stream. PaymentKit.process_webhook( request.raw_post, request.headers["X-Webhook-Signature"] ) head :ok rescue AuthenticationError => e logger&.error("[PaymentKit::WebhookController] #{e.}") head :unauthorized rescue InvalidRequestError => e logger&.error("[PaymentKit::WebhookController] #{e.}") head :bad_request rescue StandardError => e raise if PaymentKit.error_handler.nil? PaymentKit.error_handler.call(e, request) head :ok end |