|
StripeKit 0.1.1
Stripe integration toolkit for C++
|
Handles incoming webhook deliveries through an EventDispatcher. More...
#include <WebhookProcessor.h>
Public Member Functions | |
| WebhookProcessor (WebhookDedupStore &dedup_store, EventDispatcher &dispatcher, Logger *logger=nullptr, WebhookProcessorOptions options={}) | |
| Creates a processor. | |
| WebhookResponseAction | process (const WebhookVerificationInput &input, std::string delivery_id={}) const |
| Verifies, de-duplicates, and dispatches one delivery. | |
Handles incoming webhook deliveries through an EventDispatcher.
Webhooks are HTTP requests sent by Stripe to notify about events.
Does the same work as stripekit::webhooks::process_event_once() — verify, de-duplicate, dispatch — but drives a class rather than a coroutine callback, and does so synchronously. Use it when the application's webhook handling is already organised as an object; otherwise stripekit::webhooks::process_event_once() is the simpler route.
The store, dispatcher, and logger are referenced, not owned, so all three must outlive the processor. A single processor can serve many requests, and is safe to use from several threads provided the dispatcher is.
Definition at line 54 of file WebhookProcessor.h.
| stripekit::WebhookProcessor::WebhookProcessor | ( | WebhookDedupStore & | dedup_store, |
| EventDispatcher & | dispatcher, | ||
| Logger * | logger = nullptr, | ||
| WebhookProcessorOptions | options = {} ) |
Creates a processor.
| dedup_store | Where claims are recorded. Must outlive the processor. |
| dispatcher | Called for each freshly claimed event. Must outlive the processor. |
| logger | Where to report store and dispatch failures. No logging when null. |
| options | Claim timing. |
| WebhookResponseAction stripekit::WebhookProcessor::process | ( | const WebhookVerificationInput & | input, |
| std::string | delivery_id = {} ) const |
Verifies, de-duplicates, and dispatches one delivery.
| input | The raw payload, signature header, secret, and timing rules. |
| delivery_id | Optional identifier from the adapter, passed through to the dispatcher for tracing. |
| SignatureVerificationException | The delivery cannot be trusted. Answer with HTTP 400 rather than retrying. |
| ConfigurationException | The payload is not a usable Stripe event. |