@peable.to/shared-types 0.14.0 → 0.16.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/branding.js +31 -0
- package/dist/cjs/checkoutSession.js +43 -0
- package/dist/cjs/index.js +32 -2
- package/dist/cjs/paymentLink.js +5 -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/branding.js +28 -0
- package/dist/esm/checkoutSession.js +42 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/paymentLink.js +4 -1
- 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/branding.d.ts +88 -0
- package/dist/types/charge.d.ts +8 -1
- package/dist/types/checkoutSession.d.ts +418 -39
- package/dist/types/event.d.ts +35 -0
- package/dist/types/index.d.ts +8 -4
- package/dist/types/paymentIntent.d.ts +35 -0
- package/dist/types/paymentLink.d.ts +142 -37
- package/dist/types/settlement.d.ts +39 -12
- package/package.json +1 -1
|
@@ -1,72 +1,177 @@
|
|
|
1
1
|
import type { ContributionDetails } from '@peable.to/contracts';
|
|
2
|
+
import type { CheckoutBranding } from './branding';
|
|
3
|
+
import type { CheckoutAdjustableQuantity, CheckoutAfterCompletion, CheckoutBillingAddressCollection, CheckoutCustomField, CheckoutCustomFieldParams, CheckoutCustomerCreation, CheckoutLineItem, CheckoutLocale, CheckoutSubmitType } from './checkoutSession';
|
|
2
4
|
import type { CurrencyCode } from './money';
|
|
3
|
-
import type { NetworkType } from './network';
|
|
4
5
|
import type { MerchantDisplay } from './merchantDisplay';
|
|
6
|
+
import type { NetworkType } from './network';
|
|
5
7
|
import type { PaymentIntentRail } from './paymentIntent';
|
|
6
|
-
|
|
8
|
+
export declare const PAYMENT_LINK_LIMITS: Readonly<{
|
|
9
|
+
lineItemsMax: 20;
|
|
10
|
+
customMessageMax: 500;
|
|
11
|
+
}>;
|
|
7
12
|
export interface PaymentLink {
|
|
8
13
|
id: string;
|
|
9
14
|
object: 'payment_link';
|
|
10
|
-
/**
|
|
11
|
-
* Which of the provider's two worlds this object belongs to (ADR 0017):
|
|
12
|
-
* `true` for a `production` merchant, `false` for every other environment.
|
|
13
|
-
*/
|
|
14
15
|
livemode: boolean;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Amount in the currency's smallest unit, as a canonical integer string.
|
|
18
|
-
* Never a float, and never interpretable without `currency`.
|
|
19
|
-
*/
|
|
20
|
-
amount: string;
|
|
16
|
+
active: boolean;
|
|
21
17
|
currency: CurrencyCode;
|
|
22
18
|
rail: PaymentIntentRail;
|
|
23
|
-
/** FairCoin rail only; `null` on a card link. */
|
|
24
19
|
network: NetworkType | null;
|
|
25
|
-
|
|
20
|
+
/** The link's prices (`GET /v1/payment_links/:id/line_items` lists them in full). */
|
|
21
|
+
line_items: CheckoutLineItem[];
|
|
22
|
+
allow_promotion_codes: boolean;
|
|
23
|
+
billing_address_collection: CheckoutBillingAddressCollection;
|
|
24
|
+
shipping_address_collection: {
|
|
25
|
+
allowed_countries: string[];
|
|
26
|
+
} | null;
|
|
27
|
+
phone_number_collection: {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
};
|
|
30
|
+
tax_id_collection: {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
};
|
|
33
|
+
custom_fields: CheckoutCustomField[];
|
|
34
|
+
consent_collection: {
|
|
35
|
+
terms_of_service: 'none' | 'required';
|
|
36
|
+
} | null;
|
|
37
|
+
automatic_tax: {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
};
|
|
40
|
+
customer_creation: CheckoutCustomerCreation;
|
|
41
|
+
after_completion: CheckoutAfterCompletion;
|
|
42
|
+
restrictions: {
|
|
43
|
+
completed_sessions: {
|
|
44
|
+
limit: number;
|
|
45
|
+
count: number;
|
|
46
|
+
};
|
|
47
|
+
} | null;
|
|
48
|
+
submit_type: CheckoutSubmitType;
|
|
49
|
+
locale: CheckoutLocale | null;
|
|
50
|
+
/** Present on an organization contribution link (FairCoin). */
|
|
51
|
+
contribution?: ContributionDetails;
|
|
26
52
|
metadata: Record<string, string>;
|
|
27
|
-
/**
|
|
28
|
-
success_url?: string;
|
|
29
|
-
/** Canonical `checkout.peable.to/l/<id>` URL. */
|
|
53
|
+
/** `checkout.peable.to/l/<id>` — share it, or render it as a QR code. */
|
|
30
54
|
url: string;
|
|
31
55
|
created: number;
|
|
32
56
|
updated_at: number;
|
|
33
57
|
}
|
|
34
|
-
/** What an
|
|
58
|
+
/** What an anonymous visitor may see before checkout starts — no metadata, no counts. */
|
|
35
59
|
export interface PublicPaymentLink {
|
|
36
60
|
id: string;
|
|
37
61
|
object: 'payment_link';
|
|
38
|
-
/**
|
|
39
|
-
* Which of the provider's two worlds this object belongs to (ADR 0017):
|
|
40
|
-
* `true` for a `production` merchant, `false` for every other environment.
|
|
41
|
-
*/
|
|
42
62
|
livemode: boolean;
|
|
43
|
-
|
|
44
|
-
amount: string;
|
|
63
|
+
active: boolean;
|
|
45
64
|
currency: CurrencyCode;
|
|
46
65
|
rail: PaymentIntentRail;
|
|
47
66
|
network: NetworkType | null;
|
|
48
|
-
|
|
67
|
+
line_items: CheckoutLineItem[];
|
|
68
|
+
contribution?: ContributionDetails;
|
|
69
|
+
/** A fixed contribution's amount; `null` when the payer chooses (or for a price link). */
|
|
70
|
+
contribution_amount: string | null;
|
|
49
71
|
merchant: MerchantDisplay;
|
|
72
|
+
branding: CheckoutBranding;
|
|
73
|
+
locale: CheckoutLocale | null;
|
|
74
|
+
}
|
|
75
|
+
export interface PaymentLinkLineItemParams {
|
|
76
|
+
price: string;
|
|
77
|
+
quantity: number;
|
|
78
|
+
adjustable_quantity?: {
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
minimum?: number;
|
|
81
|
+
maximum?: number;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export interface PaymentLinkAfterCompletionParams {
|
|
85
|
+
type: 'redirect' | 'hosted_confirmation';
|
|
86
|
+
/** `type: redirect` — may carry `{CHECKOUT_SESSION_ID}`. */
|
|
87
|
+
redirect?: {
|
|
88
|
+
url: string;
|
|
89
|
+
};
|
|
90
|
+
hosted_confirmation?: {
|
|
91
|
+
custom_message?: string;
|
|
92
|
+
};
|
|
50
93
|
}
|
|
51
94
|
export interface CreatePaymentLinkParams {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
95
|
+
/** 1–20 prices of ONE currency, one-time prices only. */
|
|
96
|
+
line_items: PaymentLinkLineItemParams[];
|
|
97
|
+
allow_promotion_codes?: boolean;
|
|
98
|
+
billing_address_collection?: CheckoutBillingAddressCollection;
|
|
99
|
+
shipping_address_collection?: {
|
|
100
|
+
allowed_countries: string[];
|
|
101
|
+
};
|
|
102
|
+
phone_number_collection?: {
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
};
|
|
105
|
+
tax_id_collection?: {
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
};
|
|
108
|
+
custom_fields?: CheckoutCustomFieldParams[];
|
|
109
|
+
consent_collection?: {
|
|
110
|
+
terms_of_service?: 'none' | 'required';
|
|
111
|
+
};
|
|
112
|
+
automatic_tax?: {
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
};
|
|
115
|
+
customer_creation?: CheckoutCustomerCreation;
|
|
116
|
+
after_completion?: PaymentLinkAfterCompletionParams;
|
|
117
|
+
restrictions?: {
|
|
118
|
+
completed_sessions: {
|
|
119
|
+
limit: number;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
submit_type?: CheckoutSubmitType;
|
|
123
|
+
locale?: CheckoutLocale | 'auto';
|
|
59
124
|
metadata?: Record<string, string>;
|
|
60
|
-
success_url?: string;
|
|
61
125
|
}
|
|
62
126
|
/**
|
|
63
|
-
* `POST /v1/payment_links/:id`.
|
|
64
|
-
*
|
|
127
|
+
* `POST /v1/payment_links/:id`. The line items are fixed once shared (a payer
|
|
128
|
+
* may hold a session priced from them); everything else may change.
|
|
65
129
|
*/
|
|
66
130
|
export interface UpdatePaymentLinkParams {
|
|
67
131
|
active?: boolean;
|
|
132
|
+
allow_promotion_codes?: boolean;
|
|
133
|
+
billing_address_collection?: CheckoutBillingAddressCollection;
|
|
134
|
+
shipping_address_collection?: {
|
|
135
|
+
allowed_countries: string[];
|
|
136
|
+
} | '';
|
|
137
|
+
phone_number_collection?: {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
};
|
|
140
|
+
tax_id_collection?: {
|
|
141
|
+
enabled: boolean;
|
|
142
|
+
};
|
|
143
|
+
custom_fields?: CheckoutCustomFieldParams[] | '';
|
|
144
|
+
consent_collection?: {
|
|
145
|
+
terms_of_service?: 'none' | 'required';
|
|
146
|
+
};
|
|
147
|
+
automatic_tax?: {
|
|
148
|
+
enabled: boolean;
|
|
149
|
+
};
|
|
150
|
+
customer_creation?: CheckoutCustomerCreation;
|
|
151
|
+
after_completion?: PaymentLinkAfterCompletionParams;
|
|
152
|
+
restrictions?: {
|
|
153
|
+
completed_sessions: {
|
|
154
|
+
limit: number;
|
|
155
|
+
};
|
|
156
|
+
} | '';
|
|
157
|
+
submit_type?: CheckoutSubmitType;
|
|
158
|
+
locale?: CheckoutLocale | 'auto';
|
|
68
159
|
/** A patch: named keys are set, `""` removes a key, others are kept. */
|
|
69
160
|
metadata?: Record<string, string>;
|
|
70
|
-
/** `null` removes it. */
|
|
71
|
-
success_url?: string | null;
|
|
72
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* `POST /v1/payment_links/:id/checkout_sessions` — a payer starting checkout
|
|
164
|
+
* (anonymous, rate-limited). A contribution link the payer prices takes
|
|
165
|
+
* `amount`; nothing else is the payer's to say.
|
|
166
|
+
*/
|
|
167
|
+
export interface CreatePaymentLinkSessionParams {
|
|
168
|
+
amount?: string;
|
|
169
|
+
}
|
|
170
|
+
/** Its answer: where to go — the hosted session and the secret that opens it. */
|
|
171
|
+
export interface PaymentLinkSessionStart {
|
|
172
|
+
object: 'checkout_session_start';
|
|
173
|
+
id: string;
|
|
174
|
+
client_secret: string;
|
|
175
|
+
url: string;
|
|
176
|
+
}
|
|
177
|
+
export type { CheckoutAdjustableQuantity };
|
|
@@ -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.16.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",
|