@peable.to/contracts 3.0.0 → 4.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.
Files changed (58) hide show
  1. package/dist/cjs/resources/billingEngine/public.js +22 -3
  2. package/dist/cjs/resources/checkout/checkoutSessions.js +34 -9
  3. package/dist/cjs/resources/checkout/merchants.js +10 -23
  4. package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +56 -10
  5. package/dist/cjs/resources/connect/balance.js +5 -0
  6. package/dist/cjs/resources/connect/connectedAccounts.js +11 -12
  7. package/dist/cjs/resources/connect/onboarding.js +13 -24
  8. package/dist/cjs/resources/events/webhookDeliveries.js +1 -1
  9. package/dist/cjs/resources/events/webhookEndpoints.js +1 -1
  10. package/dist/cjs/resources/payments/disputes.js +16 -0
  11. package/dist/cjs/resources/payments/paymentIntents.js +39 -2
  12. package/dist/cjs/resources/payments/refunds.js +46 -11
  13. package/dist/cjs/vocabulary/checkout.js +18 -1
  14. package/dist/cjs/vocabulary/errors.js +5 -3
  15. package/dist/cjs/vocabulary/events.js +5 -0
  16. package/dist/cjs/vocabulary/paymentMethodConfigurations.js +24 -4
  17. package/dist/esm/resources/billingEngine/public.js +22 -3
  18. package/dist/esm/resources/checkout/checkoutSessions.js +35 -10
  19. package/dist/esm/resources/checkout/merchants.js +10 -23
  20. package/dist/esm/resources/checkout/paymentMethodConfigurations.js +57 -11
  21. package/dist/esm/resources/connect/balance.js +5 -0
  22. package/dist/esm/resources/connect/connectedAccounts.js +11 -12
  23. package/dist/esm/resources/connect/onboarding.js +12 -23
  24. package/dist/esm/resources/events/webhookDeliveries.js +1 -1
  25. package/dist/esm/resources/events/webhookEndpoints.js +1 -1
  26. package/dist/esm/resources/payments/disputes.js +16 -0
  27. package/dist/esm/resources/payments/paymentIntents.js +39 -2
  28. package/dist/esm/resources/payments/refunds.js +46 -11
  29. package/dist/esm/vocabulary/checkout.js +17 -0
  30. package/dist/esm/vocabulary/errors.js +5 -3
  31. package/dist/esm/vocabulary/events.js +5 -0
  32. package/dist/esm/vocabulary/paymentMethodConfigurations.js +25 -5
  33. package/dist/types/resources/billingEngine/index.d.ts +16 -2
  34. package/dist/types/resources/billingEngine/public.d.ts +32 -3
  35. package/dist/types/resources/checkout/checkoutSessions.d.ts +96 -31
  36. package/dist/types/resources/checkout/index.d.ts +406 -41
  37. package/dist/types/resources/checkout/merchants.d.ts +17 -28
  38. package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +440 -8
  39. package/dist/types/resources/connect/balance.d.ts +103 -10
  40. package/dist/types/resources/connect/connectedAccounts.d.ts +4 -4
  41. package/dist/types/resources/connect/index.d.ts +105 -14
  42. package/dist/types/resources/connect/onboarding.d.ts +15 -15
  43. package/dist/types/resources/connect/payouts.d.ts +66 -4
  44. package/dist/types/resources/events/index.d.ts +5 -0
  45. package/dist/types/resources/events/webhookEndpoints.d.ts +7 -0
  46. package/dist/types/resources/payments/disputes.d.ts +35 -0
  47. package/dist/types/resources/payments/index.d.ts +382 -0
  48. package/dist/types/resources/payments/paymentIntents.d.ts +380 -0
  49. package/dist/types/resources/payments/refunds.d.ts +56 -5
  50. package/dist/types/resources/payments/testHelpers.d.ts +31 -0
  51. package/dist/types/resources/tax/deadlines.d.ts +3 -3
  52. package/dist/types/resources/tax/index.d.ts +2 -2
  53. package/dist/types/resources/tax/registrations.d.ts +2 -2
  54. package/dist/types/vocabulary/checkout.d.ts +13 -0
  55. package/dist/types/vocabulary/errors.d.ts +5 -3
  56. package/dist/types/vocabulary/events.d.ts +5 -1
  57. package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +21 -7
  58. package/package.json +1 -1
@@ -10,7 +10,8 @@ const route_1 = require("../../route");
10
10
  const money_1 = require("../../vocabulary/money");
11
11
  const payments_1 = require("../../vocabulary/payments");
12
12
  /**
13
- * Refunds (`re_…`) and a payment's settlement figures. The provider's own
13
+ * Refunds (`re_…`) and the settlement figures of a payment, a refund or a
14
+ * dispute. The provider's own
14
15
  * refund id never appears: a merchant integrates against Peable and never
15
16
  * learns which acquirer sat behind it (ADR 0001 D3).
16
17
  */
@@ -56,23 +57,42 @@ exports.refundSchema = (0, objects_1.defineObject)('refund', 'Refund', zod_1.z
56
57
  ],
57
58
  });
