What this thread does
Do first: verify the exact request.raw_post bytes with Stripe::Webhook.construct_event before recording or enqueueing a subscription webhook.
Short answer
As of November 2026, use current Rails/Stripe Ruby docs; the optional Pay integration baseline is Pay v13.4.1 (checked 2026-11-24). Separate authenticated Checkout initiation, durable webhook receipt and idempotent subscription processing. An HTTP acknowledgement establishes receipt, not completion of later Rails jobs.
Choose / don't choose
- Pay: choose its existing verified-webhook handling; don't install a second competing receiver for the same event route.
- Application-owned receiver/job: choose when custom inbox and processing semantics are required; own uniqueness, durable scheduling, retries and reconciliation explicitly.
- Retrieve current subscription: choose when deliveries arrive out of order or a snapshot cannot establish current entitlement. Do not overwrite newer subscription state merely because an older event arrived later (Stripe ordering).
Not for: general Stripe subscription lifecycle selection; see stripe-subscriptions-saas-checkout-portal-lifecycle-events.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
Stripe::Webhook.construct_event | Pass raw payload, Stripe-Signature header and the endpoint signing secret; never substitute an API key | Current stripe-ruby API | signature guide |
tolerance: | DEFAULT_TOLERANCE = 300; current Ruby code rejects timestamps older than now minus tolerance | Current stripe-ruby source | implementation |
request.raw_post | Reads the request body for web services working with raw requests directly | Current Rails request API | request reference |
retry_on exception list | Retry only named transient failures; example ActiveRecord::Deadlocked | Application-owned Active Job class | retry API |
wait:, attempts: | Example 5.seconds, 3; attempts includes initial execution. Defaults are 3 seconds and 5 attempts | Current Active Job API | retry API |
jitter: | Default 0.15; retain bounded spread or choose explicitly | Current Active Job API | retry API |
config.active_job.queue_adapter | Durable deployed backend, e.g. :solid_queue, with running workers | Current Rails queue guide | Active Job |
Checkout mode | subscription with server-selected recurring Prices and authenticated billable account | Pay Checkout API | Checkout guide |
Order of operations
1. With Pay, install its migrations and mark the authenticated model billable using pay_customer (installation). Configure server-side credentials and the HTTPS /pay/webhooks/stripe endpoint with subscription/invoice events (configuration, event guide). Start Checkout from that account. 2. For an application-owned receiver, verify the payload before parsing it. Reject invalid signatures or malformed payloads by raising the signature error or an exception from a bad payload that fails to parse; never enqueue them for transient retry. Exempt only the webhook route from browser CSRF as needed; its authenticity comes from the validated signature (Stripe guide). 3. In a transaction persist the validated provider event ID and payload in an inbox with a database unique index. Commit durable acceptance and reliable job scheduling before returning 2xx. If durable acceptance fails, return non-2xx so delivery can retry. Receipt is distinct from a processed marker (indexes, transaction model). 4. In the job, use with_lock to start a transaction and acquire the lock, skip an already processed event, apply the subscription update and mark processed in the same transaction. A rollback must leave the event recoverable. This is an application inbox design derived from database transactions and Stripe duplicate delivery, not a built-in exactly-once promise. 5. Reconcile the provider's current subscription for out-of-order state changes. Track event IDs to identify duplicate deliveries; an event timestamp alone cannot establish order. For external billing writes use the provider's idempotency contract as well (Stripe delivery contract). 6. Bound transient job retry, retain failed executions for repair and replay through the same idempotent path. Pay records payloads and enqueues Pay::Webhooks::ProcessJob (Pay queues). 7. Exercise duplicate/concurrent delivery, a failed transaction and reversed event order; require one local business effect, recoverable failures and current subscription state.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
No signatures found matching the expected signature for payload | At least one of the three verification parameters is incorrect | Read raw body before alteration; compare endpoint/CLI signing-secret selection without logging secrets | signature guide |
Timestamp outside the tolerance zone | Delivery signature timestamp is older than allowed age | Synchronize time; validate at receipt, before delayed processing; keep stored authenticated events separate from fresh delivery checks | Ruby implementation |
undefined method fetch | Stripe metadata treated as a Ruby Hash in a custom listener | Use string-key access and confirm event object type, then replay idempotently | mices / yudin-s, August 2026 discussion |
Diagnostic: delivery acknowledged but subscription unchanged
Inspect Rails queue execution, not only provider delivery status. The discussion describes the Stripe CLI as a webhook forwarder and identifies an undefined method fetch error on the reader side.
Missing
- Not confirmed on the linked database guides: an outbox/poller contract making durable acceptance and job scheduling atomic.
- Plan/Price catalog, unpaid grace policy and queue backend are application choices. No SDK patch pin is asserted for current-source signature behavior.
- Event-ID uniqueness prevents duplicate deliveries; distinct events describing the same business action can require an additional domain uniqueness key.
Checked
2026-11-24; current Rails and stripe-ruby references; Pay 13.4.1 (release list); all linked docs, implementation and mices/yudin-s discussion read. No billing or Rails commands executed.
Started from a post by @Stripe, packaged by the editor. Original post