@peable.to/shared-types 0.10.0 → 0.12.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/catalog.js +53 -0
- package/dist/cjs/charge.js +2 -0
- package/dist/cjs/customer.js +2 -0
- package/dist/cjs/event.js +7 -0
- package/dist/cjs/index.js +29 -8
- package/dist/cjs/paymentIntent.js +90 -188
- package/dist/cjs/paymentMethod.js +2 -0
- package/dist/cjs/setupIntent.js +11 -0
- package/dist/cjs/webhookEndpoint.js +20 -0
- package/dist/cjs/webhookSigner.js +35 -12
- package/dist/esm/catalog.js +50 -0
- package/dist/esm/charge.js +1 -0
- package/dist/esm/customer.js +1 -0
- package/dist/esm/event.js +6 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/paymentIntent.js +89 -186
- package/dist/esm/paymentMethod.js +1 -0
- package/dist/esm/setupIntent.js +8 -0
- package/dist/esm/webhookEndpoint.js +17 -0
- package/dist/esm/webhookSigner.js +35 -12
- package/dist/types/catalog.d.ts +390 -0
- package/dist/types/charge.d.ts +56 -0
- package/dist/types/customer.d.ts +39 -0
- package/dist/types/dispute.d.ts +2 -2
- package/dist/types/event.d.ts +120 -89
- package/dist/types/index.d.ts +8 -2
- package/dist/types/merchant.d.ts +0 -1
- package/dist/types/paymentIntent.d.ts +215 -84
- package/dist/types/paymentMethod.d.ts +33 -0
- package/dist/types/settlement.d.ts +0 -9
- package/dist/types/setupIntent.d.ts +39 -0
- package/dist/types/webhookDelivery.d.ts +15 -32
- package/dist/types/webhookEndpoint.d.ts +81 -0
- package/dist/types/webhookSigner.d.ts +13 -5
- package/package.json +1 -1
package/dist/types/event.d.ts
CHANGED
|
@@ -1,73 +1,18 @@
|
|
|
1
|
+
import type { Charge } from './charge';
|
|
2
|
+
import type { Coupon, Price, Product, PromotionCode } from './catalog';
|
|
3
|
+
import type { Customer } from './customer';
|
|
1
4
|
import type { Dispute } from './dispute';
|
|
2
5
|
import type { PaymentIntent } from './paymentIntent';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
6
|
+
import type { PaymentMethod } from './paymentMethod';
|
|
7
|
+
import type { ConnectedAccount, Refund } from './settlement';
|
|
8
|
+
import type { SetupIntent } from './setupIntent';
|
|
9
|
+
import type { WebhookEndpoint } from './webhookEndpoint';
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* from the provider's own dashboard, or a dispute the network resolved
|
|
10
|
-
* against the merchant. A merchant who only ever learned about their own
|
|
11
|
-
* refunds would reconcile to a balance that disagrees with the provider's,
|
|
12
|
-
* with nothing to explain the difference.
|
|
13
|
-
*
|
|
14
|
-
* Additive to a published contract: an existing consumer that switches on
|
|
15
|
-
* this union keeps compiling and simply never matches them.
|
|
16
|
-
*/
|
|
17
|
-
| 'payment_intent.refunded' | 'payment_intent.partially_refunded'
|
|
18
|
-
/**
|
|
19
|
-
* The network is holding this payment's money while a cardholder contests it.
|
|
20
|
-
*
|
|
21
|
-
* Two events and not one because the two moments demand different things of a
|
|
22
|
-
* merchant. `disputed` is a DEADLINE — evidence is due, and a merchant who
|
|
23
|
-
* learns about it late has already lost. `dispute_closed` carries the outcome,
|
|
24
|
-
* which is when the money is finally theirs or finally gone.
|
|
25
|
-
*
|
|
26
|
-
* Neither is a payment-intent STATUS. A dispute is the network's process, not
|
|
27
|
-
* a stage of the payment's lifecycle — the payment stayed `settled` throughout
|
|
28
|
-
* and may end there. That is also how Stripe models it: a charge is
|
|
29
|
-
* `disputed`, a PaymentIntent has no such status.
|
|
30
|
-
*
|
|
31
|
-
* These two carry a {@link Dispute} as their `data.object`, NOT the payment
|
|
32
|
-
* intent — see {@link WebhookEventPayload}. The `paymentIntentId` on it is
|
|
33
|
-
* how a consumer gets back to the payment.
|
|
34
|
-
*
|
|
35
|
-
* Additive to a published contract: an existing consumer that switches on
|
|
36
|
-
* this union keeps compiling and simply never matches them.
|
|
37
|
-
*/
|
|
38
|
-
| 'payment_intent.disputed' | 'payment_intent.dispute_closed'
|
|
39
|
-
/**
|
|
40
|
-
* A seller's account changed — their READINESS, in practice.
|
|
41
|
-
*
|
|
42
|
-
* The first event here that is not about a payment, and it exists because
|
|
43
|
-
* readiness is the one fact about a seller a marketplace cannot act without
|
|
44
|
-
* and could not learn: the gateway refreshed the account row from the
|
|
45
|
-
* provider and told the merchant nothing, so the only ways to find out a
|
|
46
|
-
* seller had finished onboarding were to poll `GET /v1/connected_accounts`
|
|
47
|
-
* or to attempt a settlement and read the refusal.
|
|
48
|
-
*
|
|
49
|
-
* Emitted when the fields a merchant ACTS on change — payability, the two
|
|
50
|
-
* capabilities, the requirement counts, the disabled reasons — and not on
|
|
51
|
-
* every refresh. A periodic sync sweep re-reads every account whether or not
|
|
52
|
-
* anything moved, and an event per sweep would be a stream a merchant learns
|
|
53
|
-
* to ignore.
|
|
54
|
-
*
|
|
55
|
-
* It carries a {@link ConnectedAccount} and its delivery names NO payment
|
|
56
|
-
* intent, which is why `WebhookDelivery.intentId` is nullable.
|
|
57
|
-
*
|
|
58
|
-
* Additive to a published contract: an existing consumer that switches on
|
|
59
|
-
* this union keeps compiling and simply never matches it.
|
|
60
|
-
*/
|
|
61
|
-
| 'connected_account.updated' | 'billing.observation.updated';
|
|
62
|
-
/**
|
|
63
|
-
* Which resource each event type carries under `data.object`.
|
|
64
|
-
*
|
|
65
|
-
* TOTAL over `WebhookEventType`, so a new event type cannot be added without
|
|
66
|
-
* saying what it delivers. That matters more here than anywhere else in this
|
|
67
|
-
* contract: `data.object` is the whole payload, and an event type added with
|
|
68
|
-
* the default would silently ship a PaymentIntent to a consumer expecting
|
|
69
|
-
* something else — which typechecks on both sides and fails only in production.
|
|
11
|
+
* The wire date every response names in `Peable-Version`, and the
|
|
12
|
+
* `api_version` an event is stored under (ADR 0014 D2/D4). One constant, so
|
|
13
|
+
* the header and the stored events cannot name two different wires.
|
|
70
14
|
*/
|
|
15
|
+
export declare const PEABLE_API_VERSION = "2026-11-03";
|
|
71
16
|
/** Wake-up only. Re-read the owner-bound SDK resource; this is never paid or grant authority. */
|
|
72
17
|
export interface BillingObservation {
|
|
73
18
|
object: 'billing_observation';
|
|
@@ -80,18 +25,101 @@ export interface BillingObservation {
|
|
|
80
25
|
revision: number;
|
|
81
26
|
observed_at: number;
|
|
82
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Which resource each event type carries under `data.object`.
|
|
30
|
+
*
|
|
31
|
+
* TOTAL over {@link WebhookEventType} (which is derived from its keys), so a new
|
|
32
|
+
* event type cannot exist without saying what it delivers: an event added with
|
|
33
|
+
* a default would silently ship a PaymentIntent to a consumer expecting
|
|
34
|
+
* something else — which typechecks on both sides and fails only in production.
|
|
35
|
+
*
|
|
36
|
+
* The `payment_intent.*` events follow the status the intent reached
|
|
37
|
+
* (ADR 0019): `created` when it is minted, then one per transition —
|
|
38
|
+
* `requires_action`, `processing`, `amount_capturable_updated` (authorized,
|
|
39
|
+
* awaiting capture), `succeeded`, `payment_failed` (an attempt failed; a card
|
|
40
|
+
* returns to `requires_payment_method`, a FairCoin underpayment is also
|
|
41
|
+
* `canceled`) and `canceled` (by the merchant, by expiry — `abandoned` — or
|
|
42
|
+
* underpaid).
|
|
43
|
+
*
|
|
44
|
+
* Refunds are not PaymentIntent statuses: `refund.created|updated|failed` carry
|
|
45
|
+
* the Refund, and `charge.refunded` the Charge whose `amount_refunded` moved.
|
|
46
|
+
* A dispute is the network's process beside a payment that stays `succeeded`:
|
|
47
|
+
* `charge.dispute.created` is a DEADLINE (evidence is due), `closed` carries
|
|
48
|
+
* the outcome.
|
|
49
|
+
*/
|
|
83
50
|
export interface WebhookEventPayload {
|
|
84
|
-
'
|
|
85
|
-
'payment_intent.
|
|
86
|
-
'payment_intent.
|
|
87
|
-
'payment_intent.
|
|
88
|
-
'payment_intent.
|
|
89
|
-
'payment_intent.
|
|
90
|
-
'payment_intent.
|
|
91
|
-
'
|
|
92
|
-
'
|
|
93
|
-
'
|
|
51
|
+
'payment_intent.created': PaymentIntent;
|
|
52
|
+
'payment_intent.requires_action': PaymentIntent;
|
|
53
|
+
'payment_intent.processing': PaymentIntent;
|
|
54
|
+
'payment_intent.amount_capturable_updated': PaymentIntent;
|
|
55
|
+
'payment_intent.succeeded': PaymentIntent;
|
|
56
|
+
'payment_intent.payment_failed': PaymentIntent;
|
|
57
|
+
'payment_intent.canceled': PaymentIntent;
|
|
58
|
+
'charge.refunded': Charge;
|
|
59
|
+
'charge.dispute.created': Dispute;
|
|
60
|
+
'charge.dispute.updated': Dispute;
|
|
61
|
+
'charge.dispute.closed': Dispute;
|
|
62
|
+
'refund.created': Refund;
|
|
63
|
+
'refund.updated': Refund;
|
|
64
|
+
'refund.failed': Refund;
|
|
65
|
+
'customer.created': Customer;
|
|
66
|
+
'customer.updated': Customer;
|
|
67
|
+
'customer.deleted': Customer;
|
|
68
|
+
'payment_method.attached': PaymentMethod;
|
|
69
|
+
'payment_method.detached': PaymentMethod;
|
|
70
|
+
'payment_method.updated': PaymentMethod;
|
|
71
|
+
'setup_intent.created': SetupIntent;
|
|
72
|
+
'setup_intent.requires_action': SetupIntent;
|
|
73
|
+
'setup_intent.succeeded': SetupIntent;
|
|
74
|
+
'setup_intent.setup_failed': SetupIntent;
|
|
75
|
+
'setup_intent.canceled': SetupIntent;
|
|
76
|
+
/**
|
|
77
|
+
* The catalog (ADR 0018): each create, update and delete of a product,
|
|
78
|
+
* price, coupon or promotion code, carrying the object as it stands after
|
|
79
|
+
* the change (a deleted one as it stood before). An update names the moved
|
|
80
|
+
* fields in `data.previous_attributes`; an update that moved nothing records
|
|
81
|
+
* no event. Prices and promotion codes are never deleted — they are archived
|
|
82
|
+
* with `active: false` — so there is no `price.deleted` or
|
|
83
|
+
* `promotion_code.deleted`: a type that can never be sent is a promise the
|
|
84
|
+
* catalog cannot keep.
|
|
85
|
+
*/
|
|
86
|
+
'product.created': Product;
|
|
87
|
+
'product.updated': Product;
|
|
88
|
+
'product.deleted': Product;
|
|
89
|
+
'price.created': Price;
|
|
90
|
+
'price.updated': Price;
|
|
91
|
+
'coupon.created': Coupon;
|
|
92
|
+
'coupon.updated': Coupon;
|
|
93
|
+
'coupon.deleted': Coupon;
|
|
94
|
+
'promotion_code.created': PromotionCode;
|
|
95
|
+
'promotion_code.updated': PromotionCode;
|
|
96
|
+
/**
|
|
97
|
+
* A seller's account changed — their READINESS, in practice. Emitted when the
|
|
98
|
+
* fields a merchant ACTS on change, not on every refresh. It names no payment
|
|
99
|
+
* intent.
|
|
100
|
+
*/
|
|
94
101
|
'connected_account.updated': ConnectedAccount;
|
|
102
|
+
'billing.observation.updated': BillingObservation;
|
|
103
|
+
/**
|
|
104
|
+
* A synthetic event sent to ONE endpoint when its owner asks to test it
|
|
105
|
+
* (Orbit's "send test event"). Stored like any other event, but it never fans
|
|
106
|
+
* out and it cannot be subscribed to: `enabled_events` refuses it. The
|
|
107
|
+
* endpoint being tested, as `GET /v1/webhook_endpoints/:id` returns it.
|
|
108
|
+
*/
|
|
109
|
+
'webhook_endpoint.test': WebhookEndpoint;
|
|
110
|
+
}
|
|
111
|
+
/** Every event type, Stripe's names. */
|
|
112
|
+
export type WebhookEventType = keyof WebhookEventPayload;
|
|
113
|
+
/**
|
|
114
|
+
* What caused an event, when an API request did (Stripe's `event.request`).
|
|
115
|
+
* Both `null` for an event caused by something else — the chain watcher, the
|
|
116
|
+
* expiry sweeper, a provider's own notification.
|
|
117
|
+
*/
|
|
118
|
+
export interface WebhookEventRequest {
|
|
119
|
+
/** The `Request-Id` of the request whose change produced the event. */
|
|
120
|
+
id: string | null;
|
|
121
|
+
/** The `Idempotency-Key` that request carried, if any. */
|
|
122
|
+
idempotency_key: string | null;
|
|
95
123
|
}
|
|
96
124
|
/**
|
|
97
125
|
* One delivered event.
|
|
@@ -100,20 +128,13 @@ export interface WebhookEventPayload {
|
|
|
100
128
|
* a switch on `type` with no cast:
|
|
101
129
|
*
|
|
102
130
|
* ```ts
|
|
103
|
-
* if (event.type === '
|
|
131
|
+
* if (event.type === 'charge.dispute.created') {
|
|
104
132
|
* event.data.object.evidence_due_at; // Dispute, not PaymentIntent
|
|
105
133
|
* }
|
|
106
134
|
* ```
|
|
107
135
|
*
|
|
108
|
-
*
|
|
109
|
-
* `
|
|
110
|
-
* which typechecks identically at the boundary and then lets a consumer read a
|
|
111
|
-
* `Dispute`'s fields off a settlement.
|
|
112
|
-
*
|
|
113
|
-
* The parameter narrows to a subset of event types — `WebhookEvent<'payment_intent.disputed'>`
|
|
114
|
-
* is the dispute event alone. It takes an event TYPE and not a payload type,
|
|
115
|
-
* because the payload is derivable from the event and the reverse is not: two
|
|
116
|
-
* event types share `Dispute`.
|
|
136
|
+
* The parameter narrows to a subset of event types —
|
|
137
|
+
* `WebhookEvent<'payment_intent.succeeded'>` is that event alone.
|
|
117
138
|
*/
|
|
118
139
|
export type WebhookEvent<K extends WebhookEventType = WebhookEventType> = {
|
|
119
140
|
[T in K]: {
|
|
@@ -126,13 +147,23 @@ export type WebhookEvent<K extends WebhookEventType = WebhookEventType> = {
|
|
|
126
147
|
/**
|
|
127
148
|
* The connected account (`ca_…`) this event is about — Stripe's
|
|
128
149
|
* `event.account` (ADR 0012 D7). Present on every event for an on-behalf
|
|
129
|
-
* payment and on `connected_account.updated`; absent
|
|
130
|
-
* merchant's own payments. Lets a platform route an event to a seller
|
|
131
|
-
* without opening `data.object`.
|
|
150
|
+
* payment and on `connected_account.updated`; absent otherwise.
|
|
132
151
|
*/
|
|
133
152
|
account?: string;
|
|
153
|
+
/**
|
|
154
|
+
* The wire version the event was rendered with — the `Peable-Version` of
|
|
155
|
+
* the deployment that stored it. An event is a stored snapshot; it is not
|
|
156
|
+
* re-rendered when the wire moves on.
|
|
157
|
+
*/
|
|
158
|
+
api_version: string;
|
|
134
159
|
data: {
|
|
135
160
|
object: WebhookEventPayload[T];
|
|
161
|
+
/**
|
|
162
|
+
* The fields of `object` that this change moved, with their values
|
|
163
|
+
* BEFORE it. Absent when the event is not a change of an existing object.
|
|
164
|
+
*/
|
|
165
|
+
previous_attributes?: Record<string, unknown>;
|
|
136
166
|
};
|
|
167
|
+
request: WebhookEventRequest;
|
|
137
168
|
};
|
|
138
169
|
}[K];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export { UNITS_PER_COIN, isBaseUnitString, type CurrencyCode, CURRENCY_CODES, CURRENCY_DECIMALS, decimalsFor, isCurrencyCode, } from './money';
|
|
2
2
|
export type { NetworkType } from './network';
|
|
3
3
|
export type { ExpandParams, List, ListParams, RangeQuery } from './list';
|
|
4
|
-
export { type
|
|
5
|
-
export type {
|
|
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';
|
|
5
|
+
export type { CardDetails, Charge, ChargeOutcome } from './charge';
|
|
6
|
+
export type { CreateCustomerParams, Customer, DeletedCustomer, UpdateCustomerParams, } from './customer';
|
|
7
|
+
export type { AttachPaymentMethodParams, BillingDetails, PaymentMethod, UpdatePaymentMethodParams, } from './paymentMethod';
|
|
8
|
+
export { type CancelSetupIntentParams, type CreateSetupIntentParams, type SetupIntent, type SetupIntentCancellationReason, type SetupIntentStatus, type SetupIntentUsage, SETUP_INTENT_STATUSES, } from './setupIntent';
|
|
9
|
+
export { PEABLE_API_VERSION, type WebhookEventType, type WebhookEvent, type WebhookEventPayload, type WebhookEventRequest, type BillingObservation, } from './event';
|
|
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
|
+
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';
|
|
6
12
|
export type { Dispute, DisputeEvidence, DisputeStatus } from './dispute';
|
|
7
13
|
export type { CapabilityStatus, ConnectedAccount, ConnectedAccountFaircoin, ConnectedAccountFaircoinStatus, ConnectedAccountRail, Refund, RefundOrigin, RefundStatus, Settlement, Transfer, TransferReversal, TransferReversalStatus, TransferStatus, TransferWithReversal, } from './settlement';
|
|
8
14
|
export type { WebhookDelivery, WebhookDeliveryStatus, } from './webhookDelivery';
|
package/dist/types/merchant.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export interface Merchant {
|
|
|
23
23
|
network: NetworkType | null;
|
|
24
24
|
/** `null` on a card-only merchant. Nullable together with `network`. */
|
|
25
25
|
xpub: string | null;
|
|
26
|
-
webhook_url?: string;
|
|
27
26
|
required_confirmations: number;
|
|
28
27
|
/**
|
|
29
28
|
* Payer-facing branding. Absent when unset — `MerchantDisplay` is what a
|