@peable.to/shared-types 0.13.0 → 0.15.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/account.js +23 -0
- package/dist/cjs/balance.js +39 -0
- package/dist/cjs/dispute.js +76 -0
- package/dist/cjs/file.js +44 -0
- package/dist/cjs/index.js +27 -1
- package/dist/cjs/money.js +36 -4
- package/dist/cjs/paymentMethodConfiguration.js +54 -0
- package/dist/cjs/settlement.js +3 -0
- package/dist/esm/account.js +20 -0
- package/dist/esm/balance.js +36 -0
- package/dist/esm/dispute.js +74 -1
- package/dist/esm/file.js +41 -0
- package/dist/esm/index.js +7 -1
- package/dist/esm/money.js +35 -3
- package/dist/esm/paymentMethodConfiguration.js +51 -0
- package/dist/esm/settlement.js +2 -1
- package/dist/types/account.d.ts +120 -0
- package/dist/types/balance.d.ts +204 -0
- package/dist/types/charge.d.ts +8 -1
- package/dist/types/dispute.d.ts +106 -99
- package/dist/types/event.d.ts +27 -2
- package/dist/types/file.d.ts +78 -0
- package/dist/types/index.d.ts +9 -4
- package/dist/types/merchant.d.ts +7 -0
- package/dist/types/merchantDisplay.d.ts +2 -0
- package/dist/types/money.d.ts +11 -3
- package/dist/types/paymentIntent.d.ts +57 -3
- package/dist/types/paymentMethodConfiguration.d.ts +116 -0
- package/dist/types/settlement.d.ts +39 -12
- package/package.json +1 -1
package/dist/types/event.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Account } from './account';
|
|
2
|
+
import type { ApplicationFee, Balance, Payout } from './balance';
|
|
1
3
|
import type { Charge } from './charge';
|
|
2
4
|
import type { Coupon, Price, Product, PromotionCode } from './catalog';
|
|
3
5
|
import type { Customer } from './customer';
|
|
@@ -44,8 +46,10 @@ export interface BillingObservation {
|
|
|
44
46
|
* Refunds are not PaymentIntent statuses: `refund.created|updated|failed` carry
|
|
45
47
|
* the Refund, and `charge.refunded` the Charge whose `amount_refunded` moved.
|
|
46
48
|
* A dispute is the network's process beside a payment that stays `succeeded`:
|
|
47
|
-
* `charge.dispute.created` is a DEADLINE (evidence is due), `
|
|
48
|
-
* the outcome
|
|
49
|
+
* `charge.dispute.created` is a DEADLINE (evidence is due), `updated` follows
|
|
50
|
+
* a staged or submitted response, `closed` carries the outcome, and
|
|
51
|
+
* `funds_withdrawn` / `funds_reinstated` the money's movement — never the
|
|
52
|
+
* evidence, which is not stored and so is never in an event.
|
|
49
53
|
*/
|
|
50
54
|
export interface WebhookEventPayload {
|
|
51
55
|
'payment_intent.created': PaymentIntent;
|
|
@@ -59,6 +63,10 @@ export interface WebhookEventPayload {
|
|
|
59
63
|
'charge.dispute.created': Dispute;
|
|
60
64
|
'charge.dispute.updated': Dispute;
|
|
61
65
|
'charge.dispute.closed': Dispute;
|
|
66
|
+
/** The network took the disputed amount from the balance. */
|
|
67
|
+
'charge.dispute.funds_withdrawn': Dispute;
|
|
68
|
+
/** The network returned it (the dispute was won, or withdrawn by the cardholder). */
|
|
69
|
+
'charge.dispute.funds_reinstated': Dispute;
|
|
62
70
|
'refund.created': Refund;
|
|
63
71
|
'refund.updated': Refund;
|
|
64
72
|
'refund.failed': Refund;
|
|
@@ -99,6 +107,23 @@ export interface WebhookEventPayload {
|
|
|
99
107
|
* intent.
|
|
100
108
|
*/
|
|
101
109
|
'connected_account.updated': ConnectedAccount;
|
|
110
|
+
/**
|
|
111
|
+
* The merchant's OWN fiat account changed (ADR 0015 §1) — readiness,
|
|
112
|
+
* requirements, settings. Emitted when a field the merchant acts on moved.
|
|
113
|
+
*/
|
|
114
|
+
'account.updated': Account;
|
|
115
|
+
/** Orbit's fee was taken on a succeeded charge (ADR 0015 §3). */
|
|
116
|
+
'application_fee.created': ApplicationFee;
|
|
117
|
+
/** Part or all of a fee went back (a refund with `refund_application_fee`). */
|
|
118
|
+
'application_fee.refunded': ApplicationFee;
|
|
119
|
+
/** A payout of the merchant's account, mirrored from the provider (ADR 0015 §5). */
|
|
120
|
+
'payout.created': Payout;
|
|
121
|
+
'payout.updated': Payout;
|
|
122
|
+
'payout.paid': Payout;
|
|
123
|
+
'payout.failed': Payout;
|
|
124
|
+
'payout.canceled': Payout;
|
|
125
|
+
/** Funds became available in the account; carries the balance read from the ledger. */
|
|
126
|
+
'balance.available': Balance;
|
|
102
127
|
'billing.observation.updated': BillingObservation;
|
|
103
128
|
/**
|
|
104
129
|
* A synthetic event sent to ONE endpoint when its owner asks to test it
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a file is FOR. Decided at upload and never changed: the purpose is what
|
|
3
|
+
* sets the type and size policy, who may see the bytes, and which objects may
|
|
4
|
+
* reference the file — a `business_logo` is public, a `dispute_evidence` file
|
|
5
|
+
* is private and can only be attached to the merchant's own disputes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FILE_PURPOSES: readonly ["dispute_evidence", "business_logo", "identity_document", "additional_verification"];
|
|
8
|
+
export type FilePurpose = (typeof FILE_PURPOSES)[number];
|
|
9
|
+
/** The stored format, by its conventional extension (Stripe's `type`). */
|
|
10
|
+
export declare const FILE_TYPES: readonly ["pdf", "png", "jpg"];
|
|
11
|
+
export type FileType = (typeof FILE_TYPES)[number];
|
|
12
|
+
/**
|
|
13
|
+
* Whether the bytes can be used right now.
|
|
14
|
+
*
|
|
15
|
+
* - `available` — Oxy serves the file; it can be shown or forwarded.
|
|
16
|
+
* - `withheld` — the file still exists and is not being served (its owner
|
|
17
|
+
* trashed it or made it private); it can come back.
|
|
18
|
+
* - `removed` — Oxy said the file is gone for good (deleted, taken down, lost).
|
|
19
|
+
* The object stays so whatever referenced it can say why it stopped working.
|
|
20
|
+
*/
|
|
21
|
+
export declare const FILE_STATUSES: readonly ["available", "withheld", "removed"];
|
|
22
|
+
export type FileStatus = (typeof FILE_STATUSES)[number];
|
|
23
|
+
/**
|
|
24
|
+
* The upload policy of each purpose: the formats it takes, recognised from the
|
|
25
|
+
* bytes and never from a client's `Content-Type`, and the largest file.
|
|
26
|
+
*
|
|
27
|
+
* The provider's own ceilings, restated where the upload is parsed, so a file
|
|
28
|
+
* the card network would refuse is refused at upload — not at the one-shot
|
|
29
|
+
* dispute submission it was meant for.
|
|
30
|
+
*/
|
|
31
|
+
export declare const FILE_PURPOSE_POLICIES: Readonly<Record<FilePurpose, {
|
|
32
|
+
readonly types: readonly FileType[];
|
|
33
|
+
readonly max_bytes: number;
|
|
34
|
+
}>>;
|
|
35
|
+
/**
|
|
36
|
+
* The API's `file` object. Named `FileObject` rather than `File` so it never
|
|
37
|
+
* shadows the DOM's `File` in a browser that imports both.
|
|
38
|
+
*/
|
|
39
|
+
export interface FileObject {
|
|
40
|
+
/** `file_…`. */
|
|
41
|
+
id: string;
|
|
42
|
+
object: 'file';
|
|
43
|
+
/** The mode of the merchant that uploaded it (ADR 0017). */
|
|
44
|
+
livemode: boolean;
|
|
45
|
+
purpose: FilePurpose;
|
|
46
|
+
/** The name it was uploaded with, if it had a printable one. */
|
|
47
|
+
filename: string | null;
|
|
48
|
+
/** Bytes. */
|
|
49
|
+
size: number;
|
|
50
|
+
type: FileType;
|
|
51
|
+
status: FileStatus;
|
|
52
|
+
/**
|
|
53
|
+
* A public URL for a `business_logo` that is `available` — what a payer
|
|
54
|
+
* surface renders. `null` for every other purpose: evidence and identity
|
|
55
|
+
* documents are never addressable by URL, and their bytes leave Peable only
|
|
56
|
+
* to the provider they are submitted to.
|
|
57
|
+
*/
|
|
58
|
+
url: string | null;
|
|
59
|
+
created: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `POST /v1/files` — exactly one source:
|
|
63
|
+
*
|
|
64
|
+
* - the bytes, as `multipart/form-data` with a `purpose` field and a `file`
|
|
65
|
+
* part (the SDK's `files.create({ purpose, file })` builds it);
|
|
66
|
+
* - `oxy_file`: as JSON, an Oxy file the caller already owns (their
|
|
67
|
+
* application's, or an account they are or act for). Its ownership is
|
|
68
|
+
* checked once, here, and never again.
|
|
69
|
+
*/
|
|
70
|
+
export interface CreateFileFromOxyParams {
|
|
71
|
+
purpose: FilePurpose;
|
|
72
|
+
/** Oxy file id. */
|
|
73
|
+
oxy_file: string;
|
|
74
|
+
}
|
|
75
|
+
/** `GET /v1/files`. */
|
|
76
|
+
export interface ListFilesParams {
|
|
77
|
+
purpose?: FilePurpose;
|
|
78
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { UNITS_PER_COIN, isBaseUnitString, type CurrencyCode, CURRENCY_CODES, CURRENCY_DECIMALS, decimalsFor, isCurrencyCode, } from './money';
|
|
1
|
+
export { UNITS_PER_COIN, isBaseUnitString, type CurrencyCode, type FiatCurrencyCode, CURRENCY_CODES, CURRENCY_DECIMALS, FIAT_CURRENCY_CODES, decimalsFor, isCurrencyCode, } from './money';
|
|
2
2
|
export type { NetworkType } from './network';
|
|
3
3
|
export type { ExpandParams, List, ListParams, RangeQuery } from './list';
|
|
4
|
-
export { type Address, type AddressParams, type CancelPaymentIntentParams, type CapturePaymentIntentParams, type ConfirmPaymentIntentParams, type CreatePaymentIntentParams, type PaymentIntent, type PaymentIntentCancellationReason, type PaymentIntentCaptureMethod, type PaymentIntentFaircoin, type PaymentIntentLastPaymentError, type PaymentIntentNextAction, type PaymentIntentRail, type PaymentIntentSetupFutureUsage, type PaymentIntentStatus, type PaymentMethodType, type Shipping, type ShippingParams, type UpdatePaymentIntentParams, CARD_ONLY_STATUSES, EXPIRABLE_STATUSES, MERCHANT_CANCELLATION_REASONS, PAYMENT_INTENT_CANCELLATION_REASONS, PAYMENT_INTENT_CAPTURE_METHODS, PAYMENT_INTENT_RAILS, PAYMENT_INTENT_SETUP_FUTURE_USAGES, PAYMENT_INTENT_STATUSES, TERMINAL_STATUSES, canExpire, canStillBePaid, isValidStatusTransition, } from './paymentIntent';
|
|
4
|
+
export { type Address, type AddressParams, type CancelPaymentIntentParams, type CapturePaymentIntentParams, type ConfirmPaymentIntentParams, type CreatePaymentIntentParams, type PaymentIntent, type PaymentIntentCancellationReason, type PaymentIntentCaptureMethod, type PaymentIntentFaircoin, type PaymentIntentLastPaymentError, type PaymentIntentNextAction, type PaymentIntentRail, type PaymentIntentSetupFutureUsage, type PaymentIntentStatus, type PaymentIntentTransferData, type PaymentMethodType, type Shipping, type ShippingParams, type UpdatePaymentIntentParams, CARD_ONLY_STATUSES, EXPIRABLE_STATUSES, MERCHANT_CANCELLATION_REASONS, PAYMENT_INTENT_CANCELLATION_REASONS, PAYMENT_INTENT_CAPTURE_METHODS, PAYMENT_INTENT_RAILS, PAYMENT_INTENT_SETUP_FUTURE_USAGES, PAYMENT_INTENT_STATUSES, TERMINAL_STATUSES, canExpire, canStillBePaid, isValidStatusTransition, } from './paymentIntent';
|
|
5
5
|
export type { CardDetails, Charge, ChargeOutcome } from './charge';
|
|
6
6
|
export type { CreateCustomerParams, Customer, DeletedCustomer, UpdateCustomerParams, } from './customer';
|
|
7
7
|
export type { AttachPaymentMethodParams, BillingDetails, PaymentMethod, UpdatePaymentMethodParams, } from './paymentMethod';
|
|
@@ -9,8 +9,13 @@ export { type CancelSetupIntentParams, type CreateSetupIntentParams, type SetupI
|
|
|
9
9
|
export { PEABLE_API_VERSION, type WebhookEventType, type WebhookEvent, type WebhookEventPayload, type WebhookEventRequest, type BillingObservation, } from './event';
|
|
10
10
|
export { WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_ENDPOINT_DISABLED_REASONS, WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT, WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS, type WebhookEnabledEvent, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEndpointDisabledReason, type DeletedWebhookEndpoint, type CreateWebhookEndpointParams, type UpdateWebhookEndpointParams, type RollWebhookEndpointSecretParams, } from './webhookEndpoint';
|
|
11
11
|
export { PRICE_BILLING_SCHEMES, PRICE_TIERS_MODES, PRICE_TYPES, RECURRING_INTERVALS, RECURRING_USAGE_TYPES, PRICE_TAX_BEHAVIORS, TRANSFORM_QUANTITY_ROUNDS, COUPON_DURATIONS, CATALOG_LIMITS, type PriceBillingScheme, type PriceTiersMode, type PriceType, type RecurringInterval, type RecurringUsageType, type PriceTaxBehavior, type TransformQuantityRound, type CouponDuration, type ProductMarketingFeature, type Product, type DeletedProduct, type PriceTier, type PriceTransformQuantity, type PriceRecurring, type Price, type Coupon, type DeletedCoupon, type PromotionCodeRestrictions, type PromotionCode, type RecurringParams, type PriceTierParams, type PriceDataParams, type DefaultPriceDataParams, type CreateProductParams, type UpdateProductParams, type ProductListParams, type CreatePriceParams, type UpdatePriceParams, type PriceListParams, type CreateCouponParams, type UpdateCouponParams, type CouponListParams, type CreatePromotionCodeParams, type UpdatePromotionCodeParams, type PromotionCodeListParams, } from './catalog';
|
|
12
|
-
export type
|
|
13
|
-
export
|
|
12
|
+
export { DISPUTE_FILE_EVIDENCE_FIELDS, DISPUTE_REASONS, DISPUTE_TEXT_EVIDENCE_FIELDS, normalizeDisputeReason, type Dispute, type DisputeEvidence, type DisputeEvidenceDetails, type DisputeEvidenceField, type DisputeEvidenceParams, type DisputeFileEvidenceField, type DisputeReason, type DisputeStatus, type DisputeTextEvidenceField, type ListDisputesParams, type UpdateDisputeParams, } from './dispute';
|
|
13
|
+
export { FILE_PURPOSES, FILE_PURPOSE_POLICIES, FILE_STATUSES, FILE_TYPES, type CreateFileFromOxyParams, type FileObject, type FilePurpose, type FileStatus, type FileType, type ListFilesParams, } from './file';
|
|
14
|
+
export { CARD_RAIL_PAYMENT_METHOD_TYPES, PAYMENT_METHOD_CONFIGURATION_TYPES, PAYMENT_METHOD_CURRENCIES, type CardRailPaymentMethodType, type CreatePaymentMethodConfigurationParams, type CreatePaymentMethodDomainParams, type ListPaymentMethodDomainsParams, type PaymentMethodConfiguration, type PaymentMethodConfigurationEntry, type PaymentMethodConfigurationEntryParams, type PaymentMethodConfigurationType, type PaymentMethodDisplayPreference, type PaymentMethodDomain, type PaymentMethodDomainWalletStatus, type PaymentMethodUnavailableReason, type UpdatePaymentMethodConfigurationParams, type UpdatePaymentMethodDomainParams, } from './paymentMethodConfiguration';
|
|
15
|
+
export { PAYOUT_INTERVALS, PAYOUT_WEEKLY_ANCHORS, type Account, type AccountBusinessProfile, type AccountCapabilityStatus, type AccountPayoutSchedule, type AccountRequirements, type AccountSettings, type AccountType, type CreateAccountLinkParams, type PayoutInterval, type PayoutWeeklyAnchor, type UpdateAccountParams, } from './account';
|
|
16
|
+
export { BALANCE_TRANSACTION_STATUSES, BALANCE_TRANSACTION_TYPES, PAYOUT_STATUSES, RECONCILIATION_MISMATCH_KINDS, type ApplicationFee, type Balance, type BalanceAmount, type BalanceTransaction, type BalanceTransactionFeeDetail, type BalanceTransactionStatus, type BalanceTransactionType, type CreatePayoutParams, type FeeRefund, type ListBalanceTransactionsParams, type ListPayoutsParams, type Payout, type PayoutReconciliationReport, type PayoutStatus, type ReconciliationMismatch, type ReconciliationMismatchKind, } from './balance';
|
|
17
|
+
export { REFUND_REASONS } from './settlement';
|
|
18
|
+
export type { CapabilityStatus, ConnectedAccount, ConnectedAccountFaircoin, ConnectedAccountFaircoinStatus, ConnectedAccountRail, CreateRefundParams, Refund, RefundOrigin, RefundReason, RefundStatus, UpdateRefundParams, Settlement, Transfer, TransferReversal, TransferReversalStatus, TransferStatus, TransferWithReversal, } from './settlement';
|
|
14
19
|
export type { WebhookDelivery, WebhookDeliveryStatus, } from './webhookDelivery';
|
|
15
20
|
export { REQUEST_LOG_METHODS, REQUEST_LOG_RETENTION_DAYS, type RequestLog, type RequestLogListParams, type RequestLogMethod, type RequestLogStatusFilter, } from './requestLog';
|
|
16
21
|
export { SIMULATED_FAIRCOIN_OUTCOMES, type SimulatedFaircoinOutcome, type SimulateFaircoinPaymentParams, } from './testHelpers';
|
package/dist/types/merchant.d.ts
CHANGED
|
@@ -35,6 +35,13 @@ export interface Merchant {
|
|
|
35
35
|
* Absent again once Oxy reports the file deleted or taken down.
|
|
36
36
|
*/
|
|
37
37
|
avatar_file_id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The wide wordmark payer surfaces show in their header: a `file_…` of
|
|
40
|
+
* purpose `business_logo`. Beside the avatar, never instead of it — the avatar
|
|
41
|
+
* is the square identity image (Stripe's branding `icon`), the logo is the
|
|
42
|
+
* wordmark (Stripe's branding `logo`). Absent when unset.
|
|
43
|
+
*/
|
|
44
|
+
business_logo?: string;
|
|
38
45
|
description?: string;
|
|
39
46
|
created: number;
|
|
40
47
|
updated_at: number;
|
|
@@ -3,5 +3,7 @@ export interface MerchantDisplay {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** Resolved server-side via the canonical media chokepoint; `null` when the merchant has no avatar. */
|
|
5
5
|
avatar_url: string | null;
|
|
6
|
+
/** The merchant's `business_logo`, resolved; `null` when unset or not being served. */
|
|
7
|
+
logo_url: string | null;
|
|
6
8
|
description: string | null;
|
|
7
9
|
}
|
package/dist/types/money.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The currencies this gateway can denominate a payment in
|
|
2
|
+
* The currencies this gateway can denominate a payment in: FairCoin on the
|
|
3
|
+
* chain rail, and on the card rail the fiat set the provider settles for the
|
|
4
|
+
* payment methods Orbit offers (cards, wallets, SEPA Debit, iDEAL, Bancontact,
|
|
5
|
+
* EPS). A local method narrows it further per payment
|
|
6
|
+
* (`PAYMENT_METHOD_CURRENCIES` in `paymentMethodConfiguration.ts`).
|
|
3
7
|
*
|
|
4
8
|
* A closed set, and the database mirrors it as a CHECK
|
|
5
9
|
* (`db/schema/valueSets.ts`). ADR 0001 D4: the scale of an amount is a property
|
|
@@ -7,7 +11,7 @@
|
|
|
7
11
|
* {@link CURRENCY_DECIMALS} exists and why {@link UNITS_PER_COIN} must never be
|
|
8
12
|
* used to interpret a fiat amount.
|
|
9
13
|
*/
|
|
10
|
-
export declare const CURRENCY_CODES: readonly ["FAIR", "EUR", "USD"];
|
|
14
|
+
export declare const CURRENCY_CODES: readonly ["FAIR", "EUR", "USD", "GBP", "CHF", "SEK", "NOK", "DKK", "PLN", "CZK", "CAD", "AUD", "JPY"];
|
|
11
15
|
export type CurrencyCode = (typeof CURRENCY_CODES)[number];
|
|
12
16
|
/** Whether an arbitrary string is a currency this gateway knows. */
|
|
13
17
|
export declare function isCurrencyCode(value: string): value is CurrencyCode;
|
|
@@ -15,11 +19,15 @@ export declare function isCurrencyCode(value: string): value is CurrencyCode;
|
|
|
15
19
|
* How many decimal places each currency's smallest unit represents — i.e. an
|
|
16
20
|
* amount of `1` means `10^-decimals` of one whole unit.
|
|
17
21
|
*
|
|
18
|
-
* FairCoin's 8 is a consensus constant and is pinned against
|
|
22
|
+
* ISO 4217's minor units for every fiat member (JPY has none). FairCoin's 8 is a consensus constant and is pinned against
|
|
19
23
|
* {@link UNITS_PER_COIN} by this package's own tests, so the two spellings of
|
|
20
24
|
* one fact cannot drift.
|
|
21
25
|
*/
|
|
22
26
|
export declare const CURRENCY_DECIMALS: Readonly<Record<CurrencyCode, number>>;
|
|
27
|
+
/** A currency the card rail can denominate a payment in. */
|
|
28
|
+
export type FiatCurrencyCode = Exclude<CurrencyCode, 'FAIR'>;
|
|
29
|
+
/** The fiat members — every currency the card rail can denominate a payment in. */
|
|
30
|
+
export declare const FIAT_CURRENCY_CODES: readonly FiatCurrencyCode[];
|
|
23
31
|
/** The decimal places of `currency`'s smallest unit. */
|
|
24
32
|
export declare function decimalsFor(currency: CurrencyCode): number;
|
|
25
33
|
export declare const UNITS_PER_COIN = 100000000n;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CardRailPaymentMethodType } from './paymentMethodConfiguration';
|
|
1
2
|
import type { Charge } from './charge';
|
|
2
3
|
import type { Customer } from './customer';
|
|
3
4
|
import type { CurrencyCode } from './money';
|
|
@@ -85,8 +86,12 @@ export declare const PAYMENT_INTENT_CAPTURE_METHODS: readonly PaymentIntentCaptu
|
|
|
85
86
|
/** Card only: keep the payment method on the customer for later (ADR 0016). */
|
|
86
87
|
export type PaymentIntentSetupFutureUsage = 'on_session' | 'off_session';
|
|
87
88
|
export declare const PAYMENT_INTENT_SETUP_FUTURE_USAGES: readonly PaymentIntentSetupFutureUsage[];
|
|
88
|
-
/**
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
|
+
* The payment method types a PaymentIntent can carry: `faircoin` on the chain
|
|
91
|
+
* rail, and on the card rail the card and the local methods the provider
|
|
92
|
+
* collects in its hosted fields. Wallets (Apple Pay, Google Pay) are `card`.
|
|
93
|
+
*/
|
|
94
|
+
export type PaymentMethodType = 'faircoin' | CardRailPaymentMethodType;
|
|
90
95
|
/** Why the last attempt failed. Peable's words, never the provider's raw prose. */
|
|
91
96
|
export interface PaymentIntentLastPaymentError {
|
|
92
97
|
/** `card_error` for a declined card; `payment_error` for a FairCoin underpayment. */
|
|
@@ -176,7 +181,16 @@ export interface PaymentIntent {
|
|
|
176
181
|
status: PaymentIntentStatus;
|
|
177
182
|
/** Which rail moves this payment. Decides which fields below are populated. */
|
|
178
183
|
rail: PaymentIntentRail;
|
|
184
|
+
/**
|
|
185
|
+
* What the payer may pay with: `['faircoin']` on the chain; on the card rail
|
|
186
|
+
* the types named at creation, or those the configuration offers in this
|
|
187
|
+
* currency.
|
|
188
|
+
*/
|
|
179
189
|
payment_method_types: PaymentMethodType[];
|
|
190
|
+
/** The `pmc_…` whose methods this card payment offers; `null` on the chain and when types were named. */
|
|
191
|
+
payment_method_configuration_details: {
|
|
192
|
+
id: string;
|
|
193
|
+
} | null;
|
|
180
194
|
/**
|
|
181
195
|
* Amount in the currency's SMALLEST unit as a canonical integer string.
|
|
182
196
|
* Never a float, and never interpretable without `currency`: m⊜ (10^-8 FAIR)
|
|
@@ -217,6 +231,21 @@ export interface PaymentIntent {
|
|
|
217
231
|
* FairCoin only, and `faircoin.address` derives from that seller's own key.
|
|
218
232
|
*/
|
|
219
233
|
connected_account: string | ConnectedAccount | null;
|
|
234
|
+
/**
|
|
235
|
+
* Orbit's fee on this card payment, taken by the provider from the
|
|
236
|
+
* destination account when the charge succeeds (ADR 0015 §3) — the
|
|
237
|
+
* INSTRUCTION; the fee actually taken is the `application_fee` object.
|
|
238
|
+
* `null` on a platform charge.
|
|
239
|
+
*/
|
|
240
|
+
application_fee_amount: string | null;
|
|
241
|
+
/**
|
|
242
|
+
* A destination charge (ADR 0015 §2): the account (`ca_…`) the funds go to,
|
|
243
|
+
* and the amount transferred when the platform named one. `null` on a
|
|
244
|
+
* platform charge.
|
|
245
|
+
*/
|
|
246
|
+
transfer_data: PaymentIntentTransferData | null;
|
|
247
|
+
/** The account (`ca_…`) that is the merchant of record, or `null` (the platform). */
|
|
248
|
+
on_behalf_of: string | null;
|
|
220
249
|
client_secret: string;
|
|
221
250
|
metadata: Record<string, string>;
|
|
222
251
|
/** When an UNPAID intent expires. Meaningful only while `can_expire`. */
|
|
@@ -226,6 +255,13 @@ export interface PaymentIntent {
|
|
|
226
255
|
created: number;
|
|
227
256
|
updated_at: number;
|
|
228
257
|
}
|
|
258
|
+
/** Where a destination charge's funds go (`transfer_data`). */
|
|
259
|
+
export interface PaymentIntentTransferData {
|
|
260
|
+
/** `ca_…` */
|
|
261
|
+
destination: string;
|
|
262
|
+
/** Base units transferred; `null` means the whole amount less `application_fee_amount`. */
|
|
263
|
+
amount: string | null;
|
|
264
|
+
}
|
|
229
265
|
/** `POST /v1/payment_intents`. */
|
|
230
266
|
export interface CreatePaymentIntentParams {
|
|
231
267
|
/** Amount in the currency's smallest unit, as a canonical integer string. */
|
|
@@ -236,8 +272,13 @@ export interface CreatePaymentIntentParams {
|
|
|
236
272
|
network?: NetworkType;
|
|
237
273
|
/** Defaults to `'FAIR'` on the faircoin rail; required on the card rail. */
|
|
238
274
|
currency?: CurrencyCode;
|
|
239
|
-
/**
|
|
275
|
+
/**
|
|
276
|
+
* `['faircoin']` on the chain rail. On the card rail, any of the card-rail
|
|
277
|
+
* types the provider offers in `currency` — instead of a configuration.
|
|
278
|
+
*/
|
|
240
279
|
payment_method_types?: PaymentMethodType[];
|
|
280
|
+
/** Card only: the `pmc_…` whose methods to offer. Defaults to the merchant's default configuration. */
|
|
281
|
+
payment_method_configuration?: string;
|
|
241
282
|
/** `cus_…`. */
|
|
242
283
|
customer?: string;
|
|
243
284
|
/** `pm_…`, card only. A saved payment method of `customer`. */
|
|
@@ -259,6 +300,19 @@ export interface CreatePaymentIntentParams {
|
|
|
259
300
|
expires_in_seconds?: number;
|
|
260
301
|
/** FairCoin only: pay this seller (`ca_…`, ADR 0012 D5). */
|
|
261
302
|
connected_account?: string;
|
|
303
|
+
/**
|
|
304
|
+
* Card only, a platform acting for one of its connected accounts: Orbit's
|
|
305
|
+
* fee for this payment. Needs `transfer_data` (or `on_behalf_of`); refused
|
|
306
|
+
* beside `transfer_data.amount`.
|
|
307
|
+
*/
|
|
308
|
+
application_fee_amount?: string;
|
|
309
|
+
/** Card only: a destination charge to one of the platform's connected accounts. */
|
|
310
|
+
transfer_data?: {
|
|
311
|
+
destination: string;
|
|
312
|
+
amount?: string;
|
|
313
|
+
};
|
|
314
|
+
/** Card only: make this connected account (`ca_…`) the merchant of record. */
|
|
315
|
+
on_behalf_of?: string;
|
|
262
316
|
/** Card only, with `confirm`: where a redirect-based challenge returns. */
|
|
263
317
|
return_url?: string;
|
|
264
318
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type FiatCurrencyCode } from './money';
|
|
2
|
+
/**
|
|
3
|
+
* The methods a configuration can turn on.
|
|
4
|
+
*
|
|
5
|
+
* `apple_pay` and `google_pay` are WALLETS over a card: a payment made with one
|
|
6
|
+
* is a `card` payment, so they appear here and never in a PaymentIntent's
|
|
7
|
+
* `payment_method_types`. `bizum` is listed because merchants ask for it and the
|
|
8
|
+
* honest answer is a reason, not an absence: the provider does not offer it.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately absent: the provider's own consumer wallet (its brand on Orbit's
|
|
11
|
+
* checkout, `payment-provider-boundary.md`) and giropay (discontinued by the
|
|
12
|
+
* scheme).
|
|
13
|
+
*/
|
|
14
|
+
export declare const PAYMENT_METHOD_CONFIGURATION_TYPES: readonly ["card", "apple_pay", "google_pay", "sepa_debit", "ideal", "bancontact", "eps", "bizum"];
|
|
15
|
+
export type PaymentMethodConfigurationType = (typeof PAYMENT_METHOD_CONFIGURATION_TYPES)[number];
|
|
16
|
+
/** The card-rail types a PaymentIntent can carry in `payment_method_types`. */
|
|
17
|
+
export declare const CARD_RAIL_PAYMENT_METHOD_TYPES: readonly ["card", "sepa_debit", "ideal", "bancontact", "eps"];
|
|
18
|
+
export type CardRailPaymentMethodType = (typeof CARD_RAIL_PAYMENT_METHOD_TYPES)[number];
|
|
19
|
+
/**
|
|
20
|
+
* Why a method cannot be offered whatever the merchant chooses.
|
|
21
|
+
*
|
|
22
|
+
* - `provider_unsupported` — the processing provider does not offer it;
|
|
23
|
+
* - `requires_card` — a wallet rides on card payments, and card is off.
|
|
24
|
+
*/
|
|
25
|
+
export type PaymentMethodUnavailableReason = 'provider_unsupported' | 'requires_card';
|
|
26
|
+
/**
|
|
27
|
+
* The currencies each method can take a payment in. A method is offered on a
|
|
28
|
+
* payment only when its currency is listed — so iDEAL never appears on a USD
|
|
29
|
+
* payment, and a payer is never shown a method that would fail.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PAYMENT_METHOD_CURRENCIES: Readonly<Record<PaymentMethodConfigurationType, readonly FiatCurrencyCode[]>>;
|
|
32
|
+
/** The merchant's choice (`none`: Orbit's default) and what is in effect. */
|
|
33
|
+
export interface PaymentMethodDisplayPreference {
|
|
34
|
+
preference: 'on' | 'off' | 'none';
|
|
35
|
+
value: 'on' | 'off';
|
|
36
|
+
}
|
|
37
|
+
export interface PaymentMethodConfigurationEntry {
|
|
38
|
+
/** Whether payers can be offered this method: it is on and nothing prevents it. */
|
|
39
|
+
available: boolean;
|
|
40
|
+
display_preference: PaymentMethodDisplayPreference;
|
|
41
|
+
/** Why it cannot be offered whatever the merchant chooses; `null` when it can. */
|
|
42
|
+
unavailable_reason: PaymentMethodUnavailableReason | null;
|
|
43
|
+
/** The payment currencies it is offered on. */
|
|
44
|
+
currencies: readonly FiatCurrencyCode[];
|
|
45
|
+
}
|
|
46
|
+
export type PaymentMethodConfiguration = {
|
|
47
|
+
/** `pmc_…`. */
|
|
48
|
+
id: string;
|
|
49
|
+
object: 'payment_method_configuration';
|
|
50
|
+
livemode: boolean;
|
|
51
|
+
name: string;
|
|
52
|
+
/** An inactive configuration cannot be named on a new PaymentIntent. The default is always active. */
|
|
53
|
+
active: boolean;
|
|
54
|
+
/** The configuration a PaymentIntent uses when it names none. Exactly one per merchant. */
|
|
55
|
+
is_default: boolean;
|
|
56
|
+
created: number;
|
|
57
|
+
updated_at: number;
|
|
58
|
+
} & {
|
|
59
|
+
[K in PaymentMethodConfigurationType]: PaymentMethodConfigurationEntry;
|
|
60
|
+
};
|
|
61
|
+
/** One method's setting in a create or update. */
|
|
62
|
+
export interface PaymentMethodConfigurationEntryParams {
|
|
63
|
+
display_preference: {
|
|
64
|
+
preference: 'on' | 'off' | 'none';
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** `POST /v1/payment_method_configurations`. */
|
|
68
|
+
export type CreatePaymentMethodConfigurationParams = {
|
|
69
|
+
name?: string;
|
|
70
|
+
} & {
|
|
71
|
+
[K in PaymentMethodConfigurationType]?: PaymentMethodConfigurationEntryParams;
|
|
72
|
+
};
|
|
73
|
+
/** `POST /v1/payment_method_configurations/:id`. */
|
|
74
|
+
export type UpdatePaymentMethodConfigurationParams = CreatePaymentMethodConfigurationParams & {
|
|
75
|
+
active?: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** A wallet's standing on one domain. */
|
|
78
|
+
export interface PaymentMethodDomainWalletStatus {
|
|
79
|
+
/** `active`: the wallet can run on pages served from this domain. */
|
|
80
|
+
status: 'active' | 'inactive';
|
|
81
|
+
/** Present while `inactive`: what the wallet's verification said, in Peable's words. */
|
|
82
|
+
status_details: {
|
|
83
|
+
error_message: string;
|
|
84
|
+
} | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A web domain the merchant serves payment pages from (`pmd_…`), registered so
|
|
88
|
+
* Apple Pay and Google Pay run there. Peable's own hosted checkout needs none:
|
|
89
|
+
* its domain is Peable's.
|
|
90
|
+
*/
|
|
91
|
+
export interface PaymentMethodDomain {
|
|
92
|
+
id: string;
|
|
93
|
+
object: 'payment_method_domain';
|
|
94
|
+
livemode: boolean;
|
|
95
|
+
/** Lowercase hostname, no scheme, port or path. */
|
|
96
|
+
domain_name: string;
|
|
97
|
+
/** Whether wallets may run on it at all. */
|
|
98
|
+
enabled: boolean;
|
|
99
|
+
apple_pay: PaymentMethodDomainWalletStatus;
|
|
100
|
+
google_pay: PaymentMethodDomainWalletStatus;
|
|
101
|
+
created: number;
|
|
102
|
+
}
|
|
103
|
+
/** `POST /v1/payment_method_domains`. */
|
|
104
|
+
export interface CreatePaymentMethodDomainParams {
|
|
105
|
+
domain_name: string;
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/** `POST /v1/payment_method_domains/:id`. */
|
|
109
|
+
export interface UpdatePaymentMethodDomainParams {
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
}
|
|
112
|
+
/** `GET /v1/payment_method_domains`. */
|
|
113
|
+
export interface ListPaymentMethodDomainsParams {
|
|
114
|
+
domain_name?: string;
|
|
115
|
+
enabled?: boolean;
|
|
116
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AccountRequirements } from './account';
|
|
1
2
|
import type { CurrencyCode } from './money';
|
|
2
3
|
import type { NetworkType } from './network';
|
|
3
4
|
import type { PaymentIntent } from './paymentIntent';
|
|
@@ -84,17 +85,12 @@ export interface ConnectedAccount {
|
|
|
84
85
|
transfers_capability: CapabilityStatus | null;
|
|
85
86
|
card_payments_capability: CapabilityStatus | null;
|
|
86
87
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
88
|
+
* What the provider is waiting on — requirement IDENTIFIERS, never their
|
|
89
|
+
* values (the gateway records that a seller owes a document; it never learns
|
|
90
|
+
* what the document says) — and the provider's own `disabled_reason`. The
|
|
91
|
+
* same shape as `Account.requirements`.
|
|
90
92
|
*/
|
|
91
|
-
requirements:
|
|
92
|
-
currently_due: number;
|
|
93
|
-
eventually_due: number;
|
|
94
|
-
past_due: number;
|
|
95
|
-
pending_verification: number;
|
|
96
|
-
};
|
|
97
|
-
disabled_reason_codes: readonly string[];
|
|
93
|
+
requirements: AccountRequirements;
|
|
98
94
|
last_synced_at: number | null;
|
|
99
95
|
created: number;
|
|
100
96
|
updated_at: number;
|
|
@@ -203,8 +199,15 @@ export interface Settlement {
|
|
|
203
199
|
/** Present only when a conversion happened. `null` is not a rate of 1. */
|
|
204
200
|
exchange_rate: number | null;
|
|
205
201
|
}
|
|
206
|
-
/**
|
|
207
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Where one refund stands — the MONEY's own lifecycle, not the payment's.
|
|
204
|
+
* `canceled` only through `POST /v1/refunds/:id/cancel`, where the provider
|
|
205
|
+
* still allows it.
|
|
206
|
+
*/
|
|
207
|
+
export type RefundStatus = 'pending' | 'succeeded' | 'failed' | 'canceled';
|
|
208
|
+
/** Stripe's refund reasons. */
|
|
209
|
+
export declare const REFUND_REASONS: readonly ["duplicate", "fraudulent", "requested_by_customer"];
|
|
210
|
+
export type RefundReason = (typeof REFUND_REASONS)[number];
|
|
208
211
|
/**
|
|
209
212
|
* Who created a refund.
|
|
210
213
|
*
|
|
@@ -229,7 +232,31 @@ export interface Refund {
|
|
|
229
232
|
amount: string;
|
|
230
233
|
currency: CurrencyCode | string;
|
|
231
234
|
status: RefundStatus;
|
|
235
|
+
reason: RefundReason | null;
|
|
232
236
|
failure_code: string | null;
|
|
237
|
+
metadata: Record<string, string>;
|
|
233
238
|
created: number;
|
|
234
239
|
updated_at: number;
|
|
235
240
|
}
|
|
241
|
+
/** `POST /v1/refunds`. */
|
|
242
|
+
export interface CreateRefundParams {
|
|
243
|
+
/** The `pi_…` being refunded. */
|
|
244
|
+
payment_intent: string;
|
|
245
|
+
/** YOUR id for this refund. The idempotency. */
|
|
246
|
+
external_ref: string;
|
|
247
|
+
/** Minor units, as a canonical integer string. Zero is refused. */
|
|
248
|
+
amount: string;
|
|
249
|
+
reason?: RefundReason;
|
|
250
|
+
metadata?: Record<string, string>;
|
|
251
|
+
/**
|
|
252
|
+
* Also refund Orbit's application fee, in proportion to the amount refunded
|
|
253
|
+
* (a payment that carried one: a destination charge, ADR 0015 §2).
|
|
254
|
+
*/
|
|
255
|
+
refund_application_fee?: boolean;
|
|
256
|
+
/** Also reverse the transfer to the destination account, in proportion. */
|
|
257
|
+
reverse_transfer?: boolean;
|
|
258
|
+
}
|
|
259
|
+
/** `POST /v1/refunds/:id` — the merchant's own bookkeeping; `metadata` is a patch. */
|
|
260
|
+
export interface UpdateRefundParams {
|
|
261
|
+
metadata?: Record<string, string>;
|
|
262
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peable.to/shared-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Shared TypeScript types for the Peable Gateway — the wire contract shared by the backend, SDK, and frontend.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|