58
59
  /**
59
- * What a payment actually came to, as the PROVIDER reports it. Every figure is
60
- * nullable and that is the contract: "the fee was zero" and "the fee is not
61
- * known yet" are different facts, and `status` says which produced the nulls.
62
- * It reports what the provider took; it attributes that cost to nobody.
60
+ * One movement of the settlement balance, as the PROVIDER reports it: what a
61
+ * payment brought in (`GET /v1/payment_intents/{intentId}/settlement`), what a
62
+ * refund took out (`GET /v1/refunds/{id}/settlement`) or what a dispute
63
+ * withdrew (`GET /v1/disputes/{disputeId}/settlement`). `refund` and `dispute`
64
+ * say which: both `null` for a payment's.
65
+ *
66
+ * Every figure is nullable and that is the contract: "the fee was zero" and
67
+ * "the fee is not known yet" are different facts, and `status` says which
68
+ * produced the nulls. It reports what the provider took; it attributes that
69
+ * cost to nobody.
70
+ *
71
+ * The signs: `gross` is the MAGNITUDE of the movement, `fee` the provider's fee
72
+ * on it (positive when charged, negative when returned), `net` its SIGNED
73
+ * effect on the balance — so `net = gross − fee` for a payment and
74
+ * `net = −gross − fee` for a refund or a dispute.
63
75
  */
