@peable.to/shared-types 0.15.0 → 0.17.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.
@@ -0,0 +1,88 @@
1
+ /** The fonts checkout may render in — system stacks only, no remote font is ever loaded. */
2
+ export declare const BRANDING_FONTS: readonly ["system", "inter", "roboto", "open_sans", "lato", "source_sans", "noto_sans", "serif", "monospace"];
3
+ export type BrandingFont = (typeof BRANDING_FONTS)[number];
4
+ export declare const BRANDING_BORDER_STYLES: readonly ["rounded", "rectangular", "pill"];
5
+ export type BrandingBorderStyle = (typeof BRANDING_BORDER_STYLES)[number];
6
+ /** `#rrggbb`, lowercase — the only colour spelling branding stores. */
7
+ export declare const BRANDING_COLOR_PATTERN: RegExp;
8
+ /** Peable's defaults, applied wherever a merchant set nothing. */
9
+ export declare const DEFAULT_BRANDING: Readonly<{
10
+ primary_color: "#1f6feb";
11
+ accent_color: "#0b1f33";
12
+ font: BrandingFont;
13
+ border_style: BrandingBorderStyle;
14
+ }>;
15
+ /**
16
+ * A merchant's branding settings, as Orbit reads and writes them
17
+ * (`GET|POST /v1/merchants/me/branding`, and the dashboard's twin).
18
+ */
19
+ export interface MerchantBranding {
20
+ object: 'branding_settings';
21
+ livemode: boolean;
22
+ /**
23
+ * The square icon: the merchant's avatar (`avatar_file_id`, an Oxy file
24
+ * Peable already governs), shown when `use_avatar_as_icon` is on.
25
+ */
26
+ use_avatar_as_icon: boolean;
27
+ /**
28
+ * The wide logo: the merchant's `business_logo` — a `file_…` of purpose
29
+ * `business_logo` (Files API) — or `null`. Setting it here and through
30
+ * `POST /v1/merchants/me {business_logo}` is the same write.
31
+ */
32
+ logo: string | null;
33
+ primary_color: string | null;
34
+ accent_color: string | null;
35
+ font: BrandingFont | null;
36
+ border_style: BrandingBorderStyle | null;
37
+ /**
38
+ * Your terms of service (`https://`). Required before a session or link can
39
+ * ask for terms acceptance (`consent_collection.terms_of_service: required`).
40
+ */
41
+ terms_of_service_url: string | null;
42
+ updated_at: number | null;
43
+ }
44
+ export interface UpdateMerchantBrandingParams {
45
+ use_avatar_as_icon?: boolean;
46
+ /** A `file_…` of purpose `business_logo`; `null` removes it. */
47
+ logo?: string | null;
48
+ /** `#rrggbb` (any case; stored lowercase), `null` for Peable's default. */
49
+ primary_color?: string | null;
50
+ accent_color?: string | null;
51
+ font?: BrandingFont | null;
52
+ border_style?: BrandingBorderStyle | null;
53
+ /** `https://` only; `null` removes it. */
54
+ terms_of_service_url?: string | null;
55
+ }
56
+ /**
57
+ * Branding as a payer surface renders it: every field resolved (defaults
58
+ * filled in), the logo and icon as URLs the gateway built through Oxy's media
59
+ * chokepoint — a withheld file is `null`, never a broken image.
60
+ */
61
+ export interface CheckoutBranding {
62
+ icon_url: string | null;
63
+ logo_url: string | null;
64
+ primary_color: string;
65
+ accent_color: string;
66
+ font: BrandingFont;
67
+ border_style: BrandingBorderStyle;
68
+ }
69
+ /** Which customer emails Peable sends for this merchant. */
70
+ export interface MerchantEmailSettings {
71
+ object: 'email_settings';
72
+ livemode: boolean;
73
+ /** A receipt when a payment succeeds and it has a `receipt_email` (or a collected email). */
74
+ payment_receipts: boolean;
75
+ /** A notice when a refund succeeds. */
76
+ refund_notices: boolean;
77
+ /** A confirmation when a checkout session completes. */
78
+ checkout_confirmations: boolean;
79
+ /** The reply-to address shown on emails, or `null` for none. */
80
+ support_email: string | null;
81
+ updated_at: number | null;
82
+ }
83
+ export interface UpdateMerchantEmailSettingsParams {
84
+ payment_receipts?: boolean;
85
+ refund_notices?: boolean;
86
+ checkout_confirmations?: boolean;
87
+ support_email?: string | null;
88
+ }
@@ -1,5 +1,6 @@
1
1
  import type { CurrencyCode } from './money';
