StripeKit 0.1.1
Stripe integration toolkit for C++
Loading...
Searching...
No Matches
Models.h
1/** Models.h
2 *
3 * Core Stripe object models exposed by StripeKit.
4 *
5 * @author Hans de Ruiter
6 *
7 * @license See LICENSE.md for details.
8 */
9
10#pragma once
11
12#include <cstdint>
13#include <string>
14#include <unordered_map>
15
16namespace stripekit {
17
18/**
19 * @addtogroup models
20 * @{
21 */
22
23/**
24 * A Stripe customer: the account everything else is billed against.
25 *
26 * @sa https://docs.stripe.com/api/customers/object
27 */
28struct Customer {
29 /** Stripe-assigned customer identifier. */
30 std::string id;
31
32 /** Customer email address. */
33 std::string email;
34
35 /** Customer display name. */
36 std::string name;
37
38 /** True when the object belongs to a live Stripe account. */
39 bool livemode = false;
40
41 /** Free-form metadata key/value pairs attached to this customer. */
42 std::unordered_map<std::string, std::string> metadata;
43};
44
45/**
46 * A Stripe Checkout session: one attempt by a customer to pay or subscribe.
47 *
48 * Send the customer to `url` to start payment. `subscription_id` or
49 * `payment_intent_id` is filled in depending on whether `mode` is subscription
50 * or payment.
51 *
52 * @sa https://docs.stripe.com/api/checkout/sessions/object
53 */
55 /** Stripe-assigned checkout session identifier. */
56 std::string id;
57
58 /** Stripe customer identifier associated with the session. */
59 std::string customer_id;
60
61 /** Stripe subscription identifier created by checkout, when present. */
62 std::string subscription_id;
63
64 /** Stripe payment intent identifier created by checkout, when present. */
65 std::string payment_intent_id;
66
67 /** Session status, for example open, complete, or expired. */
68 std::string status;
69
70 /** Checkout mode, for example subscription or payment. */
71 std::string mode;
72
73 /** Redirect URL for hosted checkout. */
74 std::string url;
75
76 /** ISO currency code, for example usd. */
77 std::string currency;
78
79 /** Total amount in the smallest currency unit. */
80 std::int64_t amount_total = 0;
81
82 /** True when the object belongs to a live Stripe account. */
83 bool livemode = false;
84
85 /** Free-form metadata key/value pairs attached to this session. */
86 std::unordered_map<std::string, std::string> metadata;
87};
88
89/**
90 * A Stripe subscription: a customer's recurring agreement to pay.
91 *
92 * `status` is what decides whether the customer should have access. "active"
93 * and "trialing" mean yes; "past_due" means Stripe is retrying a failed
94 * payment; "canceled" and "unpaid" mean no.
95 *
96 * @sa https://docs.stripe.com/api/subscriptions/object
97 */
99 /** Stripe-assigned subscription identifier. */
100 std::string id;
101
102 /** Stripe customer identifier owning this subscription. */
103 std::string customer_id;
104
105 /** Lifecycle status, for example active, trialing, or past_due. */
106 std::string status;
107
108 /** Unix timestamp for the current period start. */
110
111 /** Unix timestamp for the current period end. */
112 std::int64_t current_period_end_unix = 0;
113
114 /** True when cancellation will occur at period end. */
116
117 /** True when the object belongs to a live Stripe account. */
118 bool livemode = false;
119
120 /** Free-form metadata key/value pairs attached to this subscription. */
121 std::unordered_map<std::string, std::string> metadata;
122};
123
124/**
125 * A Stripe invoice: the bill for one subscription period.
126 *
127 * A paid invoice is the signal that a period has been paid for, and is
128 * normally what access should be granted from.
129 *
130 * @sa https://docs.stripe.com/api/invoices/object
131 */
132struct Invoice {
133 /** Stripe-assigned invoice identifier. */
134 std::string id;
135
136 /** Stripe customer identifier associated with the invoice. */
137 std::string customer_id;
138
139 /** Subscription identifier associated with the invoice, when present. */
140 std::string subscription_id;
141
142 /** Invoice status, for example paid, open, or uncollectible. */
143 std::string status;
144
145 /** ISO currency code, for example usd. */
146 std::string currency;
147
148 /** Amount due in the smallest currency unit. */
149 std::int64_t amount_due = 0;
150
151 /** Amount paid in the smallest currency unit. */
152 std::int64_t amount_paid = 0;
153
154 /** True when Stripe marks the invoice as paid. */
155 bool paid = false;
156
157 /** True when the object belongs to a live Stripe account. */
158 bool livemode = false;
159};
160
161/**
162 * A Stripe billing portal session: a short-lived link to the self-serve
163 * billing page.
164 *
165 * @sa https://docs.stripe.com/api/customer_portal/sessions/object
166 */
168 /** Stripe-assigned billing portal session identifier. */
169 std::string id;
170
171 /** Stripe customer identifier linked to this portal session. */
172 std::string customer_id;
173
174 /** Hosted billing portal URL for end-user redirection. */
175 std::string url;
176
177 /** Return URL used by Stripe after portal navigation. */
178 std::string return_url;
179
180 /** Unix timestamp when Stripe created the object. */
181 std::int64_t created_unix = 0;
182
183 /** True when the object belongs to a live Stripe account. */
184 bool livemode = false;
185};
186
187/**
188 * A Stripe event, as delivered by a webhook.
189 *
190 * `type` says what happened; `payload_json` holds Stripe's raw JSON for the
191 * event, which is where to look for any detail StripeKit does not model.
192 *
193 * @sa https://docs.stripe.com/api/events/object
194 * @sa @ref webhooks
195 */
197 /** Stripe event identifier, of the form "evt_...". */
198 std::string id;
199
200 /** What happened, for example "invoice.paid". */
201 std::string type;
202
203 /** Stripe API version the payload is formatted for. */
204 std::string api_version;
205
206 /** Unix timestamp of when the event occurred in Stripe. */
207 std::int64_t created_unix = 0;
208
209 /** True when the event belongs to a live Stripe account. */
210 bool livemode = false;
211
212 /** Id of the API request that caused the event, when there was one. */
213 std::string request_id;
214
215 /** Connected account the event belongs to, when using Stripe Connect. */
216 std::string account;
217
218 /**
219 * Stripe's raw JSON for the whole event.
220 *
221 * Parse this when the handler needs a field the models above do not carry.
222 */
223 std::string payload_json;
224};
225
226/** @} */
227
228} // namespace stripekit
Async.h.
Definition Async.h:20
A Stripe billing portal session: a short-lived link to the self-serve billing page.
Definition Models.h:167
std::string id
Stripe-assigned billing portal session identifier.
Definition Models.h:169
std::string url
Hosted billing portal URL for end-user redirection.
Definition Models.h:175
std::string customer_id
Stripe customer identifier linked to this portal session.
Definition Models.h:172
bool livemode
True when the object belongs to a live Stripe account.
Definition Models.h:184
std::int64_t created_unix
Unix timestamp when Stripe created the object.
Definition Models.h:181
std::string return_url
Return URL used by Stripe after portal navigation.
Definition Models.h:178
A Stripe Checkout session: one attempt by a customer to pay or subscribe.
Definition Models.h:54
std::string payment_intent_id
Stripe payment intent identifier created by checkout, when present.
Definition Models.h:65
std::string id
Stripe-assigned checkout session identifier.
Definition Models.h:56
std::int64_t amount_total
Total amount in the smallest currency unit.
Definition Models.h:80
bool livemode
True when the object belongs to a live Stripe account.
Definition Models.h:83
std::unordered_map< std::string, std::string > metadata
Free-form metadata key/value pairs attached to this session.
Definition Models.h:86
std::string customer_id
Stripe customer identifier associated with the session.
Definition Models.h:59
std::string mode
Checkout mode, for example subscription or payment.
Definition Models.h:71
std::string currency
ISO currency code, for example usd.
Definition Models.h:77
std::string url
Redirect URL for hosted checkout.
Definition Models.h:74
std::string subscription_id
Stripe subscription identifier created by checkout, when present.
Definition Models.h:62
std::string status
Session status, for example open, complete, or expired.
Definition Models.h:68
A Stripe customer: the account everything else is billed against.
Definition Models.h:28
std::string name
Customer display name.
Definition Models.h:36
std::string email
Customer email address.
Definition Models.h:33
bool livemode
True when the object belongs to a live Stripe account.
Definition Models.h:39
std::unordered_map< std::string, std::string > metadata
Free-form metadata key/value pairs attached to this customer.
Definition Models.h:42
std::string id
Stripe-assigned customer identifier.
Definition Models.h:30
A Stripe event, as delivered by a webhook.
Definition Models.h:196
std::string payload_json
Stripe's raw JSON for the whole event.
Definition Models.h:223
std::string account
Connected account the event belongs to, when using Stripe Connect.
Definition Models.h:216
std::string id
Stripe event identifier, of the form "evt_...".
Definition Models.h:198
std::string type
What happened, for example "invoice.paid".
Definition Models.h:201
std::int64_t created_unix
Unix timestamp of when the event occurred in Stripe.
Definition Models.h:207
bool livemode
True when the event belongs to a live Stripe account.
Definition Models.h:210
std::string api_version
Stripe API version the payload is formatted for.
Definition Models.h:204
std::string request_id
Id of the API request that caused the event, when there was one.
Definition Models.h:213
A Stripe invoice: the bill for one subscription period.
Definition Models.h:132
bool livemode
True when the object belongs to a live Stripe account.
Definition Models.h:158
std::string status
Invoice status, for example paid, open, or uncollectible.
Definition Models.h:143
bool paid
True when Stripe marks the invoice as paid.
Definition Models.h:155
std::string subscription_id
Subscription identifier associated with the invoice, when present.
Definition Models.h:140
std::string currency
ISO currency code, for example usd.
Definition Models.h:146
std::string customer_id
Stripe customer identifier associated with the invoice.
Definition Models.h:137
std::string id
Stripe-assigned invoice identifier.
Definition Models.h:134
std::int64_t amount_due
Amount due in the smallest currency unit.
Definition Models.h:149
std::int64_t amount_paid
Amount paid in the smallest currency unit.
Definition Models.h:152
A Stripe subscription: a customer's recurring agreement to pay.
Definition Models.h:98
std::string status
Lifecycle status, for example active, trialing, or past_due.
Definition Models.h:106
std::int64_t current_period_end_unix
Unix timestamp for the current period end.
Definition Models.h:112
std::string customer_id
Stripe customer identifier owning this subscription.
Definition Models.h:103
std::int64_t current_period_start_unix
Unix timestamp for the current period start.
Definition Models.h:109
std::unordered_map< std::string, std::string > metadata
Free-form metadata key/value pairs attached to this subscription.
Definition Models.h:121
bool cancel_at_period_end
True when cancellation will occur at period end.
Definition Models.h:115
std::string id
Stripe-assigned subscription identifier.
Definition Models.h:100
bool livemode
True when the object belongs to a live Stripe account.
Definition Models.h:118