StripeKit 0.1.1
Stripe integration toolkit for C++
Loading...
Searching...
No Matches
Drogon Adapter

The adapter for the Drogon web framework. More...

Collaboration diagram for Drogon Adapter:

Classes

struct  stripekit::drogon::EventLoopOptions
 Chooses which event loop outbound Stripe requests run on. More...
struct  stripekit::drogon::ClientOptions
 Settings for make_stripe_client(). More...
struct  stripekit::drogon::WebhookHandlerOptions
 Settings for register_webhook_handler(). More...
class  stripekit::drogon::HTTPClient
 Sends Stripe API requests through Drogon's HTTP client. More...
class  stripekit::drogon::WebhookEndpoint
 A Drogon route that receives Stripe webhook deliveries. More...
class  stripekit::drogon::LogBridge
 Sends StripeKit's log entries through Drogon's logging. More...

Functions

std::unique_ptr< StripeClient > stripekit::drogon::make_stripe_client (ClientOptions options)
 Creates a Stripe client that talks through Drogon.
void stripekit::drogon::register_webhook_handler (WebhookHandlerOptions options)
 Adds a Stripe webhook route to the Drogon application.

Detailed Description

The adapter for the Drogon web framework.

See also
Writing an Adapter

Function Documentation

◆ make_stripe_client()

std::unique_ptr< StripeClient > stripekit::drogon::make_stripe_client ( ClientOptions options)

Creates a Stripe client that talks through Drogon.

This is the usual way to get a stripekit::StripeClient in a Drogon application. One client is enough for the whole application: it is safe to share across threads and reuses connections to Stripe.

.api_key = std::getenv("STRIPE_SECRET_KEY")
});
std::unique_ptr< StripeClient > make_stripe_client(ClientOptions options)
Creates a Stripe client that talks through Drogon.
Parameters
optionsThe API key, and optionally the base URL and event loop.
Returns
The client. It owns its transport, so keeping this alive is enough.
Exceptions
ConfigurationExceptionThe API key is missing, or the requested event loop is not available.
See also
Quickstart

◆ register_webhook_handler()

void stripekit::drogon::register_webhook_handler ( WebhookHandlerOptions options)

Adds a Stripe webhook route to the Drogon application.

The route verifies Stripe's signature, reserves the event id in the store, and only then calls the handler. Completed events are skipped; failed or interrupted attempts may run again, so the handler must be safe to retry. Replies 200 when handled or already handled, 500 on handler or store failures, and 400 when the signature does not check out.

Call this before Drogon starts running.

static stripekit::SqliteWebhookDedupStore dedup_store("stripe-webhooks.sqlite3");
.path = "/stripe/webhook",
.endpoint_secret = std::getenv("STRIPE_WEBHOOK_SECRET"),
.dedup_store = dedup_store,
.handler = [](const stripekit::webhooks::Event& event)
co_return stripekit::webhooks::ProcessResult::Handled;
}
});
A de-duplication store that uses a SQLite database.
The result of an asynchronous StripeKit operation.
Definition Async.h:45
void register_webhook_handler(WebhookHandlerOptions options)
Adds a Stripe webhook route to the Drogon application.
EventEnvelope Event
A verified Stripe webhook event.
Definition Webhooks.h:31
Parameters
optionsThe route, signing secret, store, and handler. The store must outlive the running application.
See also
Quickstart