@peable.to/shared-types 0.15.0 → 0.16.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,31 @@
1
+ "use strict";
2
+ // Merchant branding and customer email settings (Orbit Phase 3).
3
+ //
4
+ // Branding is what the hosted checkout, the embedded checkout and Peable's
5
+ // receipts look like for one merchant. Every value is from a CLOSED set or a
6
+ // validated colour, so nothing a merchant stores can inject markup or a remote
7
+ // font into a payer's page or an email.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DEFAULT_BRANDING = exports.BRANDING_COLOR_PATTERN = exports.BRANDING_BORDER_STYLES = exports.BRANDING_FONTS = void 0;
10
+ /** The fonts checkout may render in — system stacks only, no remote font is ever loaded. */
11
+ exports.BRANDING_FONTS = [
12
+ 'system',
13
+ 'inter',
14
+ 'roboto',
15
+ 'open_sans',
16
+ 'lato',
17
+ 'source_sans',
18
+ 'noto_sans',
19
+ 'serif',
20
+ 'monospace',
21
+ ];
22
+ exports.BRANDING_BORDER_STYLES = ['rounded', 'rectangular', 'pill'];
23
+ /** `#rrggbb`, lowercase — the only colour spelling branding stores. */
24
+ exports.BRANDING_COLOR_PATTERN = /^#[0-9a-f]{6}$/;
25
+ /** Peable's defaults, applied wherever a merchant set nothing. */
26
+ exports.DEFAULT_BRANDING = Object.freeze({
27
+ primary_color: '#1f6feb',
28
+ accent_color: '#0b1f33',
29
+ font: 'system',
30
+ border_style: 'rounded',
31
+ });
@@ -1,2 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHECKOUT_SESSION_ID_TEMPLATE = exports.CHECKOUT_LIMITS = exports.CHECKOUT_TAX_ID_TYPES = exports.CHECKOUT_CUSTOM_FIELD_TYPES = exports.CHECKOUT_BILLING_ADDRESS_COLLECTIONS = exports.CHECKOUT_CUSTOMER_CREATIONS = exports.CHECKOUT_SUBMIT_TYPES = exports.CHECKOUT_LOCALES = exports.CHECKOUT_UI_MODES = exports.CHECKOUT_PAYMENT_STATUSES = exports.CHECKOUT_SESSION_STATUSES = exports.CHECKOUT_SESSION_MODES = void 0;
4
+ exports.CHECKOUT_SESSION_MODES = ['payment', 'setup', 'subscription'];
5
+ exports.CHECKOUT_SESSION_STATUSES = ['open', 'complete', 'expired'];
6
+ exports.CHECKOUT_PAYMENT_STATUSES = ['paid', 'unpaid', 'no_payment_required'];
7
+ exports.CHECKOUT_UI_MODES = ['hosted', 'embedded'];
8
+ /** The languages the hosted and embedded checkout speak. */
9
+ exports.CHECKOUT_LOCALES = ['en', 'es', 'fr', 'de', 'it', 'pt'];
10
+ exports.CHECKOUT_SUBMIT_TYPES = ['auto', 'pay', 'book', 'donate'];
11
+ exports.CHECKOUT_CUSTOMER_CREATIONS = ['always', 'if_required'];
12
+ exports.CHECKOUT_BILLING_ADDRESS_COLLECTIONS = ['auto', 'required'];
13
+ exports.CHECKOUT_CUSTOM_FIELD_TYPES = ['text', 'numeric', 'dropdown'];
14
+ /** Stripe's tax id types Peable collects; `eu_vat` covers every EU member state. */
15
+ exports.CHECKOUT_TAX_ID_TYPES = [
16
+ 'eu_vat',
17
+ 'gb_vat',
18
+ 'ch_vat',
19
+ 'no_vat',
20
+ 'us_ein',
21
+ 'ca_bn',
22
+ ];
23
+ /**
24
+ * Bounds of the session contract, shared by the gateway's validators and the
25
+ * clients that build requests, so the two cannot drift.
26
+ */
27
+ exports.CHECKOUT_LIMITS = Object.freeze({
28
+ lineItemsMax: 20,
29
+ quantityMax: 999999,
30
+ customFieldsMax: 3,
31
+ customFieldKeyMax: 200,
32
+ customFieldLabelMax: 50,
33
+ customFieldTextMax: 255,
34
+ dropdownOptionsMax: 200,
35
+ dropdownOptionLabelMax: 100,
36
+ dropdownOptionValueMax: 100,
37
+ clientReferenceIdMax: 200,
38
+ /** `expires_at` must be between 30 minutes and 24 hours from creation. */
39
+ expiresMinSeconds: 30 * 60,
40
+ expiresMaxSeconds: 24 * 3600,
41
+ shippingCountriesMax: 250,
42
+ termsTextMax: 1200,
43
+ });
44
+ /** The template a `success_url` may carry; replaced with the session's `cs_…`. */
45
+ exports.CHECKOUT_SESSION_ID_TEMPLATE = '{CHECKOUT_SESSION_ID}';
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PAYOUT_STATUSES = exports.BALANCE_TRANSACTION_TYPES = exports.BALANCE_TRANSACTION_STATUSES = exports.PAYOUT_WEEKLY_ANCHORS = exports.PAYOUT_INTERVALS = exports.PAYMENT_METHOD_CURRENCIES = exports.PAYMENT_METHOD_CONFIGURATION_TYPES = exports.CARD_RAIL_PAYMENT_METHOD_TYPES = exports.FILE_TYPES = exports.FILE_STATUSES = exports.FILE_PURPOSE_POLICIES = exports.FILE_PURPOSES = exports.normalizeDisputeReason = exports.DISPUTE_TEXT_EVIDENCE_FIELDS = exports.DISPUTE_REASONS = exports.DISPUTE_FILE_EVIDENCE_FIELDS = exports.CATALOG_LIMITS = exports.COUPON_DURATIONS = exports.TRANSFORM_QUANTITY_ROUNDS = exports.PRICE_TAX_BEHAVIORS = exports.RECURRING_USAGE_TYPES = exports.RECURRING_INTERVALS = exports.PRICE_TYPES = exports.PRICE_TIERS_MODES = exports.PRICE_BILLING_SCHEMES = exports.WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS = exports.WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT = exports.WEBHOOK_ENDPOINT_DISABLED_REASONS = exports.WEBHOOK_ENDPOINT_STATUSES = exports.PEABLE_API_VERSION = exports.SETUP_INTENT_STATUSES = exports.isValidStatusTransition = exports.canStillBePaid = exports.canExpire = exports.TERMINAL_STATUSES = exports.PAYMENT_INTENT_STATUSES = exports.PAYMENT_INTENT_SETUP_FUTURE_USAGES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_CAPTURE_METHODS = exports.PAYMENT_INTENT_CANCELLATION_REASONS = exports.MERCHANT_CANCELLATION_REASONS = exports.EXPIRABLE_STATUSES = exports.CARD_ONLY_STATUSES = exports.isCurrencyCode = exports.decimalsFor = exports.FIAT_CURRENCY_CODES = exports.CURRENCY_DECIMALS = exports.CURRENCY_CODES = exports.isBaseUnitString = exports.UNITS_PER_COIN = void 0;
4
- exports.TAX_LOCATION_EVIDENCE_TYPES = exports.TAX_REGISTRATION_SCHEMES = exports.PEABLE_BILLING_AUTHORITY_KEYS = exports.canonicalBillingTaxQuote = exports.canonicalBillingAuthority = exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.SIMULATED_FAIRCOIN_OUTCOMES = exports.REQUEST_LOG_RETENTION_DAYS = exports.REQUEST_LOG_METHODS = exports.REFUND_REASONS = exports.RECONCILIATION_MISMATCH_KINDS = void 0;
4
+ exports.TAX_LOCATION_EVIDENCE_TYPES = exports.TAX_REGISTRATION_SCHEMES = exports.PEABLE_BILLING_AUTHORITY_KEYS = exports.canonicalBillingTaxQuote = exports.canonicalBillingAuthority = exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.DEFAULT_BRANDING = exports.BRANDING_COLOR_PATTERN = exports.BRANDING_BORDER_STYLES = exports.BRANDING_FONTS = exports.CHECKOUT_SESSION_ID_TEMPLATE = exports.CHECKOUT_LIMITS = exports.CHECKOUT_TAX_ID_TYPES = exports.CHECKOUT_CUSTOM_FIELD_TYPES = exports.CHECKOUT_BILLING_ADDRESS_COLLECTIONS = exports.CHECKOUT_CUSTOMER_CREATIONS = exports.CHECKOUT_SUBMIT_TYPES = exports.CHECKOUT_LOCALES = exports.CHECKOUT_UI_MODES = exports.CHECKOUT_PAYMENT_STATUSES = exports.CHECKOUT_SESSION_STATUSES = exports.CHECKOUT_SESSION_MODES = exports.PAYMENT_LINK_LIMITS = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.SIMULATED_FAIRCOIN_OUTCOMES = exports.REQUEST_LOG_RETENTION_DAYS = exports.REQUEST_LOG_METHODS = exports.REFUND_REASONS = exports.RECONCILIATION_MISMATCH_KINDS = void 0;
5
5
  // @peable.to/shared-types — public API for the Peable Gateway contract.
