@secureprocessing/node 0.0.0-stage → 0.2.1
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/LICENSE +21 -0
- package/README.md +262 -2
- package/dist/client.d.ts +94 -0
- package/dist/client.js +196 -0
- package/dist/errors.d.ts +112 -0
- package/dist/errors.js +140 -0
- package/dist/index.d.ts +609 -0
- package/dist/index.js +526 -0
- package/dist/pagination.d.ts +32 -0
- package/dist/pagination.js +52 -0
- package/dist/types.d.ts +892 -0
- package/dist/types.js +3 -0
- package/dist/version.d.ts +8 -0
- package/dist/version.js +9 -0
- package/dist/webhooks.d.ts +22 -0
- package/dist/webhooks.js +79 -0
- package/package.json +32 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
/** The objects the API returns. Amounts are integers in the currency's minor unit. */
|
|
2
|
+
export type Currency = "bzd" | "usd";
|
|
3
|
+
/**
|
|
4
|
+
* Key-value pairs of your own, stored on the object and returned exactly as you sent them. Never
|
|
5
|
+
* shown to the customer. An update REPLACES the whole object; it does not merge into it.
|
|
6
|
+
*
|
|
7
|
+
* Limits, enforced by the API with a `400` (Stripe's, so a payload moves between the two unchanged):
|
|
8
|
+
* at most 50 keys; keys 1–40 characters with no `[` or `]` (the payments list filters on
|
|
9
|
+
* `metadata[key]=value`, and a bracketed key could be stored but never searched for); values are
|
|
10
|
+
* strings of up to 500 characters.
|
|
11
|
+
*/
|
|
12
|
+
export type MetadataParam = Record<string, string>;
|
|
13
|
+
export interface ListResponse<T> {
|
|
14
|
+
object: "list";
|
|
15
|
+
url: string;
|
|
16
|
+
has_more: boolean;
|
|
17
|
+
data: T[];
|
|
18
|
+
}
|
|
19
|
+
export interface GatewayEvidence {
|
|
20
|
+
order_id: string | null;
|
|
21
|
+
order_status: number | null;
|
|
22
|
+
action_code: string | null;
|
|
23
|
+
approval_code: string | null;
|
|
24
|
+
masked_pan: string | null;
|
|
25
|
+
card_brand: string | null;
|
|
26
|
+
}
|
|
27
|
+
export type PaymentIntentStatus = "requires_payment_method" | "processing" | "requires_action" | "requires_capture" | "succeeded" | "canceled";
|
|
28
|
+
export interface PaymentIntent {
|
|
29
|
+
id: string;
|
|
30
|
+
object: "payment_intent";
|
|
31
|
+
amount: number;
|
|
32
|
+
amount_received: number;
|
|
33
|
+
amount_capturable: number;
|
|
34
|
+
amount_refunded: number;
|
|
35
|
+
currency: Currency;
|
|
36
|
+
status: PaymentIntentStatus;
|
|
37
|
+
capture_method: "automatic" | "manual";
|
|
38
|
+
customer: string | null;
|
|
39
|
+
payment_method: string | null;
|
|
40
|
+
description: string | null;
|
|
41
|
+
receipt_email: string | null;
|
|
42
|
+
client_secret: string;
|
|
43
|
+
/** What the card was actually charged, and at what rate. A USD payment settles in BZD. */
|
|
44
|
+
settlement_amount: number | null;
|
|
45
|
+
settlement_currency: string | null;
|
|
46
|
+
fx_rate: number | null;
|
|
47
|
+
last_payment_error: {
|
|
48
|
+
type: string;
|
|
49
|
+
code: string;
|
|
50
|
+
decline_code?: string;
|
|
51
|
+
message: string;
|
|
52
|
+
} | null;
|
|
53
|
+
next_action: Record<string, unknown> | null;
|
|
54
|
+
/** What the bank reported. Useful when reconciling against the bank's own portal. */
|
|
55
|
+
gateway: GatewayEvidence | null;
|
|
56
|
+
/**
|
|
57
|
+
* What our risk rules decided before the bank was called.
|
|
58
|
+
*
|
|
59
|
+
* 🔴 `null` means NOT ASSESSED — the payment predates the check, or it was created by a path
|
|
60
|
+
* that never reaches a checkout page. It does not mean allowed.
|
|
61
|
+
*/
|
|
62
|
+
risk_outcome: RiskOutcome | null;
|
|
63
|
+
/** The review a `review` outcome opened once the payment succeeded, if any. */
|
|
64
|
+
review: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Whether a chargeback or an inquiry has ever been raised against this payment.
|
|
67
|
+
*
|
|
68
|
+
* A boolean rather than an id: a payment can be disputed more than once (a second presentment is
|
|
69
|
+
* a real thing), so no single id would be right. List `disputes` filtered by `payment_intent`.
|
|
70
|
+
*/
|
|
71
|
+
disputed: boolean;
|
|
72
|
+
cancellation_reason: string | null;
|
|
73
|
+
livemode: boolean;
|
|
74
|
+
metadata: Record<string, string>;
|
|
75
|
+
created: number;
|
|
76
|
+
}
|
|
77
|
+
export interface CheckoutSession {
|
|
78
|
+
id: string;
|
|
79
|
+
object: "checkout_session";
|
|
80
|
+
payment_intent: string;
|
|
81
|
+
status: "open" | "complete" | "expired";
|
|
82
|
+
/** Send the customer here. Null once the session is no longer open. */
|
|
83
|
+
url: string | null;
|
|
84
|
+
success_url: string;
|
|
85
|
+
cancel_url: string | null;
|
|
86
|
+
customer_email: string | null;
|
|
87
|
+
amount_total: number;
|
|
88
|
+
currency: Currency;
|
|
89
|
+
expires_at: number;
|
|
90
|
+
livemode: boolean;
|
|
91
|
+
metadata: Record<string, string>;
|
|
92
|
+
created: number;
|
|
93
|
+
}
|
|
94
|
+
export interface Refund {
|
|
95
|
+
id: string;
|
|
96
|
+
object: "refund";
|
|
97
|
+
payment_intent: string;
|
|
98
|
+
amount: number;
|
|
99
|
+
currency: Currency;
|
|
100
|
+
status: "pending" | "succeeded" | "failed" | "canceled";
|
|
101
|
+
reason: string | null;
|
|
102
|
+
/**
|
|
103
|
+
* `bank_portal` means somebody refunded it in the bank's own interface and we found it.
|
|
104
|
+
* `review` means it was given back from the risk queue rather than decided as an ordinary refund.
|
|
105
|
+
*/
|
|
106
|
+
origin: "api" | "dashboard" | "bank_portal" | "reconcile" | "review";
|
|
107
|
+
failure_reason: string | null;
|
|
108
|
+
livemode: boolean;
|
|
109
|
+
metadata: Record<string, string>;
|
|
110
|
+
created: number;
|
|
111
|
+
}
|
|
112
|
+
export interface Customer {
|
|
113
|
+
id: string;
|
|
114
|
+
object: "customer";
|
|
115
|
+
email: string | null;
|
|
116
|
+
name: string | null;
|
|
117
|
+
phone: string | null;
|
|
118
|
+
description: string | null;
|
|
119
|
+
livemode: boolean;
|
|
120
|
+
metadata: Record<string, string>;
|
|
121
|
+
created: number;
|
|
122
|
+
}
|
|
123
|
+
export interface PaymentMethod {
|
|
124
|
+
id: string;
|
|
125
|
+
object: "payment_method";
|
|
126
|
+
type: "card";
|
|
127
|
+
customer: string;
|
|
128
|
+
card: {
|
|
129
|
+
brand: string | null;
|
|
130
|
+
last4: string | null;
|
|
131
|
+
exp_month: number | null;
|
|
132
|
+
exp_year: number | null;
|
|
133
|
+
};
|
|
134
|
+
status: "active" | "detached" | "expired";
|
|
135
|
+
livemode: boolean;
|
|
136
|
+
created: number;
|
|
137
|
+
}
|
|
138
|
+
export interface Product {
|
|
139
|
+
id: string;
|
|
140
|
+
object: "product";
|
|
141
|
+
/** False means archived. Its prices are left alone. */
|
|
142
|
+
active: boolean;
|
|
143
|
+
name: string;
|
|
144
|
+
description: string | null;
|
|
145
|
+
images: string[];
|
|
146
|
+
statement_descriptor: string | null;
|
|
147
|
+
livemode: boolean;
|
|
148
|
+
metadata: Record<string, string>;
|
|
149
|
+
created: number;
|
|
150
|
+
updated: number;
|
|
151
|
+
}
|
|
152
|
+
/** A range the payer chooses an amount within. Minor units, like everything else. */
|
|
153
|
+
export interface CustomUnitAmount {
|
|
154
|
+
minimum: number;
|
|
155
|
+
maximum: number;
|
|
156
|
+
preset?: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* What a product costs.
|
|
160
|
+
*
|
|
161
|
+
* 🔴 Immutable apart from `active`, `nickname` and `metadata`. A price id is what a payment link
|
|
162
|
+
* stores, so changing the amount would silently reprice every link already in circulation. To
|
|
163
|
+
* change what something costs, create a new price and archive the old one.
|
|
164
|
+
*/
|
|
165
|
+
export interface Price {
|
|
166
|
+
id: string;
|
|
167
|
+
object: "price";
|
|
168
|
+
active: boolean;
|
|
169
|
+
product: string;
|
|
170
|
+
currency: Currency;
|
|
171
|
+
type: "one_time";
|
|
172
|
+
billing_scheme: "per_unit";
|
|
173
|
+
/** Minor units — 6000 is $60.00. Null when the price takes a custom amount. */
|
|
174
|
+
unit_amount: number | null;
|
|
175
|
+
custom_unit_amount: CustomUnitAmount | null;
|
|
176
|
+
nickname: string | null;
|
|
177
|
+
livemode: boolean;
|
|
178
|
+
metadata: Record<string, string>;
|
|
179
|
+
created: number;
|
|
180
|
+
}
|
|
181
|
+
export interface CreateProductParams {
|
|
182
|
+
name: string;
|
|
183
|
+
description?: string;
|
|
184
|
+
active?: boolean;
|
|
185
|
+
/** Up to 8 https URLs. */
|
|
186
|
+
images?: string[];
|
|
187
|
+
statement_descriptor?: string;
|
|
188
|
+
metadata?: MetadataParam;
|
|
189
|
+
}
|
|
190
|
+
export interface UpdateProductParams {
|
|
191
|
+
name?: string;
|
|
192
|
+
description?: string | null;
|
|
193
|
+
active?: boolean;
|
|
194
|
+
images?: string[];
|
|
195
|
+
statement_descriptor?: string;
|
|
196
|
+
metadata?: MetadataParam;
|
|
197
|
+
}
|
|
198
|
+
export interface CreatePriceParams {
|
|
199
|
+
product: string;
|
|
200
|
+
currency: Currency;
|
|
201
|
+
/** Minor units. Give this or `custom_unit_amount`, never both and never neither. */
|
|
202
|
+
unit_amount?: number;
|
|
203
|
+
custom_unit_amount?: CustomUnitAmount;
|
|
204
|
+
nickname?: string;
|
|
205
|
+
active?: boolean;
|
|
206
|
+
metadata?: MetadataParam;
|
|
207
|
+
}
|
|
208
|
+
/** Only these three. The amount, the currency and the product are fixed for the price's life. */
|
|
209
|
+
export interface UpdatePriceParams {
|
|
210
|
+
active?: boolean;
|
|
211
|
+
nickname?: string | null;
|
|
212
|
+
metadata?: MetadataParam;
|
|
213
|
+
}
|
|
214
|
+
/** How many of the thing a payer may buy. Both bounds are required when `enabled` is true. */
|
|
215
|
+
export interface AdjustableQuantity {
|
|
216
|
+
enabled: boolean;
|
|
217
|
+
minimum?: number;
|
|
218
|
+
maximum?: number;
|
|
219
|
+
}
|
|
220
|
+
/** A question asked on the hosted page. The answer arrives in the payment's metadata. */
|
|
221
|
+
export interface PaymentLinkCustomField {
|
|
222
|
+
key: string;
|
|
223
|
+
label: string;
|
|
224
|
+
type: "text" | "numeric" | "dropdown";
|
|
225
|
+
optional?: boolean;
|
|
226
|
+
/** Required for `dropdown`, refused for anything else. */
|
|
227
|
+
options?: string[];
|
|
228
|
+
}
|
|
229
|
+
/** What the payer sees once they have paid. A redirect url must be https. */
|
|
230
|
+
export type AfterCompletion = {
|
|
231
|
+
type: "hosted_confirmation";
|
|
232
|
+
message?: string;
|
|
233
|
+
} | {
|
|
234
|
+
type: "redirect";
|
|
235
|
+
url: string;
|
|
236
|
+
};
|
|
237
|
+
export interface PaymentLink {
|
|
238
|
+
id: string;
|
|
239
|
+
object: "payment_link";
|
|
240
|
+
active: boolean;
|
|
241
|
+
/** The page to share. The id in it is the token — it is public by design. */
|
|
242
|
+
url: string;
|
|
243
|
+
price: string;
|
|
244
|
+
quantity: number;
|
|
245
|
+
adjustable_quantity: AdjustableQuantity | null;
|
|
246
|
+
custom_fields: PaymentLinkCustomField[];
|
|
247
|
+
after_completion: AfterCompletion;
|
|
248
|
+
collect_customer_name: boolean;
|
|
249
|
+
collect_phone: boolean;
|
|
250
|
+
livemode: boolean;
|
|
251
|
+
metadata: Record<string, string>;
|
|
252
|
+
created: number;
|
|
253
|
+
}
|
|
254
|
+
export interface CreatePaymentLinkParams {
|
|
255
|
+
/** An ACTIVE price of yours. Its amount is what the link charges, for ever. */
|
|
256
|
+
price: string;
|
|
257
|
+
quantity?: number;
|
|
258
|
+
adjustable_quantity?: AdjustableQuantity;
|
|
259
|
+
/** Up to three. The answers arrive in each payment's metadata under `payment_link_fields`. */
|
|
260
|
+
custom_fields?: PaymentLinkCustomField[];
|
|
261
|
+
after_completion?: AfterCompletion;
|
|
262
|
+
collect_customer_name?: boolean;
|
|
263
|
+
collect_phone?: boolean;
|
|
264
|
+
metadata?: MetadataParam;
|
|
265
|
+
}
|
|
266
|
+
/** 🔴 No `price` and no `quantity`: see the note on `paymentLinks.update`. */
|
|
267
|
+
export interface UpdatePaymentLinkParams {
|
|
268
|
+
active?: boolean;
|
|
269
|
+
after_completion?: AfterCompletion;
|
|
270
|
+
custom_fields?: PaymentLinkCustomField[];
|
|
271
|
+
adjustable_quantity?: AdjustableQuantity | null;
|
|
272
|
+
collect_customer_name?: boolean;
|
|
273
|
+
collect_phone?: boolean;
|
|
274
|
+
metadata?: MetadataParam;
|
|
275
|
+
}
|
|
276
|
+
export interface TaxRate {
|
|
277
|
+
id: string;
|
|
278
|
+
object: "tax_rate";
|
|
279
|
+
display_name: string;
|
|
280
|
+
/** The rate as a percentage, to three decimal places. 12.5 means 12.5%. */
|
|
281
|
+
percentage: number;
|
|
282
|
+
/**
|
|
283
|
+
* True when a line's amount ALREADY contains the tax and it is backed out of it; false when the
|
|
284
|
+
* tax is added on top. 1000 at an inclusive 12.5% is 111 of tax on 889 net; the same rate
|
|
285
|
+
* exclusive is 125 of tax on 1000 net.
|
|
286
|
+
*/
|
|
287
|
+
inclusive: boolean;
|
|
288
|
+
jurisdiction: string | null;
|
|
289
|
+
active: boolean;
|
|
290
|
+
livemode: boolean;
|
|
291
|
+
metadata: Record<string, string>;
|
|
292
|
+
created: number;
|
|
293
|
+
}
|
|
294
|
+
export interface CreateTaxRateParams {
|
|
295
|
+
display_name: string;
|
|
296
|
+
percentage: number;
|
|
297
|
+
inclusive: boolean;
|
|
298
|
+
jurisdiction?: string;
|
|
299
|
+
metadata?: MetadataParam;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* 🔴 No `percentage` and no `inclusive`. A finalized invoice names the rate that produced the tax
|
|
303
|
+
* printed on it, so a rate that moved would make the two disagree on a document your customer is
|
|
304
|
+
* already holding. Create a new rate and archive this one.
|
|
305
|
+
*/
|
|
306
|
+
export interface UpdateTaxRateParams {
|
|
307
|
+
display_name?: string;
|
|
308
|
+
active?: boolean;
|
|
309
|
+
metadata?: MetadataParam;
|
|
310
|
+
}
|
|
311
|
+
export type InvoiceStatus = "draft" | "open" | "paid" | "void" | "uncollectible";
|
|
312
|
+
export interface InvoiceLineItem {
|
|
313
|
+
id: string;
|
|
314
|
+
object: "line_item";
|
|
315
|
+
description: string;
|
|
316
|
+
quantity: number;
|
|
317
|
+
/** Minor units. */
|
|
318
|
+
unit_amount: number;
|
|
319
|
+
/** Minor units. `quantity × unit_amount`; for an inclusive rate it INCLUDES the tax. */
|
|
320
|
+
amount: number;
|
|
321
|
+
/** Minor units. The tax attributable to this line alone. */
|
|
322
|
+
tax_amount: number;
|
|
323
|
+
price: string | null;
|
|
324
|
+
tax_rate: string | null;
|
|
325
|
+
metadata: Record<string, string>;
|
|
326
|
+
}
|
|
327
|
+
export interface Invoice {
|
|
328
|
+
id: string;
|
|
329
|
+
object: "invoice";
|
|
330
|
+
status: InvoiceStatus;
|
|
331
|
+
/** Assigned at finalize from your own consecutive sequence. Null while a draft. */
|
|
332
|
+
number: string | null;
|
|
333
|
+
customer: string;
|
|
334
|
+
currency: Currency;
|
|
335
|
+
collection_method: "send_invoice";
|
|
336
|
+
/** Minor units, net of tax. */
|
|
337
|
+
subtotal: number;
|
|
338
|
+
/** Minor units. */
|
|
339
|
+
tax: number;
|
|
340
|
+
/** Minor units. `subtotal + tax`. */
|
|
341
|
+
total: number;
|
|
342
|
+
/** Minor units. Can exceed `total` — see `amount_due`. */
|
|
343
|
+
amount_paid: number;
|
|
344
|
+
/**
|
|
345
|
+
* `total − amount_paid`, in minor units. NEGATIVE on an overpayment, which happens when two
|
|
346
|
+
* browser tabs on the hosted page are both paid. Reported rather than clamped: money that moved
|
|
347
|
+
* is money you owe back.
|
|
348
|
+
*/
|
|
349
|
+
amount_due: number;
|
|
350
|
+
allow_partial: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* 🔴 The page to send the customer. Its token is NOT this object's id — the id is safe in a log
|
|
353
|
+
* and this URL is not, because the page names the customer and what they owe.
|
|
354
|
+
*/
|
|
355
|
+
hosted_invoice_url: string;
|
|
356
|
+
/** The same document as a PDF. Requires your API key, so it is for your records. */
|
|
357
|
+
invoice_pdf: string;
|
|
358
|
+
/** Unix timestamp, seconds. */
|
|
359
|
+
due_date: number | null;
|
|
360
|
+
description: string | null;
|
|
361
|
+
memo: string | null;
|
|
362
|
+
footer: string | null;
|
|
363
|
+
custom_fields: {
|
|
364
|
+
name: string;
|
|
365
|
+
value: string;
|
|
366
|
+
}[];
|
|
367
|
+
lines: {
|
|
368
|
+
object: "list";
|
|
369
|
+
data: InvoiceLineItem[];
|
|
370
|
+
};
|
|
371
|
+
finalized_at: number | null;
|
|
372
|
+
paid_at: number | null;
|
|
373
|
+
voided_at: number | null;
|
|
374
|
+
sent_at: number | null;
|
|
375
|
+
reminder_count: number;
|
|
376
|
+
latest_payment_intent: string | null;
|
|
377
|
+
livemode: boolean;
|
|
378
|
+
metadata: Record<string, string>;
|
|
379
|
+
created: number;
|
|
380
|
+
}
|
|
381
|
+
export interface CreateInvoiceParams {
|
|
382
|
+
customer: string;
|
|
383
|
+
currency?: Currency;
|
|
384
|
+
/** Unix seconds. Give this OR `days_until_due`, not both. */
|
|
385
|
+
due_date?: number;
|
|
386
|
+
/** Counted from the moment you FINALIZE, not from now. Give this OR `due_date`. */
|
|
387
|
+
days_until_due?: number;
|
|
388
|
+
description?: string;
|
|
389
|
+
memo?: string;
|
|
390
|
+
footer?: string;
|
|
391
|
+
custom_fields?: {
|
|
392
|
+
name: string;
|
|
393
|
+
value: string;
|
|
394
|
+
}[];
|
|
395
|
+
allow_partial?: boolean;
|
|
396
|
+
metadata?: MetadataParam;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* 🔴 Nothing here changes money. A draft's amounts come from its lines; a finalized invoice's are
|
|
400
|
+
* frozen. Once the invoice is open, only `memo`, `footer` and `metadata` are accepted — everything
|
|
401
|
+
* else is a term of a bill the customer already has.
|
|
402
|
+
*/
|
|
403
|
+
export interface UpdateInvoiceParams {
|
|
404
|
+
due_date?: number;
|
|
405
|
+
days_until_due?: number;
|
|
406
|
+
description?: string;
|
|
407
|
+
memo?: string;
|
|
408
|
+
footer?: string;
|
|
409
|
+
custom_fields?: {
|
|
410
|
+
name: string;
|
|
411
|
+
value: string;
|
|
412
|
+
}[];
|
|
413
|
+
allow_partial?: boolean;
|
|
414
|
+
metadata?: MetadataParam;
|
|
415
|
+
}
|
|
416
|
+
export interface CreateInvoiceItemParams {
|
|
417
|
+
/** The DRAFT invoice to add the line to. */
|
|
418
|
+
invoice: string;
|
|
419
|
+
/** A price of yours. Its amount and currency are copied onto the line. */
|
|
420
|
+
price?: string;
|
|
421
|
+
/** Minor units. Give this and `description`, or give `price`. */
|
|
422
|
+
unit_amount?: number;
|
|
423
|
+
description?: string;
|
|
424
|
+
quantity?: number;
|
|
425
|
+
tax_rate?: string;
|
|
426
|
+
metadata?: MetadataParam;
|
|
427
|
+
}
|
|
428
|
+
export interface UpdateInvoiceItemParams {
|
|
429
|
+
description?: string;
|
|
430
|
+
quantity?: number;
|
|
431
|
+
/** Minor units. Setting it drops the line's link to a price. */
|
|
432
|
+
unit_amount?: number;
|
|
433
|
+
tax_rate?: string | null;
|
|
434
|
+
metadata?: MetadataParam;
|
|
435
|
+
}
|
|
436
|
+
export interface DeletedInvoiceItem {
|
|
437
|
+
id: string;
|
|
438
|
+
object: "invoice_item";
|
|
439
|
+
deleted: true;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* What you are owed, and what is not yours to spend yet.
|
|
443
|
+
*
|
|
444
|
+
* 🔴 In the SETTLEMENT currency (BZD), not the currency a payment was priced in. A payment taken in
|
|
445
|
+
* USD is settled in Belize dollars at the rate recorded on that payment, and the balance is the sum
|
|
446
|
+
* of what actually moved, not of what was quoted.
|
|
447
|
+
*/
|
|
448
|
+
/** What an account may do, per capability. */
|
|
449
|
+
export type CapabilityStatus = "inactive" | "pending" | "active";
|
|
450
|
+
export type ApplicationStatus = "draft" | "submitted" | "in_review" | "approved" | "rejected" | "more_info";
|
|
451
|
+
/**
|
|
452
|
+
* Your own account: what it is, and what it is allowed to do.
|
|
453
|
+
*
|
|
454
|
+
* 🔴 `live_enabled` is the one to branch on before attempting anything with a live key. It is false
|
|
455
|
+
* until we have approved the business, and a live request from an account that is not enabled is
|
|
456
|
+
* refused rather than quietly downgraded to test data.
|
|
457
|
+
*/
|
|
458
|
+
export interface Account {
|
|
459
|
+
id: string;
|
|
460
|
+
object: "account";
|
|
461
|
+
name: string;
|
|
462
|
+
live_enabled: boolean;
|
|
463
|
+
capabilities: {
|
|
464
|
+
card_payments: CapabilityStatus;
|
|
465
|
+
payouts: CapabilityStatus;
|
|
466
|
+
};
|
|
467
|
+
/** Null until the activation application has been started from the dashboard. */
|
|
468
|
+
application_status: ApplicationStatus | null;
|
|
469
|
+
requirements: {
|
|
470
|
+
/**
|
|
471
|
+
* What the application still needs, as keys such as `business.address` or
|
|
472
|
+
* `persons.owner_or_director`. Empty means it can be submitted. Filling it in is done from the
|
|
473
|
+
* dashboard — see https://docs.secureprocessing.app/activation.
|
|
474
|
+
*/
|
|
475
|
+
currently_due: string[];
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
export interface BalanceAmount {
|
|
479
|
+
amount: number;
|
|
480
|
+
currency: string;
|
|
481
|
+
}
|
|
482
|
+
export interface Balance {
|
|
483
|
+
object: "balance";
|
|
484
|
+
/** Taken, but not yet released to you. */
|
|
485
|
+
pending: BalanceAmount[];
|
|
486
|
+
/** Yours, and payable. */
|
|
487
|
+
available: BalanceAmount[];
|
|
488
|
+
/** Already drawn for a payout the bank has not yet confirmed. Neither pending nor available. */
|
|
489
|
+
payouts_in_transit: BalanceAmount[];
|
|
490
|
+
livemode: boolean;
|
|
491
|
+
}
|
|
492
|
+
export type PayoutStatus = "pending" | "in_transit" | "paid" | "canceled" | "failed";
|
|
493
|
+
export interface Payout {
|
|
494
|
+
id: string;
|
|
495
|
+
object: "payout";
|
|
496
|
+
/** Minor units. Payouts are always BZD: it is what leaves the pooled merchant account. */
|
|
497
|
+
amount: number;
|
|
498
|
+
currency: "bzd";
|
|
499
|
+
status: PayoutStatus;
|
|
500
|
+
method: "bank_transfer";
|
|
501
|
+
/** Never the full account number — only the last four, as they were at the moment of the cut. */
|
|
502
|
+
destination: {
|
|
503
|
+
bank_name: string | null;
|
|
504
|
+
account_name: string | null;
|
|
505
|
+
account_last4: string | null;
|
|
506
|
+
};
|
|
507
|
+
arrival_date: string | null;
|
|
508
|
+
/** The bank's own transfer reference. Present once the payout is `paid`. */
|
|
509
|
+
bank_reference: string | null;
|
|
510
|
+
failure_reason: string | null;
|
|
511
|
+
livemode: boolean;
|
|
512
|
+
created: number;
|
|
513
|
+
paid_at: number | null;
|
|
514
|
+
}
|
|
515
|
+
export type BalanceTransactionType = "charge" | "refund" | "payout" | "payout_reversal" | "adjustment" | "dispute" | "dispute_reversal";
|
|
516
|
+
/**
|
|
517
|
+
* One movement of your balance.
|
|
518
|
+
*
|
|
519
|
+
* `net` is the column that sums to your balance — over the whole list it equals
|
|
520
|
+
* `pending + available`. A charge appears ONCE and its `status` changes from `pending` to
|
|
521
|
+
* `available` when the settlement delay passes; the release is not a second transaction.
|
|
522
|
+
*/
|
|
523
|
+
export interface BalanceTransaction {
|
|
524
|
+
id: string;
|
|
525
|
+
object: "balance_transaction";
|
|
526
|
+
type: BalanceTransactionType;
|
|
527
|
+
/** Signed, in your favour positive. A refund and a payout are negative. */
|
|
528
|
+
amount: number;
|
|
529
|
+
/** Signed. Positive when we earned it here, negative when a refund gave it back. */
|
|
530
|
+
fee: number;
|
|
531
|
+
/** `amount - fee`. */
|
|
532
|
+
net: number;
|
|
533
|
+
currency: string;
|
|
534
|
+
/** The payment intent, refund or payout this belongs to. */
|
|
535
|
+
source: string;
|
|
536
|
+
status: "pending" | "available";
|
|
537
|
+
available_on: number;
|
|
538
|
+
created: number;
|
|
539
|
+
}
|
|
540
|
+
/** Both sides of a balance at one instant, in minor units of your settlement currency. */
|
|
541
|
+
export interface BalanceSide {
|
|
542
|
+
available: number;
|
|
543
|
+
pending: number;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* A period, summarised — and checked.
|
|
547
|
+
*
|
|
548
|
+
* 🔴 `reconciled` is the field to look at. `ending_balance` is derived from the period's movements
|
|
549
|
+
* on top of `starting_balance`; `ledger` is the same two figures recomputed from the ledger's own
|
|
550
|
+
* entries at the moment of the request. If they disagree, `reconciled` is false and your statement
|
|
551
|
+
* and your balance are telling you different things — that is a support call, not a number to
|
|
552
|
+
* reconcile around.
|
|
553
|
+
*
|
|
554
|
+
* Every figure is SIGNED the way the ledger signs it: a charge positive, a refund and a payout
|
|
555
|
+
* negative, `fees_returned` negative because it is a fee coming back. They add up to
|
|
556
|
+
* `ending_balance − starting_balance`, which is what makes this a statement rather than a set of
|
|
557
|
+
* numbers.
|
|
558
|
+
*/
|
|
559
|
+
export interface BalanceSummary {
|
|
560
|
+
object: "balance_summary";
|
|
561
|
+
currency: string;
|
|
562
|
+
/** `start` is inclusive; `end` is EXCLUSIVE, so twelve monthly summaries tile a year exactly. */
|
|
563
|
+
period: {
|
|
564
|
+
start: number;
|
|
565
|
+
end: number;
|
|
566
|
+
};
|
|
567
|
+
starting_balance: BalanceSide;
|
|
568
|
+
activity: {
|
|
569
|
+
charges: {
|
|
570
|
+
count: number;
|
|
571
|
+
gross: number;
|
|
572
|
+
fees: number;
|
|
573
|
+
net: number;
|
|
574
|
+
};
|
|
575
|
+
refunds: {
|
|
576
|
+
count: number;
|
|
577
|
+
amount: number;
|
|
578
|
+
fees_returned: number;
|
|
579
|
+
};
|
|
580
|
+
payouts: {
|
|
581
|
+
count: number;
|
|
582
|
+
amount: number;
|
|
583
|
+
};
|
|
584
|
+
payout_reversals: {
|
|
585
|
+
count: number;
|
|
586
|
+
amount: number;
|
|
587
|
+
};
|
|
588
|
+
adjustments: {
|
|
589
|
+
count: number;
|
|
590
|
+
amount: number;
|
|
591
|
+
};
|
|
592
|
+
/** Zero today. The field is here so you read a number rather than branch on an absence. */
|
|
593
|
+
disputes: {
|
|
594
|
+
count: number;
|
|
595
|
+
amount: number;
|
|
596
|
+
};
|
|
597
|
+
};
|
|
598
|
+
ending_balance: BalanceSide;
|
|
599
|
+
ledger: BalanceSide;
|
|
600
|
+
reconciled: boolean;
|
|
601
|
+
livemode: boolean;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* A reporting window. A unix timestamp in seconds, or an ISO date like `2026-09-01` (UTC midnight).
|
|
605
|
+
*
|
|
606
|
+
* Defaults to the current calendar month up to now. At most 366 days; for a longer span, ask one
|
|
607
|
+
* window at a time.
|
|
608
|
+
*/
|
|
609
|
+
export interface ReportWindowParams {
|
|
610
|
+
start?: string | number;
|
|
611
|
+
end?: string | number;
|
|
612
|
+
}
|
|
613
|
+
export type ExportKind = "payments" | "refunds" | "payouts" | "balance_transactions";
|
|
614
|
+
export interface ExportParams extends ReportWindowParams {
|
|
615
|
+
/** `payments`, `refunds` and `payouts` each take their own resource's status values. */
|
|
616
|
+
status?: string;
|
|
617
|
+
/** `payments` only. */
|
|
618
|
+
customer?: string;
|
|
619
|
+
/** `payments` only. */
|
|
620
|
+
payment_link?: string;
|
|
621
|
+
/** `balance_transactions` only. */
|
|
622
|
+
type?: BalanceTransactionType;
|
|
623
|
+
/** `balance_transactions` only: what one payout covers. */
|
|
624
|
+
payout?: string;
|
|
625
|
+
}
|
|
626
|
+
export interface SecureProcessingEvent<T = Record<string, unknown>> {
|
|
627
|
+
id: string;
|
|
628
|
+
object: "event";
|
|
629
|
+
type: string;
|
|
630
|
+
api_version: string;
|
|
631
|
+
data: {
|
|
632
|
+
object: T;
|
|
633
|
+
};
|
|
634
|
+
livemode: boolean;
|
|
635
|
+
created: number;
|
|
636
|
+
}
|
|
637
|
+
export interface WebhookEndpoint {
|
|
638
|
+
id: string;
|
|
639
|
+
object: "webhook_endpoint";
|
|
640
|
+
url: string;
|
|
641
|
+
description: string | null;
|
|
642
|
+
enabled_events: string[];
|
|
643
|
+
status: "enabled" | "disabled";
|
|
644
|
+
/** Present only in the response that created or rotated it. */
|
|
645
|
+
secret?: string;
|
|
646
|
+
livemode: boolean;
|
|
647
|
+
created: number;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* One attempt-tracked delivery of one event to one endpoint.
|
|
651
|
+
*
|
|
652
|
+
* ⚠️ `next_attempt_at` is null once a delivery is `succeeded` or `dead` — there is no next attempt.
|
|
653
|
+
* A `dead` delivery exhausted the retry schedule (about 35 hours); the event is still readable
|
|
654
|
+
* through `events.list`, so a missed webhook is recoverable without our help.
|
|
655
|
+
*/
|
|
656
|
+
export interface WebhookDelivery {
|
|
657
|
+
id: string;
|
|
658
|
+
object: "webhook_delivery";
|
|
659
|
+
endpoint: string;
|
|
660
|
+
event: string;
|
|
661
|
+
event_type: string;
|
|
662
|
+
status: "pending" | "succeeded" | "failed" | "dead";
|
|
663
|
+
attempt_count: number;
|
|
664
|
+
last_response_status: number | null;
|
|
665
|
+
last_error: string | null;
|
|
666
|
+
next_attempt_at: number | null;
|
|
667
|
+
created: number;
|
|
668
|
+
}
|
|
669
|
+
export interface CreatePaymentIntentParams {
|
|
670
|
+
amount: number;
|
|
671
|
+
currency: Currency;
|
|
672
|
+
capture_method?: "automatic" | "manual";
|
|
673
|
+
customer?: string;
|
|
674
|
+
payment_method?: string;
|
|
675
|
+
off_session?: boolean;
|
|
676
|
+
confirm?: boolean;
|
|
677
|
+
setup_future_usage?: "off_session";
|
|
678
|
+
/** Reaches the bank's own record. Lead with your own reference so you can find it later. */
|
|
679
|
+
description?: string;
|
|
680
|
+
receipt_email?: string;
|
|
681
|
+
statement_descriptor_suffix?: string;
|
|
682
|
+
return_url?: string;
|
|
683
|
+
metadata?: MetadataParam;
|
|
684
|
+
}
|
|
685
|
+
export interface CreateCheckoutSessionParams {
|
|
686
|
+
payment_intent?: string;
|
|
687
|
+
amount?: number;
|
|
688
|
+
currency?: Currency;
|
|
689
|
+
success_url: string;
|
|
690
|
+
cancel_url?: string;
|
|
691
|
+
customer?: string;
|
|
692
|
+
customer_email?: string;
|
|
693
|
+
line_items?: {
|
|
694
|
+
name: string;
|
|
695
|
+
amount?: number;
|
|
696
|
+
quantity?: number;
|
|
697
|
+
}[];
|
|
698
|
+
description?: string;
|
|
699
|
+
setup_future_usage?: "off_session";
|
|
700
|
+
metadata?: MetadataParam;
|
|
701
|
+
}
|
|
702
|
+
export interface CreateRefundParams {
|
|
703
|
+
payment_intent: string;
|
|
704
|
+
/** Omit to refund everything that is left. */
|
|
705
|
+
amount?: number;
|
|
706
|
+
reason?: "duplicate" | "fraudulent" | "requested_by_customer" | "other";
|
|
707
|
+
metadata?: MetadataParam;
|
|
708
|
+
}
|
|
709
|
+
export interface ListParams {
|
|
710
|
+
limit?: number;
|
|
711
|
+
starting_after?: string;
|
|
712
|
+
ending_before?: string;
|
|
713
|
+
}
|
|
714
|
+
export interface ListPaymentIntentsParams extends ListParams {
|
|
715
|
+
status?: PaymentIntentStatus;
|
|
716
|
+
customer?: string;
|
|
717
|
+
created_gte?: number;
|
|
718
|
+
created_lte?: number;
|
|
719
|
+
/** Filter by your own identifiers: `{ shop_id: "scuba-sensation" }`. */
|
|
720
|
+
metadata?: Record<string, string>;
|
|
721
|
+
risk_outcome?: RiskOutcome;
|
|
722
|
+
/** Every payment taken through one payment link. The payment-links page filters on it. */
|
|
723
|
+
payment_link?: string;
|
|
724
|
+
/** Every payment taken against one invoice; a partially paid invoice has more than one. */
|
|
725
|
+
invoice?: string;
|
|
726
|
+
created_via?: "api" | "checkout" | "dashboard" | "payment_link" | "invoice";
|
|
727
|
+
}
|
|
728
|
+
export type RiskOutcome = "allow" | "block" | "review";
|
|
729
|
+
/**
|
|
730
|
+
* What a rule can test.
|
|
731
|
+
*
|
|
732
|
+
* `amount_minor` and the five counts are numbers; `currency`, `email`, `email_domain` and
|
|
733
|
+
* `ip_country` are strings. There is deliberately no card country: the gateway does not tell us
|
|
734
|
+
* the issuing country, and an attribute that can never be populated is a rule that silently never
|
|
735
|
+
* fires.
|
|
736
|
+
*/
|
|
737
|
+
export type RiskAttribute = "amount_minor" | "currency" | "email" | "email_domain" | "ip_country" | "velocity_email_1h" | "velocity_email_24h" | "velocity_ip_1h" | "velocity_ip_24h" | "attempts_email_24h";
|
|
738
|
+
export type RiskOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "not_in" | "contains" | "ends_with";
|
|
739
|
+
export interface RiskCondition {
|
|
740
|
+
attr: RiskAttribute;
|
|
741
|
+
op: RiskOperator;
|
|
742
|
+
value: number | string | number[] | string[];
|
|
743
|
+
}
|
|
744
|
+
/** An AND of one to eight conditions. There is no `any` and no nesting: an OR is two rules. */
|
|
745
|
+
export interface RiskPredicate {
|
|
746
|
+
all: RiskCondition[];
|
|
747
|
+
}
|
|
748
|
+
export interface RiskRule {
|
|
749
|
+
id: string;
|
|
750
|
+
object: "risk_rule";
|
|
751
|
+
name: string;
|
|
752
|
+
action: "block" | "review";
|
|
753
|
+
predicate: RiskPredicate;
|
|
754
|
+
enabled: boolean;
|
|
755
|
+
priority: number;
|
|
756
|
+
/** True for a rule Secure Processing applies to every business. You cannot edit those. */
|
|
757
|
+
platform_default: boolean;
|
|
758
|
+
/** Null on a platform default, which applies in test and live alike. */
|
|
759
|
+
livemode: boolean | null;
|
|
760
|
+
metadata: Record<string, string>;
|
|
761
|
+
created: number;
|
|
762
|
+
updated: number;
|
|
763
|
+
}
|
|
764
|
+
export interface CreateRiskRuleParams {
|
|
765
|
+
name: string;
|
|
766
|
+
action: "block" | "review";
|
|
767
|
+
predicate: RiskPredicate;
|
|
768
|
+
enabled?: boolean;
|
|
769
|
+
priority?: number;
|
|
770
|
+
metadata?: MetadataParam;
|
|
771
|
+
}
|
|
772
|
+
/** 🔴 No predicate and no action: a changed test is a new rule. See `riskRules.update`. */
|
|
773
|
+
export interface UpdateRiskRuleParams {
|
|
774
|
+
name?: string;
|
|
775
|
+
enabled?: boolean;
|
|
776
|
+
priority?: number;
|
|
777
|
+
metadata?: MetadataParam;
|
|
778
|
+
}
|
|
779
|
+
export type RiskListKind = "email" | "email_domain" | "ip" | "card_fingerprint";
|
|
780
|
+
export interface RiskListItem {
|
|
781
|
+
id: string;
|
|
782
|
+
object: "risk_list_item";
|
|
783
|
+
list: "allow" | "block";
|
|
784
|
+
kind: RiskListKind;
|
|
785
|
+
value: string;
|
|
786
|
+
note: string | null;
|
|
787
|
+
livemode: boolean;
|
|
788
|
+
created: number;
|
|
789
|
+
}
|
|
790
|
+
export interface CreateRiskListItemParams {
|
|
791
|
+
list: "allow" | "block";
|
|
792
|
+
kind: RiskListKind;
|
|
793
|
+
value: string;
|
|
794
|
+
note?: string;
|
|
795
|
+
}
|
|
796
|
+
export interface Review {
|
|
797
|
+
id: string;
|
|
798
|
+
object: "review";
|
|
799
|
+
payment_intent: string;
|
|
800
|
+
risk_evaluation: string | null;
|
|
801
|
+
/** Which rules asked for a look, in words. */
|
|
802
|
+
reason: string | null;
|
|
803
|
+
status: "open" | "approved" | "refunded";
|
|
804
|
+
opened: number;
|
|
805
|
+
closed: number | null;
|
|
806
|
+
closed_reason: string | null;
|
|
807
|
+
livemode: boolean;
|
|
808
|
+
}
|
|
809
|
+
export type DisputeReason = "bank_cannot_process" | "check_returned" | "credit_not_processed" | "customer_initiated" | "debit_not_authorized" | "duplicate" | "fraudulent" | "general" | "incorrect_account_details" | "insufficient_funds" | "product_not_received" | "product_unacceptable" | "subscription_canceled" | "unrecognized";
|
|
810
|
+
/**
|
|
811
|
+
* A `warning_` status is an INQUIRY — a retrieval request. No money has been taken and none is
|
|
812
|
+
* held. Everything else is a chargeback, and the disputed amount is out of your available balance
|
|
813
|
+
* until the case closes.
|
|
814
|
+
*/
|
|
815
|
+
export type DisputeStatus = "warning_needs_response" | "warning_under_review" | "warning_closed" | "needs_response" | "under_review" | "won" | "lost";
|
|
816
|
+
/**
|
|
817
|
+
* Evidence, with Stripe's field names.
|
|
818
|
+
*
|
|
819
|
+
* The nine fields whose names end in a document — `receipt`, `shipping_documentation`,
|
|
820
|
+
* `customer_signature` and so on — take a `file_` id from `files.create` with
|
|
821
|
+
* `purpose: "dispute_evidence"`. The rest are text, up to 20000 characters. `null` clears a field.
|
|
822
|
+
*/
|
|
823
|
+
export interface DisputeEvidence {
|
|
824
|
+
access_activity_log?: string | null;
|
|
825
|
+
billing_address?: string | null;
|
|
826
|
+
cancellation_policy?: string | null;
|
|
827
|
+
cancellation_policy_disclosure?: string | null;
|
|
828
|
+
cancellation_rebuttal?: string | null;
|
|
829
|
+
customer_communication?: string | null;
|
|
830
|
+
customer_email_address?: string | null;
|
|
831
|
+
customer_name?: string | null;
|
|
832
|
+
customer_purchase_ip?: string | null;
|
|
833
|
+
customer_signature?: string | null;
|
|
834
|
+
duplicate_charge_documentation?: string | null;
|
|
835
|
+
duplicate_charge_explanation?: string | null;
|
|
836
|
+
duplicate_charge_id?: string | null;
|
|
837
|
+
product_description?: string | null;
|
|
838
|
+
receipt?: string | null;
|
|
839
|
+
refund_policy?: string | null;
|
|
840
|
+
refund_policy_disclosure?: string | null;
|
|
841
|
+
refund_refusal_explanation?: string | null;
|
|
842
|
+
service_date?: string | null;
|
|
843
|
+
service_documentation?: string | null;
|
|
844
|
+
shipping_address?: string | null;
|
|
845
|
+
shipping_carrier?: string | null;
|
|
846
|
+
shipping_date?: string | null;
|
|
847
|
+
shipping_documentation?: string | null;
|
|
848
|
+
shipping_tracking_number?: string | null;
|
|
849
|
+
uncategorized_file?: string | null;
|
|
850
|
+
uncategorized_text?: string | null;
|
|
851
|
+
}
|
|
852
|
+
export interface Dispute {
|
|
853
|
+
id: string;
|
|
854
|
+
object: "dispute";
|
|
855
|
+
/** Minor units, in the payment's own currency. */
|
|
856
|
+
amount: number;
|
|
857
|
+
currency: string;
|
|
858
|
+
/** Minor units of BZD: what actually moved in the ledger, at the rate the payment was taken at. */
|
|
859
|
+
settlement_amount: number;
|
|
860
|
+
settlement_currency: string;
|
|
861
|
+
payment_intent: string;
|
|
862
|
+
reason: DisputeReason;
|
|
863
|
+
status: DisputeStatus;
|
|
864
|
+
evidence: DisputeEvidence;
|
|
865
|
+
evidence_details: {
|
|
866
|
+
/** Unix seconds. Belize Bank gives no second chance. */
|
|
867
|
+
due_by: number;
|
|
868
|
+
has_evidence: boolean;
|
|
869
|
+
submission_count: number;
|
|
870
|
+
past_due: boolean;
|
|
871
|
+
submission_open: boolean;
|
|
872
|
+
};
|
|
873
|
+
balance_transactions: string[];
|
|
874
|
+
is_charge_refundable: boolean;
|
|
875
|
+
network_reason_code: string | null;
|
|
876
|
+
/** Belize Bank's own reference for the case. Quote it if you speak to them directly. */
|
|
877
|
+
bank_case_reference: string;
|
|
878
|
+
bank_opened_at: string | null;
|
|
879
|
+
/** What we charged for handling a loss, in BZD minor units. */
|
|
880
|
+
dispute_fee: number;
|
|
881
|
+
outcome_note: string | null;
|
|
882
|
+
merchant_accepted: boolean;
|
|
883
|
+
closed_at: number | null;
|
|
884
|
+
livemode: boolean;
|
|
885
|
+
created: number;
|
|
886
|
+
}
|
|
887
|
+
export interface UpdateDisputeParams {
|
|
888
|
+
/** MERGES with what is already on file. Pass `null` to clear a field. */
|
|
889
|
+
evidence?: DisputeEvidence;
|
|
890
|
+
/** Send it. After this the evidence is frozen. */
|
|
891
|
+
submit?: boolean;
|
|
892
|
+
}
|