2
2
  import type { PaymentIntent } from './paymentIntent';
3
+ import type { BillingDetails } from './paymentMethod';
3
4
  /** Card details safe to show: never the number, never the CVC. */
4
5
  export interface CardDetails {
5
6
  brand: string | null;
@@ -41,6 +42,11 @@ export interface Charge {
41
42
  refunded: boolean;
42
43
  disputed: boolean;
43
44
  outcome: ChargeOutcome | null;
45
+ /**
46
+ * Who the card's billing details name, as the provider reported them for this
47
+ * charge — `null` until the provider snapshot is read (as `outcome`).
48
+ */
49
+ billing_details: BillingDetails | null;
44
50
  payment_method_details: {
45
51
  type: 'card';
46
52
  card: CardDetails;
@@ -1,73 +1,452 @@
1
1
  import type { BillingFaircoinFxQuote } from './billing';
2
+ import type { Price, Product } from './catalog';
3
+ import type { Customer } from './customer';
4
+ import type { CheckoutBranding } from './branding';
2
5
  import type { CurrencyCode } from './money';
3
- import type { NetworkType } from './network';
4
6
  import type { MerchantDisplay } from './merchantDisplay';
5
- import type { PaymentIntent, PaymentIntentRail } from './paymentIntent';
7
+ import type { NetworkType } from './network';
8
+ import type { Address, AddressParams, PaymentIntent, PaymentIntentRail } from './paymentIntent';
6
9
  import type { ConnectedAccount } from './settlement';
7
- /** The merchant/SDK-facing DTO — returned on create and by merchant retrieve. */
8
- export interface CheckoutSession {
10
+ import type { SetupIntent } from './setupIntent';
11
+ export declare const CHECKOUT_SESSION_MODES: readonly ["payment", "setup", "subscription"];
12
+ export type CheckoutSessionMode = (typeof CHECKOUT_SESSION_MODES)[number];
13
+ export declare const CHECKOUT_SESSION_STATUSES: readonly ["open", "complete", "expired"];
14
+ export type CheckoutSessionStatus = (typeof CHECKOUT_SESSION_STATUSES)[number];
15
+ export declare const CHECKOUT_PAYMENT_STATUSES: readonly ["paid", "unpaid", "no_payment_required"];
16
+ export type CheckoutSessionPaymentStatus = (typeof CHECKOUT_PAYMENT_STATUSES)[number];
17
+ export declare const CHECKOUT_UI_MODES: readonly ["hosted", "embedded"];
18
+ export type CheckoutUiMode = (typeof CHECKOUT_UI_MODES)[number];
19
+ /** The languages the hosted and embedded checkout speak. */
20
+ export declare const CHECKOUT_LOCALES: readonly ["en", "es", "fr", "de", "it", "pt"];
21
+ export type CheckoutLocale = (typeof CHECKOUT_LOCALES)[number];
22
+ export declare const CHECKOUT_SUBMIT_TYPES: readonly ["auto", "pay", "book", "donate"];
23
+ export type CheckoutSubmitType = (typeof CHECKOUT_SUBMIT_TYPES)[number];
24
+ export declare const CHECKOUT_CUSTOMER_CREATIONS: readonly ["always", "if_required"];
25
+ export type CheckoutCustomerCreation = (typeof CHECKOUT_CUSTOMER_CREATIONS)[number];
26
+ export declare const CHECKOUT_BILLING_ADDRESS_COLLECTIONS: readonly ["auto", "required"];
27
+ export type CheckoutBillingAddressCollection = (typeof CHECKOUT_BILLING_ADDRESS_COLLECTIONS)[number];
28
+ export declare const CHECKOUT_CUSTOM_FIELD_TYPES: readonly ["text", "numeric", "dropdown"];
29
+ export type CheckoutCustomFieldType = (typeof CHECKOUT_CUSTOM_FIELD_TYPES)[number];
30
+ /** Stripe's tax id types Peable collects; `eu_vat` covers every EU member state. */
31
+ export declare const CHECKOUT_TAX_ID_TYPES: readonly ["eu_vat", "gb_vat", "ch_vat", "no_vat", "us_ein", "ca_bn"];
32
+ export type CheckoutTaxIdType = (typeof CHECKOUT_TAX_ID_TYPES)[number];
33
+ /**
34
+ * Bounds of the session contract, shared by the gateway's validators and the
35
+ * clients that build requests, so the two cannot drift.
36
+ */
37
+ export declare const CHECKOUT_LIMITS: Readonly<{
38
+ lineItemsMax: 20;
39
+ quantityMax: 999999;
40
+ customFieldsMax: 3;
41
+ customFieldKeyMax: 200;
42
+ customFieldLabelMax: 50;
43
+ customFieldTextMax: 255;
44
+ dropdownOptionsMax: 200;
45
+ dropdownOptionLabelMax: 100;
46
+ dropdownOptionValueMax: 100;
47
+ clientReferenceIdMax: 200;
48
+ /** `expires_at` must be between 30 minutes and 24 hours from creation. */
49
+ expiresMinSeconds: number;
50
+ expiresMaxSeconds: number;
51
+ shippingCountriesMax: 250;
52
+ termsTextMax: 1200;
53
+ }>;
54
+ /** The template a `success_url` may carry; replaced with the session's `cs_…`. */
55
+ export declare const CHECKOUT_SESSION_ID_TEMPLATE = "{CHECKOUT_SESSION_ID}";
56
+ export interface CheckoutAdjustableQuantity {
57
+ enabled: boolean;
58
+ /** Default 0 when enabled. */
59
+ minimum: number | null;
60
+ /** Default 99 when enabled. */
61
+ maximum: number | null;
62
+ }
63
+ /** One line of a session — Stripe's `item` (`GET /v1/checkout_sessions/:id/line_items`). */
64
+ export interface CheckoutLineItem {
9
65
  id: string;
10
- object: 'checkout_session';
66
+ object: 'item';
67
+ /** The product's name, or the inline `product_data.name`. */
68
+ description: string;
11
69
  /**
12
- * Which of the provider's two worlds this object belongs to (ADR 0017):
13
- * `true` for a `production` merchant, `false` for every other environment.
70
+ * The catalog price (`price_…`, or the object with `expand[]=data.price`), or
71
+ * `null` for an inline `price_data` line — an inline price is a snapshot on
72
+ * the line, never a stored `price_…`.
14
73
  */
74
+ price: string | Price | null;
75
+ /** The catalog product (`prod_…`, expandable), or `null` for `product_data`. */
76
+ product: string | Product | null;
77
+ /** Images to show beside the line (the product's, or `product_data.images`). */
78
+ images: string[];
79
+ quantity: number;
80
+ adjustable_quantity: CheckoutAdjustableQuantity | null;
81
+ currency: CurrencyCode;
82
+ /** The per-unit amount for a per-unit price; `null` for a tiered one. */
83
+ unit_amount: string | null;
84
+ /** Before discount and tax. */
85
+ amount_subtotal: string;
86
+ amount_discount: string;
87
+ amount_tax: string;
88
+ /** `amount_subtotal - amount_discount + amount_tax` (exclusive tax only). */
89
+ amount_total: string;
90
+ }
91
+ export interface CheckoutTaxId {
92
+ type: CheckoutTaxIdType;
93
+ value: string;
94
+ }
95
+ /** What the payer told checkout about themselves — Stripe's `customer_details`. */
96
+ export interface CheckoutCustomerDetails {
97
+ email: string | null;
98
+ name: string | null;
99
+ phone: string | null;
100
+ address: Address | null;
101
+ tax_ids: CheckoutTaxId[];
102
+ }
103
+ export interface CheckoutShippingDetails {
104
+ name: string;
105
+ address: Address;
106
+ }
107
+ export interface CheckoutCustomFieldLabel {
108
+ type: 'custom';
109
+ custom: string;
110
+ }
111
+ export interface CheckoutCustomFieldDropdownOption {
112
+ label: string;
113
+ value: string;
114
+ }
115
+ /** A merchant-defined field the payer fills in; `value`s are what they entered. */
116
+ export interface CheckoutCustomField {
117
+ key: string;
118
+ label: CheckoutCustomFieldLabel;
119
+ type: CheckoutCustomFieldType;
120
+ optional: boolean;
121
+ dropdown: {
122
+ options: CheckoutCustomFieldDropdownOption[];
123
+ value: string | null;
124
+ } | null;
125
+ text: {
126
+ minimum_length: number | null;
127
+ maximum_length: number | null;
128
+ value: string | null;
129
+ } | null;
130
+ numeric: {
131
+ minimum_length: number | null;
132
+ maximum_length: number | null;
133
+ value: string | null;
134
+ } | null;
135
+ }
136
+ export interface CheckoutDiscount {
137
+ /** The coupon applied (`coupon` id — merchant-chosen or `coupon_…`). */
138
+ coupon: string;
139
+ /** The promotion code it was redeemed through (`promo_…`), or `null`. */
140
+ promotion_code: string | null;
141
+ }
142
+ export interface CheckoutTotalDetails {
143
+ amount_discount: string;
144
+ amount_tax: string;
145
+ amount_shipping: string;
146
+ }
147
+ /**
148
+ * `automatic_tax` — Peable Tax (ADR 0011). `requires_location_inputs` until
149
+ * the payer gave an address Peable Tax can locate them with; `failed` when the
150
+ * sale is covered and could not be priced (checkout refuses to proceed: tax
151
+ * fails CLOSED, never zero).
152
+ */
153
+ export interface CheckoutAutomaticTax {
154
+ enabled: boolean;
155
+ status: 'complete' | 'requires_location_inputs' | 'failed' | null;
156
+ }
157
+ export interface CheckoutConsentCollection {
158
+ terms_of_service: 'none' | 'required';
159
+ }
160
+ export interface CheckoutConsent {
161
+ terms_of_service: 'accepted' | null;
162
+ }
163
+ export interface CheckoutAfterCompletion {
164
+ type: 'redirect' | 'hosted_confirmation';
165
+ redirect: {
166
+ url: string;
167
+ } | null;
168
+ hosted_confirmation: {
169
+ custom_message: string | null;
170
+ } | null;
171
+ }
172
+ /** The merchant/SDK-facing session — Stripe's Checkout Session. */
173
+ export interface CheckoutSession {
174
+ id: string;
175
+ object: 'checkout_session';
176
+ /** ADR 0017: `true` for a `production` merchant. */
15
177
  livemode: boolean;
16
- /** The wrapped payment's `pi_…`, or the {@link PaymentIntent} with `expand[]=payment_intent`. */
17
- payment_intent: string | PaymentIntent;
18
- /** The wrapped intent's `client_secret`, returned to the merchant on create. */
19
- client_secret: string;
20
- amount: string;
178
+ mode: CheckoutSessionMode;
179
+ status: CheckoutSessionStatus;
180
+ payment_status: CheckoutSessionPaymentStatus;
181
+ ui_mode: CheckoutUiMode;
182
+ /** The language checkout renders in; `null` follows the payer's browser. */
183
+ locale: CheckoutLocale | null;
184
+ submit_type: CheckoutSubmitType;
21
185
  currency: CurrencyCode;
22
186
  rail: PaymentIntentRail;
23
187
  /** FairCoin rail only; `null` on a card session. */
24
188
  network: NetworkType | null;
189
+ payment_method_types: string[];
190
+ amount_subtotal: string;
191
+ amount_total: string;
192
+ total_details: CheckoutTotalDetails;
193
+ discounts: CheckoutDiscount[];
194
+ allow_promotion_codes: boolean;
195
+ automatic_tax: CheckoutAutomaticTax;
196
+ /** `cus_…` (expandable) — given on create, or created at completion. */
197
+ customer: string | Customer | null;
198
+ customer_email: string | null;
199
+ customer_creation: CheckoutCustomerCreation;
200
+ customer_details: CheckoutCustomerDetails | null;
201
+ billing_address_collection: CheckoutBillingAddressCollection;
202
+ shipping_address_collection: {
203
+ allowed_countries: string[];
204
+ } | null;
205
+ shipping_details: CheckoutShippingDetails | null;
206
+ phone_number_collection: {
207
+ enabled: boolean;
208
+ };
209
+ tax_id_collection: {
210
+ enabled: boolean;
211
+ };
212
+ custom_fields: CheckoutCustomField[];
213
+ consent_collection: CheckoutConsentCollection | null;
214
+ consent: CheckoutConsent | null;
25
215
  /**
26
- * The seller the wrapped payment is made on behalf of (`ca_…`, or the
27
- * object with `expand[]=connected_account`), or `null` (ADR 0012 D5).
216
+ * The payment this session created (`pi_…`, expandable), once the payer
217
+ * confirmed; `null` before, and always in `setup` mode.
28
218
  */
219
+ payment_intent: string | PaymentIntent | null;
220
+ /** `setup` mode: the SetupIntent (`seti_…`, expandable) once confirmed. */
221
+ setup_intent: string | SetupIntent | null;
222
+ /** The seller an on-behalf payment pays (`ca_…`, expandable). */
29
223
  connected_account: string | ConnectedAccount | null;
224
+ /** The payment link this session was created from (`link_…`), if any. */
225
+ payment_link: string | null;
226
+ client_reference_id: string | null;
30
227
  metadata: Record<string, string>;
31
- success_url?: string;
32
- cancel_url?: string;
33
- /** Canonical `checkout.peable.to/c/<id>` URL. */
34
- url: string;
228
+ /** With `{CHECKOUT_SESSION_ID}` as given; checkout substitutes it. */
229
+ success_url: string | null;
230
+ cancel_url: string | null;
231
+ /** Hosted mode: the URL to send the payer to. `null` in embedded mode. */
232
+ url: string | null;
233
+ /** Embedded mode: what `PeableCheckout.mountCheckout` takes. `null` in hosted mode. */
234
+ client_secret: string | null;
235
+ expires_at: number;
35
236
  created: number;
36
- updated_at: number;
37
237
  }
38
238
  /**
39
- * What the checkout page loads at `/c/:id`, authorized by possession of the
40
- * wrapped intent's `client_secret` (never a service token). `paymentIntent`
41
- * reuses `toPaymentIntentDTO`'s output unchanged — it already carries
42
- * `clientSecret`, which the page needs to open the socket and to `submit_tx`.
239
+ * What the hosted/embedded checkout loads, authorized by the session's
240
+ * `client_secret` (or, for a session wrapping a payment, that payment's). No
241
+ * metadata, no client reference, no internal ids.
43
242
  */
44
243
  export interface CheckoutSessionPublic {
45
- /** Frozen commercial USD price and exact FAIR settlement quote; no payer metadata. */
46
- billing_quote?: BillingFaircoinFxQuote;
47
244
  id: string;
48
245
  object: 'checkout_session';
246
+ livemode: boolean;
247
+ mode: CheckoutSessionMode;
248
+ status: CheckoutSessionStatus;
249
+ payment_status: CheckoutSessionPaymentStatus;
250
+ ui_mode: CheckoutUiMode;
251
+ locale: CheckoutLocale | null;
252
+ submit_type: CheckoutSubmitType;
253
+ currency: CurrencyCode;
254
+ rail: PaymentIntentRail;
255
+ network: NetworkType | null;
256
+ line_items: CheckoutLineItem[];
257
+ amount_subtotal: string;
258
+ amount_total: string;
259
+ total_details: CheckoutTotalDetails;
49
260
  /**
50
- * Which of the provider's two worlds this object belongs to (ADR 0017):
51
- * `true` for a `production` merchant, `false` for every other environment.
261
+ * The discount applied, with what the payer sees — the code they typed (or
262
+ * the coupon's name) and how much it took off.
52
263
  */
53
- livemode: boolean;
54
- success_url?: string;
55
- cancel_url?: string;
264
+ discount: {
265
+ promotion_code: string | null;
266
+ coupon_name: string | null;
267
+ amount_off: string | null;
268
+ percent_off: number | null;
269
+ } | null;
270
+ allow_promotion_codes: boolean;
271
+ automatic_tax: CheckoutAutomaticTax;
272
+ /** Prefilled from `customer_email` / the customer; then what the payer entered. */
273
+ customer_details: CheckoutCustomerDetails;
274
+ /** Whether the email is fixed by the merchant (a `customer` or `customer_email`). */
275
+ customer_email_locked: boolean;
276
+ billing_address_collection: CheckoutBillingAddressCollection;
277
+ shipping_address_collection: {
278
+ allowed_countries: string[];
279
+ } | null;
280
+ shipping_details: CheckoutShippingDetails | null;
281
+ phone_number_collection: {
282
+ enabled: boolean;
283
+ };
284
+ tax_id_collection: {
285
+ enabled: boolean;
286
+ };
287
+ custom_fields: CheckoutCustomField[];
288
+ consent_collection: CheckoutConsentCollection | null;
289
+ consent: CheckoutConsent | null;
290
+ /** The merchant's terms URL when `consent_collection.terms_of_service` is required. */
291
+ terms_of_service_url: string | null;
292
+ /** The payment the payer confirmed — with its `client_secret`, the payer's capability. */
293
+ payment_intent: PaymentIntent | null;
294
+ /** `setup` mode: the SetupIntent id and client secret, once confirmed. */
295
+ setup_intent: {
296
+ id: string;
297
+ client_secret: string;
298
+ status: SetupIntent['status'];
299
+ } | null;
300
+ /** `success_url` with `{CHECKOUT_SESSION_ID}` substituted; only once `complete`. */
301
+ success_url: string | null;
302
+ /** Shown as "Back to <merchant>" before payment. */
303
+ cancel_url: string | null;
304
+ /** A payment link's hosted confirmation, shown once `complete`. */
305
+ confirmation_message: string | null;
56
306
  merchant: MerchantDisplay;
57
- payment_intent: PaymentIntent;
307
+ branding: CheckoutBranding;
308
+ /**
309
+ * The card provider's PUBLIC key for this session's mode (ADR 0017), so the
310
+ * payment fields can mount before the payment exists. `null` on FairCoin.
311
+ */
312
+ publishable_key: string | null;
313
+ /** FairCoin billing invoices: the frozen USD price and FAIR settlement quote. */
314
+ billing_quote?: BillingFaircoinFxQuote;
315
+ expires_at: number;
316
+ }
317
+ /** `POST /v1/checkout_sessions/:id/public` — what the payer changes before confirming. */
318
+ export interface UpdateCheckoutSessionPublicParams {
319
+ /** Adjust a line's quantity, within its `adjustable_quantity` bounds. */
320
+ line_items?: {
321
+ id: string;
322
+ quantity: number;
323
+ }[];
324
+ /** A code to redeem (`allow_promotion_codes`), or `''` to remove the one applied. */
325
+ promotion_code?: string;
326
+ customer_details?: {
327
+ email?: string;
328
+ name?: string;
329
+ phone?: string;
330
+ address?: AddressParams;
331
+ tax_ids?: CheckoutTaxId[];
332
+ };
333
+ shipping_details?: {
334
+ name: string;
335
+ address: AddressParams;
336
+ } | null;
337
+ /** By `key`: the payer's value for each custom field. */
338
+ custom_fields?: {
339
+ key: string;
340
+ value: string;
341
+ }[];
342
+ consent?: {
343
+ terms_of_service?: 'accepted';
344
+ };
345
+ }
346
+ /**
347
+ * `POST /v1/checkout_sessions/:id/public/confirm` — lock the order and create
348
+ * the payment (or setup). The answer is the session with `payment_intent` /
349
+ * `setup_intent` set; completing it is the payment's, and `complete` is only
350
+ * ever what the gateway says.
351
+ */
352
+ export type ConfirmCheckoutSessionPublicParams = Record<string, never>;
353
+ export interface CheckoutProductDataParams {
354
+ name: string;
355
+ description?: string;
356
+ images?: string[];
357
+ tax_code?: string;
358
+ }
359
+ export interface CheckoutPriceDataParams {
360
+ currency: CurrencyCode;
361
+ unit_amount: string;
362
+ /** Exactly one of `product` and `product_data`. */
363
+ product?: string;
364
+ product_data?: CheckoutProductDataParams;
365
+ recurring?: {
366
+ interval: 'day' | 'week' | 'month' | 'year';
367
+ interval_count?: number;
368
+ };
369
+ tax_behavior?: 'inclusive' | 'exclusive' | 'unspecified';
370
+ }
371
+ export interface CheckoutLineItemParams {
372
+ /** Exactly one of `price` and `price_data`. */
373
+ price?: string;
374
+ price_data?: CheckoutPriceDataParams;
375
+ quantity: number;
376
+ adjustable_quantity?: {
377
+ enabled: boolean;
378
+ minimum?: number;
379
+ maximum?: number;
380
+ };
381
+ }
382
+ export interface CheckoutCustomFieldParams {
383
+ key: string;
384
+ label: CheckoutCustomFieldLabel;
385
+ type: CheckoutCustomFieldType;
386
+ optional?: boolean;
387
+ dropdown?: {
388
+ options: CheckoutCustomFieldDropdownOption[];
389
+ };
390
+ text?: {
391
+ minimum_length?: number;
392
+ maximum_length?: number;
393
+ };
394
+ numeric?: {
395
+ minimum_length?: number;
396
+ maximum_length?: number;
397
+ };
58
398
  }
59
399
  export interface CreateCheckoutSessionParams {
60
- amount: string;
61
- /** Defaults to `'faircoin'`, so pre-ADR-0001 integrations keep working. */
62
- rail?: PaymentIntentRail;
63
- /** Required on the faircoin rail; refused on the card rail. */
64
- network?: NetworkType;
65
- /** Defaults to `'FAIR'` on the faircoin rail; required on the card rail. */
400
+ /** Default `payment`. `subscription` answers 400 until the billing engine fulfils it. */
401
+ mode?: CheckoutSessionMode;
402
+ /** Required in `payment` and `subscription` mode; refused in `setup` mode. */
403
+ line_items?: CheckoutLineItemParams[];
404
+ /** `setup` mode: the currency of the method being saved (card rail only). */
66
405
  currency?: CurrencyCode;
67
- metadata?: Record<string, string>;
406
+ /** At most one; mutually exclusive with `allow_promotion_codes`. */
407
+ discounts?: ({
408
+ coupon: string;
409
+ } | {
410
+ promotion_code: string;
411
+ })[];
412
+ allow_promotion_codes?: boolean;
413
+ /** `cus_…`; mutually exclusive with `customer_email`. */
414
+ customer?: string;
415
+ customer_email?: string;
416
+ /** Default `if_required` (a customer is created only when something needs one). */
417
+ customer_creation?: CheckoutCustomerCreation;
418
+ billing_address_collection?: CheckoutBillingAddressCollection;
419
+ shipping_address_collection?: {
420
+ allowed_countries: string[];
421
+ };
422
+ phone_number_collection?: {
423
+ enabled: boolean;
424
+ };
425
+ tax_id_collection?: {
426
+ enabled: boolean;
427
+ };
428
+ /** At most three. */
429
+ custom_fields?: CheckoutCustomFieldParams[];
430
+ consent_collection?: {
431
+ terms_of_service?: 'none' | 'required';
432
+ };
433
+ automatic_tax?: {
434
+ enabled: boolean;
435
+ };
436
+ /** `['card']` or `['faircoin']` — the rail the line items' currency allows. */
437
+ payment_method_types?: string[];
438
+ locale?: CheckoutLocale | 'auto';
439
+ ui_mode?: CheckoutUiMode;
440
+ /** Required in hosted mode; may carry `{CHECKOUT_SESSION_ID}`. */
68
441
  success_url?: string;
442
+ /** Hosted mode only: the "Back to merchant" link. */
69
443
  cancel_url?: string;
70
- /** Pay this seller (`ca_…`) rather than the merchant — see `CreatePaymentIntentParams.connectedAccount`. */
444
+ /** Unix seconds, 30 minutes to 24 hours from now. Default 24 hours. */
445
+ expires_at?: number;
446
+ client_reference_id?: string;
447
+ metadata?: Record<string, string>;
448
+ submit_type?: CheckoutSubmitType;
449
+ /** Pay this seller (`ca_…`) rather than the merchant (ADR 0012); FairCoin only. */
71
450
  connected_account?: string;
72
451
  }
73
452
  /** `POST /v1/checkout_sessions/:id` — the merchant's `metadata`, as a patch. */
@@ -1,11 +1,14 @@
1
1
  import type { Account } from './account';
2
2
  import type { ApplicationFee, Balance, Payout } from './balance';
3
3
  import type { Charge } from './charge';
4
+ import type { CheckoutSession } from './checkoutSession';
4
5
  import type { Coupon, Price, Product, PromotionCode } from './catalog';
5
6
  import type { Customer } from './customer';
6
7
  import type { Dispute } from './dispute';
7
8
  import type { PaymentIntent } from './paymentIntent';
9
+ import type { PaymentLink } from './paymentLink';
8
10
  import type { PaymentMethod } from './paymentMethod';
11
+ import type { ReportRun } from './reporting';
9
12
  import type { ConnectedAccount, Refund } from './settlement';
10
13
  import type { SetupIntent } from './setupIntent';
11
14
  import type { WebhookEndpoint } from './webhookEndpoint';
@@ -101,6 +104,20 @@ export interface WebhookEventPayload {
101
104
  'coupon.deleted': Coupon;
102
105
  'promotion_code.created': PromotionCode;
103
106
  'promotion_code.updated': PromotionCode;
107
+ /**
108
+ * Checkout (Orbit Phase 3). `completed` when the payer finished: the payment
109
+ * succeeded (`payment_status: paid`), was authorized for a manual capture,
110
+ * or — a FairCoin payment — was broadcast and is confirming (`unpaid`), in
111
+ * which case `async_payment_succeeded` or `async_payment_failed` follows
112
+ * when the chain decides. `expired` when it ran out or the merchant expired
113
+ * it. Each carries the session as `GET /v1/checkout_sessions/:id` returns it.
114
+ */
115
+ 'checkout.session.completed': CheckoutSession;
116
+ 'checkout.session.expired': CheckoutSession;
117
+ 'checkout.session.async_payment_succeeded': CheckoutSession;
118
+ 'checkout.session.async_payment_failed': CheckoutSession;
119
+ 'payment_link.created': PaymentLink;
120
+ 'payment_link.updated': PaymentLink;
104
121
  /**
105
122
  * A seller's account changed — their READINESS, in practice. Emitted when the
106
123
  * fields a merchant ACTS on change, not on every refresh. It names no payment
@@ -124,6 +141,10 @@ export interface WebhookEventPayload {
124
141
  'payout.canceled': Payout;
125
142
  /** Funds became available in the account; carries the balance read from the ledger. */
126
143
  'balance.available': Balance;
144
+ /** A report run finished: its CSV is `result` (a `finance_report_run` file). */
145
+ 'reporting.report_run.succeeded': ReportRun;
146
+ /** A report run could not be produced; `error` says why. */
147
+ 'reporting.report_run.failed': ReportRun;
127
148
  'billing.observation.updated': BillingObservation;
128
149
  /**
129
150
  * A synthetic event sent to ONE endpoint when its owner asks to test it