6
6
  var money_1 = require("./money");
7
7
  Object.defineProperty(exports, "UNITS_PER_COIN", { enumerable: true, get: function () { return money_1.UNITS_PER_COIN; } });
@@ -77,6 +77,26 @@ Object.defineProperty(exports, "signWebhook", { enumerable: true, get: function
77
77
  Object.defineProperty(exports, "verifyWebhook", { enumerable: true, get: function () { return webhookSigner_1.verifyWebhook; } });
78
78
  var merchant_1 = require("./merchant");
79
79
  Object.defineProperty(exports, "MERCHANT_ENVIRONMENTS", { enumerable: true, get: function () { return merchant_1.MERCHANT_ENVIRONMENTS; } });
80
+ var paymentLink_1 = require("./paymentLink");
81
+ Object.defineProperty(exports, "PAYMENT_LINK_LIMITS", { enumerable: true, get: function () { return paymentLink_1.PAYMENT_LINK_LIMITS; } });
82
+ var checkoutSession_1 = require("./checkoutSession");
83
+ Object.defineProperty(exports, "CHECKOUT_SESSION_MODES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_SESSION_MODES; } });
84
+ Object.defineProperty(exports, "CHECKOUT_SESSION_STATUSES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_SESSION_STATUSES; } });
85
+ Object.defineProperty(exports, "CHECKOUT_PAYMENT_STATUSES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_PAYMENT_STATUSES; } });
86
+ Object.defineProperty(exports, "CHECKOUT_UI_MODES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_UI_MODES; } });
87
+ Object.defineProperty(exports, "CHECKOUT_LOCALES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_LOCALES; } });
88
+ Object.defineProperty(exports, "CHECKOUT_SUBMIT_TYPES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_SUBMIT_TYPES; } });
89
+ Object.defineProperty(exports, "CHECKOUT_CUSTOMER_CREATIONS", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_CUSTOMER_CREATIONS; } });
90
+ Object.defineProperty(exports, "CHECKOUT_BILLING_ADDRESS_COLLECTIONS", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_BILLING_ADDRESS_COLLECTIONS; } });
91
+ Object.defineProperty(exports, "CHECKOUT_CUSTOM_FIELD_TYPES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_CUSTOM_FIELD_TYPES; } });
92
+ Object.defineProperty(exports, "CHECKOUT_TAX_ID_TYPES", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_TAX_ID_TYPES; } });
93
+ Object.defineProperty(exports, "CHECKOUT_LIMITS", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_LIMITS; } });
94
+ Object.defineProperty(exports, "CHECKOUT_SESSION_ID_TEMPLATE", { enumerable: true, get: function () { return checkoutSession_1.CHECKOUT_SESSION_ID_TEMPLATE; } });
95
+ var branding_1 = require("./branding");
96
+ Object.defineProperty(exports, "BRANDING_FONTS", { enumerable: true, get: function () { return branding_1.BRANDING_FONTS; } });
97
+ Object.defineProperty(exports, "BRANDING_BORDER_STYLES", { enumerable: true, get: function () { return branding_1.BRANDING_BORDER_STYLES; } });
98
+ Object.defineProperty(exports, "BRANDING_COLOR_PATTERN", { enumerable: true, get: function () { return branding_1.BRANDING_COLOR_PATTERN; } });
99
+ Object.defineProperty(exports, "DEFAULT_BRANDING", { enumerable: true, get: function () { return branding_1.DEFAULT_BRANDING; } });
80
100
  var social_1 = require("./social");
81
101
  Object.defineProperty(exports, "SOCIAL_SOURCE_APP_MAX_LENGTH", { enumerable: true, get: function () { return social_1.SOCIAL_SOURCE_APP_MAX_LENGTH; } });
82
102
  Object.defineProperty(exports, "SOCIAL_SOURCE_REF_MAX_LENGTH", { enumerable: true, get: function () { return social_1.SOCIAL_SOURCE_REF_MAX_LENGTH; } });
@@ -1,2 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PAYMENT_LINK_LIMITS = void 0;
4
+ exports.PAYMENT_LINK_LIMITS = Object.freeze({
5
+ lineItemsMax: 20,
6
+ customMessageMax: 500,
7
+ });
@@ -0,0 +1,28 @@
1
+ // Merchant branding and customer email settings (Orbit Phase 3).
2
+ //
3
+ // Branding is what the hosted checkout, the embedded checkout and Peable's
4
+ // receipts look like for one merchant. Every value is from a CLOSED set or a
5
+ // validated colour, so nothing a merchant stores can inject markup or a remote
6
+ // font into a payer's page or an email.
7
+ /** The fonts checkout may render in — system stacks only, no remote font is ever loaded. */
8
+ export const BRANDING_FONTS = [
9
+ 'system',
10
+ 'inter',
11
+ 'roboto',
12
+ 'open_sans',
13
+ 'lato',
14
+ 'source_sans',
15
+ 'noto_sans',
16
+ 'serif',
17
+ 'monospace',
18
+ ];
19
+ export const BRANDING_BORDER_STYLES = ['rounded', 'rectangular', 'pill'];
20
+ /** `#rrggbb`, lowercase — the only colour spelling branding stores. */
21
+ export const BRANDING_COLOR_PATTERN = /^#[0-9a-f]{6}$/;
22
+ /** Peable's defaults, applied wherever a merchant set nothing. */
23
+ export const DEFAULT_BRANDING = Object.freeze({
24
+ primary_color: '#1f6feb',
25
+ accent_color: '#0b1f33',
26
+ font: 'system',
27
+ border_style: 'rounded',
28
+ });
@@ -1 +1,42 @@
1
- export {};
1
+ export const CHECKOUT_SESSION_MODES = ['payment', 'setup', 'subscription'];
2
+ export const CHECKOUT_SESSION_STATUSES = ['open', 'complete', 'expired'];
3
+ export const CHECKOUT_PAYMENT_STATUSES = ['paid', 'unpaid', 'no_payment_required'];
4
+ export const CHECKOUT_UI_MODES = ['hosted', 'embedded'];
5
+ /** The languages the hosted and embedded checkout speak. */
6
+ export const CHECKOUT_LOCALES = ['en', 'es', 'fr', 'de', 'it', 'pt'];
7
+ export const CHECKOUT_SUBMIT_TYPES = ['auto', 'pay', 'book', 'donate'];
8
+ export const CHECKOUT_CUSTOMER_CREATIONS = ['always', 'if_required'];
9
+ export const CHECKOUT_BILLING_ADDRESS_COLLECTIONS = ['auto', 'required'];
10
+ export const CHECKOUT_CUSTOM_FIELD_TYPES = ['text', 'numeric', 'dropdown'];
11
+ /** Stripe's tax id types Peable collects; `eu_vat` covers every EU member state. */
12
+ export const CHECKOUT_TAX_ID_TYPES = [
13
+ 'eu_vat',
14
+ 'gb_vat',
15
+ 'ch_vat',
16
+ 'no_vat',
17
+ 'us_ein',
18
+ 'ca_bn',
19
+ ];
20
+ /**
21
+ * Bounds of the session contract, shared by the gateway's validators and the
22
+ * clients that build requests, so the two cannot drift.
23
+ */
24
+ export const CHECKOUT_LIMITS = Object.freeze({
25
+ lineItemsMax: 20,
26
+ quantityMax: 999999,
27
+ customFieldsMax: 3,
28
+ customFieldKeyMax: 200,
29
+ customFieldLabelMax: 50,
30
+ customFieldTextMax: 255,
31
+ dropdownOptionsMax: 200,
32
+ dropdownOptionLabelMax: 100,
33
+ dropdownOptionValueMax: 100,
34
+ clientReferenceIdMax: 200,
35
+ /** `expires_at` must be between 30 minutes and 24 hours from creation. */
36
+ expiresMinSeconds: 30 * 60,
37
+ expiresMaxSeconds: 24 * 3600,
38
+ shippingCountriesMax: 250,
39
+ termsTextMax: 1200,
40
+ });
41
+ /** The template a `success_url` may carry; replaced with the session's `cs_…`. */
42
+ export const CHECKOUT_SESSION_ID_TEMPLATE = '{CHECKOUT_SESSION_ID}';
package/dist/esm/index.js CHANGED
@@ -15,6 +15,9 @@ export { REQUEST_LOG_METHODS, REQUEST_LOG_RETENTION_DAYS, } from './requestLog.j
15
15
  export { SIMULATED_FAIRCOIN_OUTCOMES, } from './testHelpers.js';
16
16
  export { signWebhook, verifyWebhook } from './webhookSigner.js';
17
17
  export { MERCHANT_ENVIRONMENTS, } from './merchant.js';
18
+ export { PAYMENT_LINK_LIMITS, } from './paymentLink.js';
19
+ export { CHECKOUT_SESSION_MODES, CHECKOUT_SESSION_STATUSES, CHECKOUT_PAYMENT_STATUSES, CHECKOUT_UI_MODES, CHECKOUT_LOCALES, CHECKOUT_SUBMIT_TYPES, CHECKOUT_CUSTOMER_CREATIONS, CHECKOUT_BILLING_ADDRESS_COLLECTIONS, CHECKOUT_CUSTOM_FIELD_TYPES, CHECKOUT_TAX_ID_TYPES, CHECKOUT_LIMITS, CHECKOUT_SESSION_ID_TEMPLATE, } from './checkoutSession.js';
20
+ export { BRANDING_FONTS, BRANDING_BORDER_STYLES, BRANDING_COLOR_PATTERN, DEFAULT_BRANDING, } from './branding.js';
18
21
  export { SOCIAL_SOURCE_APP_MAX_LENGTH, SOCIAL_SOURCE_REF_MAX_LENGTH, } from './social.js';
19
22
  export { BILLING_SUBSCRIPTION_STATUSES, } from './billing.js';
20
23
  export { canonicalBillingAuthority, canonicalBillingTaxQuote, PEABLE_BILLING_AUTHORITY_KEYS, } from './billing-authority.js';
@@ -1 +1,4 @@
1
- export {};
1
+ export const PAYMENT_LINK_LIMITS = Object.freeze({
2
+ lineItemsMax: 20,
3
+ customMessageMax: 500,
4
+ });
@@ -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,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,10 +1,12 @@
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';
9
11
  import type { ConnectedAccount, Refund } from './settlement';
10
12
  import type { SetupIntent } from './setupIntent';
@@ -101,6 +103,20 @@ export interface WebhookEventPayload {
101
103
  'coupon.deleted': Coupon;
102
104
  'promotion_code.created': PromotionCode;
103
105
  'promotion_code.updated': PromotionCode;
106
+ /**
107
+ * Checkout (Orbit Phase 3). `completed` when the payer finished: the payment
108
+ * succeeded (`payment_status: paid`), was authorized for a manual capture,
109
+ * or — a FairCoin payment — was broadcast and is confirming (`unpaid`), in
110
+ * which case `async_payment_succeeded` or `async_payment_failed` follows
111
+ * when the chain decides. `expired` when it ran out or the merchant expired
112
+ * it. Each carries the session as `GET /v1/checkout_sessions/:id` returns it.
113
+ */
114
+ 'checkout.session.completed': CheckoutSession;
115
+ 'checkout.session.expired': CheckoutSession;
116
+ 'checkout.session.async_payment_succeeded': CheckoutSession;
117
+ 'checkout.session.async_payment_failed': CheckoutSession;
118
+ 'payment_link.created': PaymentLink;
119
+ 'payment_link.updated': PaymentLink;
104
120
  /**
105
121
  * A seller's account changed — their READINESS, in practice. Emitted when the
106
122
  * fields a merchant ACTS on change, not on every refresh. It names no payment
@@ -23,8 +23,9 @@ export { signWebhook, verifyWebhook } from './webhookSigner';
23
23
  export { type MerchantEnvironment, type Merchant, MERCHANT_ENVIRONMENTS, } from './merchant';
24
24
  export type { MerchantDisplay } from './merchantDisplay';
25
25
  export type { AccountLink, ConnectOnboarding, ConnectOnboardingComplete, RegisterFaircoinKeyParams, } from './connect';
26
- export type { PaymentLink, PublicPaymentLink, CreatePaymentLinkParams, UpdatePaymentLinkParams, } from './paymentLink';
27
- export type { CheckoutSession, CheckoutSessionPublic, CreateCheckoutSessionParams, UpdateCheckoutSessionParams, } from './checkoutSession';
26
+ export { PAYMENT_LINK_LIMITS, type PaymentLink, type PublicPaymentLink, type PaymentLinkLineItemParams, type PaymentLinkAfterCompletionParams, type CreatePaymentLinkParams, type UpdatePaymentLinkParams, type CreatePaymentLinkSessionParams, type PaymentLinkSessionStart, } from './paymentLink';
27
+ export { CHECKOUT_SESSION_MODES, CHECKOUT_SESSION_STATUSES, CHECKOUT_PAYMENT_STATUSES, CHECKOUT_UI_MODES, CHECKOUT_LOCALES, CHECKOUT_SUBMIT_TYPES, CHECKOUT_CUSTOMER_CREATIONS, CHECKOUT_BILLING_ADDRESS_COLLECTIONS, CHECKOUT_CUSTOM_FIELD_TYPES, CHECKOUT_TAX_ID_TYPES, CHECKOUT_LIMITS, CHECKOUT_SESSION_ID_TEMPLATE, type CheckoutSessionMode, type CheckoutSessionStatus, type CheckoutSessionPaymentStatus, type CheckoutUiMode, type CheckoutLocale, type CheckoutSubmitType, type CheckoutCustomerCreation, type CheckoutBillingAddressCollection, type CheckoutCustomFieldType, type CheckoutTaxIdType, type CheckoutAdjustableQuantity, type CheckoutLineItem, type CheckoutTaxId, type CheckoutCustomerDetails, type CheckoutShippingDetails, type CheckoutCustomFieldLabel, type CheckoutCustomFieldDropdownOption, type CheckoutCustomField, type CheckoutDiscount, type CheckoutTotalDetails, type CheckoutAutomaticTax, type CheckoutConsentCollection, type CheckoutConsent, type CheckoutAfterCompletion, type CheckoutSession, type CheckoutSessionPublic, type UpdateCheckoutSessionPublicParams, type ConfirmCheckoutSessionPublicParams, type CheckoutProductDataParams, type CheckoutPriceDataParams, type CheckoutLineItemParams, type CheckoutCustomFieldParams, type CreateCheckoutSessionParams, type UpdateCheckoutSessionParams, } from './checkoutSession';
28
+ export { BRANDING_FONTS, BRANDING_BORDER_STYLES, BRANDING_COLOR_PATTERN, DEFAULT_BRANDING, type BrandingFont, type BrandingBorderStyle, type MerchantBranding, type UpdateMerchantBrandingParams, type CheckoutBranding, type MerchantEmailSettings, type UpdateMerchantEmailSettingsParams, } from './branding';
28
29
  export { SOCIAL_SOURCE_APP_MAX_LENGTH, SOCIAL_SOURCE_REF_MAX_LENGTH, type SocialPaymentSource, type SocialNextAddressRequest, type SocialNextAddressResponse, type SocialReceiveCursorResponse, type SocialPaymentDirection, type SocialPayment, type SocialPaymentsResponse, type EnrichmentKind, type EnrichmentResult, type EnrichRequest, type EnrichResponse, } from './social';
29
30
  export { BILLING_SUBSCRIPTION_STATUSES, type BillingSubscriptionStatus, type CreateBillingTaxQuoteParams, type BillingTaxQuote, type BillingInvoiceAuthoritySource, type BillingFinalInvoice, type BillingFinalInvoiceAuthority, type BillingFaircoinRenewalChoice, type BillingFaircoinRenewalConsent, type BillingFaircoinRenewalRevocation, type BillingCheckoutSession, type BillingEmbeddedCheckoutSession, type BillingEmbeddedCheckoutConfiguration, type BillingEmbeddedCheckoutBinding, type BillingEmbeddedCheckoutAction, type BillingEmbeddedCheckoutScope, type BillingCheckoutObservation, type RetrieveBillingCheckoutOperationParams, type BillingCheckoutOperationSource, type BillingCheckoutOperationRecovery, type BillingPaidInvoice, type BillingInvoiceState, type BillingCustomer, type BillingRail, type BillingRailSettlement, type BillingRailOffer, type BillingRailOption, type BillingRailList, type EnsureBillingCustomerParams, type CreateBillingCheckoutParams, type CreateBillingPortalParams, type BillingHostedSession, type BillingSubscription, } from './billing';
30
31
  export { canonicalBillingAuthority, canonicalBillingTaxQuote, PEABLE_BILLING_AUTHORITY_KEYS, } from './billing-authority';
@@ -1,72 +1,177 @@
1
1
  import type { ContributionDetails } from '@peable.to/contracts';
2
+ import type { CheckoutBranding } from './branding';
3
+ import type { CheckoutAdjustableQuantity, CheckoutAfterCompletion, CheckoutBillingAddressCollection, CheckoutCustomField, CheckoutCustomFieldParams, CheckoutCustomerCreation, CheckoutLineItem, CheckoutLocale, CheckoutSubmitType } from './checkoutSession';
2
4
  import type { CurrencyCode } from './money';
3
- import type { NetworkType } from './network';
4
5
  import type { MerchantDisplay } from './merchantDisplay';
6
+ import type { NetworkType } from './network';
5
7
  import type { PaymentIntentRail } from './paymentIntent';
6
- /** The merchant-facing DTO — returned by the merchant-authed CRUD routes. */
8
+ export declare const PAYMENT_LINK_LIMITS: Readonly<{
9
+ lineItemsMax: 20;
10
+ customMessageMax: 500;
11
+ }>;
7
12
  export interface PaymentLink {
8
13
  id: string;
9
14
  object: 'payment_link';
10
- /**
11
- * Which of the provider's two worlds this object belongs to (ADR 0017):
12
- * `true` for a `production` merchant, `false` for every other environment.
13
- */
14
15
  livemode: boolean;
15
- contribution?: ContributionDetails;
16
- /**
17
- * Amount in the currency's smallest unit, as a canonical integer string.
18
- * Never a float, and never interpretable without `currency`.
19
- */
20
- amount: string;
16
+ active: boolean;
21
17
  currency: CurrencyCode;
22
18
  rail: PaymentIntentRail;
23
- /** FairCoin rail only; `null` on a card link. */
24
19
  network: NetworkType | null;
25
- active: boolean;
20
+ /** The link's prices (`GET /v1/payment_links/:id/line_items` lists them in full). */
21
+ line_items: CheckoutLineItem[];
22
+ allow_promotion_codes: boolean;
23
+ billing_address_collection: CheckoutBillingAddressCollection;
24
+ shipping_address_collection: {
25
+ allowed_countries: string[];
26
+ } | null;
27
+ phone_number_collection: {
28
+ enabled: boolean;
29
+ };
30
+ tax_id_collection: {
31
+ enabled: boolean;
32
+ };
33
+ custom_fields: CheckoutCustomField[];
34
+ consent_collection: {
35
+ terms_of_service: 'none' | 'required';
36
+ } | null;
37
+ automatic_tax: {
38
+ enabled: boolean;
39
+ };
40
+ customer_creation: CheckoutCustomerCreation;
41
+ after_completion: CheckoutAfterCompletion;
42
+ restrictions: {
43
+ completed_sessions: {
44
+ limit: number;
45
+ count: number;
46
+ };
47
+ } | null;
48
+ submit_type: CheckoutSubmitType;
49
+ locale: CheckoutLocale | null;
50
+ /** Present on an organization contribution link (FairCoin). */
51
+ contribution?: ContributionDetails;
26
52
  metadata: Record<string, string>;
27
- /** Optional post-payment redirect target for the checkout page. */
28
- success_url?: string;
29
- /** Canonical `checkout.peable.to/l/<id>` URL. */
53
+ /** `checkout.peable.to/l/<id>` — share it, or render it as a QR code. */
30
54
  url: string;
31
55
  created: number;
32
56
  updated_at: number;
33
57
  }
34
- /** What an unauthenticated checkout-page visitor may see — no secrets, no metadata. */
58
+ /** What an anonymous visitor may see before checkout starts — no metadata, no counts. */
35
59
  export interface PublicPaymentLink {
36
60
  id: string;
37
61
  object: 'payment_link';
38
- /**
39
- * Which of the provider's two worlds this object belongs to (ADR 0017):
40
- * `true` for a `production` merchant, `false` for every other environment.
41
- */
42
62
  livemode: boolean;
43
- contribution?: ContributionDetails;
44
- amount: string;
63
+ active: boolean;
45
64
  currency: CurrencyCode;
46
65
  rail: PaymentIntentRail;
47
66
  network: NetworkType | null;
48
- active: boolean;
67
+ line_items: CheckoutLineItem[];
68
+ contribution?: ContributionDetails;
69
+ /** A fixed contribution's amount; `null` when the payer chooses (or for a price link). */
70
+ contribution_amount: string | null;
49
71
  merchant: MerchantDisplay;
72
+ branding: CheckoutBranding;
73
+ locale: CheckoutLocale | null;
74
+ }
75
+ export interface PaymentLinkLineItemParams {
76
+ price: string;
77
+ quantity: number;
78
+ adjustable_quantity?: {
79
+ enabled: boolean;
80
+ minimum?: number;
81
+ maximum?: number;
82
+ };
83
+ }
84
+ export interface PaymentLinkAfterCompletionParams {
85
+ type: 'redirect' | 'hosted_confirmation';
86
+ /** `type: redirect` — may carry `{CHECKOUT_SESSION_ID}`. */
87
+ redirect?: {
88
+ url: string;
89
+ };
90
+ hosted_confirmation?: {
91
+ custom_message?: string;
92
+ };
50
93
  }
51
94
  export interface CreatePaymentLinkParams {
52
- amount: string;
53
- /** Defaults to `'faircoin'`, so pre-ADR-0001 integrations keep working. */
54
- rail?: PaymentIntentRail;
55
- /** Required on the faircoin rail; refused on the card rail. */
56
- network?: NetworkType;
57
- /** Defaults to `'FAIR'` on the faircoin rail; required on the card rail. */
58
- currency?: CurrencyCode;
95
+ /** 1–20 prices of ONE currency, one-time prices only. */
96
+ line_items: PaymentLinkLineItemParams[];
97
+ allow_promotion_codes?: boolean;
98
+ billing_address_collection?: CheckoutBillingAddressCollection;
99
+ shipping_address_collection?: {
100
+ allowed_countries: string[];
101
+ };
102
+ phone_number_collection?: {
103
+ enabled: boolean;
104
+ };
105
+ tax_id_collection?: {
106
+ enabled: boolean;
107
+ };
108
+ custom_fields?: CheckoutCustomFieldParams[];
109
+ consent_collection?: {
110
+ terms_of_service?: 'none' | 'required';
111
+ };
112
+ automatic_tax?: {
113
+ enabled: boolean;
114
+ };
115
+ customer_creation?: CheckoutCustomerCreation;
116
+ after_completion?: PaymentLinkAfterCompletionParams;
117
+ restrictions?: {
118
+ completed_sessions: {
119
+ limit: number;
120
+ };
121
+ };
122
+ submit_type?: CheckoutSubmitType;
123
+ locale?: CheckoutLocale | 'auto';
59
124
  metadata?: Record<string, string>;
60
- success_url?: string;
61
125
  }
62
126
  /**
63
- * `POST /v1/payment_links/:id`. `amount`/`network` are deliberately absent — a
64
- * link's price is immutable once shared.
127
+ * `POST /v1/payment_links/:id`. The line items are fixed once shared (a payer
128
+ * may hold a session priced from them); everything else may change.
65
129
  */
66
130
  export interface UpdatePaymentLinkParams {
67
131
  active?: boolean;
132
+ allow_promotion_codes?: boolean;
133
+ billing_address_collection?: CheckoutBillingAddressCollection;
134
+ shipping_address_collection?: {
135
+ allowed_countries: string[];
136
+ } | '';
137
+ phone_number_collection?: {
138
+ enabled: boolean;
139
+ };
140
+ tax_id_collection?: {
141
+ enabled: boolean;
142
+ };
143
+ custom_fields?: CheckoutCustomFieldParams[] | '';
144
+ consent_collection?: {
145
+ terms_of_service?: 'none' | 'required';
146
+ };
147
+ automatic_tax?: {
148
+ enabled: boolean;
149
+ };
150
+ customer_creation?: CheckoutCustomerCreation;
151
+ after_completion?: PaymentLinkAfterCompletionParams;
152
+ restrictions?: {
153
+ completed_sessions: {
154
+ limit: number;
155
+ };
156
+ } | '';
157
+ submit_type?: CheckoutSubmitType;
158
+ locale?: CheckoutLocale | 'auto';
68
159
  /** A patch: named keys are set, `""` removes a key, others are kept. */
69
160
  metadata?: Record<string, string>;
70
- /** `null` removes it. */
71
- success_url?: string | null;
72
161
  }
162
+ /**
163
+ * `POST /v1/payment_links/:id/checkout_sessions` — a payer starting checkout
164
+ * (anonymous, rate-limited). A contribution link the payer prices takes
165
+ * `amount`; nothing else is the payer's to say.
166
+ */
167
+ export interface CreatePaymentLinkSessionParams {
168
+ amount?: string;
169
+ }
170
+ /** Its answer: where to go — the hosted session and the secret that opens it. */
171
+ export interface PaymentLinkSessionStart {
172
+ object: 'checkout_session_start';
173
+ id: string;
174
+ client_secret: string;
175
+ url: string;
176
+ }
177
+ export type { CheckoutAdjustableQuantity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peable.to/shared-types",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Shared TypeScript types for the Peable Gateway — the wire contract shared by the backend, SDK, and frontend.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",