12#include "StripeKit/Client.h"
13#include "StripeKit/Errors.h"
14#include "StripeKit/HTTPClient.h"
20struct CallbackLifetime;
212 class CustomerOperations final :
public Customers {
222 void retrieve(std::string customer_id,
223 const RequestOptions& options,
230 class CheckoutSessionOperations final :
public CheckoutSessions {
233 Task<CheckoutSession> create_async(
const CreateCheckoutSessionRequest& request,
234 const RequestOptions& options = {})
override;
235 void create(
const CreateCheckoutSessionRequest& request,
236 const RequestOptions& options,
243 class CheckoutOperations final :
public Checkout {
246 CheckoutSessions&
sessions()
override;
252 class SubscriptionOperations final :
public Subscriptions {
255 Task<Subscription> retrieve_async(std::string subscription_id,
256 const RequestOptions& options = {})
override;
257 void retrieve(std::string subscription_id,
258 const RequestOptions& options,
260 Task<Subscription> cancel_async(std::string subscription_id,
261 const RequestOptions& options = {})
override;
262 void cancel(std::string subscription_id,
263 const RequestOptions& options,
270 class BillingPortalSessionOperations final :
public BillingPortalSessions {
273 Task<BillingPortalSession> create_async(
const CreateBillingPortalSessionRequest& request,
274 const RequestOptions& options = {})
override;
275 void create(
const CreateBillingPortalSessionRequest& request,
276 const RequestOptions& options,
283 class BillingPortalOperations final :
public BillingPortal {
286 BillingPortalSessions&
sessions()
override;
292 HTTPClient& http_client;
293 JsonStripeResponseParser default_response_parser;
294 const StripeResponseParser& response_parser;
295 std::shared_ptr<CallbackLifetime> callback_lifetime;
296 CustomerOperations customer_operations;
297 CheckoutSessionOperations checkout_session_operations;
298 CheckoutOperations checkout_operations;
299 SubscriptionOperations subscription_operations;
300 BillingPortalSessionOperations billing_portal_session_operations;
301 BillingPortalOperations billing_portal_operations;
std::function< void(CallbackResult< BillingPortalSession >)> CreateCompletion
Completion callback for the callback form of create().
Groups the billing portal operations.
virtual BillingPortalSessions & sessions()=0
Returns the billing portal session operations.
std::function< void(CallbackResult< CheckoutSession >)> CreateCompletion
Completion callback for the callback form of create().
Groups the Checkout operations.
virtual CheckoutSessions & sessions()=0
Returns the Checkout session operations.
Creates and retrieves Stripe customers.
std::function< void(CallbackResult< Customer >)> CreateCompletion
Completion callback for the callback form of create().
std::function< void(CallbackResult< Customer >)> RetrieveCompletion
Completion callback for the callback form of retrieve().
Sends StripeKit's requests to Stripe.
The response parser StripeKit uses by default.
Customer parse_customer(const HttpResponse &response) const override
Reads a customer out of a successful response.
BillingPortalSession parse_billing_portal_session(const HttpResponse &response) const override
Reads a billing portal session out of a successful response.
CheckoutSession parse_checkout_session(const HttpResponse &response) const override
Reads a Checkout session out of a successful response.
StripeErrorPayload parse_error(const HttpResponse &response) const override
Reads the error details out of a failed response.
Subscription parse_subscription(const HttpResponse &response) const override
Reads a subscription out of a successful response.
StripeApiClient(HTTPClient &http_client)
Creates a client that decodes responses with JsonCpp.
Subscriptions & subscriptions() override
Returns the subscription operations.
StripeApiClient(HTTPClient &http_client, const StripeResponseParser &response_parser)
Creates a client that decodes responses with a parser of your own.
Customers & customers() override
Returns the customer operations.
BillingPortal & billing_portal() override
Returns the billing portal operations.
Checkout & checkout() override
Returns the Checkout operations.
~StripeApiClient() override
Destroys the client and its operation groups.
The entry point for talking to Stripe.
Turns Stripe's responses into StripeKit models.
virtual ~StripeResponseParser()=default
Destroys the parser instance.
virtual Customer parse_customer(const HttpResponse &response) const =0
Reads a customer out of a successful response.
virtual CheckoutSession parse_checkout_session(const HttpResponse &response) const =0
Reads a Checkout session out of a successful response.
virtual Subscription parse_subscription(const HttpResponse &response) const =0
Reads a subscription out of a successful response.
virtual BillingPortalSession parse_billing_portal_session(const HttpResponse &response) const =0
Reads a billing portal session out of a successful response.
virtual StripeErrorPayload parse_error(const HttpResponse &response) const =0
Reads the error details out of a failed response.
Retrieves and cancels Stripe subscriptions.
std::function< void(CallbackResult< Subscription >)> RetrieveCompletion
Completion callback for the callback form of retrieve().
std::function< void(CallbackResult< Subscription >)> CancelCompletion
Completion callback for the callback form of cancel().
The result of an asynchronous StripeKit operation.
A Stripe billing portal session: a short-lived link to the self-serve billing page.
A Stripe Checkout session: one attempt by a customer to pay or subscribe.
Describes the customer to create.
A Stripe customer: the account everything else is billed against.
Stripe's answer to a request.
Per-call settings accepted by every client operation.
The details Stripe returned about a failure.
A Stripe subscription: a customer's recurring agreement to pay.