64
76
  exports.settlementSchema = (0, objects_1.defineObject)('settlement', 'Settlement', zod_1.z
65
77
  .object({
66
78
  object: zod_1.z.literal('settlement'),
67
79
  livemode: primitives_1.livemode,
68
- payment_intent: (0, objects_1.expandable)('payment_intent', 'The `pi_…` this describes, or the PaymentIntent with `expand[]=payment_intent`.'),
80
+ payment_intent: (0, objects_1.expandable)('payment_intent', 'The `pi_…` this describes (the refunded or disputed payment, for a refund or a dispute), or the PaymentIntent with `expand[]=payment_intent`.'),
81
+ refund: (0, objects_1.expandable)('refund', 'The `re_…` whose movement this is, or the Refund with `expand[]=refund`; `null` unless this is the settlement of a refund.').nullable(),
82
+ dispute: (0, objects_1.expandable)('dispute', 'The `dp_…` whose withdrawal this is, or the Dispute with `expand[]=dispute`; `null` unless this is the settlement of a dispute.').nullable(),
69
83
  status: zod_1.z
70
84
  .enum(payments_1.SETTLEMENT_STATUSES)
71
- .describe('`available`: settled, the figures are final; `pending`: not final yet; `unknown`: there is none to read — **not zero**.'),
72
- gross: primitives_1.amount.nullable().describe('Base units of `currency`.'),
73
- fee: primitives_1.amount.nullable(),
74
- net: primitives_1.signedAmount.nullable(),
75
- currency: primitives_1.nullableString.describe("The SETTLEMENT currency (uppercase ISO 4217), which may differ from the payment's."),
85
+ .describe('`available`: settled, the figures are final; `pending`: not final yet; `unknown`: there is none to read — **not zero**. A dispute inquiry, which moves no money, and a refund that failed or was canceled are `unknown`.'),
86
+ gross: primitives_1.amount
87
+ .nullable()
88
+ .describe('The MAGNITUDE of the movement, never negative, in base units of `currency`: what the payment brought in, the refund took out or the dispute withdrew.'),
89
+ fee: primitives_1.signedAmount
90
+ .nullable()
91
+ .describe("The provider's fee on THIS movement, as the provider signs it: positive when charged to the balance (a payment's processing fee, a dispute fee), negative when returned to it (part of the original fee on some refunds). A refund's is usually `0`."),
92
+ net: primitives_1.signedAmount
93
+ .nullable()
94
+ .describe('The SIGNED effect on the balance: positive for a payment, negative for a refund or a dispute. Always `gross − fee` for a payment and `−gross − fee` for a refund or a dispute.'),
95
+ currency: primitives_1.nullableString.describe("The SETTLEMENT currency (uppercase ISO 4217) every figure is in, which may differ from the payment's, refund's or dispute's."),
76
96
  available_on: primitives_1.unixSeconds.nullable().describe('When the funds become available.'),
77
97
  exchange_rate: zod_1.z
78
98
  .number()
@@ -228,6 +248,21 @@ exports.refundRoutes = [
228
248
  sdk: 'refunds.settlement',
229
249
  expandable: 'settlement',
230
250
  }),
251
+ (0, route_1.defineRoute)({
252
+ operationId: 'retrieveRefundSettlement',
253
+ method: 'get',
254
+ path: '/v1/refunds/{id}/settlement',
255
+ tag: 'Refunds',
256
+ summary: "Retrieve a refund's settlement",
257
+ description: 'What the refund took off the settlement balance — `gross`, `fee`, a negative `net` — in the settlement currency, read live from the provider. A missing figure is `null` with a `status`, never `0`; a refund that failed or was canceled is `unknown`.',
258
+ auth: 'service',
259
+ scope: 'payments:read',
260
+ params: refundId,
261
+ query: params_1.expandOnlyQuery,
262
+ response: exports.settlementSchema,
263
+ sdk: 'refunds.refundSettlement',
264
+ expandable: 'settlement',
265
+ }),
231
266
  (0, route_1.defineRoute)({
232
267
  operationId: 'searchRefunds',
233
268
  method: 'get',
@@ -4,7 +4,24 @@
4
4
  // the wallet import them without the schemas (`@peable.to/contracts/vocabulary`,
5
5
  // re-exported by `@peable.to/shared-types`).
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PAYMENT_LINK_LIMITS = 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;
7
+ exports.PAYMENT_LINK_LIMITS = 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.FAIRCOIN_UNAVAILABLE_REASONS = void 0;
8
+ /**
9
+ * Why FairCoin cannot be paid with on an order right now (ADR 0021). It is
10
+ * still offered — never hidden — and says why:
11
+ *
12
+ * - `faircoin_wallet_missing` — the Peable wallet of the account that receives
13
+ * (the merchant's owner, or the seller) isn't set up yet: no identity key;
14
+ * - `faircoin_network_closed` — this deployment does not open payments on the
15
+ * order's FairCoin network yet (ADR 0002's gate);
16
+ * - `price_unavailable` — no fresh FairCoin price exists to quote a fiat order;
17
+ * - `temporarily_unavailable` — whether the wallet exists could not be checked.
18
+ */
19
+ exports.FAIRCOIN_UNAVAILABLE_REASONS = [
20
+ 'faircoin_wallet_missing',
21
+ 'faircoin_network_closed',
22
+ 'price_unavailable',
23
+ 'temporarily_unavailable',
24
+ ];
8
25
  exports.CHECKOUT_SESSION_MODES = ['payment', 'setup', 'subscription'];
9
26
  exports.CHECKOUT_SESSION_STATUSES = ['open', 'complete', 'expired'];
10
27
  exports.CHECKOUT_PAYMENT_STATUSES = ['paid', 'unpaid', 'no_payment_required'];
@@ -60,6 +60,7 @@ exports.ERROR_CODE_DESCRIPTIONS = {
60
60
  parameter_missing: 'A required parameter is missing; `param` names it.',
61
61
  parameter_unknown: 'The request carries a parameter this route does not accept; `param` names it.',
62
62
  payment_intent_unexpected_state: 'The PaymentIntent is in a status that does not allow this operation.',
63
+ payment_method_locked: 'The payment method cannot be turned off or removed: FairCoin is always offered to every payer; `param` names the field.',
63
64
  payout_not_allowed: 'Payouts cannot be created for this account.',
64
65
  rate_limited: 'Too many requests; back off and retry.',
65
66
  refund_not_cancelable: 'The refund has already left a cancelable state.',
@@ -70,7 +71,6 @@ exports.ERROR_CODE_DESCRIPTIONS = {
70
71
  test_mode_only: 'This operation exists in test mode only.',
71
72
  too_many_streams: 'Too many live streams are open for this merchant.',
72
73
  url_invalid: 'The URL is not an allowed https URL.',
73
- watch_only_violation: 'The extended key carries a private key. Peable only ever accepts watch-only (public) keys.',
74
74
  webhook_endpoint_disabled: 'The webhook endpoint is disabled.',
75
75
  webhook_endpoint_limit_reached: 'The merchant already has the maximum number of webhook endpoints.',
76
76
  account_not_ready: 'The connected account cannot take this payment yet: its onboarding or a capability is incomplete.',
@@ -131,6 +131,9 @@ exports.ERROR_CODE_DESCRIPTIONS = {
131
131
  promotion_code_minimum_amount: 'The purchase is below the promotion code minimum amount.',
132
132
  payment_method_missing: 'No payment method is available to charge.',
133
133
  faircoin_cannot_debit: 'A FairCoin invoice cannot be charged automatically: the payer signs every payment.',
134
+ faircoin_price_unavailable: 'No fresh FairCoin price exists right now, so this order cannot be quoted in FAIR. The other payment methods still work; try FairCoin again shortly.',
135
+ faircoin_wallet_missing: "The Peable wallet that receives this payment (the merchant owner's, or the seller's) isn't set up yet, so it cannot be paid in FairCoin. The other payment methods still work.",
136
+ faircoin_network_closed: 'FairCoin payments on this network are not open on this deployment yet. The other payment methods still work.',
134
137
  credit_note_exceeds_invoice: "The credit note's amount exceeds what the invoice can still credit.",
135
138
  test_clock_unexpected_state: 'The test clock is advancing; wait until it is ready.',
136
139
  meter_event_customer_missing: 'The meter event names no customer of this merchant.',
@@ -143,8 +146,7 @@ exports.ERROR_CODE_DESCRIPTIONS = {
143
146
  // Connect onboarding (ADR 0012 D3): the seller-facing refusals.
144
147
  link_expired: 'The onboarding link has expired or was already used; `refresh_url` is where the seller gets a fresh one.',
145
148
  wrong_seller: 'The onboarding link names a different Oxy account; sign in as the seller it was minted for.',
146
- already_registered: 'The seller already registered a FairCoin key, and it cannot be changed.',
147
- key_in_use: 'The key already receives payments for another account.',
149
+ already_registered: 'The seller already confirmed FairCoin payments into their Peable wallet.',
148
150
  no_faircoin_half: 'The connected account has no FairCoin half to register a key for.',
149
151
  // The dashboard routes (`/v1/dashboard/*`, Orbit): the signed-in person, not a credential.
150
152
  merchant_missing: 'The application has no merchant in this environment yet; register one (Orbit shows "Set up payments").',
@@ -150,10 +150,15 @@ exports.WEBHOOK_ENDPOINT_STATUSES = ['enabled', 'disabled'];
150
150
  * - `delivery_failures` — every delivery to it failed for three days
151
151
  * straight, so Peable stopped sending. Re-enabling it (`disabled: false`)
152
152
  * starts the clock again.
153
+ * - `url_refused` — its stored `url` breaks the rules a URL is
154
+ * registered under (https in live mode, ports 80/443, no private, loopback
155
+ * or reserved address), judged again before every delivery, so Peable never
156
+ * sent to it. It is re-enabled only together with a `url` that passes.
153
157
  */
154
158
  exports.WEBHOOK_ENDPOINT_DISABLED_REASONS = [
155
159
  'disabled_by_merchant',
156
160
  'delivery_failures',
161
+ 'url_refused',
157
162
  ];
158
163
  /** At most this many endpoints per merchant (per mode). */
159
164
  exports.WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT = 16;
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
- // Payment method breadth on the card rail (`pmc_…`, `pmd_…`). Zod-free.
2
+ // Payment method breadth (`pmc_…`, `pmd_…`): the merchant's card-rail methods,
3
+ // and FairCoin, which is always offered (ADR 0021). Zod-free.
3
4
  Object.defineProperty(exports, "__esModule", { value: true });
4
5
  exports.PAYMENT_METHOD_CURRENCIES = exports.PAYMENT_METHOD_UNAVAILABLE_REASONS = exports.PAYMENT_METHOD_CONFIGURATION_TYPES = void 0;
5
6
  const money_1 = require("./money");
6
7
  /**
7
- * The methods a configuration can turn on.
8
+ * The methods a configuration lists.
9
+ *
10
+ * `faircoin` is listed and LOCKED (ADR 0021 D2): every payer can always pay
11
+ * with FairCoin, so its entry is always `display_preference.value: 'on'` with
12
+ * `locked: true`, and a create or update that sets it `off` is refused with
13
+ * `payment_method_locked`. It is the chain rail, never a card-provider method:
14
+ * it is never pushed to the provider and never appears in a card PaymentIntent's
15
+ * `payment_method_types`. Every other method is the merchant's to turn on and off.
8
16
  *
9
17
  * `apple_pay` and `google_pay` are WALLETS over a card: a payment made with one
10
18
  * is a `card` payment, so they appear here and never in a PaymentIntent's
@@ -16,6 +24,7 @@ const money_1 = require("./money");
16
24
  * scheme).
17
25
  */
18
26
  exports.PAYMENT_METHOD_CONFIGURATION_TYPES = [
27
+ 'faircoin',
19
28
  'card',
20
29
  'apple_pay',
21
30
  'google_pay',
@@ -29,18 +38,29 @@ exports.PAYMENT_METHOD_CONFIGURATION_TYPES = [
29
38
  * Why a method cannot be offered whatever the merchant chooses.
30
39
  *
31
40
  * - `provider_unsupported` — the processing provider does not offer it;
32
- * - `requires_card` — a wallet rides on card payments, and card is off.
41
+ * - `requires_card` — a wallet rides on card payments, and card is off;
42
+ * - `faircoin_wallet_missing` — the Peable wallet of the account that owns
43
+ * the merchant isn't set up yet (no identity key), so FairCoin cannot be
44
+ * received (ADR 0021 D5); the owner sets it up in Peable;
45
+ * - `faircoin_network_closed` — the deployment does not open the merchant's
46
+ * FairCoin network yet (ADR 0002's gate);
47
+ * - `temporarily_unavailable` — the wallet could not be checked just now.
33
48
  */
34
49
  exports.PAYMENT_METHOD_UNAVAILABLE_REASONS = [
35
50
  'provider_unsupported',
36
51
  'requires_card',
52
+ 'faircoin_wallet_missing',
53
+ 'faircoin_network_closed',
54
+ 'temporarily_unavailable',
37
55
  ];
38
56
  /**
39
57
  * The currencies each method can take a payment in. A method is offered on a
40
58
  * payment only when its currency is listed — so iDEAL never appears on a USD
41
- * payment, and a payer is never shown a method that would fail.
59
+ * payment, and a payer is never shown a method that would fail. FairCoin takes
60
+ * every currency: a `FAIR` order directly, a fiat one at a quoted price (ADR 0021).
42
61
  */
43
62
  exports.PAYMENT_METHOD_CURRENCIES = Object.freeze({
63
+ faircoin: money_1.CURRENCY_CODES,
44
64
  card: money_1.FIAT_CURRENCY_CODES,
45
65
  apple_pay: money_1.FIAT_CURRENCY_CODES,
46
66
  google_pay: money_1.FIAT_CURRENCY_CODES,
@@ -5,6 +5,7 @@ import { idParam } from '../../common/params.js';
5
5
  import { amount, currency, livemode, signedAmount, unixSeconds } from '../../common/primitives.js';
6
6
  import { defineRoute } from '../../route.js';
7
7
  import { PORTAL_PAYMENT_METHOD_UPDATE_STATUSES } from '../../vocabulary/billingPortal.js';
8
+ import { FAIRCOIN_UNAVAILABLE_REASONS } from '../../vocabulary/checkout.js';
8
9
  import { INVOICE_STATUSES, PUBLIC_INVOICE_PAYMENT_METHOD_TYPES } from '../../vocabulary/invoices.js';
9
10
  import { COLLECTION_METHODS, SUBSCRIPTION_STATUSES } from '../../vocabulary/subscriptions.js';
10
11
  import { billingPortalBusinessProfileSchema, billingPortalFeaturesSchema } from './billingPortal.js';
@@ -54,7 +55,17 @@ export const publicInvoiceSchema = defineObject('public_invoice', 'PublicInvoice
54
55
  paid_at: unixSeconds.nullable(),
55
56
  payment_method_types: z
56
57
  .array(z.enum(PUBLIC_INVOICE_PAYMENT_METHOD_TYPES))
57
- .describe("Which rail pays it: a card through the provider's fields, FairCoin from the payer's wallet."),
58
+ .describe("What the payer may choose: `['card', 'faircoin']` on a fiat invoice, `['faircoin']` on a FAIR one. FairCoin is always offered (ADR 0021); on a fiat invoice it is quoted when chosen."),
59
+ faircoin: z
60
+ .object({
61
+ available: z.boolean(),
62
+ unavailable_reason: z
63
+ .enum(FAIRCOIN_UNAVAILABLE_REASONS)
64
+ .nullable()
65
+ .describe('Why FairCoin cannot be paid with right now; it is still shown, never hidden.'),
66
+ })
67
+ .strict()
68
+ .describe('Whether the payer can choose FairCoin now (ADR 0021).'),
58
69
  invoice_pdf: z.string(),
59
70
  })
60
71
  .strict());
@@ -178,7 +189,15 @@ export const portalPaymentMethodUpdateResultSchema = defineComponent('PortalPaym
178
189
  })
179
190
  .strict());
180
191
  // ---- Requests ------------------------------------------------------------------------
181
- export const payPublicInvoiceParams = emptyBody;
192
+ /** How the payer pays the invoice (ADR 0021 D3). */
193
+ export const payPublicInvoiceParams = z
194
+ .object({
195
+ payment_method_type: z
196
+ .enum(PUBLIC_INVOICE_PAYMENT_METHOD_TYPES)
197
+ .optional()
198
+ .describe("One of the invoice's `payment_method_types`. Default: the rail of its currency (`card` on a fiat invoice). `faircoin` on a fiat invoice quotes the amount due in FAIR for 10 minutes; paying again with the other method replaces a payment that has not started moving money."),
199
+ })
200
+ .strict();
182
201
  /** A portal action on one of the customer's subscriptions. */
183
202
  export const portalSubscriptionParams = z.object({ subscription: idParam }).strict();
184
203
  /** Switch a (single-item) subscription to one of the configuration's plans, or change its quantity. */
@@ -221,7 +240,7 @@ export const publicBillingRoutes = [
221
240
  path: '/v1/invoices/public/{token}/pay',
222
241
  tag: 'Hosted invoices',
223
242
  summary: 'Pay a hosted invoice',
224
- description: 'The PaymentIntent the payer completes — a card through the provider’s own fields, FairCoin from the payer’s wallet. The same invoice answers the same intent while it can still be paid.',
243
+ description: 'The PaymentIntent the payer completes in the method they chose — a card through the provider’s own fields, or FairCoin from the payer’s wallet (quoted on a fiat invoice, ADR 0021). The same invoice answers the same intent while it can still be paid in that method.',
225
244
  auth: 'public',
226
245
  params: invoiceToken,
227
246
  body: payPublicInvoiceParams,
@@ -7,7 +7,7 @@ import { defineComponent, defineObject, expandable } from '../../common/objects.
7
7
  import { expandOnlyQuery, expandParam, listQuery, metadataCreateParam, metadataUpdateParam, } from '../../common/params.js';
8
8
  import { amount, currency, livemode, metadata, network, unixSeconds, } from '../../common/primitives.js';
9
9
  import { defineRoute } from '../../route.js';
10
- import { CHECKOUT_CUSTOMER_CREATIONS, CHECKOUT_LIMITS, CHECKOUT_LOCALES, CHECKOUT_PAYMENT_STATUSES, CHECKOUT_SESSION_MODES, CHECKOUT_SESSION_STATUSES, CHECKOUT_SUBMIT_TYPES, CHECKOUT_TAX_ID_TYPES, CHECKOUT_UI_MODES, } from '../../vocabulary/checkout.js';
10
+ import { CHECKOUT_CUSTOMER_CREATIONS, CHECKOUT_LIMITS, CHECKOUT_LOCALES, CHECKOUT_PAYMENT_STATUSES, CHECKOUT_SESSION_MODES, CHECKOUT_SESSION_STATUSES, CHECKOUT_SUBMIT_TYPES, CHECKOUT_TAX_ID_TYPES, CHECKOUT_UI_MODES, FAIRCOIN_UNAVAILABLE_REASONS, } from '../../vocabulary/checkout.js';
11
11
  import { adjustableIssues, adjustableQuantityParam, amountParam, checkoutAutomaticTaxSchema, checkoutBrandingSchema, checkoutConsentSchema, checkoutCustomerDetailsSchema, checkoutDiscountSchema, checkoutIdParam, checkoutLineItemSchema, checkoutShippingDetailsSchema, checkoutTotalDetailsSchema, collectionParams, collectionResponseFields, countryCodeParam, checkoutEmailParam, localeParam, merchantDisplaySchema, quantityParam, railSchema, redirectUrlParam, } from './shared.js';
12
12
  /**
13
13
  * Checkout Sessions (`cs_…`, Orbit Phase 3) — Stripe Checkout's session model:
@@ -30,8 +30,13 @@ const sessionFields = {
30
30
  .describe("The language checkout renders in; `null` follows the payer's browser."),
31
31
  submit_type: z.enum(CHECKOUT_SUBMIT_TYPES),
32
32
  currency,
33
- rail: railSchema,
34
- network: network.nullable().describe('FairCoin rail only; `null` on a card session.'),
33
+ rail: railSchema.describe("The rail that settles the order's currency: `faircoin` for a FAIR order, `card` for a fiat one. FairCoin is offered on every order beside it (`payment_method_types`, ADR 0021)."),
34
+ network: network
35
+ .nullable()
36
+ .describe('The FairCoin network a FairCoin payment of this order uses — the merchant’s (or the seller’s); `null` when the payee has no FairCoin key yet (test mode) and in `setup` mode.'),
37
+ payment_method_types: z
38
+ .array(railSchema)
39
+ .describe("What the payer may choose: `['card', 'faircoin']` on a fiat order, `['faircoin']` on a FAIR one. FairCoin is always offered (ADR 0021); `['card']` in `setup` mode."),
35
40
  amount_subtotal: amount,
36
41
  amount_total: amount,
37
42
  total_details: checkoutTotalDetailsSchema,
@@ -46,7 +51,6 @@ const sessionFields = {
46
51
  export const checkoutSessionSchema = defineObject('checkout_session', 'CheckoutSession', z
47
52
  .object({
48
53
  ...sessionFields,
49
- payment_method_types: z.array(railSchema),
50
54
  discounts: z.array(checkoutDiscountSchema),
51
55
  customer: expandable('customer', '`cus_…` (expandable) — given on create, or created at completion.').nullable(),
52
56
  customer_email: z.string().nullable(),
@@ -90,8 +94,8 @@ export const checkoutSessionSchema = defineObject('checkout_session', 'CheckoutS
90
94
  submit_type: 'auto',
91
95
  currency: 'EUR',
92
96
  rail: 'card',
93
- network: null,
94
- payment_method_types: ['card'],
97
+ network: 'mainnet',
98
+ payment_method_types: ['card', 'faircoin'],
95
99
  amount_subtotal: '1999',
96
100
  amount_total: '1999',
97
101
  total_details: { amount_discount: '0', amount_tax: '0', amount_shipping: '0' },
@@ -179,6 +183,17 @@ export const checkoutSessionPublicSchema = defineComponent('CheckoutSessionPubli
179
183
  .string()
180
184
  .nullable()
181
185
  .describe("The card provider's PUBLIC key for this session's mode, so the payment fields can mount before the payment exists. `null` on FairCoin."),
186
+ faircoin: z
187
+ .object({
188
+ available: z.boolean(),
189
+ unavailable_reason: z
190
+ .enum(FAIRCOIN_UNAVAILABLE_REASONS)
191
+ .nullable()
192
+ .describe('Why FairCoin cannot be paid with right now; it is still shown, never hidden.'),
193
+ })
194
+ .strict()
195
+ .nullable()
196
+ .describe('Whether the payer can choose FairCoin now (ADR 0021). On a fiat order the FAIR amount is quoted when the payer chooses it (`payment_intent.faircoin.quote`). `null` in `setup` mode.'),
182
197
  })
183
198
  .strict());
184
199
  // ---- Merchant create/update ---------------------------------------------------
@@ -279,9 +294,9 @@ export const createCheckoutSessionParams = z
279
294
  payment_method_types: z
280
295
  .array(z.enum(['card', 'faircoin']))
281
296
  .min(1)
282
- .max(1)
297
+ .max(2)
283
298
  .optional()
284
- .describe("`['card']` or `['faircoin']` — the rail the line items' currency allows."),
299
+ .describe("Must include `faircoin`, which is always offered (ADR 0021; leaving it out is 400 `payment_method_locked`): `['card', 'faircoin']` on a fiat order, `['faircoin']` on a FAIR one. Omit it for exactly that. The fiat methods are chosen in the payment method configuration."),
285
300
  locale: localeParam.optional(),
286
301
  ui_mode: z.enum(CHECKOUT_UI_MODES).optional(),
287
302
  success_url: redirectUrlParam
@@ -425,8 +440,18 @@ export const updateCheckoutSessionPublicParams = z
425
440
  .optional(),
426
441
  })
427
442
  .strict();
428
- /** `POST /v1/checkout_sessions/{id}/public/confirm` takes nothing: the order is the session's. */
429
- export const confirmCheckoutSessionPublicParams = z.object({}).strict();
443
+ /**
444
+ * `POST /v1/checkout_sessions/{id}/public/confirm` — the order is the
445
+ * session's; the payer only chooses how to pay it (ADR 0021 D3).
446
+ */
447
+ export const confirmCheckoutSessionPublicParams = z
448
+ .object({
449
+ payment_method_type: z
450
+ .enum(['card', 'faircoin'])
451
+ .optional()
452
+ .describe("How the payer pays: one of the session's `payment_method_types`. Default: the rail of the order's currency (`card` on a fiat order). `faircoin` on a fiat order quotes its total in FAIR for 10 minutes; confirming again with the other method replaces a payment that has not started moving money."),
453
+ })
454
+ .strict();
430
455
  /** `POST /v1/test_helpers/checkout_sessions/{id}/expire` takes nothing. */
431
456
  export const expireCheckoutSessionTestHelperParams = z.object({}).strict();
432
457
  const sessionId = { id: 'The Checkout Session (`cs_…`).' };
@@ -17,13 +17,11 @@ export const merchantSchema = defineObject('merchant', 'Merchant', z
17
17
  livemode: livemode.describe('`true` for a `production` merchant (ADR 0017).'),
18
18
  oxy_app_id: z.string().describe('The Oxy application this merchant belongs to.'),
19
19
  environment: z.enum(MERCHANT_ENVIRONMENTS),
20
- network: network
21
- .nullable()
22
- .describe('The FairCoin chain this merchant accepts on; `null` on a card-only merchant. Nullable together with `xpub`.'),
23
- xpub: z
20
+ network: network.describe("The FairCoin network this merchant's payments use — its environment's: `mainnet` live, `testnet` otherwise (ADR 0021 D5)."),
21
+ owner_account: z
24
22
  .string()
25
23
  .nullable()
26
- .describe('The watch-only account key receive addresses derive from; `null` on a card-only merchant.'),
24
+ .describe('The Oxy account (a person or an organization) that owns the application — its Peable wallet receives the merchant’s FairCoin (ADR 0021 D5). No key is ever registered. `null` until Peable has seen the owner.'),
27
25
  required_confirmations: z.number().int().positive(),
28
26
  display_name: z
29
27
  .string()
@@ -50,7 +48,7 @@ export const merchantSchema = defineObject('merchant', 'Merchant', z
50
48
  oxy_app_id: 'app_0193b8f2c1a87d3e9f4b',
51
49
  environment: 'development',
52
50
  network: 'testnet',
53
- xpub: 'tpubDC5FSnBiZDMmhiuCmWAYsLwgLYrrT9rAqvTySfuCCrgsWz8wxMXUS9Tb9iVMvcRbvFcAHGkMD5Kx8koh4GquNGNTfohfk7pgjhaPCdXpoba',
51
+ owner_account: '0193b8f2-c1a8-7d3e-9f4a-5b6c7d8e9f01',
54
52
  required_confirmations: 6,
55
53
  display_name: 'Jenny’s Plants',
56
54
  created: 1793750400,
@@ -66,32 +64,21 @@ const displayName = z.string().min(1).max(64);
66
64
  const avatarFileId = z.string().min(1).max(128);
67
65
  const merchantDescription = z.string().min(1).max(512);
68
66
  /**
69
- * `POST /v1/merchants`. The FairCoin half is OPTIONAL — both `network` and
70
- * `xpub`, or neither: a card-only merchant supplies no key for a chain it
71
- * never intends to use.
67
+ * `POST /v1/merchants`. No FairCoin key and no network: the network is the
68
+ * environment's, and FairCoin is received into the Peable wallet of the
69
+ * account that owns the application (ADR 0021 D5).
72
70
  */
73
71
  export const registerMerchantParams = z
74
72
  .object({
75
- network: network.optional(),
76
- xpub: z
77
- .string()
78
- .min(1)
79
- .optional()
80
- .describe('A watch-only account xpub. A private extended key is refused.'),
81
73
  required_confirmations: z.number().int().positive().optional(),
82
74
  display_name: displayName.optional(),
83
75
  avatar_file_id: avatarFileId.optional(),
84
76
  description: merchantDescription.optional(),
85
77
  })
86
- .strict()
87
- .refine((body) => (body.network === undefined) === (body.xpub === undefined), {
88
- message: 'accepting FairCoin needs both a network and a watch-only xpub, or neither — ' +
89
- 'omit both to register a card-only merchant',
90
- });
78
+ .strict();
91
79
  /**
92
- * `POST /v1/merchants/me`. `null` clears a field. The key, network and
93
- * environment never change: addresses already derived from the key, and the
94
- * test/live firewall, depend on them.
80
+ * `POST /v1/merchants/me`. `null` clears a field. The network and environment
81
+ * never change: the test/live firewall depends on them.
95
82
  */
96
83
  export const updateMerchantParams = z
97
84
  .object({
@@ -2,15 +2,17 @@ import { z } from 'zod';
2
2
  import { listOf } from '../../common/envelopes.js';
3
3
  import { defineComponent, defineObject } from '../../common/objects.js';
4
4
  import { expandOnlyQuery, listQuery, queryBoolean } from '../../common/params.js';
5
- import { fiatCurrency, livemode, unixSeconds } from '../../common/primitives.js';
5
+ import { currency, livemode, unixSeconds } from '../../common/primitives.js';
6
6
  import { defineRoute } from '../../route.js';
7
7
  import { PAYMENT_METHOD_CONFIGURATION_TYPES, PAYMENT_METHOD_UNAVAILABLE_REASONS, } from '../../vocabulary/paymentMethodConfigurations.js';
8
8
  /**
9
- * Payment method breadth on the card rail — which methods a merchant's payers
10
- * are offered (`pmc_…`), and the web domains wallets may run on (`pmd_…`).
11
- * Both are Orbit's objects; the provider's configuration and domain are
12
- * bindings behind them (ADR 0016). Card data and bank credentials are entered
13
- * in the provider's hosted fields and never reach Peable (PCI SAQ-A).
9
+ * Payment method breadth — which methods a merchant's payers are offered
10
+ * (`pmc_…`), and the web domains wallets may run on (`pmd_…`). FairCoin is an
11
+ * entry of every configuration and is locked on (ADR 0021 D2); the card-rail
12
+ * methods are the merchant's choice. Both are Orbit's objects; the provider's
13
+ * configuration and domain are bindings behind them (ADR 0016). Card data and
14
+ * bank credentials are entered in the provider's hosted fields and never reach
15
+ * Peable (PCI SAQ-A).
14
16
  */
15
17
  /** The merchant's choice (`none`: Orbit's default) and what is in effect. */
16
18
  export const paymentMethodDisplayPreferenceSchema = z
@@ -25,13 +27,28 @@ export const paymentMethodConfigurationEntrySchema = defineComponent('PaymentMet
25
27
  .boolean()
26
28
  .describe('Whether payers can be offered this method: it is on and nothing prevents it.'),
27
29
  display_preference: paymentMethodDisplayPreferenceSchema,
30
+ locked: z
31
+ .boolean()
32
+ .describe('Whether the merchant can change it. Only `faircoin` is locked: it is always on, because every payer can always pay with FairCoin (ADR 0021), and setting it `off` is refused with `payment_method_locked`.'),
28
33
  unavailable_reason: z
29
34
  .enum(PAYMENT_METHOD_UNAVAILABLE_REASONS)
30
35
  .nullable()
31
36
  .describe('Why it cannot be offered whatever the merchant chooses; `null` when it can.'),
32
- currencies: z.array(fiatCurrency).describe('The payment currencies it is offered on.'),
37
+ currencies: z.array(currency).describe('The payment currencies it is offered on.'),
33
38
  })
34
39
  .strict());
40
+ /** One entry of the configuration's documented example (abbreviated currency lists). */
41
+ function exampleEntry(preference, value, overrides = {}) {
42
+ const unavailable_reason = overrides.unavailable_reason ?? null;
43
+ return {
44
+ available: value === 'on' && unavailable_reason === null,
45
+ display_preference: { preference, value },
46
+ locked: false,
47
+ unavailable_reason,
48
+ currencies: ['EUR', 'USD', 'GBP'],
49
+ ...overrides,
50
+ };
51
+ }
35
52
  const entryFields = Object.fromEntries(PAYMENT_METHOD_CONFIGURATION_TYPES.map((type) => [type, paymentMethodConfigurationEntrySchema]));
36
53
  export const paymentMethodConfigurationSchema = defineObject('payment_method_configuration', 'PaymentMethodConfiguration', z
37
54
  .object({
@@ -49,7 +66,32 @@ export const paymentMethodConfigurationSchema = defineObject('payment_method_con
49
66
  updated_at: unixSeconds,
50
67
  ...entryFields,
51
68
  })
52
- .strict());
69
+ .strict(), {
70
+ examples: [
71
+ {
72
+ id: 'pmc_0193b8f2c1a87d3e9f4b',
73
+ object: 'payment_method_configuration',
74
+ livemode: false,
75
+ name: 'Default',
76
+ active: true,
77
+ is_default: true,
78
+ created: 1793750400,
79
+ updated_at: 1793750400,
80
+ faircoin: exampleEntry('on', 'on', { locked: true, currencies: ['FAIR', 'EUR', 'USD'] }),
81
+ card: exampleEntry('none', 'on'),
82
+ apple_pay: exampleEntry('none', 'on'),
83
+ google_pay: exampleEntry('none', 'on'),
84
+ sepa_debit: exampleEntry('on', 'on', { currencies: ['EUR'] }),
85
+ ideal: exampleEntry('none', 'off', { currencies: ['EUR'] }),
86
+ bancontact: exampleEntry('none', 'off', { currencies: ['EUR'] }),
87
+ eps: exampleEntry('none', 'off', { currencies: ['EUR'] }),
88
+ bizum: exampleEntry('none', 'off', {
89
+ currencies: ['EUR'],
90
+ unavailable_reason: 'provider_unsupported',
91
+ }),
92
+ },
93
+ ],
94
+ });
53
95
  /** A wallet's standing on one domain. */
54
96
  export const paymentMethodDomainWalletStatusSchema = defineComponent('PaymentMethodDomainWalletStatus', z
55
97
  .object({
@@ -92,7 +134,11 @@ export const paymentMethodDomainSchema = defineObject('payment_method_domain', '
92
134
  },
93
135
  ],
94
136
  });
95
- /** One method's setting in a create or update. `none` returns it to Orbit's default. */
137
+ /**
138
+ * One method's setting in a create or update. `none` returns it to Orbit's
139
+ * default. For `faircoin` only `on` and `none` are accepted, and neither stores
140
+ * anything: it is always on, and `off` is refused with `payment_method_locked`.
141
+ */
96
142
  export const paymentMethodConfigurationEntryParams = z
97
143
  .object({
98
144
  display_preference: z.object({ preference: z.enum(['on', 'off', 'none']) }).strict(),
@@ -150,7 +196,7 @@ export const paymentMethodConfigurationRoutes = [
150
196
  path: '/v1/payment_method_configurations',
151
197
  tag: 'Payment method configurations',
152
198
  summary: 'Create a payment method configuration',
153
- description: 'An additional, non-default configuration. Turning `on` a method the processing provider does not offer is refused.',
199
+ description: 'An additional, non-default configuration. Turning `on` a method the processing provider does not offer is refused, and so is turning `faircoin` `off` (`payment_method_locked`): FairCoin is always offered.',
154
200
  auth: 'service',
155
201
  scope: 'payments:write',
156
202
  idempotent: true,
@@ -178,7 +224,7 @@ export const paymentMethodConfigurationRoutes = [
178
224
  path: '/v1/payment_method_configurations/{id}',
179
225
  tag: 'Payment method configurations',
180
226
  summary: 'Update a payment method configuration',
181
- description: 'Method settings are merged; the default configuration is always active.',
227
+ description: 'Method settings are merged; the default configuration is always active. `faircoin` is locked on: setting it `off` is refused with `payment_method_locked`.',
182
228
  auth: 'service',
183
229
  scope: 'payments:write',
184
230
  idempotent: true,
@@ -4,6 +4,7 @@ import { defineComponent, defineObject } from '../../common/objects.js';
4
4
  import { expandOnlyQuery, idParam, listQuery } from '../../common/params.js';
5
5
  import { livemode, signedAmount, unixSeconds } from '../../common/primitives.js';
6
6
  import { defineRoute } from '../../route.js';
7
+ import { faircoinQuoteSchema } from '../payments/paymentIntents.js';
7
8
  import { BALANCE_TRANSACTION_FEE_TYPES, BALANCE_TRANSACTION_STATUSES, BALANCE_TRANSACTION_TYPES, RECONCILIATION_MISMATCH_KINDS, } from '../../vocabulary/connect.js';
8
9
  /**
9
10
  * Balance and balance transactions (ADR 0015 §3–§5).
@@ -87,6 +88,9 @@ export const balanceTransactionSchema = defineObject('balance_transaction', 'Bal
87
88
  created: unixSeconds.describe('When it happened at its source.'),
88
89
  description: z.string().nullable(),
89
90
  exchange_rate: z.number().nullable(),
91
+ faircoin_quote: faircoinQuoteSchema
92
+ .nullable()
93
+ .describe('A FairCoin payment of a fiat order: the quote it was priced at — its fiat equivalent (ADR 0021). Informational; no fiat moved.'),
90
94
  fee_details: z.array(balanceTransactionFeeDetailSchema),
91
95
  source: z
92
96
  .string()
@@ -118,6 +122,7 @@ export const balanceTransactionSchema = defineObject('balance_transaction', 'Bal
118
122
  created: 1793750400,
119
123
  description: 'Order 6735',
120
124
  exchange_rate: null,
125
+ faircoin_quote: null,
121
126
  fee_details: [{ amount: '88', currency: 'EUR', type: 'processing_fee' }],
122
127
  source: 'ch_0193b8f2f7c94b1d8e02',
123
128
  payout: null,