|
StripeKit 0.1.1
Stripe integration toolkit for C++
|
Sends Stripe API requests through Drogon's HTTP client. More...
#include <Drogon.h>
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(). | |
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.
|
explicit |
Creates a client for a Stripe account.
| api_key | Stripe secret key. Sent as the bearer token on every request; never logged. |
| api_base_url | Stripe API base URL. HTTPS is required except for a loopback mock server. |
| event_loop | Which event loop requests run on. Inside a Drogon server, pass EventLoopOptions::drogon_framework(). |
|
overridevirtual |
Destroys the client, stopping its event loop thread if it owns one.
Reimplemented from stripekit::HTTPClient.
|
overridevirtual |
Sends a request to Stripe.
| request | What to send, including the options to honour. |
| std::exception | Stripe could not be reached. |
Implements stripekit::HTTPClient.
|
overridevirtual |
Sends a request to Stripe, reporting the result through a callback.
The callback runs exactly once, on the client's event loop.
| request | What to send, including the options to honour. |
| completion | Receives Stripe's response, or the transport failure. |
Implements stripekit::HTTPClient.