@peable.to/contracts 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/resources/catalog/index.js +1 -5
- package/dist/cjs/resources/checkout/checkoutSessions.js +0 -4
- package/dist/cjs/resources/events/events.js +1 -32
- package/dist/cjs/vocabulary/catalog.js +1 -17
- package/dist/cjs/vocabulary/errors.js +0 -13
- package/dist/cjs/vocabulary/events.js +0 -1
- package/dist/esm/resources/catalog/index.js +1 -5
- package/dist/esm/resources/checkout/checkoutSessions.js +0 -4
- package/dist/esm/resources/events/events.js +0 -31
- package/dist/esm/vocabulary/catalog.js +0 -16
- package/dist/esm/vocabulary/errors.js +0 -13
- package/dist/esm/vocabulary/events.js +0 -1
- package/dist/types/resources/catalog/index.d.ts +1 -851
- package/dist/types/resources/checkout/checkoutSessions.d.ts +13 -61
- package/dist/types/resources/checkout/index.d.ts +10 -46
- package/dist/types/resources/events/events.d.ts +0 -22
- package/dist/types/resources/events/index.d.ts +2 -15
- package/dist/types/resources/events/webhookDeliveries.d.ts +0 -3
- package/dist/types/resources/events/webhookEndpoints.d.ts +4 -16
- package/dist/types/resources/payments/index.d.ts +10 -10
- package/dist/types/resources/payments/paymentIntents.d.ts +10 -10
- package/dist/types/resources/payments/testHelpers.d.ts +1 -1
- package/dist/types/resources/tax/index.d.ts +1 -1
- package/dist/types/resources/tax/registrations.d.ts +2 -2
- package/dist/types/vocabulary/catalog.d.ts +0 -9
- package/dist/types/vocabulary/errors.d.ts +0 -13
- package/dist/types/vocabulary/events.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/resources/catalog/billing.js +0 -753
- package/dist/esm/resources/catalog/billing.js +0 -750
- package/dist/types/resources/catalog/billing.d.ts +0 -1723
|
@@ -1,753 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.billingRoutes = exports.cancelBillingSubscriptionParams = exports.billingFaircoinFxQuoteSchema = exports.billingFaircoinRenewalChoiceSchema = exports.billingFaircoinRenewalRevocationSchema = exports.billingFaircoinRenewalConsentSchema = exports.retrieveBillingInvoiceAuthorityQuery = exports.billingFinalInvoiceAuthoritySchema = exports.billingFinalInvoiceSchema = exports.billingInvoiceAuthoritySourceSchema = exports.billingInvoiceTaxLineSchema = exports.billingInvoiceStateSchema = exports.billingPaidInvoiceSchema = exports.createBillingPortalParams = exports.billingCheckoutOperationRecoverySchema = exports.billingCheckoutOperationSourceSchema = exports.billingCheckoutOperationParams = exports.retrieveBillingCheckoutOperationQuery = exports.billingCheckoutObservationSchema = exports.billingSubscriptionSchema = exports.billingEmbeddedCheckoutBindingSchema = exports.billingEmbeddedCheckoutActionSchema = exports.billingEmbeddedCheckoutConfigurationSchema = exports.billingEmbeddedCheckoutScopeSchema = exports.billingEmbeddedCheckoutSessionSchema = exports.billingCheckoutSessionSchema = exports.billingHostedSessionSchema = exports.createBillingCheckoutParams = exports.billingTaxQuoteSchema = exports.createBillingTaxQuoteParams = exports.billingCustomerSchema = exports.ensureBillingCustomerParams = exports.billingRailListSchema = exports.billingRailOptionSchema = exports.billingRailOfferSchema = exports.billingPriceRef = exports.billingCustomerRef = exports.billingInstant = exports.billingReturnUrl = exports.billingRailId = exports.billingIdempotencyKey = exports.billingReference = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const objects_1 = require("../../common/objects");
|
|
6
|
-
const primitives_1 = require("../../common/primitives");
|
|
7
|
-
const route_1 = require("../../route");
|
|
8
|
-
const catalog_1 = require("../../vocabulary/catalog");
|
|
9
|
-
/**
|
|
10
|
-
* The recurring billing transport (`/v1/billing/*`): an Oxy app's own
|
|
11
|
-
* subscription checkout — Oxy One, Mention Plus — over a configured settlement
|
|
12
|
-
* rail (a fiat provider such as Stripe, or FairCoin). Store and plan references
|
|
13
|
-
* belong to the authenticated app; they do not identify an Oxy payer or convey
|
|
14
|
-
* entitlements. Payment success and access require the authoritative backend
|
|
15
|
-
* outcome read here — never a closed sheet or a browser callback.
|
|
16
|
-
*
|
|
17
|
-
* Every write takes an `Idempotency-Key` header, which the route REQUIRES
|
|
18
|
-
* (a missing or malformed key is a 400): the key is the operation's identity
|
|
19
|
-
* at the provider, not a replay convenience.
|
|
20
|
-
*/
|
|
21
|
-
// ---- Shared pieces ---------------------------------------------------------------
|
|
22
|
-
/** An opaque app or provider reference: 1–128 of `A–Z a–z 0–9 _ . : -`. */
|
|
23
|
-
exports.billingReference = zod_1.z
|
|
24
|
-
.string()
|
|
25
|
-
.min(1)
|
|
26
|
-
.max(128)
|
|
27
|
-
.regex(/^[A-Za-z0-9_.:-]+$/);
|
|
28
|
-
/** The `Idempotency-Key` of a billing write: 1–200 of `A–Z a–z 0–9 _ . : -`. */
|
|
29
|
-
exports.billingIdempotencyKey = zod_1.z
|
|
30
|
-
.string()
|
|
31
|
-
.min(1)
|
|
32
|
-
.max(200)
|
|
33
|
-
.regex(/^[A-Za-z0-9_.:-]+$/);
|
|
34
|
-
/**
|
|
35
|
-
* A configured settlement rail's name (`stripe`, `faircoin`, a further fiat
|
|
36
|
-
* provider). Selecting one never configures it: an unconfigured rail is
|
|
37
|
-
* refused.
|
|
38
|
-
*/
|
|
39
|
-
exports.billingRailId = zod_1.z
|
|
40
|
-
.string()
|
|
41
|
-
.regex(/^[a-z][a-z0-9_]{1,31}$/)
|
|
42
|
-
.describe('A settlement rail: `stripe`, `faircoin`, or a further fiat provider.');
|
|
43
|
-
/** HTTPS destinations only; the authenticated app supplies its own return page. */
|
|
44
|
-
exports.billingReturnUrl = zod_1.z
|
|
45
|
-
.string()
|
|
46
|
-
.url()
|
|
47
|
-
.max(2048)
|
|
48
|
-
.refine((value) => {
|
|
49
|
-
const url = new URL(value);
|
|
50
|
-
return url.protocol === 'https:' && !url.username && !url.password;
|
|
51
|
-
}, 'An HTTPS return URL without credentials is required');
|
|
52
|
-
/** An instant in signed billing evidence: integer Unix seconds that stay a safe integer. */
|
|
53
|
-
exports.billingInstant = zod_1.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
54
|
-
/** A billing customer reference (`cus_…`). */
|
|
55
|
-
exports.billingCustomerRef = zod_1.z
|
|
56
|
-
.string()
|
|
57
|
-
.regex(/^cus_[A-Za-z0-9]+$/)
|
|
58
|
-
.max(128);
|
|
59
|
-
/** A billing price reference (`price_…`). */
|
|
60
|
-
exports.billingPriceRef = zod_1.z
|
|
61
|
-
.string()
|
|
62
|
-
.regex(/^price_[A-Za-z0-9]+$/)
|
|
63
|
-
.max(128);
|
|
64
|
-
const mode = zod_1.z.enum(['test', 'live']);
|
|
65
|
-
const environment = zod_1.z.enum(['development', 'staging', 'production']);
|
|
66
|
-
const taxTreatment = zod_1.z.enum(['inclusive', 'exclusive']);
|
|
67
|
-
const billingInterval = zod_1.z.enum(['month', 'year']);
|
|
68
|
-
const ed25519Signature = zod_1.z
|
|
69
|
-
.object({
|
|
70
|
-
algorithm: zod_1.z.literal('Ed25519'),
|
|
71
|
-
key_id: exports.billingReference,
|
|
72
|
-
value: zod_1.z.string().regex(/^[A-Za-z0-9_-]{86}$/),
|
|
73
|
-
})
|
|
74
|
-
.strict()
|
|
75
|
-
.describe('Ed25519 over the canonical JSON (v1) of everything beside it.');
|
|
76
|
-
// ---- Rails -------------------------------------------------------------------------
|
|
77
|
-
/**
|
|
78
|
-
* One offer a rail can sell. Fiat provider rails bind their prices from the
|
|
79
|
-
* app's own provider catalogue, so they list `offers: null`.
|
|
80
|
-
*/
|
|
81
|
-
exports.billingRailOfferSchema = (0, objects_1.defineComponent)('BillingRailOffer', zod_1.z
|
|
82
|
-
.object({
|
|
83
|
-
provider_price_id: zod_1.z.string(),
|
|
84
|
-
plan_id: zod_1.z.string(),
|
|
85
|
-
interval: billingInterval,
|
|
86
|
-
currency: zod_1.z.string(),
|
|
87
|
-
gross_minor_units: primitives_1.amount,
|
|
88
|
-
tax_treatment: taxTreatment,
|
|
89
|
-
})
|
|
90
|
-
.strict());
|
|
91
|
-
exports.billingRailOptionSchema = (0, objects_1.defineComponent)('BillingRailOption', zod_1.z
|
|
92
|
-
.object({
|
|
93
|
-
rail: zod_1.z.string().describe('The rail: `stripe`, `faircoin`, or a further fiat provider.'),
|
|
94
|
-
settlement: zod_1.z.enum(catalog_1.BILLING_RAIL_SETTLEMENTS),
|
|
95
|
-
default: zod_1.z
|
|
96
|
-
.boolean()
|
|
97
|
-
.describe('The rail a request that names none is served by: the first configured.'),
|
|
98
|
-
tax_quotes: zod_1.z.boolean().describe('Whether `POST /v1/billing/tax_quotes` answers for it.'),
|
|
99
|
-
renewal: zod_1.z
|
|
100
|
-
.enum(catalog_1.BILLING_RAIL_RENEWALS)
|
|
101
|
-
.describe('`automatic`: the provider charges each period. `payer_initiated`: each period is an explicit payment (`renew`).'),
|
|
102
|
-
offers: zod_1.z.array(exports.billingRailOfferSchema).nullable(),
|
|
103
|
-
})
|
|
104
|
-
.strict());
|
|
105
|
-
/** Every rail this merchant's payers can choose between, default first. A complete set. */
|
|
106
|
-
exports.billingRailListSchema = (0, objects_1.defineComponent)('BillingRailList', zod_1.z.object({ object: zod_1.z.literal('list'), data: zod_1.z.array(exports.billingRailOptionSchema) }).strict());
|
|
107
|
-
// ---- Customers ---------------------------------------------------------------------
|
|
108
|
-
exports.ensureBillingCustomerParams = zod_1.z
|
|
109
|
-
.object({
|
|
110
|
-
store_id: exports.billingReference.describe("The app's own store / account reference."),
|
|
111
|
-
store_name: zod_1.z.string().min(1).max(200),
|
|
112
|
-
rail: exports.billingRailId
|
|
113
|
-
.optional()
|
|
114
|
-
.describe("The payer's chosen rail; default: the merchant's first. A customer belongs to one rail, and its checkouts and subscriptions follow it."),
|
|
115
|
-
})
|
|
116
|
-
.strict();
|
|
117
|
-
exports.billingCustomerSchema = (0, objects_1.defineComponent)('BillingCustomer', zod_1.z.object({ provider_customer_id: zod_1.z.string() }).strict());
|
|
118
|
-
// ---- Tax quotes ----------------------------------------------------------------------
|
|
119
|
-
/**
|
|
120
|
-
* A merchant asks Peable to quote a registered product. Monetary and fiscal
|
|
121
|
-
* configuration is resolved inside Peable, never supplied by a consumer.
|
|
122
|
-
*/
|
|
123
|
-
exports.createBillingTaxQuoteParams = zod_1.z
|
|
124
|
-
.object({
|
|
125
|
-
rail: exports.billingRailId
|
|
126
|
-
.optional()
|
|
127
|
-
.describe("Default: the first of the merchant's rails that answers tax quotes."),
|
|
128
|
-
store_id: exports.billingReference,
|
|
129
|
-
plan_id: exports.billingReference,
|
|
130
|
-
provider_price_id: exports.billingReference
|
|
131
|
-
.optional()
|
|
132
|
-
.describe('Selects one offer when a plan is sold at several prices.'),
|
|
133
|
-
customer_location_evidence_id: exports.billingReference.describe('A `tax.location_evidence` id (`taxloc_…`) recorded for this `store_id`.'),
|
|
134
|
-
})
|
|
135
|
-
.strict();
|
|
136
|
-
/** A signed, immutable, single-use Peable Tax quote (schema version 3). */
|
|
137
|
-
exports.billingTaxQuoteSchema = (0, objects_1.defineComponent)('BillingTaxQuote', zod_1.z
|
|
138
|
-
.object({
|
|
139
|
-
schema_version: zod_1.z.literal(3),
|
|
140
|
-
source: zod_1.z
|
|
141
|
-
.object({
|
|
142
|
-
merchant_id: exports.billingReference,
|
|
143
|
-
app_id: exports.billingReference,
|
|
144
|
-
store_id: exports.billingReference,
|
|
145
|
-
plan_id: exports.billingReference,
|
|
146
|
-
mode,
|
|
147
|
-
environment,
|
|
148
|
-
})
|
|
149
|
-
.strict(),
|
|
150
|
-
quote: zod_1.z
|
|
151
|
-
.object({
|
|
152
|
-
id: exports.billingReference,
|
|
153
|
-
currency: zod_1.z.string().regex(/^[A-Z]{3}$/),
|
|
154
|
-
gross_minor_units: primitives_1.amount,
|
|
155
|
-
net_minor_units: primitives_1.amount,
|
|
156
|
-
tax_minor_units: primitives_1.amount,
|
|
157
|
-
tax_treatment: taxTreatment,
|
|
158
|
-
seller_id: exports.billingReference,
|
|
159
|
-
invoice_issuer_id: exports.billingReference,
|
|
160
|
-
tax_remitter_id: exports.billingReference,
|
|
161
|
-
tax_service_ref: exports.billingReference,
|
|
162
|
-
country: zod_1.z.string().regex(/^[A-Z]{2}$/),
|
|
163
|
-
coverage_evidence_id: exports.billingReference,
|
|
164
|
-
tax_rate_evidence_id: exports.billingReference,
|
|
165
|
-
customer_location_evidence_id: exports.billingReference,
|
|
166
|
-
quoted_at: exports.billingInstant,
|
|
167
|
-
expires_at: exports.billingInstant,
|
|
168
|
-
})
|
|
169
|
-
.strict(),
|
|
170
|
-
signature: ed25519Signature,
|
|
171
|
-
})
|
|
172
|
-
.strict());
|
|
173
|
-
// ---- Checkout ------------------------------------------------------------------------
|
|
174
|
-
exports.createBillingCheckoutParams = zod_1.z
|
|
175
|
-
.object({
|
|
176
|
-
rail: exports.billingRailId
|
|
177
|
-
.optional()
|
|
178
|
-
.describe('An assertion of the rail; it must be the rail of `provider_customer_id`.'),
|
|
179
|
-
provider_customer_id: exports.billingCustomerRef,
|
|
180
|
-
provider_price_id: exports.billingPriceRef,
|
|
181
|
-
trial_days: zod_1.z.number().int().min(0).max(730),
|
|
182
|
-
tax_quote: exports.billingTaxQuoteSchema
|
|
183
|
-
.optional()
|
|
184
|
-
.describe('Opt-in fiscal checkout: the complete signed quote, immutable and single-use. Peable validates its pinned authority and retains immutable evidence before creating a session.'),
|
|
185
|
-
return_url: exports.billingReturnUrl,
|
|
186
|
-
store_id: exports.billingReference,
|
|
187
|
-
plan_id: exports.billingReference,
|
|
188
|
-
})
|
|
189
|
-
.strict();
|
|
190
|
-
/** A sensitive, owner-only URL. The gateway refuses replay after `expires_at`. */
|
|
191
|
-
exports.billingHostedSessionSchema = (0, objects_1.defineComponent)('BillingHostedSession', zod_1.z.object({ url: zod_1.z.string(), expires_at: zod_1.z.number().int() }).strict());
|
|
192
|
-
/** An owned recurring checkout. Completing it is not paid evidence. */
|
|
193
|
-
exports.billingCheckoutSessionSchema = (0, objects_1.defineComponent)('BillingCheckoutSession', zod_1.z.object({ id: zod_1.z.string(), url: zod_1.z.string(), expires_at: zod_1.z.number().int() }).strict());
|
|
194
|
-
/** A durable embedded-session reference. Provider secrets are never in it. */
|
|
195
|
-
exports.billingEmbeddedCheckoutSessionSchema = (0, objects_1.defineComponent)('BillingEmbeddedCheckoutSession', zod_1.z
|
|
196
|
-
.object({
|
|
197
|
-
id: zod_1.z.string(),
|
|
198
|
-
presentation: zod_1.z.literal('embedded'),
|
|
199
|
-
expires_at: zod_1.z.number().int(),
|
|
200
|
-
})
|
|
201
|
-
.strict());
|
|
202
|
-
exports.billingEmbeddedCheckoutScopeSchema = (0, objects_1.defineComponent)('BillingEmbeddedCheckoutScope', zod_1.z
|
|
203
|
-
.object({
|
|
204
|
-
merchant_id: zod_1.z.string(),
|
|
205
|
-
app_id: zod_1.z.string(),
|
|
206
|
-
environment,
|
|
207
|
-
mode,
|
|
208
|
-
})
|
|
209
|
-
.strict());
|
|
210
|
-
exports.billingEmbeddedCheckoutConfigurationSchema = (0, objects_1.defineComponent)('BillingEmbeddedCheckoutConfiguration', zod_1.z
|
|
211
|
-
.object({
|
|
212
|
-
scope: exports.billingEmbeddedCheckoutScopeSchema,
|
|
213
|
-
publishable_key: zod_1.z.string(),
|
|
214
|
-
payment_methods: zod_1.z.array(zod_1.z.object({ id: zod_1.z.literal('card'), available: zod_1.z.boolean() }).strict()),
|
|
215
|
-
})
|
|
216
|
-
.strict());
|
|
217
|
-
/** An ephemeral processor capability, released only to the authenticated owning workload. */
|
|
218
|
-
exports.billingEmbeddedCheckoutActionSchema = (0, objects_1.defineComponent)('BillingEmbeddedCheckoutAction', zod_1.z
|
|
219
|
-
.object({
|
|
220
|
-
kind: zod_1.z.literal('checkout_session'),
|
|
221
|
-
provider: zod_1.z.literal('stripe'),
|
|
222
|
-
session_id: zod_1.z.string(),
|
|
223
|
-
client_secret: zod_1.z.string(),
|
|
224
|
-
publishable_key: zod_1.z.string(),
|
|
225
|
-
amount_minor_units: primitives_1.amount,
|
|
226
|
-
currency: zod_1.z.string(),
|
|
227
|
-
})
|
|
228
|
-
.strict());
|
|
229
|
-
exports.billingEmbeddedCheckoutBindingSchema = (0, objects_1.defineComponent)('BillingEmbeddedCheckoutBinding', zod_1.z
|
|
230
|
-
.object({
|
|
231
|
-
status: zod_1.z.enum(['open', 'complete', 'expired']),
|
|
232
|
-
action: exports.billingEmbeddedCheckoutActionSchema
|
|
233
|
-
.nullable()
|
|
234
|
-
.describe('`null` once the session is complete or expired.'),
|
|
235
|
-
scope: exports.billingEmbeddedCheckoutScopeSchema
|
|
236
|
-
.extend({
|
|
237
|
-
store_id: zod_1.z.string(),
|
|
238
|
-
plan_id: zod_1.z.string(),
|
|
239
|
-
provider_customer_id: zod_1.z.string(),
|
|
240
|
-
provider_price_id: zod_1.z.string(),
|
|
241
|
-
})
|
|
242
|
-
.strict(),
|
|
243
|
-
tax_quote: exports.billingTaxQuoteSchema,
|
|
244
|
-
expires_at: zod_1.z.number().int(),
|
|
245
|
-
})
|
|
246
|
-
.strict());
|
|
247
|
-
// ---- Subscriptions -------------------------------------------------------------------
|
|
248
|
-
/** Provider observations only. Consumers own plan, status and entitlement interpretation. */
|
|
249
|
-
exports.billingSubscriptionSchema = (0, objects_1.defineComponent)('BillingSubscription', zod_1.z
|
|
250
|
-
.object({
|
|
251
|
-
provider_subscription_id: zod_1.z.string(),
|
|
252
|
-
latest_invoice_id: zod_1.z
|
|
253
|
-
.string()
|
|
254
|
-
.nullable()
|
|
255
|
-
.optional()
|
|
256
|
-
.describe('Discovery only: the invoice must still be read and proven paid.'),
|
|
257
|
-
provider_customer_id: zod_1.z.string(),
|
|
258
|
-
provider_price_id: zod_1.z.string(),
|
|
259
|
-
store_id: zod_1.z.string(),
|
|
260
|
-
plan_id: zod_1.z.string(),
|
|
261
|
-
livemode: zod_1.z.boolean(),
|
|
262
|
-
status: zod_1.z.enum(catalog_1.BILLING_SUBSCRIPTION_STATUSES),
|
|
263
|
-
interval: billingInterval,
|
|
264
|
-
cancel_at_period_end: zod_1.z.boolean(),
|
|
265
|
-
current_period_start: zod_1.z.number().int(),
|
|
266
|
-
current_period_end: zod_1.z.number().int(),
|
|
267
|
-
trial_ends_at: zod_1.z.number().int().nullable(),
|
|
268
|
-
cancel_at: zod_1.z.number().int().nullable(),
|
|
269
|
-
cancelled_at: zod_1.z.number().int().nullable(),
|
|
270
|
-
})
|
|
271
|
-
.strict());
|
|
272
|
-
exports.billingCheckoutObservationSchema = (0, objects_1.defineComponent)('BillingCheckoutObservation', zod_1.z
|
|
273
|
-
.object({
|
|
274
|
-
initial_invoice_id: zod_1.z
|
|
275
|
-
.string()
|
|
276
|
-
.nullable()
|
|
277
|
-
.describe('The immutable `subscription_create` invoice proven for this exact checkout. Discovery only, never paid authority.'),
|
|
278
|
-
id: zod_1.z.string(),
|
|
279
|
-
status: zod_1.z.enum(['open', 'complete', 'expired']),
|
|
280
|
-
store_id: zod_1.z.string(),
|
|
281
|
-
plan_id: zod_1.z.string(),
|
|
282
|
-
provider_customer_id: zod_1.z.string(),
|
|
283
|
-
provider_price_id: zod_1.z.string(),
|
|
284
|
-
subscription: exports.billingSubscriptionSchema.nullable(),
|
|
285
|
-
})
|
|
286
|
-
.strict());
|
|
287
|
-
// ---- Checkout operation recovery -----------------------------------------------------
|
|
288
|
-
/** The query of a recovery read; the `Idempotency-Key` is its path. */
|
|
289
|
-
exports.retrieveBillingCheckoutOperationQuery = zod_1.z
|
|
290
|
-
.object({
|
|
291
|
-
provider_customer_id: exports.billingReference,
|
|
292
|
-
provider_price_id: exports.billingReference,
|
|
293
|
-
store_id: exports.billingReference,
|
|
294
|
-
plan_id: exports.billingReference,
|
|
295
|
-
})
|
|
296
|
-
.strict();
|
|
297
|
-
/** A recovery read as a caller names it: the key and the operation it keyed. */
|
|
298
|
-
exports.billingCheckoutOperationParams = exports.retrieveBillingCheckoutOperationQuery
|
|
299
|
-
.extend({ idempotency_key: exports.billingIdempotencyKey })
|
|
300
|
-
.strict();
|
|
301
|
-
const checkoutOperationSource = zod_1.z
|
|
302
|
-
.object({
|
|
303
|
-
idempotency_key: zod_1.z.string(),
|
|
304
|
-
provider_customer_id: zod_1.z.string(),
|
|
305
|
-
provider_price_id: zod_1.z.string(),
|
|
306
|
-
store_id: zod_1.z.string(),
|
|
307
|
-
plan_id: zod_1.z.string(),
|
|
308
|
-
tax_quote_id: zod_1.z.string().nullable(),
|
|
309
|
-
merchant_id: zod_1.z.string(),
|
|
310
|
-
app_id: zod_1.z.string(),
|
|
311
|
-
mode,
|
|
312
|
-
environment,
|
|
313
|
-
})
|
|
314
|
-
.strict();
|
|
315
|
-
exports.billingCheckoutOperationSourceSchema = (0, objects_1.defineComponent)('BillingCheckoutOperationSource', checkoutOperationSource);
|
|
316
|
-
/**
|
|
317
|
-
* Read-only recovery of one previously attempted recurring checkout. Neither
|
|
318
|
-
* absence nor uncertainty permits cancellation or another financial operation.
|
|
319
|
-
*/
|
|
320
|
-
exports.billingCheckoutOperationRecoverySchema = (0, objects_1.defineComponent)('BillingCheckoutOperationRecovery', zod_1.z.union([
|
|
321
|
-
zod_1.z
|
|
322
|
-
.object({
|
|
323
|
-
state: zod_1.z.enum(['not_found', 'pending', 'indeterminate']),
|
|
324
|
-
source: exports.billingCheckoutOperationSourceSchema,
|
|
325
|
-
})
|
|
326
|
-
.strict(),
|
|
327
|
-
zod_1.z
|
|
328
|
-
.object({
|
|
329
|
-
state: zod_1.z.literal('succeeded'),
|
|
330
|
-
source: exports.billingCheckoutOperationSourceSchema,
|
|
331
|
-
checkout: zod_1.z
|
|
332
|
-
.object({ id: zod_1.z.string(), expires_at: zod_1.z.number().int(), url: zod_1.z.string().optional() })
|
|
333
|
-
.strict(),
|
|
334
|
-
})
|
|
335
|
-
.strict(),
|
|
336
|
-
]));
|
|
337
|
-
// ---- Portal ----------------------------------------------------------------------------
|
|
338
|
-
exports.createBillingPortalParams = zod_1.z
|
|
339
|
-
.object({ provider_customer_id: exports.billingCustomerRef, return_url: exports.billingReturnUrl })
|
|
340
|
-
.strict();
|
|
341
|
-
// ---- Invoices ---------------------------------------------------------------------------
|
|
342
|
-
/** An authenticated authoritative read: one settled, full, non-prorated line only. */
|
|
343
|
-
exports.billingPaidInvoiceSchema = (0, objects_1.defineComponent)('BillingPaidInvoice', zod_1.z
|
|
344
|
-
.object({
|
|
345
|
-
invoice_id: zod_1.z.string(),
|
|
346
|
-
line_id: zod_1.z.string(),
|
|
347
|
-
payment_intent_id: zod_1.z.string(),
|
|
348
|
-
provider_subscription_id: zod_1.z.string(),
|
|
349
|
-
provider_customer_id: zod_1.z.string(),
|
|
350
|
-
provider_price_id: zod_1.z.string(),
|
|
351
|
-
store_id: zod_1.z.string(),
|
|
352
|
-
plan_id: zod_1.z.string(),
|
|
353
|
-
livemode: zod_1.z.boolean(),
|
|
354
|
-
currency: zod_1.z.string(),
|
|
355
|
-
amount_paid: primitives_1.amount,
|
|
356
|
-
net_amount: primitives_1.amount.nullable(),
|
|
357
|
-
tax_amount: primitives_1.amount
|
|
358
|
-
.nullable()
|
|
359
|
-
.describe('A provider observation, not a tax quote or seller configuration.'),
|
|
360
|
-
period_start: zod_1.z.number().int(),
|
|
361
|
-
period_end: zod_1.z.number().int(),
|
|
362
|
-
paid_at: zod_1.z.number().int(),
|
|
363
|
-
observed_at: zod_1.z.number().int(),
|
|
364
|
-
})
|
|
365
|
-
.strict());
|
|
366
|
-
exports.billingInvoiceStateSchema = (0, objects_1.defineComponent)('BillingInvoiceState', exports.billingPaidInvoiceSchema
|
|
367
|
-
.extend({
|
|
368
|
-
charge_id: zod_1.z.string(),
|
|
369
|
-
amount_refunded: primitives_1.amount,
|
|
370
|
-
state: zod_1.z.enum(['paid', 'fully_refunded', 'partially_refunded']),
|
|
371
|
-
})
|
|
372
|
-
.strict());
|
|
373
|
-
/** One frozen Peable Tax line behind a signed invoice's tax amount. */
|
|
374
|
-
exports.billingInvoiceTaxLineSchema = (0, objects_1.defineComponent)('BillingInvoiceTaxLine', zod_1.z
|
|
375
|
-
.object({
|
|
376
|
-
calculation_id: exports.billingReference,
|
|
377
|
-
country: zod_1.z.string().regex(/^[A-Z]{2}$/),
|
|
378
|
-
state: zod_1.z.string().nullable(),
|
|
379
|
-
tax_type: zod_1.z.string().nullable(),
|
|
380
|
-
rate_percentage: zod_1.z.string().nullable(),
|
|
381
|
-
taxable_minor_units: primitives_1.amount,
|
|
382
|
-
tax_minor_units: primitives_1.amount,
|
|
383
|
-
inclusive: zod_1.z.boolean(),
|
|
384
|
-
taxability_reason: zod_1.z.string().min(1),
|
|
385
|
-
})
|
|
386
|
-
.strict());
|
|
387
|
-
/**
|
|
388
|
-
* Provider-independent fiscal evidence. Values come from the configured
|
|
389
|
-
* authority, never from invoice amounts, merchant metadata, or an application
|
|
390
|
-
* tax guess.
|
|
391
|
-
*/
|
|
392
|
-
exports.billingInvoiceAuthoritySourceSchema = (0, objects_1.defineComponent)('BillingInvoiceAuthoritySource', zod_1.z
|
|
393
|
-
.object({
|
|
394
|
-
invoice_id: exports.billingReference,
|
|
395
|
-
payment_intent_id: exports.billingReference,
|
|
396
|
-
customer_id: exports.billingReference,
|
|
397
|
-
subscription_id: exports.billingReference,
|
|
398
|
-
price_id: exports.billingReference,
|
|
399
|
-
plan_id: exports.billingReference,
|
|
400
|
-
merchant_id: exports.billingReference,
|
|
401
|
-
app_id: exports.billingReference,
|
|
402
|
-
mode,
|
|
403
|
-
environment,
|
|
404
|
-
})
|
|
405
|
-
.strict());
|
|
406
|
-
exports.billingFinalInvoiceSchema = (0, objects_1.defineComponent)('BillingFinalInvoice', zod_1.z
|
|
407
|
-
.object({
|
|
408
|
-
platform: zod_1.z.literal('peable'),
|
|
409
|
-
currency: zod_1.z.string().regex(/^[A-Z]{3}$/),
|
|
410
|
-
gross_minor_units: primitives_1.amount,
|
|
411
|
-
net_minor_units: primitives_1.amount,
|
|
412
|
-
tax_minor_units: primitives_1.amount,
|
|
413
|
-
merchant_fee_minor_units: primitives_1.amount,
|
|
414
|
-
tax_treatment: taxTreatment,
|
|
415
|
-
seller_id: exports.billingReference,
|
|
416
|
-
invoice_issuer_id: exports.billingReference,
|
|
417
|
-
tax_quote_id: exports.billingReference,
|
|
418
|
-
customer_location_evidence_id: exports.billingReference,
|
|
419
|
-
tax_rate_evidence_id: exports.billingReference,
|
|
420
|
-
context: zod_1.z
|
|
421
|
-
.object({
|
|
422
|
-
payer_account_id: exports.billingReference,
|
|
423
|
-
beneficiary_account_id: exports.billingReference,
|
|
424
|
-
provider_subscription_id: exports.billingReference,
|
|
425
|
-
offer_id: exports.billingReference,
|
|
426
|
-
offer_version: zod_1.z.number().int().positive(),
|
|
427
|
-
period_start: exports.billingInstant,
|
|
428
|
-
period_end: exports.billingInstant,
|
|
429
|
-
mode,
|
|
430
|
-
environment,
|
|
431
|
-
})
|
|
432
|
-
.strict(),
|
|
433
|
-
issued_at: exports.billingInstant,
|
|
434
|
-
expires_at: exports.billingInstant,
|
|
435
|
-
faircoin_quote: zod_1.z
|
|
436
|
-
.object({
|
|
437
|
-
id: exports.billingReference,
|
|
438
|
-
amount_base_units: zod_1.z
|
|
439
|
-
.string()
|
|
440
|
-
.regex(/^[1-9][0-9]*$/)
|
|
441
|
-
.max(80),
|
|
442
|
-
quoted_at: exports.billingInstant,
|
|
443
|
-
expires_at: exports.billingInstant,
|
|
444
|
-
rounding_evidence_id: exports.billingReference,
|
|
445
|
-
})
|
|
446
|
-
.strict()
|
|
447
|
-
.optional()
|
|
448
|
-
.describe('On a FairCoin invoice: the FX quote that bounds the payment.'),
|
|
449
|
-
tax_lines: zod_1.z
|
|
450
|
-
.array(exports.billingInvoiceTaxLineSchema)
|
|
451
|
-
.max(500)
|
|
452
|
-
.optional()
|
|
453
|
-
.describe('Present only when asked for (`include=tax_lines`): the frozen Peable Tax lines behind `tax_minor_units`, covered by the same signature.'),
|
|
454
|
-
})
|
|
455
|
-
.strict());
|
|
456
|
-
/** A signed final invoice authority (schema version 3). Verify it against the pinned keys. */
|
|
457
|
-
exports.billingFinalInvoiceAuthoritySchema = (0, objects_1.defineComponent)('BillingFinalInvoiceAuthority', zod_1.z
|
|
458
|
-
.object({
|
|
459
|
-
schema_version: zod_1.z.literal(3),
|
|
460
|
-
source: exports.billingInvoiceAuthoritySourceSchema,
|
|
461
|
-
invoice: exports.billingFinalInvoiceSchema,
|
|
462
|
-
method: zod_1.z.enum(['card', 'faircoin']),
|
|
463
|
-
signature: ed25519Signature,
|
|
464
|
-
})
|
|
465
|
-
.strict());
|
|
466
|
-
exports.retrieveBillingInvoiceAuthorityQuery = zod_1.z.object({
|
|
467
|
-
include: zod_1.z
|
|
468
|
-
.literal('tax_lines')
|
|
469
|
-
.optional()
|
|
470
|
-
.describe('`tax_lines`: include the frozen Peable Tax lines, inside the signature.'),
|
|
471
|
-
});
|
|
472
|
-
// ---- FairCoin renewal authority -------------------------------------------------------
|
|
473
|
-
const positiveBaseUnits = zod_1.z
|
|
474
|
-
.string()
|
|
475
|
-
.regex(/^[1-9][0-9]*$/)
|
|
476
|
-
.max(80);
|
|
477
|
-
/**
|
|
478
|
-
* An automatic FairCoin renewal authorization: an explicit, bounded
|
|
479
|
-
* instruction. Transporting it creates no mandate and authorizes no custody of
|
|
480
|
-
* payer keys.
|
|
481
|
-
*/
|
|
482
|
-
exports.billingFaircoinRenewalConsentSchema = (0, objects_1.defineComponent)('BillingFaircoinRenewalConsent', zod_1.z
|
|
483
|
-
.object({
|
|
484
|
-
authorization_id: exports.billingReference,
|
|
485
|
-
payer_account_id: exports.billingReference,
|
|
486
|
-
merchant_id: exports.billingReference,
|
|
487
|
-
app_id: exports.billingReference,
|
|
488
|
-
subscription_id: exports.billingReference,
|
|
489
|
-
plan_id: exports.billingReference,
|
|
490
|
-
mode,
|
|
491
|
-
environment,
|
|
492
|
-
explicit_consent: zod_1.z.literal(true),
|
|
493
|
-
consent_evidence_id: exports.billingReference,
|
|
494
|
-
maximum_amount_base_units: positiveBaseUnits,
|
|
495
|
-
interval: zod_1.z.literal('month'),
|
|
496
|
-
interval_count: zod_1.z.literal(1),
|
|
497
|
-
starts_at: exports.billingInstant,
|
|
498
|
-
expires_at: exports.billingInstant,
|
|
499
|
-
accepted_at: exports.billingInstant,
|
|
500
|
-
})
|
|
501
|
-
.strict()
|
|
502
|
-
.refine((value) => value.expires_at > value.starts_at &&
|
|
503
|
-
value.accepted_at <= value.starts_at &&
|
|
504
|
-
(value.mode === 'live') === (value.environment === 'production'), 'Invalid consent period or environment'));
|
|
505
|
-
exports.billingFaircoinRenewalRevocationSchema = (0, objects_1.defineComponent)('BillingFaircoinRenewalRevocation', zod_1.z
|
|
506
|
-
.object({
|
|
507
|
-
authorization_id: exports.billingReference,
|
|
508
|
-
revoked_at: exports.billingInstant,
|
|
509
|
-
revocation_evidence_id: exports.billingReference,
|
|
510
|
-
})
|
|
511
|
-
.strict());
|
|
512
|
-
exports.billingFaircoinRenewalChoiceSchema = (0, objects_1.defineComponent)('BillingFaircoinRenewalChoice', zod_1.z.union([
|
|
513
|
-
zod_1.z.object({ method: zod_1.z.literal('faircoin'), renewal: zod_1.z.literal('manual_monthly') }).strict(),
|
|
514
|
-
zod_1.z
|
|
515
|
-
.object({
|
|
516
|
-
method: zod_1.z.literal('faircoin'),
|
|
517
|
-
renewal: zod_1.z.literal('automatic'),
|
|
518
|
-
consent: exports.billingFaircoinRenewalConsentSchema,
|
|
519
|
-
})
|
|
520
|
-
.strict(),
|
|
521
|
-
]));
|
|
522
|
-
/** A FAIR/USD quote: the FAIR a USD amount costs, ceiled to a base unit, for a bounded time. */
|
|
523
|
-
exports.billingFaircoinFxQuoteSchema = (0, objects_1.defineComponent)('BillingFaircoinFxQuote', zod_1.z
|
|
524
|
-
.object({
|
|
525
|
-
id: zod_1.z.string(),
|
|
526
|
-
currency: zod_1.z.literal('USD'),
|
|
527
|
-
gross_minor_units: primitives_1.amount,
|
|
528
|
-
amount_base_units: zod_1.z.string(),
|
|
529
|
-
usd_per_fair: zod_1.z.string(),
|
|
530
|
-
source: zod_1.z.string(),
|
|
531
|
-
observed_at: zod_1.z.number().int(),
|
|
532
|
-
quoted_at: zod_1.z.number().int(),
|
|
533
|
-
expires_at: zod_1.z.number().int(),
|
|
534
|
-
rounding: zod_1.z.literal('ceil_to_base_unit'),
|
|
535
|
-
})
|
|
536
|
-
.strict());
|
|
537
|
-
// ---- Routes ----------------------------------------------------------------------------
|
|
538
|
-
/** The body of `cancel_at_period_end`: nothing. */
|
|
539
|
-
exports.cancelBillingSubscriptionParams = zod_1.z.object({}).strict();
|
|
540
|
-
const requiresKey = 'Requires an `Idempotency-Key` header: it is the operation’s identity at the provider.';
|
|
541
|
-
const subscription = { id: 'The provider subscription (`provider_subscription_id`).' };
|
|
542
|
-
const invoice = {
|
|
543
|
-
...subscription,
|
|
544
|
-
invoiceId: 'The invoice of that subscription.',
|
|
545
|
-
};
|
|
546
|
-
exports.billingRoutes = [
|
|
547
|
-
(0, route_1.defineRoute)({
|
|
548
|
-
operationId: 'listBillingRails',
|
|
549
|
-
method: 'get',
|
|
550
|
-
path: '/v1/billing/rails',
|
|
551
|
-
tag: 'Recurring billing',
|
|
552
|
-
summary: 'List the settlement rails',
|
|
553
|
-
description: "The rails this merchant's payers can choose between (card and other fiat providers, FairCoin), default first, with each rail's offers. Pass the payer's choice as `rail` to `ensureCustomer`.",
|
|
554
|
-
auth: 'service',
|
|
555
|
-
scope: 'payments:read',
|
|
556
|
-
response: exports.billingRailListSchema,
|
|
557
|
-
sdk: 'billing.listRails',
|
|
558
|
-
}),
|
|
559
|
-
(0, route_1.defineRoute)({
|
|
560
|
-
operationId: 'createBillingTaxQuote',
|
|
561
|
-
method: 'post',
|
|
562
|
-
path: '/v1/billing/tax_quotes',
|
|
563
|
-
tag: 'Recurring billing',
|
|
564
|
-
summary: 'Quote the tax of a plan',
|
|
565
|
-
description: 'A signed Peable Tax quote for one plan and one customer location. Verify its signature against the pinned keys before passing it to a checkout.',
|
|
566
|
-
auth: 'service',
|
|
567
|
-
scope: 'payments:read',
|
|
568
|
-
body: exports.createBillingTaxQuoteParams,
|
|
569
|
-
response: exports.billingTaxQuoteSchema,
|
|
570
|
-
sdk: 'billing.createTaxQuote',
|
|
571
|
-
}),
|
|
572
|
-
(0, route_1.defineRoute)({
|
|
573
|
-
operationId: 'ensureBillingCustomer',
|
|
574
|
-
method: 'post',
|
|
575
|
-
path: '/v1/billing/customers',
|
|
576
|
-
tag: 'Recurring billing',
|
|
577
|
-
summary: 'Ensure the billing customer of a store',
|
|
578
|
-
description: `The same store always answers the same customer. ${requiresKey}`,
|
|
579
|
-
auth: 'service',
|
|
580
|
-
scope: 'payments:write',
|
|
581
|
-
body: exports.ensureBillingCustomerParams,
|
|
582
|
-
response: exports.billingCustomerSchema,
|
|
583
|
-
sdk: 'billing.ensureCustomer',
|
|
584
|
-
}),
|
|
585
|
-
(0, route_1.defineRoute)({
|
|
586
|
-
operationId: 'createBillingCheckoutSession',
|
|
587
|
-
method: 'post',
|
|
588
|
-
path: '/v1/billing/checkout_sessions',
|
|
589
|
-
tag: 'Recurring billing',
|
|
590
|
-
summary: 'Create a subscription checkout',
|
|
591
|
-
description: `A hosted checkout for one plan. Completing it is not paid evidence: read the subscription and its paid invoice. ${requiresKey}`,
|
|
592
|
-
auth: 'service',
|
|
593
|
-
scope: 'payments:write',
|
|
594
|
-
body: exports.createBillingCheckoutParams,
|
|
595
|
-
response: exports.billingCheckoutSessionSchema,
|
|
596
|
-
sdk: 'billing.createCheckoutSession',
|
|
597
|
-
}),
|
|
598
|
-
(0, route_1.defineRoute)({
|
|
599
|
-
operationId: 'retrieveBillingEmbeddedCheckoutConfiguration',
|
|
600
|
-
method: 'get',
|
|
601
|
-
path: '/v1/billing/embedded_checkout_configuration',
|
|
602
|
-
tag: 'Recurring billing',
|
|
603
|
-
summary: 'Retrieve the embedded checkout configuration',
|
|
604
|
-
auth: 'service',
|
|
605
|
-
scope: 'payments:read',
|
|
606
|
-
response: exports.billingEmbeddedCheckoutConfigurationSchema,
|
|
607
|
-
sdk: 'billing.embeddedCheckoutConfiguration',
|
|
608
|
-
}),
|
|
609
|
-
(0, route_1.defineRoute)({
|
|
610
|
-
operationId: 'createBillingEmbeddedCheckoutSession',
|
|
611
|
-
method: 'post',
|
|
612
|
-
path: '/v1/billing/embedded_checkout_sessions',
|
|
613
|
-
tag: 'Recurring billing',
|
|
614
|
-
summary: 'Create an embedded subscription checkout',
|
|
615
|
-
description: `Fiscal checkout only: \`tax_quote\` is required. ${requiresKey}`,
|
|
616
|
-
auth: 'service',
|
|
617
|
-
scope: 'payments:write',
|
|
618
|
-
body: exports.createBillingCheckoutParams,
|
|
619
|
-
response: exports.billingEmbeddedCheckoutSessionSchema,
|
|
620
|
-
sdk: 'billing.createEmbeddedCheckoutSession',
|
|
621
|
-
}),
|
|
622
|
-
(0, route_1.defineRoute)({
|
|
623
|
-
operationId: 'retrieveBillingEmbeddedCheckoutAction',
|
|
624
|
-
method: 'get',
|
|
625
|
-
path: '/v1/billing/embedded_checkout_sessions/{id}/client_action',
|
|
626
|
-
tag: 'Recurring billing',
|
|
627
|
-
summary: 'Retrieve an embedded checkout’s client action',
|
|
628
|
-
description: 'The ephemeral processor capability to mount the embedded checkout, released only to the owning workload; `action` is `null` once the session is complete or expired.',
|
|
629
|
-
auth: 'service',
|
|
630
|
-
scope: 'payments:read',
|
|
631
|
-
params: { id: 'The embedded checkout session (`cs_…`).' },
|
|
632
|
-
response: exports.billingEmbeddedCheckoutBindingSchema,
|
|
633
|
-
sdk: 'billing.retrieveEmbeddedCheckoutAction',
|
|
634
|
-
}),
|
|
635
|
-
(0, route_1.defineRoute)({
|
|
636
|
-
operationId: 'createRecurringBillingPortalSession',
|
|
637
|
-
method: 'post',
|
|
638
|
-
path: '/v1/billing/portal_sessions',
|
|
639
|
-
tag: 'Recurring billing',
|
|
640
|
-
summary: "Open the provider's billing portal",
|
|
641
|
-
description: `A short-lived, owner-only URL. ${requiresKey}`,
|
|
642
|
-
auth: 'service',
|
|
643
|
-
scope: 'payments:write',
|
|
644
|
-
body: exports.createBillingPortalParams,
|
|
645
|
-
response: exports.billingHostedSessionSchema,
|
|
646
|
-
sdk: 'billing.createPortalSession',
|
|
647
|
-
}),
|
|
648
|
-
(0, route_1.defineRoute)({
|
|
649
|
-
operationId: 'retrieveBillingCheckoutOperation',
|
|
650
|
-
method: 'get',
|
|
651
|
-
path: '/v1/billing/checkout_operations/{key}',
|
|
652
|
-
tag: 'Recurring billing',
|
|
653
|
-
summary: 'Recover a checkout operation',
|
|
654
|
-
description: 'Reads the state of a checkout attempted under this `Idempotency-Key`, even after its quote or session expired. Missing, pending or indeterminate never authorizes another create or a cancellation.',
|
|
655
|
-
auth: 'service',
|
|
656
|
-
scope: 'payments:read',
|
|
657
|
-
params: { key: 'The `Idempotency-Key` the checkout was created with.' },
|
|
658
|
-
query: exports.retrieveBillingCheckoutOperationQuery,
|
|
659
|
-
response: exports.billingCheckoutOperationRecoverySchema,
|
|
660
|
-
sdk: 'billing.retrieveCheckoutOperation',
|
|
661
|
-
}),
|
|
662
|
-
(0, route_1.defineRoute)({
|
|
663
|
-
operationId: 'retrieveBillingCheckoutSession',
|
|
664
|
-
method: 'get',
|
|
665
|
-
path: '/v1/billing/checkout_sessions/{id}',
|
|
666
|
-
tag: 'Recurring billing',
|
|
667
|
-
summary: 'Retrieve a subscription checkout',
|
|
668
|
-
auth: 'service',
|
|
669
|
-
scope: 'payments:read',
|
|
670
|
-
params: { id: 'The checkout session (`cs_…`).' },
|
|
671
|
-
response: exports.billingCheckoutObservationSchema,
|
|
672
|
-
sdk: 'billing.retrieveCheckout',
|
|
673
|
-
}),
|
|
674
|
-
(0, route_1.defineRoute)({
|
|
675
|
-
operationId: 'retrieveBillingInvoiceAuthority',
|
|
676
|
-
method: 'get',
|
|
677
|
-
path: '/v1/billing/subscriptions/{id}/invoice_authorities/{invoiceId}',
|
|
678
|
-
tag: 'Recurring billing',
|
|
679
|
-
summary: 'Retrieve the signed final invoice authority',
|
|
680
|
-
description: 'Signed fiscal evidence of one paid invoice. Verify the signature against the pinned keys (`PEABLE_BILLING_AUTHORITY_KEYS`).',
|
|
681
|
-
auth: 'service',
|
|
682
|
-
scope: 'payments:read',
|
|
683
|
-
params: invoice,
|
|
684
|
-
query: exports.retrieveBillingInvoiceAuthorityQuery,
|
|
685
|
-
response: exports.billingFinalInvoiceAuthoritySchema,
|
|
686
|
-
sdk: 'billing.retrieveFinalInvoiceAuthority',
|
|
687
|
-
}),
|
|
688
|
-
(0, route_1.defineRoute)({
|
|
689
|
-
operationId: 'retrieveBillingInvoiceState',
|
|
690
|
-
method: 'get',
|
|
691
|
-
path: '/v1/billing/subscriptions/{id}/invoice_states/{invoiceId}',
|
|
692
|
-
tag: 'Recurring billing',
|
|
693
|
-
summary: 'Retrieve the refund state of a paid invoice',
|
|
694
|
-
auth: 'service',
|
|
695
|
-
scope: 'payments:read',
|
|
696
|
-
params: invoice,
|
|
697
|
-
response: exports.billingInvoiceStateSchema,
|
|
698
|
-
sdk: 'billing.retrieveInvoiceState',
|
|
699
|
-
}),
|
|
700
|
-
(0, route_1.defineRoute)({
|
|
701
|
-
operationId: 'retrieveBillingPaidInvoice',
|
|
702
|
-
method: 'get',
|
|
703
|
-
path: '/v1/billing/subscriptions/{id}/paid_invoices/{invoiceId}',
|
|
704
|
-
tag: 'Recurring billing',
|
|
705
|
-
summary: 'Retrieve a paid invoice',
|
|
706
|
-
description: 'Paid-period evidence: answers only for a settled, full, non-prorated invoice.',
|
|
707
|
-
auth: 'service',
|
|
708
|
-
scope: 'payments:read',
|
|
709
|
-
params: invoice,
|
|
710
|
-
response: exports.billingPaidInvoiceSchema,
|
|
711
|
-
sdk: 'billing.retrievePaidInvoice',
|
|
712
|
-
}),
|
|
713
|
-
(0, route_1.defineRoute)({
|
|
714
|
-
operationId: 'retrieveBillingSubscription',
|
|
715
|
-
method: 'get',
|
|
716
|
-
path: '/v1/billing/subscriptions/{id}',
|
|
717
|
-
tag: 'Recurring billing',
|
|
718
|
-
summary: 'Retrieve a subscription',
|
|
719
|
-
auth: 'service',
|
|
720
|
-
scope: 'payments:read',
|
|
721
|
-
params: subscription,
|
|
722
|
-
response: exports.billingSubscriptionSchema,
|
|
723
|
-
sdk: 'billing.retrieveSubscription',
|
|
724
|
-
}),
|
|
725
|
-
(0, route_1.defineRoute)({
|
|
726
|
-
operationId: 'renewBillingSubscription',
|
|
727
|
-
method: 'post',
|
|
728
|
-
path: '/v1/billing/subscriptions/{id}/renew',
|
|
729
|
-
tag: 'Recurring billing',
|
|
730
|
-
summary: 'Renew a payer-initiated subscription',
|
|
731
|
-
description: `Opens a new expiring FAIR payment for one monthly period. Never auto-debits. ${requiresKey}`,
|
|
732
|
-
auth: 'service',
|
|
733
|
-
scope: 'payments:write',
|
|
734
|
-
params: subscription,
|
|
735
|
-
body: exports.createBillingCheckoutParams,
|
|
736
|
-
response: exports.billingCheckoutSessionSchema,
|
|
737
|
-
sdk: 'billing.renewSubscription',
|
|
738
|
-
}),
|
|
739
|
-
(0, route_1.defineRoute)({
|
|
740
|
-
operationId: 'cancelBillingSubscriptionAtPeriodEnd',
|
|
741
|
-
method: 'post',
|
|
742
|
-
path: '/v1/billing/subscriptions/{id}/cancel_at_period_end',
|
|
743
|
-
tag: 'Recurring billing',
|
|
744
|
-
summary: 'Cancel a subscription at period end',
|
|
745
|
-
description: `Access continues to the end of the paid period. ${requiresKey}`,
|
|
746
|
-
auth: 'service',
|
|
747
|
-
scope: 'payments:write',
|
|
748
|
-
params: subscription,
|
|
749
|
-
body: exports.cancelBillingSubscriptionParams,
|
|
750
|
-
response: exports.billingSubscriptionSchema,
|
|
751
|
-
sdk: 'billing.cancelAtPeriodEnd',
|
|
752
|
-
}),
|
|
753
|
-
];
|