@peable.to/contracts 0.3.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 -97
- 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 -94
- 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 -134
- 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 -138
- package/dist/esm/openapi.js +0 -134
- package/dist/types/openapi.d.ts +0 -145
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf, searchResultOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject, expandable } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, idParam, listQuery, searchQuery } from '../../common/params.js';
|
|
5
|
+
import { amount, currency, livemode, metadata, nullableString, unixSeconds, } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { billingDetailsSchema, cardDetailsSchema } from '../core/paymentMethods.js';
|
|
8
|
+
/**
|
|
9
|
+
* Charges (`ch_…`) — the read-only record of the money a CARD PaymentIntent
|
|
10
|
+
* moved (ADR 0019). Peable's object over the provider's charge, which stays an
|
|
11
|
+
* internal binding (ADR 0016). A FairCoin payment has no charge: its chain side
|
|
12
|
+
* is `PaymentIntent.faircoin`.
|
|
13
|
+
*/
|
|
14
|
+
export const chargeOutcomeSchema = defineComponent('ChargeOutcome', z
|
|
15
|
+
.object({
|
|
16
|
+
network_status: nullableString.describe('`approved_by_network`, `declined_by_network`, `not_sent_to_network`, `reversed_after_approval`.'),
|
|
17
|
+
risk_level: nullableString.describe('`normal`, `elevated`, `highest`, or `not_assessed`.'),
|
|
18
|
+
type: nullableString.describe('`authorized`, `manual_review`, `issuer_declined`, `blocked`, `invalid`.'),
|
|
19
|
+
seller_message: nullableString.describe("Peable's own one-line explanation for the merchant — never the provider's prose."),
|
|
20
|
+
})
|
|
21
|
+
.strict());
|
|
22
|
+
export const chargeSchema = defineObject('charge', 'Charge', z
|
|
23
|
+
.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
object: z.literal('charge'),
|
|
26
|
+
livemode,
|
|
27
|
+
payment_intent: expandable('payment_intent', '`pi_…`, or the PaymentIntent with `expand[]=payment_intent`.'),
|
|
28
|
+
customer: expandable('customer', '`cus_…`, or the Customer with `expand[]=customer`.').nullable(),
|
|
29
|
+
payment_method: expandable('payment_method', '`pm_…`, or the PaymentMethod with `expand[]=payment_method`.').nullable(),
|
|
30
|
+
amount,
|
|
31
|
+
amount_captured: amount,
|
|
32
|
+
amount_refunded: amount,
|
|
33
|
+
currency,
|
|
34
|
+
status: z
|
|
35
|
+
.literal('succeeded')
|
|
36
|
+
.describe('Always `succeeded`: Peable records the authorization that succeeded.'),
|
|
37
|
+
paid: z.boolean(),
|
|
38
|
+
captured: z.boolean(),
|
|
39
|
+
refunded: z
|
|
40
|
+
.boolean()
|
|
41
|
+
.describe('All of it came back — by refunds, or by releasing an uncaptured authorization.'),
|
|
42
|
+
disputed: z.boolean(),
|
|
43
|
+
outcome: chargeOutcomeSchema.nullable(),
|
|
44
|
+
billing_details: billingDetailsSchema
|
|
45
|
+
.nullable()
|
|
46
|
+
.describe("Who the card's billing details name, as the provider reported them; `null` until the provider snapshot is read."),
|
|
47
|
+
payment_method_details: z
|
|
48
|
+
.object({ type: z.literal('card'), card: cardDetailsSchema })
|
|
49
|
+
.strict()
|
|
50
|
+
.nullable(),
|
|
51
|
+
receipt_url: nullableString.describe("The provider's own URL never reaches the wire."),
|
|
52
|
+
balance_transaction: nullableString.describe("The ledger's `txn_…` once the provider's balance transaction was ingested (ADR 0015 §4); never a guess."),
|
|
53
|
+
application_fee: nullableString.describe("Orbit's `fee_…` taken on this charge, once the provider created it."),
|
|
54
|
+
application_fee_amount: amount
|
|
55
|
+
.nullable()
|
|
56
|
+
.describe('The fee instructed on the payment (`application_fee_amount`).'),
|
|
57
|
+
description: nullableString,
|
|
58
|
+
receipt_email: nullableString,
|
|
59
|
+
metadata,
|
|
60
|
+
created: unixSeconds,
|
|
61
|
+
})
|
|
62
|
+
.strict(), {
|
|
63
|
+
examples: [
|
|
64
|
+
{
|
|
65
|
+
id: 'ch_0193b8f2c1a87d3e9f4a',
|
|
66
|
+
object: 'charge',
|
|
67
|
+
livemode: false,
|
|
68
|
+
payment_intent: 'pi_0193b8f2c1a87d3e9f4a',
|
|
69
|
+
customer: 'cus_0193b8f2c1a87d3e9f4a',
|
|
70
|
+
payment_method: 'pm_0193b8f2c1a87d3e9f4a',
|
|
71
|
+
amount: '2500',
|
|
72
|
+
amount_captured: '2500',
|
|
73
|
+
amount_refunded: '0',
|
|
74
|
+
currency: 'EUR',
|
|
75
|
+
status: 'succeeded',
|
|
76
|
+
paid: true,
|
|
77
|
+
captured: true,
|
|
78
|
+
refunded: false,
|
|
79
|
+
disputed: false,
|
|
80
|
+
outcome: {
|
|
81
|
+
network_status: 'approved_by_network',
|
|
82
|
+
risk_level: 'normal',
|
|
83
|
+
type: 'authorized',
|
|
84
|
+
seller_message: 'Payment complete.',
|
|
85
|
+
},
|
|
86
|
+
billing_details: null,
|
|
87
|
+
payment_method_details: {
|
|
88
|
+
type: 'card',
|
|
89
|
+
card: {
|
|
90
|
+
brand: 'visa',
|
|
91
|
+
last4: '4242',
|
|
92
|
+
exp_month: 12,
|
|
93
|
+
exp_year: 2030,
|
|
94
|
+
country: 'US',
|
|
95
|
+
funding: 'credit',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
receipt_url: null,
|
|
99
|
+
balance_transaction: null,
|
|
100
|
+
application_fee: null,
|
|
101
|
+
application_fee_amount: null,
|
|
102
|
+
description: null,
|
|
103
|
+
receipt_email: null,
|
|
104
|
+
metadata: {},
|
|
105
|
+
created: 1793750400,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
});
|
|
109
|
+
export const listChargesQuery = listQuery({
|
|
110
|
+
payment_intent: idParam.optional().describe("Only this payment's charges (`pi_…`)."),
|
|
111
|
+
});
|
|
112
|
+
export const chargeRoutes = [
|
|
113
|
+
defineRoute({
|
|
114
|
+
operationId: 'listCharges',
|
|
115
|
+
method: 'get',
|
|
116
|
+
path: '/v1/charges',
|
|
117
|
+
tag: 'Charges',
|
|
118
|
+
summary: 'List charges',
|
|
119
|
+
auth: 'service',
|
|
120
|
+
scope: 'payments:read',
|
|
121
|
+
query: listChargesQuery,
|
|
122
|
+
response: listOf(chargeSchema),
|
|
123
|
+
sdk: 'charges.list',
|
|
124
|
+
expandable: 'charge',
|
|
125
|
+
}),
|
|
126
|
+
defineRoute({
|
|
127
|
+
operationId: 'retrieveCharge',
|
|
128
|
+
method: 'get',
|
|
129
|
+
path: '/v1/charges/{id}',
|
|
130
|
+
tag: 'Charges',
|
|
131
|
+
summary: 'Retrieve a charge',
|
|
132
|
+
auth: 'service',
|
|
133
|
+
scope: 'payments:read',
|
|
134
|
+
params: { id: 'The charge (`ch_…`).' },
|
|
135
|
+
query: expandOnlyQuery,
|
|
136
|
+
response: chargeSchema,
|
|
137
|
+
sdk: 'charges.retrieve',
|
|
138
|
+
expandable: 'charge',
|
|
139
|
+
}),
|
|
140
|
+
defineRoute({
|
|
141
|
+
operationId: 'searchCharges',
|
|
142
|
+
method: 'get',
|
|
143
|
+
path: '/v1/charges/search',
|
|
144
|
+
tag: 'Charges',
|
|
145
|
+
summary: 'Search charges',
|
|
146
|
+
description: "Stripe's query language over `amount`, `currency`, `customer`, `payment_intent`, `status`, `captured`, `refunded`, `disputed`, `created` and `metadata['key']`.",
|
|
147
|
+
auth: 'service',
|
|
148
|
+
scope: 'payments:read',
|
|
149
|
+
query: searchQuery,
|
|
150
|
+
response: searchResultOf(chargeSchema),
|
|
151
|
+
sdk: 'charges.search',
|
|
152
|
+
expandable: 'charge',
|
|
153
|
+
}),
|
|
154
|
+
];
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject, expandable } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, idParam, listQuery, metadataUpdateParam } from '../../common/params.js';
|
|
5
|
+
import { amount, currency, livemode, metadata, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { DISPUTE_EVIDENCE_TEXT_MAX, DISPUTE_FILE_EVIDENCE_FIELDS, DISPUTE_REASONS, DISPUTE_STATUSES, DISPUTE_TEXT_EVIDENCE_FIELDS, } from '../../vocabulary/payments.js';
|
|
8
|
+
/**
|
|
9
|
+
* Disputes (`dp_…`) — the card network holding a payment's money while a
|
|
10
|
+
* cardholder contests it. A dispute is a DEADLINE: `evidence_details.due_by`
|
|
11
|
+
* arrives with it. The network's own dispute id never appears.
|
|
12
|
+
*/
|
|
13
|
+
/** Every evidence field, `null` when unset. */
|
|
14
|
+
const evidenceFields = (field) => Object.fromEntries([...DISPUTE_TEXT_EVIDENCE_FIELDS, ...DISPUTE_FILE_EVIDENCE_FIELDS].map((name) => [name, field]));
|
|
15
|
+
/**
|
|
16
|
+
* A merchant's evidence as the dispute holds it. Present ONLY on a live read
|
|
17
|
+
* (`GET /v1/disputes/{id}` and the answers of its update and close): the text
|
|
18
|
+
* is read from the provider, where a draft lives (Peable keeps none of its
|
|
19
|
+
* words); the file half is the `file_…` ids attached. Lists and events never
|
|
20
|
+
* carry it.
|
|
21
|
+
*/
|
|
22
|
+
export const disputeEvidenceSchema = defineComponent('DisputeEvidence', z.object(evidenceFields(z.string().nullable())).strict());
|
|
23
|
+
export const disputeEvidenceDetailsSchema = defineComponent('DisputeEvidenceDetails', z
|
|
24
|
+
.object({
|
|
25
|
+
due_by: unixSeconds
|
|
26
|
+
.nullable()
|
|
27
|
+
.describe('When the network stops accepting evidence; `null` once the dispute is closed.'),
|
|
28
|
+
has_evidence: z.boolean().describe('Whether any evidence has been staged or submitted.'),
|
|
29
|
+
past_due: z.boolean().describe('Whether the deadline passed without a submission.'),
|
|
30
|
+
submission_count: z
|
|
31
|
+
.number()
|
|
32
|
+
.int()
|
|
33
|
+
.min(0)
|
|
34
|
+
.max(1)
|
|
35
|
+
.describe('`0` or `1`: a response is one-shot at the network.'),
|
|
36
|
+
submitted_at: unixSeconds
|
|
37
|
+
.nullable()
|
|
38
|
+
.describe('When the response reached the network; `null` while it has not.'),
|
|
39
|
+
})
|
|
40
|
+
.strict());
|
|
41
|
+
export const disputeSchema = defineObject('dispute', 'Dispute', z
|
|
42
|
+
.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
object: z.literal('dispute'),
|
|
45
|
+
livemode,
|
|
46
|
+
amount: amount.describe("The DISPUTED amount, which may be less than the payment's: a cardholder can contest part of a charge."),
|
|
47
|
+
currency,
|
|
48
|
+
charge: expandable('charge', '`ch_…`, or the Charge with `expand[]=charge`.').nullable(),
|
|
49
|
+
payment_intent: expandable('payment_intent', 'The disputed payment (`pi_…`), or the PaymentIntent with `expand[]=payment_intent`.'),
|
|
50
|
+
status: z
|
|
51
|
+
.enum(DISPUTE_STATUSES)
|
|
52
|
+
.describe('`needs_response` and `under_review` are open; `won` and `lost` are terminal and say where the money ended up.'),
|
|
53
|
+
reason: z.enum(DISPUTE_REASONS),
|
|
54
|
+
is_charge_refundable: z
|
|
55
|
+
.boolean()
|
|
56
|
+
.describe('Whether the disputed payment can still be refunded.'),
|
|
57
|
+
evidence_details: disputeEvidenceDetailsSchema,
|
|
58
|
+
evidence: disputeEvidenceSchema
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Live reads only: never on a list or an event.'),
|
|
61
|
+
metadata,
|
|
62
|
+
created: unixSeconds,
|
|
63
|
+
updated_at: unixSeconds,
|
|
64
|
+
})
|
|
65
|
+
.strict(), {
|
|
66
|
+
examples: [
|
|
67
|
+
{
|
|
68
|
+
id: 'dp_0193b8f2c1a87d3e9f4a',
|
|
69
|
+
object: 'dispute',
|
|
70
|
+
livemode: false,
|
|
71
|
+
amount: '2500',
|
|
72
|
+
currency: 'EUR',
|
|
73
|
+
charge: 'ch_0193b8f2c1a87d3e9f4a',
|
|
74
|
+
payment_intent: 'pi_0193b8f2c1a87d3e9f4a',
|
|
75
|
+
status: 'needs_response',
|
|
76
|
+
reason: 'product_not_received',
|
|
77
|
+
is_charge_refundable: true,
|
|
78
|
+
evidence_details: {
|
|
79
|
+
due_by: 1794355200,
|
|
80
|
+
has_evidence: false,
|
|
81
|
+
past_due: false,
|
|
82
|
+
submission_count: 0,
|
|
83
|
+
submitted_at: null,
|
|
84
|
+
},
|
|
85
|
+
metadata: {},
|
|
86
|
+
created: 1793750400,
|
|
87
|
+
updated_at: 1793750400,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
const FILE_ID_MAX = 255;
|
|
92
|
+
/** `""` unsets a field, as on Stripe. */
|
|
93
|
+
const textEvidence = z.string().max(DISPUTE_EVIDENCE_TEXT_MAX).optional();
|
|
94
|
+
const fileEvidence = z.string().max(FILE_ID_MAX).optional();
|
|
95
|
+
/**
|
|
96
|
+
* The evidence fields, in the network's names — a CLOSED set. Unknown keys are
|
|
97
|
+
* REFUSED rather than dropped: a merchant who sent `tracking_number` instead of
|
|
98
|
+
* `shipping_tracking_number` would otherwise submit, finally, a response
|
|
99
|
+
* missing the field they relied on.
|
|
100
|
+
*/
|
|
101
|
+
export const disputeEvidenceParams = z
|
|
102
|
+
.object({
|
|
103
|
+
...Object.fromEntries(DISPUTE_TEXT_EVIDENCE_FIELDS.map((field) => [field, textEvidence])),
|
|
104
|
+
...Object.fromEntries(DISPUTE_FILE_EVIDENCE_FIELDS.map((field) => [field, fileEvidence])),
|
|
105
|
+
})
|
|
106
|
+
.strict()
|
|
107
|
+
.describe('Any subset of the fields: a text field is your words (at most 20,000 characters), a file field a `file_…` of purpose `dispute_evidence`. `""` unsets a field.');
|
|
108
|
+
/**
|
|
109
|
+
* `submit: false` (the default) STAGES the evidence: text goes to the provider
|
|
110
|
+
* as a draft, files are attached by id. `submit: true` uploads the attached
|
|
111
|
+
* files and submits everything — ONCE; a second submission is refused.
|
|
112
|
+
*/
|
|
113
|
+
export const updateDisputeParams = z
|
|
114
|
+
.object({
|
|
115
|
+
evidence: disputeEvidenceParams.optional(),
|
|
116
|
+
metadata: metadataUpdateParam.optional(),
|
|
117
|
+
submit: z.boolean().optional(),
|
|
118
|
+
})
|
|
119
|
+
.strict();
|
|
120
|
+
export const closeDisputeParams = z.object({}).strict();
|
|
121
|
+
export const listDisputesQuery = listQuery({
|
|
122
|
+
payment_intent: idParam.optional().describe("Only this payment's disputes (`pi_…`)."),
|
|
123
|
+
charge: idParam.optional().describe("Only this charge's disputes (`ch_…`)."),
|
|
124
|
+
});
|
|
125
|
+
/** The per-payment sub-list: the payment is in the path. */
|
|
126
|
+
export const listPaymentIntentDisputesQuery = listQuery({});
|
|
127
|
+
const disputeId = { disputeId: 'The dispute (`dp_…`).' };
|
|
128
|
+
export const disputeRoutes = [
|
|
129
|
+
defineRoute({
|
|
130
|
+
operationId: 'listPaymentIntentDisputes',
|
|
131
|
+
method: 'get',
|
|
132
|
+
path: '/v1/payment_intents/{intentId}/disputes',
|
|
133
|
+
tag: 'Disputes',
|
|
134
|
+
summary: "List a payment's disputes",
|
|
135
|
+
auth: 'service',
|
|
136
|
+
scope: 'payments:read',
|
|
137
|
+
params: { intentId: 'The payment intent (`pi_…`).' },
|
|
138
|
+
query: listPaymentIntentDisputesQuery,
|
|
139
|
+
response: listOf(disputeSchema),
|
|
140
|
+
sdk: 'disputes.listForPaymentIntent',
|
|
141
|
+
expandable: 'dispute',
|
|
142
|
+
}),
|
|
143
|
+
defineRoute({
|
|
144
|
+
operationId: 'listDisputes',
|
|
145
|
+
method: 'get',
|
|
146
|
+
path: '/v1/disputes',
|
|
147
|
+
tag: 'Disputes',
|
|
148
|
+
summary: 'List disputes',
|
|
149
|
+
auth: 'service',
|
|
150
|
+
scope: 'payments:read',
|
|
151
|
+
query: listDisputesQuery,
|
|
152
|
+
response: listOf(disputeSchema),
|
|
153
|
+
sdk: 'disputes.list',
|
|
154
|
+
expandable: 'dispute',
|
|
155
|
+
}),
|
|
156
|
+
defineRoute({
|
|
157
|
+
operationId: 'retrieveDispute',
|
|
158
|
+
method: 'get',
|
|
159
|
+
path: '/v1/disputes/{disputeId}',
|
|
160
|
+
tag: 'Disputes',
|
|
161
|
+
summary: 'Retrieve a dispute',
|
|
162
|
+
description: 'The one read that carries `evidence`, read live from the provider.',
|
|
163
|
+
auth: 'service',
|
|
164
|
+
scope: 'payments:read',
|
|
165
|
+
params: disputeId,
|
|
166
|
+
query: expandOnlyQuery,
|
|
167
|
+
response: disputeSchema,
|
|
168
|
+
sdk: 'disputes.retrieve',
|
|
169
|
+
expandable: 'dispute',
|
|
170
|
+
}),
|
|
171
|
+
defineRoute({
|
|
172
|
+
operationId: 'updateDispute',
|
|
173
|
+
method: 'post',
|
|
174
|
+
path: '/v1/disputes/{disputeId}',
|
|
175
|
+
tag: 'Disputes',
|
|
176
|
+
summary: 'Update a dispute',
|
|
177
|
+
description: 'Metadata, a staged draft of evidence, or — with `submit: true` — the one submission. A dispute that no longer takes evidence answers 409.',
|
|
178
|
+
auth: 'service',
|
|
179
|
+
scope: 'payments:write',
|
|
180
|
+
idempotent: true,
|
|
181
|
+
params: disputeId,
|
|
182
|
+
body: updateDisputeParams,
|
|
183
|
+
response: disputeSchema,
|
|
184
|
+
sdk: 'disputes.update',
|
|
185
|
+
}),
|
|
186
|
+
defineRoute({
|
|
187
|
+
operationId: 'closeDispute',
|
|
188
|
+
method: 'post',
|
|
189
|
+
path: '/v1/disputes/{disputeId}/close',
|
|
190
|
+
tag: 'Disputes',
|
|
191
|
+
summary: 'Close a dispute',
|
|
192
|
+
description: 'Accept the dispute: it is lost.',
|
|
193
|
+
auth: 'service',
|
|
194
|
+
scope: 'payments:write',
|
|
195
|
+
idempotent: true,
|
|
196
|
+
params: disputeId,
|
|
197
|
+
body: closeDisputeParams,
|
|
198
|
+
response: disputeSchema,
|
|
199
|
+
sdk: 'disputes.close',
|
|
200
|
+
}),
|
|
201
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { chargeRoutes } from './charges.js';
|
|
2
|
+
import { disputeRoutes } from './disputes.js';
|
|
3
|
+
import { paymentIntentRoutes } from './paymentIntents.js';
|
|
4
|
+
import { refundRoutes } from './refunds.js';
|
|
5
|
+
import { setupIntentRoutes } from './setupIntents.js';
|
|
6
|
+
import { socialRoutes } from './social.js';
|
|
7
|
+
import { paymentIntentTestHelperRoutes } from './testHelpers.js';
|
|
8
|
+
export * from './charges.js';
|
|
9
|
+
export * from './disputes.js';
|
|
10
|
+
export * from './paymentIntents.js';
|
|
11
|
+
export * from './refunds.js';
|
|
12
|
+
export * from './setupIntents.js';
|
|
13
|
+
export * from './social.js';
|
|
14
|
+
export * from './testHelpers.js';
|
|
15
|
+
/** Payment intents, charges, refunds, disputes, setup intents, social payments. */
|
|
16
|
+
export const paymentsRoutes = [
|
|
17
|
+
...paymentIntentRoutes,
|
|
18
|
+
...chargeRoutes,
|
|
19
|
+
...refundRoutes,
|
|
20
|
+
...disputeRoutes,
|
|
21
|
+
...setupIntentRoutes,
|
|
22
|
+
...socialRoutes,
|
|
23
|
+
...paymentIntentTestHelperRoutes,
|
|
24
|
+
];
|