StripeKit 0.1.1
Stripe integration toolkit for C++
Loading...
Searching...
No Matches
stripekit::WebhookProcessor Class Referencefinal

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ WebhookProcessor()

stripekit::WebhookProcessor::WebhookProcessor ( WebhookDedupStore & dedup_store,
EventDispatcher & dispatcher,
Logger * logger = nullptr,
WebhookProcessorOptions options = {} )

Creates a processor.

Parameters
dedup_storeWhere claims are recorded. Must outlive the processor.
dispatcherCalled for each freshly claimed event. Must outlive the processor.
loggerWhere to report store and dispatch failures. No logging when null.
optionsClaim timing.

Member Function Documentation

◆ process()

WebhookResponseAction stripekit::WebhookProcessor::process ( const WebhookVerificationInput & input,
std::string delivery_id = {} ) const

Verifies, de-duplicates, and dispatches one delivery.

Parameters
inputThe raw payload, signature header, secret, and timing rules.
delivery_idOptional identifier from the adapter, passed through to the dispatcher for tracing.
Returns
Whether to answer Stripe with success, or ask it to retry.
Exceptions
SignatureVerificationExceptionThe delivery cannot be trusted. Answer with HTTP 400 rather than retrying.
ConfigurationExceptionThe payload is not a usable Stripe event.

The documentation for this class was generated from the following file: