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

Turns Stripe's responses into StripeKit models. More...

#include <StripeApiClient.h>

Inheritance diagram for stripekit::StripeResponseParser:
[legend]

Public Member Functions

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.

Detailed Description

Turns Stripe's responses into StripeKit models.

StripeKit decodes Stripe's JSON with JsonStripeResponseParser by default. Implement this only when the application needs different decoding, such as to reuse a JSON library it already links.

Definition at line 34 of file StripeApiClient.h.

Constructor & Destructor Documentation

◆ ~StripeResponseParser()

virtual stripekit::StripeResponseParser::~StripeResponseParser ( )
virtualdefault

Destroys the parser instance.

Member Function Documentation

◆ parse_customer()

virtual Customer stripekit::StripeResponseParser::parse_customer ( const HttpResponse & response) const
pure virtual

Reads a customer out of a successful response.

Parameters
responseThe response body and status from Stripe.
Returns
The parsed customer.
Exceptions
ConfigurationExceptionThe body was not a valid customer object.

Implemented in stripekit::JsonStripeResponseParser.

◆ parse_checkout_session()

virtual CheckoutSession stripekit::StripeResponseParser::parse_checkout_session ( const HttpResponse & response) const
pure virtual

Reads a Checkout session out of a successful response.

Parameters
responseThe response body and status from Stripe.
Returns
The parsed session.
Exceptions
ConfigurationExceptionThe body was not a valid session object.

Implemented in stripekit::JsonStripeResponseParser.

◆ parse_subscription()

virtual Subscription stripekit::StripeResponseParser::parse_subscription ( const HttpResponse & response) const
pure virtual

Reads a subscription out of a successful response.

Parameters
responseThe response body and status from Stripe.
Returns
The parsed subscription.
Exceptions
ConfigurationExceptionThe body was not a valid subscription object.

Implemented in stripekit::JsonStripeResponseParser.

◆ parse_billing_portal_session()

virtual BillingPortalSession stripekit::StripeResponseParser::parse_billing_portal_session ( const HttpResponse & response) const
pure virtual

Reads a billing portal session out of a successful response.

Parameters
responseThe response body and status from Stripe.
Returns
The parsed session.
Exceptions
ConfigurationExceptionThe body was not a valid session object.

Implemented in stripekit::JsonStripeResponseParser.

◆ parse_error()

virtual StripeErrorPayload stripekit::StripeResponseParser::parse_error ( const HttpResponse & response) const
pure virtual

Reads the error details out of a failed response.

Must not throw: it is already handling a failure. Fall back to a StripeErrorType::Unknown payload when the body cannot be parsed.

Parameters
responseThe response body and status from Stripe.
Returns
The error details, used to build a StripeApiException.

Implemented in stripekit::JsonStripeResponseParser.


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