@peable.to/contracts 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/address.js +81 -0
- package/dist/cjs/common/envelopes.js +101 -0
- package/dist/cjs/common/objects.js +85 -0
- package/dist/cjs/common/params.js +211 -0
- package/dist/cjs/common/primitives.js +39 -0
- package/dist/cjs/contributions.js +22 -0
- package/dist/cjs/index.js +40 -137
- package/dist/cjs/openapi/document.js +297 -0
- package/dist/cjs/openapi/index.js +7 -0
- package/dist/cjs/openapi/webhooks.js +17 -0
- package/dist/cjs/resources/billingEngine/billingPortal.js +237 -0
- package/dist/cjs/resources/billingEngine/creditNotes.js +189 -0
- package/dist/cjs/resources/billingEngine/customerBalanceTransactions.js +90 -0
- package/dist/cjs/resources/billingEngine/index.js +43 -0
- package/dist/cjs/resources/billingEngine/invoiceItems.js +155 -0
- package/dist/cjs/resources/billingEngine/invoices.js +509 -0
- package/dist/cjs/resources/billingEngine/params.js +43 -0
- package/dist/cjs/resources/billingEngine/public.js +326 -0
- package/dist/cjs/resources/billingEngine/subscriptions.js +476 -0
- package/dist/cjs/resources/catalog/billing.js +755 -0
- package/dist/cjs/resources/catalog/billingSettings.js +131 -0
- package/dist/cjs/resources/catalog/coupons.js +222 -0
- package/dist/cjs/resources/catalog/entitlements.js +257 -0
- package/dist/cjs/resources/catalog/index.js +58 -0
- package/dist/cjs/resources/catalog/meters.js +279 -0
- package/dist/cjs/resources/catalog/prices.js +423 -0
- package/dist/cjs/resources/catalog/products.js +228 -0
- package/dist/cjs/resources/catalog/promotionCodes.js +174 -0
- package/dist/cjs/resources/catalog/shared.js +75 -0
- package/dist/cjs/resources/catalog/testClocks.js +127 -0
- package/dist/cjs/resources/checkout/checkoutSessions.js +582 -0
- package/dist/cjs/resources/checkout/contributions.js +172 -0
- package/dist/cjs/resources/checkout/files.js +133 -0
- package/dist/cjs/resources/checkout/index.js +57 -0
- package/dist/cjs/resources/checkout/merchants.js +290 -0
- package/dist/cjs/resources/checkout/paymentLinks.js +330 -0
- package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +262 -0
- package/dist/cjs/resources/checkout/shared.js +368 -0
- package/dist/cjs/resources/connect/account.js +332 -0
- package/dist/cjs/resources/connect/applicationFees.js +113 -0
- package/dist/cjs/resources/connect/balance.js +212 -0
- package/dist/cjs/resources/connect/connectedAccounts.js +260 -0
- package/dist/cjs/resources/connect/index.js +51 -0
- package/dist/cjs/resources/connect/onboarding.js +82 -0
- package/dist/cjs/resources/connect/payouts.js +196 -0
- package/dist/cjs/resources/connect/reporting.js +235 -0
- package/dist/cjs/resources/connect/requestLogs.js +110 -0
- package/dist/cjs/resources/connect/transfers.js +227 -0
- package/dist/cjs/resources/core/customers.js +194 -0
- package/dist/cjs/resources/core/index.js +23 -0
- package/dist/cjs/resources/core/paymentMethods.js +134 -0
- package/dist/cjs/resources/events/events.js +357 -0
- package/dist/cjs/resources/events/index.js +29 -0
- package/dist/cjs/resources/events/webhookDeliveries.js +93 -0
- package/dist/cjs/resources/events/webhookEndpoints.js +215 -0
- package/dist/cjs/resources/payments/charges.js +157 -0
- package/dist/cjs/resources/payments/disputes.js +204 -0
- package/dist/cjs/resources/payments/index.js +41 -0
- package/dist/cjs/resources/payments/paymentIntents.js +529 -0
- package/dist/cjs/resources/payments/refunds.js +245 -0
- package/dist/cjs/resources/payments/setupIntents.js +158 -0
- package/dist/cjs/resources/payments/social.js +182 -0
- package/dist/cjs/resources/payments/testHelpers.js +39 -0
- package/dist/cjs/resources/tax/assessments.js +217 -0
- package/dist/cjs/resources/tax/businessProfile.js +99 -0
- package/dist/cjs/resources/tax/calculations.js +176 -0
- package/dist/cjs/resources/tax/capabilities.js +42 -0
- package/dist/cjs/resources/tax/codes.js +37 -0
- package/dist/cjs/resources/tax/complianceActions.js +56 -0
- package/dist/cjs/resources/tax/deadlines.js +59 -0
- package/dist/cjs/resources/tax/documents.js +128 -0
- package/dist/cjs/resources/tax/index.js +80 -0
- package/dist/cjs/resources/tax/locationEvidence.js +131 -0
- package/dist/cjs/resources/tax/operatingLocations.js +98 -0
- package/dist/cjs/resources/tax/products.js +67 -0
- package/dist/cjs/resources/tax/registrationDeclarations.js +124 -0
- package/dist/cjs/resources/tax/registrations.js +82 -0
- package/dist/cjs/resources/tax/reports.js +92 -0
- package/dist/cjs/resources/tax/reviewItems.js +116 -0
- package/dist/cjs/resources/tax/ruleSet.js +68 -0
- package/dist/cjs/resources/tax/salesDestinations.js +94 -0
- package/dist/cjs/resources/tax/settings.js +104 -0
- package/dist/cjs/resources/tax/shared.js +62 -0
- package/dist/cjs/resources/tax/transactions.js +102 -0
- package/dist/cjs/route.js +22 -0
- package/dist/cjs/routes.js +31 -0
- package/dist/cjs/vocabulary/billingPortal.js +15 -0
- package/dist/cjs/vocabulary/catalog.js +110 -0
- package/dist/cjs/vocabulary/checkout.js +53 -0
- package/dist/cjs/vocabulary/connect.js +95 -0
- package/dist/cjs/vocabulary/errors.js +174 -0
- package/dist/cjs/vocabulary/events.js +176 -0
- package/dist/cjs/vocabulary/files.js +44 -0
- package/dist/cjs/vocabulary/index.js +37 -0
- package/dist/cjs/vocabulary/invoices.js +52 -0
- package/dist/cjs/vocabulary/lists.js +22 -0
- package/dist/cjs/vocabulary/merchants.js +23 -0
- package/dist/cjs/vocabulary/money.js +104 -0
- package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
- package/dist/cjs/vocabulary/payments.js +195 -0
- package/dist/cjs/vocabulary/reporting.js +27 -0
- package/dist/cjs/vocabulary/subscriptions.js +60 -0
- package/dist/cjs/vocabulary/tax.js +237 -0
- package/dist/cjs/vocabulary/version.js +12 -0
- package/dist/esm/common/address.js +76 -0
- package/dist/esm/common/envelopes.js +95 -0
- package/dist/esm/common/objects.js +74 -0
- package/dist/esm/common/params.js +203 -0
- package/dist/esm/common/primitives.js +35 -0
- package/dist/esm/contributions.js +5 -0
- package/dist/esm/index.js +26 -134
- package/dist/esm/openapi/document.js +294 -0
- package/dist/esm/openapi/index.js +2 -0
- package/dist/esm/openapi/webhooks.js +14 -0
- package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
- package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
- package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
- package/dist/esm/resources/billingEngine/index.js +26 -0
- package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
- package/dist/esm/resources/billingEngine/invoices.js +506 -0
- package/dist/esm/resources/billingEngine/params.js +39 -0
- package/dist/esm/resources/billingEngine/public.js +323 -0
- package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
- package/dist/esm/resources/catalog/billing.js +752 -0
- package/dist/esm/resources/catalog/billingSettings.js +128 -0
- package/dist/esm/resources/catalog/coupons.js +219 -0
- package/dist/esm/resources/catalog/entitlements.js +254 -0
- package/dist/esm/resources/catalog/index.js +38 -0
- package/dist/esm/resources/catalog/meters.js +276 -0
- package/dist/esm/resources/catalog/prices.js +419 -0
- package/dist/esm/resources/catalog/products.js +225 -0
- package/dist/esm/resources/catalog/promotionCodes.js +171 -0
- package/dist/esm/resources/catalog/shared.js +67 -0
- package/dist/esm/resources/catalog/testClocks.js +124 -0
- package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
- package/dist/esm/resources/checkout/contributions.js +167 -0
- package/dist/esm/resources/checkout/files.js +130 -0
- package/dist/esm/resources/checkout/index.js +25 -0
- package/dist/esm/resources/checkout/merchants.js +287 -0
- package/dist/esm/resources/checkout/paymentLinks.js +327 -0
- package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
- package/dist/esm/resources/checkout/shared.js +363 -0
- package/dist/esm/resources/connect/account.js +329 -0
- package/dist/esm/resources/connect/applicationFees.js +110 -0
- package/dist/esm/resources/connect/balance.js +209 -0
- package/dist/esm/resources/connect/connectedAccounts.js +257 -0
- package/dist/esm/resources/connect/index.js +34 -0
- package/dist/esm/resources/connect/onboarding.js +79 -0
- package/dist/esm/resources/connect/payouts.js +193 -0
- package/dist/esm/resources/connect/reporting.js +232 -0
- package/dist/esm/resources/connect/requestLogs.js +107 -0
- package/dist/esm/resources/connect/transfers.js +224 -0
- package/dist/esm/resources/core/customers.js +191 -0
- package/dist/esm/resources/core/index.js +6 -0
- package/dist/esm/resources/core/paymentMethods.js +131 -0
- package/dist/esm/resources/events/events.js +353 -0
- package/dist/esm/resources/events/index.js +12 -0
- package/dist/esm/resources/events/webhookDeliveries.js +90 -0
- package/dist/esm/resources/events/webhookEndpoints.js +212 -0
- package/dist/esm/resources/payments/charges.js +154 -0
- package/dist/esm/resources/payments/disputes.js +201 -0
- package/dist/esm/resources/payments/index.js +24 -0
- package/dist/esm/resources/payments/paymentIntents.js +526 -0
- package/dist/esm/resources/payments/refunds.js +242 -0
- package/dist/esm/resources/payments/setupIntents.js +155 -0
- package/dist/esm/resources/payments/social.js +179 -0
- package/dist/esm/resources/payments/testHelpers.js +36 -0
- package/dist/esm/resources/tax/assessments.js +214 -0
- package/dist/esm/resources/tax/businessProfile.js +96 -0
- package/dist/esm/resources/tax/calculations.js +173 -0
- package/dist/esm/resources/tax/capabilities.js +39 -0
- package/dist/esm/resources/tax/codes.js +34 -0
- package/dist/esm/resources/tax/complianceActions.js +53 -0
- package/dist/esm/resources/tax/deadlines.js +56 -0
- package/dist/esm/resources/tax/documents.js +125 -0
- package/dist/esm/resources/tax/index.js +63 -0
- package/dist/esm/resources/tax/locationEvidence.js +128 -0
- package/dist/esm/resources/tax/operatingLocations.js +95 -0
- package/dist/esm/resources/tax/products.js +64 -0
- package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
- package/dist/esm/resources/tax/registrations.js +79 -0
- package/dist/esm/resources/tax/reports.js +89 -0
- package/dist/esm/resources/tax/reviewItems.js +113 -0
- package/dist/esm/resources/tax/ruleSet.js +65 -0
- package/dist/esm/resources/tax/salesDestinations.js +91 -0
- package/dist/esm/resources/tax/settings.js +101 -0
- package/dist/esm/resources/tax/shared.js +58 -0
- package/dist/esm/resources/tax/transactions.js +99 -0
- package/dist/esm/route.js +16 -0
- package/dist/esm/routes.js +27 -0
- package/dist/esm/vocabulary/billingPortal.js +12 -0
- package/dist/esm/vocabulary/catalog.js +106 -0
- package/dist/esm/vocabulary/checkout.js +50 -0
- package/dist/esm/vocabulary/connect.js +92 -0
- package/dist/esm/vocabulary/errors.js +169 -0
- package/dist/esm/vocabulary/events.js +173 -0
- package/dist/esm/vocabulary/files.js +41 -0
- package/dist/esm/vocabulary/index.js +21 -0
- package/dist/esm/vocabulary/invoices.js +49 -0
- package/dist/esm/vocabulary/lists.js +19 -0
- package/dist/esm/vocabulary/merchants.js +20 -0
- package/dist/esm/vocabulary/money.js +98 -0
- package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
- package/dist/esm/vocabulary/payments.js +192 -0
- package/dist/esm/vocabulary/reporting.js +24 -0
- package/dist/esm/vocabulary/subscriptions.js +57 -0
- package/dist/esm/vocabulary/tax.js +233 -0
- package/dist/esm/vocabulary/version.js +9 -0
- package/dist/types/common/address.d.ts +62 -0
- package/dist/types/common/envelopes.d.ts +88 -0
- package/dist/types/common/objects.d.ts +107 -0
- package/dist/types/common/params.d.ts +156 -0
- package/dist/types/common/primitives.d.ts +56 -0
- package/dist/types/contributions.d.ts +1 -0
- package/dist/types/index.d.ts +16 -171
- package/dist/types/openapi/document.d.ts +16 -0
- package/dist/types/openapi/index.d.ts +2 -0
- package/dist/types/openapi/webhooks.d.ts +15 -0
- package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
- package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
- package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
- package/dist/types/resources/billingEngine/index.d.ts +6071 -0
- package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
- package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
- package/dist/types/resources/billingEngine/params.d.ts +51 -0
- package/dist/types/resources/billingEngine/public.d.ts +1860 -0
- package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
- package/dist/types/resources/catalog/billing.d.ts +1723 -0
- package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
- package/dist/types/resources/catalog/coupons.d.ts +403 -0
- package/dist/types/resources/catalog/entitlements.d.ts +422 -0
- package/dist/types/resources/catalog/index.d.ts +3155 -0
- package/dist/types/resources/catalog/meters.d.ts +474 -0
- package/dist/types/resources/catalog/prices.d.ts +1091 -0
- package/dist/types/resources/catalog/products.d.ts +430 -0
- package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
- package/dist/types/resources/catalog/shared.d.ts +34 -0
- package/dist/types/resources/catalog/testClocks.d.ts +220 -0
- package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
- package/dist/types/resources/checkout/contributions.d.ts +375 -0
- package/dist/types/resources/checkout/files.d.ts +280 -0
- package/dist/types/resources/checkout/index.d.ts +5678 -0
- package/dist/types/resources/checkout/merchants.d.ts +395 -0
- package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
- package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
- package/dist/types/resources/checkout/shared.d.ts +419 -0
- package/dist/types/resources/connect/account.d.ts +483 -0
- package/dist/types/resources/connect/applicationFees.d.ts +198 -0
- package/dist/types/resources/connect/balance.d.ts +399 -0
- package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
- package/dist/types/resources/connect/index.d.ts +2094 -0
- package/dist/types/resources/connect/onboarding.d.ts +95 -0
- package/dist/types/resources/connect/payouts.d.ts +527 -0
- package/dist/types/resources/connect/reporting.d.ts +506 -0
- package/dist/types/resources/connect/requestLogs.d.ts +236 -0
- package/dist/types/resources/connect/transfers.d.ts +436 -0
- package/dist/types/resources/core/customers.d.ts +619 -0
- package/dist/types/resources/core/index.d.ts +679 -0
- package/dist/types/resources/core/paymentMethods.d.ts +336 -0
- package/dist/types/resources/events/events.d.ts +731 -0
- package/dist/types/resources/events/index.d.ts +1727 -0
- package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
- package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
- package/dist/types/resources/payments/charges.d.ts +390 -0
- package/dist/types/resources/payments/disputes.d.ts +822 -0
- package/dist/types/resources/payments/index.d.ts +3517 -0
- package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
- package/dist/types/resources/payments/refunds.d.ts +684 -0
- package/dist/types/resources/payments/setupIntents.d.ts +391 -0
- package/dist/types/resources/payments/social.d.ts +266 -0
- package/dist/types/resources/payments/testHelpers.d.ts +178 -0
- package/dist/types/resources/tax/assessments.d.ts +787 -0
- package/dist/types/resources/tax/businessProfile.d.ts +134 -0
- package/dist/types/resources/tax/calculations.d.ts +261 -0
- package/dist/types/resources/tax/capabilities.d.ts +81 -0
- package/dist/types/resources/tax/codes.d.ts +29 -0
- package/dist/types/resources/tax/complianceActions.d.ts +97 -0
- package/dist/types/resources/tax/deadlines.d.ts +133 -0
- package/dist/types/resources/tax/documents.d.ts +257 -0
- package/dist/types/resources/tax/index.d.ts +1946 -0
- package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
- package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
- package/dist/types/resources/tax/products.d.ts +68 -0
- package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
- package/dist/types/resources/tax/registrations.d.ts +103 -0
- package/dist/types/resources/tax/reports.d.ts +129 -0
- package/dist/types/resources/tax/reviewItems.d.ts +226 -0
- package/dist/types/resources/tax/ruleSet.d.ts +219 -0
- package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
- package/dist/types/resources/tax/settings.d.ts +122 -0
- package/dist/types/resources/tax/shared.d.ts +43 -0
- package/dist/types/resources/tax/transactions.d.ts +404 -0
- package/dist/types/route.d.ts +86 -0
- package/dist/types/routes.d.ts +23 -0
- package/dist/types/vocabulary/billingPortal.d.ts +15 -0
- package/dist/types/vocabulary/catalog.d.ts +97 -0
- package/dist/types/vocabulary/checkout.d.ts +49 -0
- package/dist/types/vocabulary/connect.d.ts +62 -0
- package/dist/types/vocabulary/errors.d.ts +145 -0
- package/dist/types/vocabulary/events.d.ts +171 -0
- package/dist/types/vocabulary/files.d.ts +30 -0
- package/dist/types/vocabulary/index.d.ts +17 -0
- package/dist/types/vocabulary/invoices.d.ts +39 -0
- package/dist/types/vocabulary/lists.d.ts +9 -0
- package/dist/types/vocabulary/merchants.d.ts +9 -0
- package/dist/types/vocabulary/money.d.ts +59 -0
- package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
- package/dist/types/vocabulary/payments.d.ts +117 -0
- package/dist/types/vocabulary/reporting.d.ts +18 -0
- package/dist/types/vocabulary/subscriptions.d.ts +45 -0
- package/dist/types/vocabulary/tax.d.ts +163 -0
- package/dist/types/vocabulary/version.d.ts +10 -0
- package/package.json +51 -11
- package/dist/cjs/openapi.js +0 -165
- package/dist/esm/openapi.js +0 -161
- package/dist/types/openapi.d.ts +0 -148
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineObject } from '../../common/objects.js';
|
|
4
|
+
import { emptyQuery, expandOnlyQuery, idParam, listQuery } from '../../common/params.js';
|
|
5
|
+
import { amount, livemode, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
/**
|
|
8
|
+
* Application fees (`fee_…`, ADR 0015 §3) — Orbit's fee on one payment, taken
|
|
9
|
+
* by the provider from the merchant's account when the charge succeeded.
|
|
10
|
+
* Created from the provider's own record, never computed after the fact, and
|
|
11
|
+
* refunded through `POST /v1/refunds` with `refund_application_fee`.
|
|
12
|
+
*/
|
|
13
|
+
/** A refund of an application fee (`fr_…`). */
|
|
14
|
+
export const feeRefundSchema = defineObject('fee_refund', 'FeeRefund', z
|
|
15
|
+
.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
object: z.literal('fee_refund'),
|
|
18
|
+
amount,
|
|
19
|
+
currency: z.string(),
|
|
20
|
+
fee: z.string().describe('The `fee_…` it refunds.'),
|
|
21
|
+
created: unixSeconds,
|
|
22
|
+
})
|
|
23
|
+
.strict());
|
|
24
|
+
export const applicationFeeSchema = defineObject('application_fee', 'ApplicationFee', z
|
|
25
|
+
.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
object: z.literal('application_fee'),
|
|
28
|
+
livemode,
|
|
29
|
+
account: z.string().describe('The account (`ca_…`) the fee was taken from.'),
|
|
30
|
+
amount,
|
|
31
|
+
amount_refunded: amount,
|
|
32
|
+
currency: z.string(),
|
|
33
|
+
charge: z
|
|
34
|
+
.string()
|
|
35
|
+
.nullable()
|
|
36
|
+
.describe('The `ch_…` it was taken on, when Orbit holds the charge.'),
|
|
37
|
+
payment_intent: z.string().describe('The `pi_…` it was taken on.'),
|
|
38
|
+
refunded: z.boolean().describe('Refunded in full.'),
|
|
39
|
+
refunds: listOf(feeRefundSchema).describe('Every refund of the fee: a complete set.'),
|
|
40
|
+
created: unixSeconds,
|
|
41
|
+
})
|
|
42
|
+
.strict(), {
|
|
43
|
+
examples: [
|
|
44
|
+
{
|
|
45
|
+
id: 'fee_0193b8f32b7f4d0e8a15',
|
|
46
|
+
object: 'application_fee',
|
|
47
|
+
livemode: false,
|
|
48
|
+
account: 'ca_0193b8f2c1a87d3e9f4a',
|
|
49
|
+
amount: '60',
|
|
50
|
+
amount_refunded: '0',
|
|
51
|
+
currency: 'EUR',
|
|
52
|
+
charge: 'ch_0193b8f2f7c94b1d8e02',
|
|
53
|
+
payment_intent: 'pi_0193b8f2e8a14f6c9d31',
|
|
54
|
+
refunded: false,
|
|
55
|
+
refunds: {
|
|
56
|
+
object: 'list',
|
|
57
|
+
data: [],
|
|
58
|
+
has_more: false,
|
|
59
|
+
url: '/v1/application_fees/fee_0193b8f32b7f4d0e8a15/refunds',
|
|
60
|
+
},
|
|
61
|
+
created: 1793750400,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
export const listApplicationFeesQuery = listQuery({
|
|
66
|
+
payment_intent: idParam.optional().describe('Only the fee taken on this payment (`pi_…`).'),
|
|
67
|
+
});
|
|
68
|
+
const feeIdParam = { id: 'The application fee (`fee_…`).' };
|
|
69
|
+
export const applicationFeeRoutes = [
|
|
70
|
+
defineRoute({
|
|
71
|
+
operationId: 'listApplicationFees',
|
|
72
|
+
method: 'get',
|
|
73
|
+
path: '/v1/application_fees',
|
|
74
|
+
tag: 'Application fees',
|
|
75
|
+
summary: 'List application fees',
|
|
76
|
+
auth: 'service',
|
|
77
|
+
scope: 'payments:read',
|
|
78
|
+
query: listApplicationFeesQuery,
|
|
79
|
+
response: listOf(applicationFeeSchema),
|
|
80
|
+
sdk: 'applicationFees.list',
|
|
81
|
+
expandable: 'application_fee',
|
|
82
|
+
}),
|
|
83
|
+
defineRoute({
|
|
84
|
+
operationId: 'retrieveApplicationFee',
|
|
85
|
+
method: 'get',
|
|
86
|
+
path: '/v1/application_fees/{id}',
|
|
87
|
+
tag: 'Application fees',
|
|
88
|
+
summary: 'Retrieve an application fee',
|
|
89
|
+
auth: 'service',
|
|
90
|
+
scope: 'payments:read',
|
|
91
|
+
params: feeIdParam,
|
|
92
|
+
query: expandOnlyQuery,
|
|
93
|
+
response: applicationFeeSchema,
|
|
94
|
+
sdk: 'applicationFees.retrieve',
|
|
95
|
+
}),
|
|
96
|
+
defineRoute({
|
|
97
|
+
operationId: 'listApplicationFeeRefunds',
|
|
98
|
+
method: 'get',
|
|
99
|
+
path: '/v1/application_fees/{id}/refunds',
|
|
100
|
+
tag: 'Application fees',
|
|
101
|
+
summary: "List an application fee's refunds",
|
|
102
|
+
description: 'A complete set (`has_more: false`): one refund per partial refund of the payment.',
|
|
103
|
+
auth: 'service',
|
|
104
|
+
scope: 'payments:read',
|
|
105
|
+
params: feeIdParam,
|
|
106
|
+
query: emptyQuery,
|
|
107
|
+
response: listOf(feeRefundSchema),
|
|
108
|
+
sdk: 'applicationFees.listRefunds',
|
|
109
|
+
}),
|
|
110
|
+
];
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, idParam, listQuery } from '../../common/params.js';
|
|
5
|
+
import { livemode, signedAmount, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { BALANCE_TRANSACTION_FEE_TYPES, BALANCE_TRANSACTION_STATUSES, BALANCE_TRANSACTION_TYPES, RECONCILIATION_MISMATCH_KINDS, } from '../../vocabulary/connect.js';
|
|
8
|
+
/**
|
|
9
|
+
* Balance and balance transactions (ADR 0015 §3–§5).
|
|
10
|
+
*
|
|
11
|
+
* MIRRORS, every one of them. The money is in the merchant's own provider
|
|
12
|
+
* account; Orbit's double-entry ledger is fed by the provider's own balance
|
|
13
|
+
* transactions and payouts for that account and reconciled against them daily.
|
|
14
|
+
* Nothing here is computed by Orbit: a figure the provider has not given is
|
|
15
|
+
* `null` with a status, never `0`.
|
|
16
|
+
*
|
|
17
|
+
* Every amount is a canonical integer STRING in the currency's smallest unit
|
|
18
|
+
* that MAY be negative (`"-1500"`): a refund or a payout takes money out of a
|
|
19
|
+
* balance.
|
|
20
|
+
*/
|
|
21
|
+
/** A currency as the provider reports it: upper-case ISO 4217, or `FAIR`. */
|
|
22
|
+
const ledgerCurrency = z.string().describe('Upper-case ISO 4217 code, or `FAIR`.');
|
|
23
|
+
/** One currency's figure in a balance. */
|
|
24
|
+
export const balanceAmountSchema = defineComponent('BalanceAmount', z.object({ amount: signedAmount, currency: ledgerCurrency }).strict());
|
|
25
|
+
/**
|
|
26
|
+
* `GET /v1/balance` — read from the ledger, per currency. A merchant without a
|
|
27
|
+
* fiat account has NO balance and is told so (404 `account_missing`), never
|
|
28
|
+
* shown zeros.
|
|
29
|
+
*/
|
|
30
|
+
export const balanceSchema = defineObject('balance', 'Balance', z
|
|
31
|
+
.object({
|
|
32
|
+
object: z.literal('balance'),
|
|
33
|
+
livemode,
|
|
34
|
+
available: z
|
|
35
|
+
.array(balanceAmountSchema)
|
|
36
|
+
.describe('Payable now: the provider has made these funds available.'),
|
|
37
|
+
pending: z.array(balanceAmountSchema).describe('Not yet available at the provider.'),
|
|
38
|
+
informational: z
|
|
39
|
+
.array(balanceAmountSchema)
|
|
40
|
+
.describe("FairCoin received straight into the merchant's own wallet (ADR 0015 §5): recorded for the books only. Orbit never held it, so it is never payable."),
|
|
41
|
+
account: z
|
|
42
|
+
.string()
|
|
43
|
+
.nullable()
|
|
44
|
+
.describe('The account (`ca_…`) this balance mirrors; `null` for an Oxy first-party merchant.'),
|
|
45
|
+
})
|
|
46
|
+
.strict(), {
|
|
47
|
+
examples: [
|
|
48
|
+
{
|
|
49
|
+
object: 'balance',
|
|
50
|
+
livemode: false,
|
|
51
|
+
available: [{ amount: '184250', currency: 'EUR' }],
|
|
52
|
+
pending: [{ amount: '12900', currency: 'EUR' }],
|
|
53
|
+
informational: [{ amount: '250000000', currency: 'FAIR' }],
|
|
54
|
+
account: 'ca_0193b8f2c1a87d3e9f4a',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
/** One component of a transaction's fee. */
|
|
59
|
+
export const balanceTransactionFeeDetailSchema = defineComponent('BalanceTransactionFeeDetail', z
|
|
60
|
+
.object({
|
|
61
|
+
amount: signedAmount,
|
|
62
|
+
currency: ledgerCurrency,
|
|
63
|
+
type: z.enum(BALANCE_TRANSACTION_FEE_TYPES),
|
|
64
|
+
})
|
|
65
|
+
.strict());
|
|
66
|
+
export const balanceTransactionSchema = defineObject('balance_transaction', 'BalanceTransaction', z
|
|
67
|
+
.object({
|
|
68
|
+
id: z.string().describe('`txn_…`'),
|
|
69
|
+
object: z.literal('balance_transaction'),
|
|
70
|
+
livemode,
|
|
71
|
+
amount: signedAmount.describe('Gross, signed.'),
|
|
72
|
+
fee: signedAmount
|
|
73
|
+
.nullable()
|
|
74
|
+
.describe('What was taken, or `null` when the source gave no figure (never `0` for unknown).'),
|
|
75
|
+
net: signedAmount
|
|
76
|
+
.nullable()
|
|
77
|
+
.describe('`amount - fee`, as the provider reports it, or `null` with `fee`.'),
|
|
78
|
+
currency: ledgerCurrency,
|
|
79
|
+
type: z.enum(BALANCE_TRANSACTION_TYPES),
|
|
80
|
+
reporting_category: z
|
|
81
|
+
.string()
|
|
82
|
+
.describe('A coarser grouping for reports (`charge`, `refund`, `payout`, `fee`, …).'),
|
|
83
|
+
status: z.enum(BALANCE_TRANSACTION_STATUSES),
|
|
84
|
+
available_on: unixSeconds
|
|
85
|
+
.nullable()
|
|
86
|
+
.describe('When the funds became (or become) available; `null` for an informational entry.'),
|
|
87
|
+
created: unixSeconds.describe('When it happened at its source.'),
|
|
88
|
+
description: z.string().nullable(),
|
|
89
|
+
exchange_rate: z.number().nullable(),
|
|
90
|
+
fee_details: z.array(balanceTransactionFeeDetailSchema),
|
|
91
|
+
source: z
|
|
92
|
+
.string()
|
|
93
|
+
.nullable()
|
|
94
|
+
.describe("The Orbit object that caused it (`ch_…`, `re_…`, `po_…`, `fee_…`, `tr_…`, `pi_…`), or `null` when the provider's source is not an object Orbit holds."),
|
|
95
|
+
payout: z
|
|
96
|
+
.string()
|
|
97
|
+
.nullable()
|
|
98
|
+
.describe('The payout (`po_…`) that paid this transaction out, once known.'),
|
|
99
|
+
account: z
|
|
100
|
+
.string()
|
|
101
|
+
.nullable()
|
|
102
|
+
.describe('The account (`ca_…`) whose balance it moved; `null` for a first-party merchant.'),
|
|
103
|
+
})
|
|
104
|
+
.strict(), {
|
|
105
|
+
examples: [
|
|
106
|
+
{
|
|
107
|
+
id: 'txn_0193b8f30a6c4e21b7d9',
|
|
108
|
+
object: 'balance_transaction',
|
|
109
|
+
livemode: false,
|
|
110
|
+
amount: '2000',
|
|
111
|
+
fee: '88',
|
|
112
|
+
net: '1912',
|
|
113
|
+
currency: 'EUR',
|
|
114
|
+
type: 'charge',
|
|
115
|
+
reporting_category: 'charge',
|
|
116
|
+
status: 'available',
|
|
117
|
+
available_on: 1794355200,
|
|
118
|
+
created: 1793750400,
|
|
119
|
+
description: 'Order 6735',
|
|
120
|
+
exchange_rate: null,
|
|
121
|
+
fee_details: [{ amount: '88', currency: 'EUR', type: 'processing_fee' }],
|
|
122
|
+
source: 'ch_0193b8f2f7c94b1d8e02',
|
|
123
|
+
payout: null,
|
|
124
|
+
account: 'ca_0193b8f2c1a87d3e9f4a',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* What the daily reconciliation found disagreeing with the provider (Orbit's
|
|
130
|
+
* dashboard reads them). Never auto-corrected.
|
|
131
|
+
*/
|
|
132
|
+
export const reconciliationMismatchSchema = defineObject('reconciliation_mismatch', 'ReconciliationMismatch', z
|
|
133
|
+
.object({
|
|
134
|
+
id: z.string(),
|
|
135
|
+
object: z.literal('reconciliation_mismatch'),
|
|
136
|
+
livemode,
|
|
137
|
+
account: z.string().nullable(),
|
|
138
|
+
kind: z.enum(RECONCILIATION_MISMATCH_KINDS),
|
|
139
|
+
object_id: z
|
|
140
|
+
.string()
|
|
141
|
+
.nullable()
|
|
142
|
+
.describe('The Orbit object concerned (`txn_…`, `po_…`), when Orbit holds one.'),
|
|
143
|
+
expected: z.record(z.string(), z.unknown()).nullable().describe('What the provider says.'),
|
|
144
|
+
actual: z.record(z.string(), z.unknown()).nullable().describe('What the ledger holds.'),
|
|
145
|
+
detected_at: unixSeconds,
|
|
146
|
+
last_seen_at: unixSeconds,
|
|
147
|
+
resolved_at: unixSeconds
|
|
148
|
+
.nullable()
|
|
149
|
+
.describe('Set when a later run no longer sees the difference.'),
|
|
150
|
+
})
|
|
151
|
+
.strict());
|
|
152
|
+
export const listBalanceTransactionsQuery = listQuery({
|
|
153
|
+
type: z.enum(BALANCE_TRANSACTION_TYPES).optional(),
|
|
154
|
+
payout: idParam.optional().describe('`po_…`: only the transactions that payout paid out.'),
|
|
155
|
+
source: idParam.optional().describe('An Orbit object id the transaction was caused by.'),
|
|
156
|
+
currency: z
|
|
157
|
+
.string()
|
|
158
|
+
.regex(/^[A-Za-z]{3,4}$/)
|
|
159
|
+
.optional()
|
|
160
|
+
.describe('Case-insensitive.'),
|
|
161
|
+
});
|
|
162
|
+
/** Reconciliation findings, as Orbit's dashboard lists them (not a public route). */
|
|
163
|
+
export const listReconciliationMismatchesQuery = listQuery({
|
|
164
|
+
open: z.enum(['true', 'false']).optional().describe('`true`: only unresolved findings.'),
|
|
165
|
+
});
|
|
166
|
+
export const balanceRoutes = [
|
|
167
|
+
defineRoute({
|
|
168
|
+
operationId: 'retrieveBalance',
|
|
169
|
+
method: 'get',
|
|
170
|
+
path: '/v1/balance',
|
|
171
|
+
tag: 'Balance',
|
|
172
|
+
summary: 'Retrieve the balance',
|
|
173
|
+
auth: 'service',
|
|
174
|
+
scope: 'payments:read',
|
|
175
|
+
peableAccount: true,
|
|
176
|
+
query: expandOnlyQuery,
|
|
177
|
+
response: balanceSchema,
|
|
178
|
+
sdk: 'balance.retrieve',
|
|
179
|
+
}),
|
|
180
|
+
defineRoute({
|
|
181
|
+
operationId: 'listBalanceTransactions',
|
|
182
|
+
method: 'get',
|
|
183
|
+
path: '/v1/balance_transactions',
|
|
184
|
+
tag: 'Balance transactions',
|
|
185
|
+
summary: 'List balance transactions',
|
|
186
|
+
description: 'Newest first, filtered by `type`, `payout`, `source`, `currency` and `created`.',
|
|
187
|
+
auth: 'service',
|
|
188
|
+
scope: 'payments:read',
|
|
189
|
+
peableAccount: true,
|
|
190
|
+
query: listBalanceTransactionsQuery,
|
|
191
|
+
response: listOf(balanceTransactionSchema),
|
|
192
|
+
sdk: 'balanceTransactions.list',
|
|
193
|
+
expandable: 'balance_transaction',
|
|
194
|
+
}),
|
|
195
|
+
defineRoute({
|
|
196
|
+
operationId: 'retrieveBalanceTransaction',
|
|
197
|
+
method: 'get',
|
|
198
|
+
path: '/v1/balance_transactions/{id}',
|
|
199
|
+
tag: 'Balance transactions',
|
|
200
|
+
summary: 'Retrieve a balance transaction',
|
|
201
|
+
auth: 'service',
|
|
202
|
+
scope: 'payments:read',
|
|
203
|
+
peableAccount: true,
|
|
204
|
+
params: { id: 'The balance transaction (`txn_…`).' },
|
|
205
|
+
query: expandOnlyQuery,
|
|
206
|
+
response: balanceTransactionSchema,
|
|
207
|
+
sdk: 'balanceTransactions.retrieve',
|
|
208
|
+
}),
|
|
209
|
+
];
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, listQuery } from '../../common/params.js';
|
|
5
|
+
import { livemode, network, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { ACCOUNT_BUSINESS_TYPES, ACCOUNT_CAPABILITY_STATUSES, CONNECTED_ACCOUNT_FAIRCOIN_STATUSES, CONNECTED_ACCOUNT_RAILS, } from '../../vocabulary/connect.js';
|
|
8
|
+
import { NETWORK_TYPES } from '../../vocabulary/money.js';
|
|
9
|
+
import { accountLinkSchema, accountRequirementsSchema } from './account.js';
|
|
10
|
+
/**
|
|
11
|
+
* Connected accounts (`ca_…`) — a marketplace's sellers (ADR 0012).
|
|
12
|
+
*
|
|
13
|
+
* ## The provider's own ids are not here, and that is the contract
|
|
14
|
+
*
|
|
15
|
+
* ADR 0001 D3: a merchant integrates against Peable and never learns which
|
|
16
|
+
* acquirer sat behind their seller, because the day that changes should be a
|
|
17
|
+
* Peable deploy and not a merchant migration. No `acct_…`, no provider name —
|
|
18
|
+
* and no seller xpub (ADR 0012 D6): an account xpub reveals every address of
|
|
19
|
+
* that account, so a platform holding it would learn the seller's whole history
|
|
20
|
+
* and balance. Nothing a platform does needs it; each payment carries its own
|
|
21
|
+
* address.
|
|
22
|
+
*/
|
|
23
|
+
const capabilityStatus = z.enum(ACCOUNT_CAPABILITY_STATUSES);
|
|
24
|
+
/** The FairCoin half of a seller's account. The seller's xpub is deliberately ABSENT (ADR 0012 D6). */
|
|
25
|
+
export const connectedAccountFaircoinSchema = defineComponent('ConnectedAccountFaircoin', z
|
|
26
|
+
.object({
|
|
27
|
+
network: network.describe('The chain the seller is paid on. Fixed when the half was opened.'),
|
|
28
|
+
status: z
|
|
29
|
+
.enum(CONNECTED_ACCOUNT_FAIRCOIN_STATUSES)
|
|
30
|
+
.describe('`pending`: the seller has not registered a key yet (an on-behalf payment is refused, `account_not_ready`). `active`: payments derive addresses from their key.'),
|
|
31
|
+
oxy_user_id: z
|
|
32
|
+
.string()
|
|
33
|
+
.describe('The Oxy user who may register the key — and, once `active`, who did.'),
|
|
34
|
+
registered_at: unixSeconds
|
|
35
|
+
.nullable()
|
|
36
|
+
.describe('When the seller registered their key. `null` while `pending`.'),
|
|
37
|
+
})
|
|
38
|
+
.strict());
|
|
39
|
+
export const connectedAccountSchema = defineObject('connected_account', 'ConnectedAccount', z
|
|
40
|
+
.object({
|
|
41
|
+
id: z.string(),
|
|
42
|
+
object: z.literal('connected_account'),
|
|
43
|
+
livemode,
|
|
44
|
+
external_ref: z
|
|
45
|
+
.string()
|
|
46
|
+
.describe("The merchant's OWN id for this seller — how they address it."),
|
|
47
|
+
rails: z
|
|
48
|
+
.array(z.enum(CONNECTED_ACCOUNT_RAILS))
|
|
49
|
+
.describe('Which halves this account has. Never empty.'),
|
|
50
|
+
faircoin: connectedAccountFaircoinSchema
|
|
51
|
+
.nullable()
|
|
52
|
+
.describe("The FairCoin half, or `null` when the platform never opened one. Readiness for FairCoin is `faircoin.status === 'active'`; `payable` is about the CARD half."),
|
|
53
|
+
country: z
|
|
54
|
+
.string()
|
|
55
|
+
.nullable()
|
|
56
|
+
.describe('ISO 3166-1 alpha-2, upper-case. `null` on a FairCoin-only seller, which has no card half.'),
|
|
57
|
+
default_currency: z.string().nullable(),
|
|
58
|
+
payable: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.describe('Whether this seller can receive a CARD settlement (a transfer) right now. A convenience: every field it is derived from is here too. Always `false` on a FairCoin-only seller.'),
|
|
61
|
+
payouts_enabled: z.boolean(),
|
|
62
|
+
charges_enabled: z.boolean(),
|
|
63
|
+
transfers_capability: capabilityStatus
|
|
64
|
+
.nullable()
|
|
65
|
+
.describe('`null`: never requested — a different fact from the provider declining it.'),
|
|
66
|
+
card_payments_capability: capabilityStatus.nullable(),
|
|
67
|
+
requirements: accountRequirementsSchema,
|
|
68
|
+
last_synced_at: unixSeconds.nullable(),
|
|
69
|
+
created: unixSeconds,
|
|
70
|
+
updated_at: unixSeconds,
|
|
71
|
+
})
|
|
72
|
+
.strict(), {
|
|
73
|
+
examples: [
|
|
74
|
+
{
|
|
75
|
+
id: 'ca_0193b8f2d4e1aa07c3b2',
|
|
76
|
+
object: 'connected_account',
|
|
77
|
+
livemode: false,
|
|
78
|
+
external_ref: 'seller_4821',
|
|
79
|
+
rails: ['card', 'faircoin'],
|
|
80
|
+
faircoin: {
|
|
81
|
+
network: 'mainnet',
|
|
82
|
+
status: 'active',
|
|
83
|
+
oxy_user_id: '665f1c0e9a1b2c3d4e5f6a7b',
|
|
84
|
+
registered_at: 1793751000,
|
|
85
|
+
},
|
|
86
|
+
country: 'DE',
|
|
87
|
+
default_currency: 'EUR',
|
|
88
|
+
payable: true,
|
|
89
|
+
payouts_enabled: true,
|
|
90
|
+
charges_enabled: true,
|
|
91
|
+
transfers_capability: 'active',
|
|
92
|
+
card_payments_capability: 'active',
|
|
93
|
+
requirements: {
|
|
94
|
+
currently_due: [],
|
|
95
|
+
eventually_due: [],
|
|
96
|
+
past_due: [],
|
|
97
|
+
pending_verification: [],
|
|
98
|
+
disabled_reason: null,
|
|
99
|
+
},
|
|
100
|
+
last_synced_at: 1793751060,
|
|
101
|
+
created: 1793750400,
|
|
102
|
+
updated_at: 1793751060,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
/** Bounded for the reason `external_ref` is: it is stored, and it is compared. */
|
|
107
|
+
const OXY_USER_ID_MAX = 128;
|
|
108
|
+
/**
|
|
109
|
+
* `POST /v1/connected_accounts`: open (or return) the account for one seller.
|
|
110
|
+
*
|
|
111
|
+
* Two halves, at least one: the CARD half (`country` + `business_type`, both or
|
|
112
|
+
* neither) and the FAIRCOIN half (`faircoin`). There is deliberately no `xpub`
|
|
113
|
+
* here: the key comes from the SELLER's own session, never from the platform
|
|
114
|
+
* (ADR 0012 D3).
|
|
115
|
+
*/
|
|
116
|
+
export const createConnectedAccountParams = z
|
|
117
|
+
.object({
|
|
118
|
+
// Bounded because it is a key: an unbounded string here is an unbounded
|
|
119
|
+
// index entry and an unbounded response field.
|
|
120
|
+
external_ref: z
|
|
121
|
+
.string()
|
|
122
|
+
.min(1)
|
|
123
|
+
.max(255)
|
|
124
|
+
.describe('Your own id for the seller. Opening the same `external_ref` again answers that account (200).'),
|
|
125
|
+
country: z
|
|
126
|
+
.string()
|
|
127
|
+
.length(2)
|
|
128
|
+
.optional()
|
|
129
|
+
.describe('The card half: ISO 3166-1 alpha-2 (case-insensitive). With `business_type`.'),
|
|
130
|
+
business_type: z
|
|
131
|
+
.enum(ACCOUNT_BUSINESS_TYPES)
|
|
132
|
+
.optional()
|
|
133
|
+
.describe('The card half: with `country`.'),
|
|
134
|
+
faircoin: z
|
|
135
|
+
.object({
|
|
136
|
+
network: z.enum(NETWORK_TYPES),
|
|
137
|
+
oxy_user_id: z
|
|
138
|
+
.string()
|
|
139
|
+
.min(1)
|
|
140
|
+
.max(OXY_USER_ID_MAX)
|
|
141
|
+
.describe("The seller's Oxy user id — the only person who may register the key."),
|
|
142
|
+
})
|
|
143
|
+
.strict()
|
|
144
|
+
.optional()
|
|
145
|
+
.describe('The FairCoin half (ADR 0012 D2): the chain the seller is paid on, and who they are.'),
|
|
146
|
+
})
|
|
147
|
+
.strict()
|
|
148
|
+
.refine((body) => (body.country === undefined) === (body.business_type === undefined), {
|
|
149
|
+
message: 'a card account needs both country and business_type, or neither',
|
|
150
|
+
})
|
|
151
|
+
.refine((body) => body.country !== undefined || body.faircoin !== undefined, {
|
|
152
|
+
message: 'open at least one rail: country and business_type for cards, faircoin for FairCoin',
|
|
153
|
+
});
|
|
154
|
+
export const listConnectedAccountsQuery = listQuery({});
|
|
155
|
+
/** `POST /v1/connected_accounts/{accountId}/refresh` takes no parameters. */
|
|
156
|
+
export const refreshConnectedAccountParams = z.object({}).strict();
|
|
157
|
+
/** A seller's onboarding link. */
|
|
158
|
+
export const createConnectedAccountLinkParams = z
|
|
159
|
+
.object({
|
|
160
|
+
refresh_url: z.url().describe('Where the seller goes when the link has expired.'),
|
|
161
|
+
return_url: z.url().describe('Where the seller returns when they leave the flow.'),
|
|
162
|
+
rail: z
|
|
163
|
+
.enum(CONNECTED_ACCOUNT_RAILS)
|
|
164
|
+
.optional()
|
|
165
|
+
.describe("Which half to onboard: `card` (the default) is the provider's hosted onboarding; `faircoin` is Peable's own page where the SELLER registers their watch-only key."),
|
|
166
|
+
})
|
|
167
|
+
.strict();
|
|
168
|
+
const accountIdParam = { accountId: 'The connected account (`ca_…`).' };
|
|
169
|
+
export const connectedAccountRoutes = [
|
|
170
|
+
defineRoute({
|
|
171
|
+
operationId: 'createConnectedAccount',
|
|
172
|
+
method: 'post',
|
|
173
|
+
path: '/v1/connected_accounts',
|
|
174
|
+
tag: 'Connected accounts',
|
|
175
|
+
summary: 'Open a connected account',
|
|
176
|
+
description: 'Opens the account for one seller (201), or answers the one this `external_ref` already opened (200) — a provider account cannot be deleted, so a converged retry says so.',
|
|
177
|
+
auth: 'service',
|
|
178
|
+
scope: 'payments:write',
|
|
179
|
+
idempotent: true,
|
|
180
|
+
body: createConnectedAccountParams,
|
|
181
|
+
response: connectedAccountSchema,
|
|
182
|
+
status: 201,
|
|
183
|
+
sdk: 'connectedAccounts.create',
|
|
184
|
+
}),
|
|
185
|
+
defineRoute({
|
|
186
|
+
operationId: 'listConnectedAccounts',
|
|
187
|
+
method: 'get',
|
|
188
|
+
path: '/v1/connected_accounts',
|
|
189
|
+
tag: 'Connected accounts',
|
|
190
|
+
summary: 'List connected accounts',
|
|
191
|
+
description: 'Every seller this merchant has onboarded, newest first.',
|
|
192
|
+
auth: 'service',
|
|
193
|
+
scope: 'payments:read',
|
|
194
|
+
query: listConnectedAccountsQuery,
|
|
195
|
+
response: listOf(connectedAccountSchema),
|
|
196
|
+
sdk: 'connectedAccounts.list',
|
|
197
|
+
expandable: 'connected_account',
|
|
198
|
+
}),
|
|
199
|
+
defineRoute({
|
|
200
|
+
operationId: 'retrieveConnectedAccountByRef',
|
|
201
|
+
method: 'get',
|
|
202
|
+
path: '/v1/connected_accounts/by_ref/{externalRef}',
|
|
203
|
+
tag: 'Connected accounts',
|
|
204
|
+
summary: 'Retrieve a connected account by your id',
|
|
205
|
+
description: 'By `external_ref`, the durable address you already hold — so a create whose answer never arrived is recoverable without a list scan.',
|
|
206
|
+
auth: 'service',
|
|
207
|
+
scope: 'payments:read',
|
|
208
|
+
params: { externalRef: 'Your own id for the seller.' },
|
|
209
|
+
query: expandOnlyQuery,
|
|
210
|
+
response: connectedAccountSchema,
|
|
211
|
+
sdk: 'connectedAccounts.retrieveByRef',
|
|
212
|
+
}),
|
|
213
|
+
defineRoute({
|
|
214
|
+
operationId: 'retrieveConnectedAccount',
|
|
215
|
+
method: 'get',
|
|
216
|
+
path: '/v1/connected_accounts/{accountId}',
|
|
217
|
+
tag: 'Connected accounts',
|
|
218
|
+
summary: 'Retrieve a connected account',
|
|
219
|
+
auth: 'service',
|
|
220
|
+
scope: 'payments:read',
|
|
221
|
+
params: accountIdParam,
|
|
222
|
+
query: expandOnlyQuery,
|
|
223
|
+
response: connectedAccountSchema,
|
|
224
|
+
sdk: 'connectedAccounts.retrieve',
|
|
225
|
+
}),
|
|
226
|
+
defineRoute({
|
|
227
|
+
operationId: 'refreshConnectedAccount',
|
|
228
|
+
method: 'post',
|
|
229
|
+
path: '/v1/connected_accounts/{accountId}/refresh',
|
|
230
|
+
tag: 'Connected accounts',
|
|
231
|
+
summary: 'Refresh a connected account',
|
|
232
|
+
description: 'Re-reads the account from the provider now. The sweep and the inbound event keep it fresh on their own; this is for a seller watching a screen.',
|
|
233
|
+
auth: 'service',
|
|
234
|
+
scope: 'payments:write',
|
|
235
|
+
idempotent: true,
|
|
236
|
+
params: accountIdParam,
|
|
237
|
+
body: refreshConnectedAccountParams,
|
|
238
|
+
response: connectedAccountSchema,
|
|
239
|
+
sdk: 'connectedAccounts.refresh',
|
|
240
|
+
}),
|
|
241
|
+
defineRoute({
|
|
242
|
+
operationId: 'createConnectedAccountLink',
|
|
243
|
+
method: 'post',
|
|
244
|
+
path: '/v1/connected_accounts/{accountId}/account_links',
|
|
245
|
+
tag: 'Connected accounts',
|
|
246
|
+
summary: "Create a seller's onboarding link",
|
|
247
|
+
description: 'Minted on demand and never stored: single-use and short-lived. A visit to `return_url` proves nothing about verification — read the account back.',
|
|
248
|
+
auth: 'service',
|
|
249
|
+
scope: 'payments:write',
|
|
250
|
+
idempotent: true,
|
|
251
|
+
params: accountIdParam,
|
|
252
|
+
body: createConnectedAccountLinkParams,
|
|
253
|
+
response: accountLinkSchema,
|
|
254
|
+
status: 201,
|
|
255
|
+
sdk: 'connectedAccounts.createAccountLink',
|
|
256
|
+
}),
|
|
257
|
+
];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { accountRoutes } from './account.js';
|
|
2
|
+
import { applicationFeeRoutes } from './applicationFees.js';
|
|
3
|
+
import { balanceRoutes } from './balance.js';
|
|
4
|
+
import { connectedAccountRoutes } from './connectedAccounts.js';
|
|
5
|
+
import { connectOnboardingRoutes } from './onboarding.js';
|
|
6
|
+
import { payoutRoutes } from './payouts.js';
|
|
7
|
+
import { reportingRoutes } from './reporting.js';
|
|
8
|
+
import { requestLogRoutes } from './requestLogs.js';
|
|
9
|
+
import { transferRoutes } from './transfers.js';
|
|
10
|
+
export * from './account.js';
|
|
11
|
+
export * from './applicationFees.js';
|
|
12
|
+
export * from './balance.js';
|
|
13
|
+
export * from './connectedAccounts.js';
|
|
14
|
+
export * from './onboarding.js';
|
|
15
|
+
export * from './payouts.js';
|
|
16
|
+
export * from './reporting.js';
|
|
17
|
+
export * from './requestLogs.js';
|
|
18
|
+
export * from './transfers.js';
|
|
19
|
+
/**
|
|
20
|
+
* Connect and money (ADR 0012, ADR 0015): connected accounts and their
|
|
21
|
+
* onboarding, the merchant's account, balance, payouts, application fees,
|
|
22
|
+
* transfers, reporting and the request log.
|
|
23
|
+
*/
|
|
24
|
+
export const connectRoutes = [
|
|
25
|
+
...connectedAccountRoutes,
|
|
26
|
+
...accountRoutes,
|
|
27
|
+
...balanceRoutes,
|
|
28
|
+
...payoutRoutes,
|
|
29
|
+
...applicationFeeRoutes,
|
|
30
|
+
...connectOnboardingRoutes,
|
|
31
|
+
...transferRoutes,
|
|
32
|
+
...reportingRoutes,
|
|
33
|
+
...requestLogRoutes,
|
|
34
|
+
];
|