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

Sends Stripe API requests through Drogon's HTTP client. More...

#include <Drogon.h>

Inheritance diagram for stripekit::drogon::HTTPClient:
[legend]

Public Member Functions

 HTTPClient (std::string api_key, std::string api_base_url="https://api.stripe.com", EventLoopOptions event_loop={})
 Creates a client for a Stripe account.
 ~HTTPClient () override
 Destroys the client, stopping its event loop thread if it owns one.
 HTTPClient (const HTTPClient &)=delete
HTTPClient & operator= (const HTTPClient &)=delete
Task< HttpResponse > send_async (const HttpRequest &request) override
 Sends a request to Stripe.
void send (const HttpRequest &request, Completion completion) override
 Sends a request to Stripe, reporting the result through a callback.

Additional Inherited Members

Public Types inherited from stripekit::HTTPClient
using Completion = std::function<void(std::variant<HttpResponse, std::exception_ptr>)>
 Completion callback for the callback form of send().

Detailed Description

Sends Stripe API requests through Drogon's HTTP client.

Construct this directly only when supplying a custom stripekit::StripeResponseParser; otherwise make_stripe_client() does it for you.

Safe to use from several threads.

Definition at line 143 of file Drogon.h.

Constructor & Destructor Documentation

◆ HTTPClient()

stripekit::drogon::HTTPClient::HTTPClient ( std::string api_key,
std::string api_base_url = "https://api.stripe.com",
EventLoopOptions event_loop = {} )
explicit

Creates a client for a Stripe account.

Parameters
api_keyStripe secret key. Sent as the bearer token on every request; never logged.
api_base_urlStripe API base URL. HTTPS is required except for a loopback mock server.
event_loopWhich event loop requests run on. Inside a Drogon server, pass EventLoopOptions::drogon_framework().

◆ ~HTTPClient()

stripekit::drogon::HTTPClient::~HTTPClient ( )
overridevirtual

Destroys the client, stopping its event loop thread if it owns one.

Reimplemented from stripekit::HTTPClient.

Member Function Documentation

◆ send_async()

Task< HttpResponse > stripekit::drogon::HTTPClient::send_async ( const HttpRequest & request)
overridevirtual

Sends a request to Stripe.

Parameters
requestWhat to send, including the options to honour.
Returns
A task producing Stripe's response. An error status is reported in the response rather than thrown.
Exceptions
std::exceptionStripe could not be reached.

Implements stripekit::HTTPClient.

◆ send()

void stripekit::drogon::HTTPClient::send ( const HttpRequest & request,
Completion completion )
overridevirtual

Sends a request to Stripe, reporting the result through a callback.

The callback runs exactly once, on the client's event loop.

Parameters
requestWhat to send, including the options to honour.
completionReceives Stripe's response, or the transport failure.

Implements stripekit::HTTPClient.


The documentation for this class was generated from the following file:
  • src/adapters/drogon/include/StripeKit/Adapters/Drogon.h