@cosmosapp/pay_sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +458 -0
- package/dist/index.cjs +1205 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1244 -0
- package/dist/index.d.ts +1244 -0
- package/dist/index.js +1171 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1244 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type definitions for the Cosmos Pay Payments API.
|
|
6
|
+
*
|
|
7
|
+
* These mirror the server's OpenAPI schema (Stellar SEP-7 payment intents,
|
|
8
|
+
* webhooks, products, customers and analytics). Every type is exported so
|
|
9
|
+
* TypeScript consumers get full intellisense; JavaScript consumers can ignore
|
|
10
|
+
* them entirely.
|
|
11
|
+
*/
|
|
12
|
+
/** Lifecycle state of a payment intent. */
|
|
13
|
+
declare const PaymentIntentStatus: {
|
|
14
|
+
readonly Pending: "PENDING";
|
|
15
|
+
readonly Submitted: "SUBMITTED";
|
|
16
|
+
readonly Succeeded: "SUCCEEDED";
|
|
17
|
+
readonly Failed: "FAILED";
|
|
18
|
+
readonly Cancelled: "CANCELLED";
|
|
19
|
+
readonly Expired: "EXPIRED";
|
|
20
|
+
};
|
|
21
|
+
type PaymentIntentStatus = (typeof PaymentIntentStatus)[keyof typeof PaymentIntentStatus];
|
|
22
|
+
/** SEP-7 operation a payment intent represents. */
|
|
23
|
+
declare const PaymentIntentKind: {
|
|
24
|
+
/** Source account is known → unsigned XDR + `web+stellar:tx` URI. */
|
|
25
|
+
readonly Tx: "TX";
|
|
26
|
+
/** No source → `web+stellar:pay` URI only (wallet picks the source). */
|
|
27
|
+
readonly Pay: "PAY";
|
|
28
|
+
};
|
|
29
|
+
type PaymentIntentKind = (typeof PaymentIntentKind)[keyof typeof PaymentIntentKind];
|
|
30
|
+
/** Domain events an integrator can subscribe a webhook to. */
|
|
31
|
+
declare const WebhookEventType: {
|
|
32
|
+
readonly PaymentIntentCreated: "PAYMENT_INTENT_CREATED";
|
|
33
|
+
readonly PaymentIntentUpdated: "PAYMENT_INTENT_UPDATED";
|
|
34
|
+
readonly PaymentIntentSucceeded: "PAYMENT_INTENT_SUCCEEDED";
|
|
35
|
+
readonly PaymentIntentFailed: "PAYMENT_INTENT_FAILED";
|
|
36
|
+
readonly PaymentIntentCancelled: "PAYMENT_INTENT_CANCELLED";
|
|
37
|
+
readonly PaymentIntentDeleted: "PAYMENT_INTENT_DELETED";
|
|
38
|
+
};
|
|
39
|
+
type WebhookEventType = (typeof WebhookEventType)[keyof typeof WebhookEventType];
|
|
40
|
+
/** Delivery state of a single webhook attempt. */
|
|
41
|
+
declare const WebhookDeliveryStatus: {
|
|
42
|
+
readonly Pending: "PENDING";
|
|
43
|
+
readonly Succeeded: "SUCCEEDED";
|
|
44
|
+
readonly Failed: "FAILED";
|
|
45
|
+
};
|
|
46
|
+
type WebhookDeliveryStatus = (typeof WebhookDeliveryStatus)[keyof typeof WebhookDeliveryStatus];
|
|
47
|
+
/** Product billing kind. */
|
|
48
|
+
declare const ProductKind: {
|
|
49
|
+
readonly Recurring: "recurring";
|
|
50
|
+
readonly OneTime: "one_time";
|
|
51
|
+
readonly Link: "link";
|
|
52
|
+
};
|
|
53
|
+
type ProductKind = (typeof ProductKind)[keyof typeof ProductKind];
|
|
54
|
+
/** Body for `POST /v1/payment-intents/tx`. */
|
|
55
|
+
interface CreateTxPaymentIntentOptions {
|
|
56
|
+
/** Payer's Stellar account — the transaction source. */
|
|
57
|
+
source: string;
|
|
58
|
+
/** Payee's Stellar account. */
|
|
59
|
+
destination: string;
|
|
60
|
+
/** Amount as a decimal string (max 7 decimals). */
|
|
61
|
+
amount: string;
|
|
62
|
+
/** Asset code. Omit (or `XLM`/`native`) for native lumens. */
|
|
63
|
+
assetCode?: string;
|
|
64
|
+
/** Issuer account for a non-native asset. */
|
|
65
|
+
assetIssuer?: string;
|
|
66
|
+
/** MEMO_ID (numeric uint64) for idempotency + on-chain identification. Auto-generated when omitted. */
|
|
67
|
+
memo?: string;
|
|
68
|
+
/** SEP-7 `msg`: shown to the user in their wallet (≤ 300 chars). */
|
|
69
|
+
msg?: string;
|
|
70
|
+
/** SEP-7 `callback` where the wallet POSTs the signed XDR, e.g. `url:https://...`. */
|
|
71
|
+
callback?: string;
|
|
72
|
+
}
|
|
73
|
+
/** Body for `POST /v1/payment-intents/pay`. */
|
|
74
|
+
interface CreatePayPaymentIntentOptions {
|
|
75
|
+
/** Payee's Stellar account. */
|
|
76
|
+
destination: string;
|
|
77
|
+
/** Amount the destination should receive. Omit to let the user enter it (e.g. donations). */
|
|
78
|
+
amount?: string;
|
|
79
|
+
/** Asset code the destination receives. Omit for native lumens (XLM). */
|
|
80
|
+
assetCode?: string;
|
|
81
|
+
/** Issuer account for a non-native asset. */
|
|
82
|
+
assetIssuer?: string;
|
|
83
|
+
/** MEMO_ID (numeric uint64) for idempotency + on-chain identification. Auto-generated when omitted. */
|
|
84
|
+
memo?: string;
|
|
85
|
+
/** SEP-7 `msg`: shown to the user in their wallet (≤ 300 chars). */
|
|
86
|
+
msg?: string;
|
|
87
|
+
/** SEP-7 `callback`, e.g. `url:https://...`. */
|
|
88
|
+
callback?: string;
|
|
89
|
+
}
|
|
90
|
+
/** Body for `PATCH /v1/payment-intents/:id`. */
|
|
91
|
+
interface UpdatePaymentIntentOptions {
|
|
92
|
+
status?: PaymentIntentStatus;
|
|
93
|
+
/** Stellar transaction hash once the signed tx is submitted. */
|
|
94
|
+
txHash?: string;
|
|
95
|
+
/** Merchant reference. */
|
|
96
|
+
reference?: string;
|
|
97
|
+
}
|
|
98
|
+
/** Query for `GET /v1/payment-intents`. */
|
|
99
|
+
interface ListPaymentIntentsOptions {
|
|
100
|
+
status?: PaymentIntentStatus;
|
|
101
|
+
/** Page size (max 100, default 20). */
|
|
102
|
+
take?: number;
|
|
103
|
+
/** Offset (default 0). */
|
|
104
|
+
skip?: number;
|
|
105
|
+
}
|
|
106
|
+
/** Raw payment intent payload returned by the API. */
|
|
107
|
+
interface PaymentIntentData {
|
|
108
|
+
id: string;
|
|
109
|
+
kind: PaymentIntentKind;
|
|
110
|
+
status: PaymentIntentStatus;
|
|
111
|
+
network: string;
|
|
112
|
+
source: string | null;
|
|
113
|
+
destination: string;
|
|
114
|
+
amount: string | null;
|
|
115
|
+
asset: string;
|
|
116
|
+
assetIssuer: string | null;
|
|
117
|
+
memo: string;
|
|
118
|
+
msg: string | null;
|
|
119
|
+
callback: string | null;
|
|
120
|
+
xdr: string | null;
|
|
121
|
+
uri: string;
|
|
122
|
+
qr: string;
|
|
123
|
+
txHash: string | null;
|
|
124
|
+
reference: string | null;
|
|
125
|
+
createdAt: string;
|
|
126
|
+
updatedAt: string;
|
|
127
|
+
}
|
|
128
|
+
/** Raw paginated list of payment intents. */
|
|
129
|
+
interface PaymentIntentListData {
|
|
130
|
+
data: PaymentIntentData[];
|
|
131
|
+
total: number;
|
|
132
|
+
take: number;
|
|
133
|
+
skip: number;
|
|
134
|
+
}
|
|
135
|
+
/** Body for `POST /v1/payment-intents/:id/validate`. */
|
|
136
|
+
interface ValidatePaymentIntentOptions {
|
|
137
|
+
/** Hash of the submitted Stellar transaction to validate against this intent. */
|
|
138
|
+
txHash: string;
|
|
139
|
+
}
|
|
140
|
+
/** Raw outcome of a validation attempt. */
|
|
141
|
+
interface ValidationOutcomeData {
|
|
142
|
+
valid: boolean;
|
|
143
|
+
status: PaymentIntentStatus;
|
|
144
|
+
reason?: string | null;
|
|
145
|
+
paymentIntent?: PaymentIntentData;
|
|
146
|
+
}
|
|
147
|
+
/** Raw `{ id, deleted }` response. */
|
|
148
|
+
interface DeletedData {
|
|
149
|
+
id: string;
|
|
150
|
+
deleted: boolean;
|
|
151
|
+
}
|
|
152
|
+
/** Body for `POST /v1/webhooks`. */
|
|
153
|
+
interface CreateWebhookEndpointOptions {
|
|
154
|
+
/** HTTPS URL that will receive POSTed event notifications. */
|
|
155
|
+
url: string;
|
|
156
|
+
description?: string;
|
|
157
|
+
/** Event types to subscribe to. Omit/empty to receive all events. */
|
|
158
|
+
eventTypes?: WebhookEventType[];
|
|
159
|
+
}
|
|
160
|
+
/** Body for `PATCH /v1/webhooks/:id`. */
|
|
161
|
+
interface UpdateWebhookEndpointOptions {
|
|
162
|
+
url?: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
/** Pause/resume deliveries to this endpoint. */
|
|
165
|
+
enabled?: boolean;
|
|
166
|
+
eventTypes?: WebhookEventType[];
|
|
167
|
+
}
|
|
168
|
+
/** Raw webhook endpoint payload. */
|
|
169
|
+
interface WebhookEndpointData {
|
|
170
|
+
id: string;
|
|
171
|
+
url: string;
|
|
172
|
+
description: string | null;
|
|
173
|
+
enabled: boolean;
|
|
174
|
+
eventTypes: WebhookEventType[];
|
|
175
|
+
createdAt: string;
|
|
176
|
+
updatedAt: string;
|
|
177
|
+
}
|
|
178
|
+
/** Raw webhook endpoint payload including the one-time signing secret. */
|
|
179
|
+
interface WebhookEndpointWithSecretData extends WebhookEndpointData {
|
|
180
|
+
/** HMAC signing secret — shown once. Store it securely. */
|
|
181
|
+
secret: string;
|
|
182
|
+
}
|
|
183
|
+
/** Raw result of a webhook ping. */
|
|
184
|
+
interface WebhookPingData {
|
|
185
|
+
ok: boolean;
|
|
186
|
+
responseStatus: number | null;
|
|
187
|
+
error: string | null;
|
|
188
|
+
}
|
|
189
|
+
/** Raw webhook delivery (audit) record. */
|
|
190
|
+
interface WebhookDeliveryData {
|
|
191
|
+
id: string;
|
|
192
|
+
endpointId: string;
|
|
193
|
+
eventType: WebhookEventType;
|
|
194
|
+
eventId: string;
|
|
195
|
+
payload: Record<string, unknown>;
|
|
196
|
+
status: WebhookDeliveryStatus;
|
|
197
|
+
attempts: number;
|
|
198
|
+
responseStatus: number | null;
|
|
199
|
+
error: string | null;
|
|
200
|
+
lastAttemptAt: string | null;
|
|
201
|
+
createdAt: string;
|
|
202
|
+
updatedAt: string;
|
|
203
|
+
}
|
|
204
|
+
/** Raw paginated list of webhook deliveries. */
|
|
205
|
+
interface WebhookDeliveryListData {
|
|
206
|
+
data: WebhookDeliveryData[];
|
|
207
|
+
total: number;
|
|
208
|
+
take: number;
|
|
209
|
+
skip: number;
|
|
210
|
+
}
|
|
211
|
+
/** Query for `GET /v1/webhooks/:id/deliveries`. */
|
|
212
|
+
interface ListWebhookDeliveriesOptions {
|
|
213
|
+
status?: WebhookDeliveryStatus;
|
|
214
|
+
take?: number;
|
|
215
|
+
skip?: number;
|
|
216
|
+
}
|
|
217
|
+
/** Shape of the JSON body POSTed to an integrator's webhook URL. */
|
|
218
|
+
interface WebhookEvent<T = PaymentIntentData> {
|
|
219
|
+
/** Stable event id (use for idempotency). */
|
|
220
|
+
id: string;
|
|
221
|
+
type: WebhookEventType;
|
|
222
|
+
createdAt: string;
|
|
223
|
+
data: T;
|
|
224
|
+
}
|
|
225
|
+
/** Body for `POST /v1/products`. */
|
|
226
|
+
interface CreateProductOptions {
|
|
227
|
+
name: string;
|
|
228
|
+
description?: string;
|
|
229
|
+
/** Decimal price (≤ 7 decimals). Omit for a customer-set amount. */
|
|
230
|
+
amount?: string;
|
|
231
|
+
/** Asset code the price is in. Omit for native lumens (XLM). */
|
|
232
|
+
assetCode?: string;
|
|
233
|
+
kind?: ProductKind;
|
|
234
|
+
active?: boolean;
|
|
235
|
+
reference?: string;
|
|
236
|
+
}
|
|
237
|
+
/** Body for `PATCH /v1/products/:id`. */
|
|
238
|
+
type UpdateProductOptions = Partial<CreateProductOptions>;
|
|
239
|
+
/** Raw product payload. */
|
|
240
|
+
interface ProductData {
|
|
241
|
+
id: string;
|
|
242
|
+
name: string;
|
|
243
|
+
description: string | null;
|
|
244
|
+
amount: string | null;
|
|
245
|
+
asset: string;
|
|
246
|
+
kind: ProductKind;
|
|
247
|
+
active: boolean;
|
|
248
|
+
reference: string | null;
|
|
249
|
+
createdAt: string;
|
|
250
|
+
updatedAt: string;
|
|
251
|
+
}
|
|
252
|
+
/** Body for `POST /v1/customers`. */
|
|
253
|
+
interface CreateCustomerOptions {
|
|
254
|
+
name: string;
|
|
255
|
+
alias?: string;
|
|
256
|
+
note?: string;
|
|
257
|
+
email?: string;
|
|
258
|
+
/** Optional Stellar account to associate the customer with. */
|
|
259
|
+
account?: string;
|
|
260
|
+
reference?: string;
|
|
261
|
+
}
|
|
262
|
+
/** Body for `PATCH /v1/customers/:id`. */
|
|
263
|
+
type UpdateCustomerOptions = Partial<CreateCustomerOptions>;
|
|
264
|
+
/** Raw customer payload. */
|
|
265
|
+
interface CustomerData {
|
|
266
|
+
id: string;
|
|
267
|
+
consumerId: string;
|
|
268
|
+
name: string;
|
|
269
|
+
alias: string | null;
|
|
270
|
+
note: string | null;
|
|
271
|
+
email: string | null;
|
|
272
|
+
account: string | null;
|
|
273
|
+
reference: string | null;
|
|
274
|
+
createdAt: string;
|
|
275
|
+
updatedAt: string;
|
|
276
|
+
/** Derived on-chain stats (present in list responses). */
|
|
277
|
+
payments?: number;
|
|
278
|
+
succeeded?: number;
|
|
279
|
+
total?: string;
|
|
280
|
+
}
|
|
281
|
+
/** Raw `{ data, total }` list of customers. */
|
|
282
|
+
interface CustomerListData {
|
|
283
|
+
data: CustomerData[];
|
|
284
|
+
total: number;
|
|
285
|
+
}
|
|
286
|
+
interface AnalyticsVolumeEntry {
|
|
287
|
+
asset: string;
|
|
288
|
+
amount: string;
|
|
289
|
+
count: number;
|
|
290
|
+
}
|
|
291
|
+
interface AnalyticsSeriesPoint {
|
|
292
|
+
date: string;
|
|
293
|
+
count: number;
|
|
294
|
+
volume: string;
|
|
295
|
+
}
|
|
296
|
+
interface AnalyticsRecentRow {
|
|
297
|
+
id: string;
|
|
298
|
+
kind: string;
|
|
299
|
+
status: PaymentIntentStatus;
|
|
300
|
+
amount: string | null;
|
|
301
|
+
asset: string;
|
|
302
|
+
destination: string;
|
|
303
|
+
createdAt: string;
|
|
304
|
+
}
|
|
305
|
+
/** Raw overview metrics returned by `GET /v1/summary`. */
|
|
306
|
+
interface AnalyticsSummaryData {
|
|
307
|
+
totals: {
|
|
308
|
+
all: number;
|
|
309
|
+
succeeded: number;
|
|
310
|
+
pending: number;
|
|
311
|
+
submitted: number;
|
|
312
|
+
failed: number;
|
|
313
|
+
cancelled: number;
|
|
314
|
+
expired: number;
|
|
315
|
+
successRate: number;
|
|
316
|
+
};
|
|
317
|
+
volume: AnalyticsVolumeEntry[];
|
|
318
|
+
webhooks: {
|
|
319
|
+
endpoints: number;
|
|
320
|
+
deliveries: number;
|
|
321
|
+
failedDeliveries: number;
|
|
322
|
+
};
|
|
323
|
+
customers: number;
|
|
324
|
+
series: AnalyticsSeriesPoint[];
|
|
325
|
+
recent: AnalyticsRecentRow[];
|
|
326
|
+
}
|
|
327
|
+
interface AnalyticsBalanceEntry {
|
|
328
|
+
asset: string;
|
|
329
|
+
amount: string;
|
|
330
|
+
pending: string;
|
|
331
|
+
count: number;
|
|
332
|
+
}
|
|
333
|
+
/** Raw balances returned by `GET /v1/balances`. */
|
|
334
|
+
interface AnalyticsBalancesData {
|
|
335
|
+
data: AnalyticsBalanceEntry[];
|
|
336
|
+
total: number;
|
|
337
|
+
}
|
|
338
|
+
interface ApiLogRow {
|
|
339
|
+
id: string;
|
|
340
|
+
method: string;
|
|
341
|
+
path: string;
|
|
342
|
+
statusCode: number;
|
|
343
|
+
durationMs: number;
|
|
344
|
+
ip: string | null;
|
|
345
|
+
userAgent: string | null;
|
|
346
|
+
status: 'ok' | 'pending' | 'fail';
|
|
347
|
+
at: string;
|
|
348
|
+
}
|
|
349
|
+
/** Raw API request log returned by `GET /v1/logs`. */
|
|
350
|
+
interface ApiLogsData {
|
|
351
|
+
data: ApiLogRow[];
|
|
352
|
+
total: number;
|
|
353
|
+
}
|
|
354
|
+
interface WebhookLogRow {
|
|
355
|
+
id: string;
|
|
356
|
+
endpointId: string;
|
|
357
|
+
url: string | null;
|
|
358
|
+
eventType: WebhookEventType;
|
|
359
|
+
eventId: string;
|
|
360
|
+
attempts: number;
|
|
361
|
+
responseStatus: number | null;
|
|
362
|
+
error: string | null;
|
|
363
|
+
status: 'ok' | 'pending' | 'fail';
|
|
364
|
+
at: string;
|
|
365
|
+
}
|
|
366
|
+
/** Raw webhook delivery log returned by `GET /v1/logs/webhooks`. */
|
|
367
|
+
interface WebhookLogsData {
|
|
368
|
+
data: WebhookLogRow[];
|
|
369
|
+
total: number;
|
|
370
|
+
}
|
|
371
|
+
interface HealthCheckData {
|
|
372
|
+
status: string;
|
|
373
|
+
info?: Record<string, {
|
|
374
|
+
status: string;
|
|
375
|
+
} & Record<string, unknown>> | null;
|
|
376
|
+
error?: Record<string, {
|
|
377
|
+
status: string;
|
|
378
|
+
} & Record<string, unknown>> | null;
|
|
379
|
+
details?: Record<string, {
|
|
380
|
+
status: string;
|
|
381
|
+
} & Record<string, unknown>>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Read-only analytics derived from the consumer's intents and deliveries —
|
|
386
|
+
* `client.analytics`. Powers dashboard-style Overview / Balances / Logs views.
|
|
387
|
+
*/
|
|
388
|
+
declare class AnalyticsManager {
|
|
389
|
+
readonly client: Client;
|
|
390
|
+
constructor(client: Client);
|
|
391
|
+
private get rest();
|
|
392
|
+
/** Overview metrics: totals, settled volume, webhook health, 30-day series. */
|
|
393
|
+
summary(): Promise<AnalyticsSummaryData>;
|
|
394
|
+
/** Settled (and pending) amount per asset. */
|
|
395
|
+
balances(): Promise<AnalyticsBalancesData>;
|
|
396
|
+
/** Recent API requests reaching the service (with details). */
|
|
397
|
+
apiLogs(): Promise<ApiLogsData>;
|
|
398
|
+
/** Recent webhook deliveries across all endpoints (with details). */
|
|
399
|
+
webhookLogs(): Promise<WebhookLogsData>;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Root of every API structure. Holds a back-reference to the {@link Client} so
|
|
404
|
+
* instances can perform their own actions (e.g. `paymentIntent.delete()`), and
|
|
405
|
+
* provides the `_patch`/`toJSON` plumbing shared by all structures.
|
|
406
|
+
*/
|
|
407
|
+
declare abstract class Base<Data extends {
|
|
408
|
+
id: string;
|
|
409
|
+
}> {
|
|
410
|
+
/** The client that instantiated this structure. */
|
|
411
|
+
readonly client: Client;
|
|
412
|
+
/** Unique identifier of the resource. */
|
|
413
|
+
id: string;
|
|
414
|
+
protected constructor(client: Client, data: Data);
|
|
415
|
+
/** Merge raw API data onto this instance. Subclasses override and call super. */
|
|
416
|
+
protected _patch(data: Data): this;
|
|
417
|
+
/** Return the raw API representation of this structure. */
|
|
418
|
+
abstract toJSON(): Data;
|
|
419
|
+
/** Allow `String(structure)` / template literals to resolve to the id. */
|
|
420
|
+
valueOf(): string;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** A customer record, optionally enriched with on-chain payment stats. */
|
|
424
|
+
declare class Customer extends Base<CustomerData> {
|
|
425
|
+
consumerId: string;
|
|
426
|
+
name: string;
|
|
427
|
+
alias: string | null;
|
|
428
|
+
note: string | null;
|
|
429
|
+
email: string | null;
|
|
430
|
+
/** Optional Stellar account associated with the customer. */
|
|
431
|
+
account: string | null;
|
|
432
|
+
reference: string | null;
|
|
433
|
+
createdAt: Date;
|
|
434
|
+
updatedAt: Date;
|
|
435
|
+
/** Number of payment intents from this customer's account (list view only). */
|
|
436
|
+
payments: number | null;
|
|
437
|
+
/** Number of succeeded payments (list view only). */
|
|
438
|
+
succeeded: number | null;
|
|
439
|
+
/** Total settled amount as a decimal string (list view only). */
|
|
440
|
+
total: string | null;
|
|
441
|
+
constructor(client: Client, data: CustomerData);
|
|
442
|
+
protected _patch(data: CustomerData): this;
|
|
443
|
+
/** Re-fetch this customer. */
|
|
444
|
+
fetch(): Promise<Customer>;
|
|
445
|
+
/** Update this customer. Mutates and returns this. */
|
|
446
|
+
edit(options: UpdateCustomerOptions): Promise<this>;
|
|
447
|
+
/** Delete this customer. */
|
|
448
|
+
delete(): Promise<{
|
|
449
|
+
id: string;
|
|
450
|
+
deleted: boolean;
|
|
451
|
+
}>;
|
|
452
|
+
toJSON(): CustomerData;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/** A `fetch`-compatible function (defaults to the global `fetch`). */
|
|
456
|
+
type FetchLike = typeof fetch;
|
|
457
|
+
/** Options accepted when constructing a {@link REST} instance. */
|
|
458
|
+
interface RESTOptions {
|
|
459
|
+
/**
|
|
460
|
+
* Base URL of the Cosmos Pay gateway (no trailing slash), e.g.
|
|
461
|
+
* `https://gateway.example.com`. The version segment is appended automatically.
|
|
462
|
+
*/
|
|
463
|
+
baseURL: string;
|
|
464
|
+
/**
|
|
465
|
+
* API key issued by the Cosmos developer platform. Sent as
|
|
466
|
+
* `Authorization: Bearer <apiKey>` (and `apikey: <apiKey>`) to the gateway.
|
|
467
|
+
*/
|
|
468
|
+
apiKey?: string;
|
|
469
|
+
/**
|
|
470
|
+
* Shared gateway secret (`X-Gateway-Secret`). Only needed when calling the
|
|
471
|
+
* service directly (bypassing APISIX) — typically local development.
|
|
472
|
+
*/
|
|
473
|
+
gatewaySecret?: string;
|
|
474
|
+
/**
|
|
475
|
+
* Authenticated consumer username (`X-Consumer-Username`). Pair with
|
|
476
|
+
* `gatewaySecret` for direct service access.
|
|
477
|
+
*/
|
|
478
|
+
consumerUsername?: string;
|
|
479
|
+
/**
|
|
480
|
+
* API version segment prefixed to every route. Defaults to `v1`. Set to an
|
|
481
|
+
* empty string when your gateway already injects the version.
|
|
482
|
+
*/
|
|
483
|
+
version?: string;
|
|
484
|
+
/** Per-request timeout in milliseconds (default 30000). */
|
|
485
|
+
timeout?: number;
|
|
486
|
+
/** Retries for transient failures — network errors, 429 and 5xx (default 2). */
|
|
487
|
+
retries?: number;
|
|
488
|
+
/** Extra headers merged into every request. */
|
|
489
|
+
headers?: Record<string, string>;
|
|
490
|
+
/** Custom fetch implementation (e.g. a polyfill on old runtimes). */
|
|
491
|
+
fetch?: FetchLike;
|
|
492
|
+
}
|
|
493
|
+
/** Internal options for a single request. */
|
|
494
|
+
interface RequestOptions {
|
|
495
|
+
/** Query string parameters; `undefined`/`null` values are dropped. */
|
|
496
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
497
|
+
/** JSON body to send. */
|
|
498
|
+
body?: unknown;
|
|
499
|
+
/** Per-request header overrides. */
|
|
500
|
+
headers?: Record<string, string>;
|
|
501
|
+
/** Per-request AbortSignal. */
|
|
502
|
+
signal?: AbortSignal;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* The HTTP layer. Owns the base URL, authentication and retry/timeout policy,
|
|
506
|
+
* and exposes thin verb helpers (`get`/`post`/`patch`/`delete`). Managers call
|
|
507
|
+
* these — they never touch `fetch` directly.
|
|
508
|
+
*/
|
|
509
|
+
declare class REST extends EventEmitter {
|
|
510
|
+
baseURL: string;
|
|
511
|
+
readonly version: string;
|
|
512
|
+
private readonly timeout;
|
|
513
|
+
private readonly retries;
|
|
514
|
+
private readonly fetchFn;
|
|
515
|
+
private readonly extraHeaders;
|
|
516
|
+
private apiKey?;
|
|
517
|
+
private gatewaySecret?;
|
|
518
|
+
private consumerUsername?;
|
|
519
|
+
constructor(options: RESTOptions);
|
|
520
|
+
/** Replace the API key used for subsequent requests. */
|
|
521
|
+
setApiKey(apiKey: string): this;
|
|
522
|
+
/** Set direct-access gateway credentials (local/dev usage). */
|
|
523
|
+
setGatewayCredentials(secret: string, consumerUsername: string): this;
|
|
524
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
525
|
+
post<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
526
|
+
patch<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
527
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
528
|
+
/** Build the absolute URL for a route, applying the version prefix + query. */
|
|
529
|
+
buildURL(path: string, query?: RequestOptions['query']): string;
|
|
530
|
+
private buildHeaders;
|
|
531
|
+
/** Core request with retry, timeout and structured error handling. */
|
|
532
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
533
|
+
private backoff;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Base class for all resource managers. Each manager owns a slice of the API
|
|
538
|
+
* (payment intents, webhooks, ...) and a lightweight in-memory cache of the
|
|
539
|
+
* structures it has materialized — mirroring discord.js's manager pattern.
|
|
540
|
+
*
|
|
541
|
+
* Extends EventEmitter so managers that surface real-time events (e.g. the
|
|
542
|
+
* webhook listener) can `emit`/`on` without extra plumbing.
|
|
543
|
+
*/
|
|
544
|
+
declare abstract class BaseManager<Structure extends {
|
|
545
|
+
id: string;
|
|
546
|
+
}> extends EventEmitter {
|
|
547
|
+
readonly client: Client;
|
|
548
|
+
/** Cache of structures keyed by id, populated on fetch/create. */
|
|
549
|
+
readonly cache: Map<string, Structure>;
|
|
550
|
+
constructor(client: Client);
|
|
551
|
+
/** Shortcut to the shared REST instance. */
|
|
552
|
+
protected get rest(): REST;
|
|
553
|
+
/** Store a structure in the cache and return it. */
|
|
554
|
+
protected _add(structure: Structure): Structure;
|
|
555
|
+
/** Resolve an id from either a raw id or a structure instance. */
|
|
556
|
+
resolveId(idOrStructure: string | {
|
|
557
|
+
id: string;
|
|
558
|
+
}): string;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
type CustomerDeletedData = {
|
|
562
|
+
id: string;
|
|
563
|
+
deleted: boolean;
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* Manages customers — `client.customers`.
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
* const customer = await client.customers.create({
|
|
570
|
+
* name: 'Acme Inc.', email: 'billing@acme.com',
|
|
571
|
+
* });
|
|
572
|
+
*/
|
|
573
|
+
declare class CustomerManager extends BaseManager<Customer> {
|
|
574
|
+
private readonly route;
|
|
575
|
+
/** Create a customer. */
|
|
576
|
+
create(options: CreateCustomerOptions): Promise<Customer>;
|
|
577
|
+
/** List the consumer's customers (with payment stats). */
|
|
578
|
+
list(): Promise<Customer[]>;
|
|
579
|
+
/** Get a customer by id. */
|
|
580
|
+
fetch(id: string): Promise<Customer>;
|
|
581
|
+
/** Update a customer. */
|
|
582
|
+
update(id: string, options: UpdateCustomerOptions): Promise<Customer>;
|
|
583
|
+
/** Delete a customer. */
|
|
584
|
+
delete(id: string): Promise<CustomerDeletedData>;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Service health probes — `client.health`. These routes are public (they don't
|
|
589
|
+
* require an authenticated consumer).
|
|
590
|
+
*/
|
|
591
|
+
declare class HealthManager {
|
|
592
|
+
readonly client: Client;
|
|
593
|
+
constructor(client: Client);
|
|
594
|
+
private get rest();
|
|
595
|
+
/** Liveness probe — resolves when the service is up. */
|
|
596
|
+
liveness(): Promise<boolean>;
|
|
597
|
+
/** Readiness probe (checks the database). Returns the health report. */
|
|
598
|
+
readiness(): Promise<HealthCheckData>;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* A Stellar SEP-7 payment intent.
|
|
603
|
+
*
|
|
604
|
+
* Wraps the raw API payload with typed accessors and atomic action methods so
|
|
605
|
+
* you can operate on it directly: `await intent.validate(txHash)`,
|
|
606
|
+
* `await intent.cancel()`, `await intent.delete()`.
|
|
607
|
+
*/
|
|
608
|
+
declare class PaymentIntent extends Base<PaymentIntentData> {
|
|
609
|
+
kind: PaymentIntentKind;
|
|
610
|
+
status: PaymentIntentStatus;
|
|
611
|
+
network: string;
|
|
612
|
+
/** Payer account (null for PAY intents). */
|
|
613
|
+
source: string | null;
|
|
614
|
+
destination: string;
|
|
615
|
+
amount: string | null;
|
|
616
|
+
/** Asset code, or `native` for XLM. */
|
|
617
|
+
asset: string;
|
|
618
|
+
assetIssuer: string | null;
|
|
619
|
+
/** Mandatory MEMO_ID. */
|
|
620
|
+
memo: string;
|
|
621
|
+
msg: string | null;
|
|
622
|
+
callback: string | null;
|
|
623
|
+
/** Unsigned transaction envelope (base64 XDR); null for PAY intents. */
|
|
624
|
+
xdr: string | null;
|
|
625
|
+
/** SEP-7 deep link (`tx` or `pay`). */
|
|
626
|
+
uri: string;
|
|
627
|
+
/** QR code of the SEP-7 URI (PNG data URL). */
|
|
628
|
+
qr: string;
|
|
629
|
+
txHash: string | null;
|
|
630
|
+
reference: string | null;
|
|
631
|
+
createdAt: Date;
|
|
632
|
+
updatedAt: Date;
|
|
633
|
+
constructor(client: Client, data: PaymentIntentData);
|
|
634
|
+
protected _patch(data: PaymentIntentData): this;
|
|
635
|
+
/** Whether this is a SEP-7 `tx` intent (known source, has XDR). */
|
|
636
|
+
get isTx(): boolean;
|
|
637
|
+
/** Whether this is a SEP-7 `pay` intent (no source). */
|
|
638
|
+
get isPay(): boolean;
|
|
639
|
+
/** Whether the payment has settled on-chain. */
|
|
640
|
+
get isSucceeded(): boolean;
|
|
641
|
+
/** Whether the intent is still awaiting payment. */
|
|
642
|
+
get isPending(): boolean;
|
|
643
|
+
/** Human-readable asset label (`XLM` for native). */
|
|
644
|
+
get assetLabel(): string;
|
|
645
|
+
/** Re-fetch this intent from the API, returning a fresh instance. */
|
|
646
|
+
fetch(): Promise<PaymentIntent>;
|
|
647
|
+
/** Update this intent (status / txHash / reference). Mutates and returns it. */
|
|
648
|
+
edit(options: UpdatePaymentIntentOptions): Promise<this>;
|
|
649
|
+
/**
|
|
650
|
+
* Validate a submitted transaction against this intent. On a match the status
|
|
651
|
+
* is finalized server-side and the webhook fires.
|
|
652
|
+
*/
|
|
653
|
+
validate(txHash: string): Promise<ValidationOutcome>;
|
|
654
|
+
/** Mark this intent as cancelled. */
|
|
655
|
+
cancel(): Promise<this>;
|
|
656
|
+
/** Delete this intent. */
|
|
657
|
+
delete(): Promise<DeletedData>;
|
|
658
|
+
toJSON(): PaymentIntentData;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/** A page of payment intents plus its pagination metadata. */
|
|
662
|
+
interface PaymentIntentPage {
|
|
663
|
+
items: PaymentIntent[];
|
|
664
|
+
total: number;
|
|
665
|
+
take: number;
|
|
666
|
+
skip: number;
|
|
667
|
+
}
|
|
668
|
+
/** Validation outcome with the (optional) refreshed intent materialized. */
|
|
669
|
+
interface ValidationOutcome {
|
|
670
|
+
valid: boolean;
|
|
671
|
+
status: ValidationOutcomeData['status'];
|
|
672
|
+
reason: string | null;
|
|
673
|
+
paymentIntent: PaymentIntent | null;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Manages Stellar payment intents — `client.paymentIntents`.
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* const intent = await client.paymentIntents.createTx({
|
|
680
|
+
* source: 'G...', destination: 'G...', amount: '25.5',
|
|
681
|
+
* });
|
|
682
|
+
* console.log(intent.uri, intent.qr);
|
|
683
|
+
*/
|
|
684
|
+
declare class PaymentIntentManager extends BaseManager<PaymentIntent> {
|
|
685
|
+
private readonly route;
|
|
686
|
+
/** Create a SEP-7 `tx` intent (source known → unsigned XDR + tx URI + QR). */
|
|
687
|
+
createTx(options: CreateTxPaymentIntentOptions): Promise<PaymentIntent>;
|
|
688
|
+
/** Create a SEP-7 `pay` intent (no source → pay URI + QR, no XDR). */
|
|
689
|
+
createPay(options: CreatePayPaymentIntentOptions): Promise<PaymentIntent>;
|
|
690
|
+
/** Get a single payment intent by id. */
|
|
691
|
+
fetch(id: string): Promise<PaymentIntent>;
|
|
692
|
+
/** List the consumer's payment intents (paginated). */
|
|
693
|
+
list(options?: ListPaymentIntentsOptions): Promise<PaymentIntentPage>;
|
|
694
|
+
/** Update a payment intent (status / txHash / reference). */
|
|
695
|
+
update(id: string, options: UpdatePaymentIntentOptions): Promise<PaymentIntent>;
|
|
696
|
+
/** Delete a payment intent. */
|
|
697
|
+
delete(id: string): Promise<DeletedData>;
|
|
698
|
+
/**
|
|
699
|
+
* Validate a submitted transaction against the intent (tx success +
|
|
700
|
+
* destination + amount + memo). Finalizes status server-side and fires events.
|
|
701
|
+
*/
|
|
702
|
+
validate(id: string, options: ValidatePaymentIntentOptions): Promise<ValidationOutcome>;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** A product / price the consumer can charge for. */
|
|
706
|
+
declare class Product extends Base<ProductData> {
|
|
707
|
+
name: string;
|
|
708
|
+
description: string | null;
|
|
709
|
+
amount: string | null;
|
|
710
|
+
/** Asset code, or `native` for XLM. */
|
|
711
|
+
asset: string;
|
|
712
|
+
kind: ProductKind;
|
|
713
|
+
active: boolean;
|
|
714
|
+
reference: string | null;
|
|
715
|
+
createdAt: Date;
|
|
716
|
+
updatedAt: Date;
|
|
717
|
+
constructor(client: Client, data: ProductData);
|
|
718
|
+
protected _patch(data: ProductData): this;
|
|
719
|
+
/** Human-readable asset label (`XLM` for native). */
|
|
720
|
+
get assetLabel(): string;
|
|
721
|
+
/** Re-fetch this product. */
|
|
722
|
+
fetch(): Promise<Product>;
|
|
723
|
+
/** Update this product. Mutates and returns this. */
|
|
724
|
+
edit(options: UpdateProductOptions): Promise<this>;
|
|
725
|
+
/** Mark the product active. */
|
|
726
|
+
activate(): Promise<this>;
|
|
727
|
+
/** Mark the product inactive. */
|
|
728
|
+
deactivate(): Promise<this>;
|
|
729
|
+
/** Delete this product. */
|
|
730
|
+
delete(): Promise<{
|
|
731
|
+
id: string;
|
|
732
|
+
deleted: boolean;
|
|
733
|
+
}>;
|
|
734
|
+
toJSON(): ProductData;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
type ProductDeletedData = {
|
|
738
|
+
id: string;
|
|
739
|
+
deleted: boolean;
|
|
740
|
+
};
|
|
741
|
+
/**
|
|
742
|
+
* Manages products / prices — `client.products`.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* const product = await client.products.create({
|
|
746
|
+
* name: 'Pro plan — monthly', amount: '49.00', assetCode: 'USDC',
|
|
747
|
+
* });
|
|
748
|
+
*/
|
|
749
|
+
declare class ProductManager extends BaseManager<Product> {
|
|
750
|
+
private readonly route;
|
|
751
|
+
/** Create a product. */
|
|
752
|
+
create(options: CreateProductOptions): Promise<Product>;
|
|
753
|
+
/** List the consumer's products. */
|
|
754
|
+
list(): Promise<Product[]>;
|
|
755
|
+
/** Get a product by id. */
|
|
756
|
+
fetch(id: string): Promise<Product>;
|
|
757
|
+
/** Update a product. */
|
|
758
|
+
update(id: string, options: UpdateProductOptions): Promise<Product>;
|
|
759
|
+
/** Delete a product. */
|
|
760
|
+
delete(id: string): Promise<ProductDeletedData>;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** A single attempt to deliver an event to a webhook endpoint (audit record). */
|
|
764
|
+
declare class WebhookDelivery extends Base<WebhookDeliveryData> {
|
|
765
|
+
endpointId: string;
|
|
766
|
+
eventType: WebhookEventType;
|
|
767
|
+
eventId: string;
|
|
768
|
+
payload: Record<string, unknown>;
|
|
769
|
+
status: WebhookDeliveryStatus;
|
|
770
|
+
attempts: number;
|
|
771
|
+
responseStatus: number | null;
|
|
772
|
+
error: string | null;
|
|
773
|
+
lastAttemptAt: Date | null;
|
|
774
|
+
createdAt: Date;
|
|
775
|
+
updatedAt: Date;
|
|
776
|
+
constructor(client: Client, data: WebhookDeliveryData);
|
|
777
|
+
protected _patch(data: WebhookDeliveryData): this;
|
|
778
|
+
get isSucceeded(): boolean;
|
|
779
|
+
/** Manually re-send this delivery. */
|
|
780
|
+
redeliver(): Promise<WebhookDelivery>;
|
|
781
|
+
toJSON(): WebhookDeliveryData;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* A registered webhook endpoint.
|
|
786
|
+
*
|
|
787
|
+
* Note: the signing `secret` is only ever present on the instance returned by
|
|
788
|
+
* `create()` / `rotateSecret()` — list/get responses never include it.
|
|
789
|
+
*/
|
|
790
|
+
declare class WebhookEndpoint extends Base<WebhookEndpointData> {
|
|
791
|
+
url: string;
|
|
792
|
+
description: string | null;
|
|
793
|
+
enabled: boolean;
|
|
794
|
+
eventTypes: WebhookEventType[];
|
|
795
|
+
createdAt: Date;
|
|
796
|
+
updatedAt: Date;
|
|
797
|
+
/** HMAC signing secret — only set on create/rotate responses. */
|
|
798
|
+
readonly secret: string | null;
|
|
799
|
+
constructor(client: Client, data: WebhookEndpointData | WebhookEndpointWithSecretData);
|
|
800
|
+
protected _patch(data: WebhookEndpointData | WebhookEndpointWithSecretData): this;
|
|
801
|
+
/** Whether the endpoint receives all events (empty subscription). */
|
|
802
|
+
get receivesAllEvents(): boolean;
|
|
803
|
+
/** Re-fetch this endpoint. */
|
|
804
|
+
fetch(): Promise<WebhookEndpoint>;
|
|
805
|
+
/** Update url/description/enabled/eventTypes. Mutates and returns this. */
|
|
806
|
+
edit(options: UpdateWebhookEndpointOptions): Promise<this>;
|
|
807
|
+
/** Pause deliveries to this endpoint. */
|
|
808
|
+
disable(): Promise<this>;
|
|
809
|
+
/** Resume deliveries to this endpoint. */
|
|
810
|
+
enable(): Promise<this>;
|
|
811
|
+
/** Rotate the signing secret (returns a new instance carrying the secret). */
|
|
812
|
+
rotateSecret(): Promise<WebhookEndpoint>;
|
|
813
|
+
/** Send a test event to verify the endpoint. */
|
|
814
|
+
ping(): Promise<WebhookPingData>;
|
|
815
|
+
/** List delivery attempts for this endpoint. */
|
|
816
|
+
fetchDeliveries(options?: ListWebhookDeliveriesOptions): Promise<WebhookDeliveryPage>;
|
|
817
|
+
/** Delete this endpoint. */
|
|
818
|
+
delete(): Promise<{
|
|
819
|
+
id: string;
|
|
820
|
+
deleted: boolean;
|
|
821
|
+
}>;
|
|
822
|
+
toJSON(): WebhookEndpointData;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
type WebhookDeletedData = {
|
|
826
|
+
id: string;
|
|
827
|
+
deleted: boolean;
|
|
828
|
+
};
|
|
829
|
+
/** A page of webhook deliveries plus its pagination metadata. */
|
|
830
|
+
interface WebhookDeliveryPage {
|
|
831
|
+
items: WebhookDelivery[];
|
|
832
|
+
total: number;
|
|
833
|
+
take: number;
|
|
834
|
+
skip: number;
|
|
835
|
+
}
|
|
836
|
+
/** Options for verifying + dispatching an incoming webhook. */
|
|
837
|
+
interface WebhookProcessOptions {
|
|
838
|
+
/** Signing secret. Falls back to the client's `webhookSecret` when omitted. */
|
|
839
|
+
secret?: string;
|
|
840
|
+
/** Replay tolerance in seconds (default 300; 0 disables). */
|
|
841
|
+
toleranceSeconds?: number;
|
|
842
|
+
}
|
|
843
|
+
/** Options for the built-in HTTP webhook handlers. */
|
|
844
|
+
type WebhookHandlerOptions = WebhookProcessOptions;
|
|
845
|
+
/**
|
|
846
|
+
* Listener signatures for {@link WebhookManager}. You can subscribe with the raw
|
|
847
|
+
* event type (`PAYMENT_INTENT_SUCCEEDED`), its camelCase alias
|
|
848
|
+
* (`paymentIntentSucceeded`), or `event` to catch them all.
|
|
849
|
+
*/
|
|
850
|
+
interface WebhookListenerEvents {
|
|
851
|
+
event: [WebhookEvent<PaymentIntentData>];
|
|
852
|
+
PAYMENT_INTENT_CREATED: [WebhookEvent<PaymentIntentData>];
|
|
853
|
+
PAYMENT_INTENT_UPDATED: [WebhookEvent<PaymentIntentData>];
|
|
854
|
+
PAYMENT_INTENT_SUCCEEDED: [WebhookEvent<PaymentIntentData>];
|
|
855
|
+
PAYMENT_INTENT_FAILED: [WebhookEvent<PaymentIntentData>];
|
|
856
|
+
PAYMENT_INTENT_CANCELLED: [WebhookEvent<PaymentIntentData>];
|
|
857
|
+
PAYMENT_INTENT_DELETED: [WebhookEvent<PaymentIntentData>];
|
|
858
|
+
paymentIntentCreated: [WebhookEvent<PaymentIntentData>];
|
|
859
|
+
paymentIntentUpdated: [WebhookEvent<PaymentIntentData>];
|
|
860
|
+
paymentIntentSucceeded: [WebhookEvent<PaymentIntentData>];
|
|
861
|
+
paymentIntentFailed: [WebhookEvent<PaymentIntentData>];
|
|
862
|
+
paymentIntentCancelled: [WebhookEvent<PaymentIntentData>];
|
|
863
|
+
paymentIntentDeleted: [WebhookEvent<PaymentIntentData>];
|
|
864
|
+
}
|
|
865
|
+
/** Minimal Express-like request (so we don't depend on `@types/express`). */
|
|
866
|
+
interface RequestLike {
|
|
867
|
+
headers: Record<string, string | string[] | undefined>;
|
|
868
|
+
body?: unknown;
|
|
869
|
+
rawBody?: unknown;
|
|
870
|
+
[key: string]: unknown;
|
|
871
|
+
}
|
|
872
|
+
/** Minimal Express-like response. */
|
|
873
|
+
interface ResponseLike {
|
|
874
|
+
status(code: number): ResponseLike;
|
|
875
|
+
send(body?: unknown): unknown;
|
|
876
|
+
end(body?: unknown): unknown;
|
|
877
|
+
}
|
|
878
|
+
interface WebhookManager {
|
|
879
|
+
on<E extends keyof WebhookListenerEvents>(event: E, listener: (...args: WebhookListenerEvents[E]) => void): this;
|
|
880
|
+
once<E extends keyof WebhookListenerEvents>(event: E, listener: (...args: WebhookListenerEvents[E]) => void): this;
|
|
881
|
+
off<E extends keyof WebhookListenerEvents>(event: E, listener: (...args: WebhookListenerEvents[E]) => void): this;
|
|
882
|
+
emit<E extends keyof WebhookListenerEvents>(event: E, ...args: WebhookListenerEvents[E]): boolean;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Manages webhook endpoints, their delivery audit trail, **and** the incoming
|
|
886
|
+
* event listener — `client.webhooks`.
|
|
887
|
+
*
|
|
888
|
+
* Registering endpoints (server-side CRUD):
|
|
889
|
+
* @example
|
|
890
|
+
* const endpoint = await client.webhooks.create({
|
|
891
|
+
* url: 'https://me.example.com/hooks',
|
|
892
|
+
* eventTypes: ['PAYMENT_INTENT_SUCCEEDED'],
|
|
893
|
+
* });
|
|
894
|
+
* console.log(endpoint.secret); // shown once — store it!
|
|
895
|
+
*
|
|
896
|
+
* Receiving events (listener):
|
|
897
|
+
* @example
|
|
898
|
+
* client.webhooks.on('paymentIntentSucceeded', (event) => {
|
|
899
|
+
* console.log('Paid!', event.data.id);
|
|
900
|
+
* });
|
|
901
|
+
*
|
|
902
|
+
* import { createServer } from 'node:http';
|
|
903
|
+
* createServer(client.webhooks.createHandler()).listen(4242);
|
|
904
|
+
*/
|
|
905
|
+
declare class WebhookManager extends BaseManager<WebhookEndpoint> {
|
|
906
|
+
private readonly route;
|
|
907
|
+
/** Register a webhook endpoint (the returned instance carries the secret once). */
|
|
908
|
+
create(options: CreateWebhookEndpointOptions): Promise<WebhookEndpoint>;
|
|
909
|
+
/** List the consumer's webhook endpoints. */
|
|
910
|
+
list(): Promise<WebhookEndpoint[]>;
|
|
911
|
+
/** Get a webhook endpoint by id. */
|
|
912
|
+
fetch(id: string): Promise<WebhookEndpoint>;
|
|
913
|
+
/** Update a webhook endpoint (url/description/enabled/eventTypes). */
|
|
914
|
+
update(id: string, options: UpdateWebhookEndpointOptions): Promise<WebhookEndpoint>;
|
|
915
|
+
/** Delete a webhook endpoint. */
|
|
916
|
+
delete(id: string): Promise<WebhookDeletedData>;
|
|
917
|
+
/** Rotate the signing secret (returns a new instance carrying the secret). */
|
|
918
|
+
rotateSecret(id: string): Promise<WebhookEndpoint>;
|
|
919
|
+
/** Send a test event to verify the endpoint. */
|
|
920
|
+
ping(id: string): Promise<WebhookPingData>;
|
|
921
|
+
/** List delivery attempts for an endpoint (audit trail). */
|
|
922
|
+
fetchDeliveries(id: string, options?: ListWebhookDeliveriesOptions): Promise<WebhookDeliveryPage>;
|
|
923
|
+
/** Manually re-send a past delivery. */
|
|
924
|
+
redeliver(id: string, deliveryId: string): Promise<WebhookDelivery>;
|
|
925
|
+
/**
|
|
926
|
+
* Verify a raw incoming webhook request and dispatch it to the listeners
|
|
927
|
+
* registered via {@link WebhookManager.on}. Returns the parsed event.
|
|
928
|
+
*
|
|
929
|
+
* Emits, in order: the raw type (`PAYMENT_INTENT_SUCCEEDED`), the camelCase
|
|
930
|
+
* alias (`paymentIntentSucceeded`) and the catch-all `event`.
|
|
931
|
+
*
|
|
932
|
+
* @throws {WebhookSignatureError} when the signature is missing/invalid.
|
|
933
|
+
*/
|
|
934
|
+
process(rawBody: string | Uint8Array, signatureHeader: string | null | undefined, options?: WebhookProcessOptions): WebhookEvent<PaymentIntentData>;
|
|
935
|
+
/**
|
|
936
|
+
* Build a Node.js `http`/`https` request handler that verifies the signature,
|
|
937
|
+
* dispatches the event to your listeners, and replies `200`/`400`.
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* import { createServer } from 'node:http';
|
|
941
|
+
* createServer(client.webhooks.createHandler({ secret })).listen(4242);
|
|
942
|
+
*/
|
|
943
|
+
createHandler(options?: WebhookHandlerOptions): (req: IncomingMessage, res: ServerResponse) => void;
|
|
944
|
+
/**
|
|
945
|
+
* Express-style middleware. Expects the **raw** body (e.g. mounted with
|
|
946
|
+
* `express.raw({ type: '*/*' })`). On success it attaches the parsed event to
|
|
947
|
+
* `req.cosmosEvent` and calls `next()`; on a bad signature it replies `400`.
|
|
948
|
+
*
|
|
949
|
+
* @example
|
|
950
|
+
* app.post('/hooks', express.raw({ type: '*/*' }), client.webhooks.middleware({ secret }));
|
|
951
|
+
*/
|
|
952
|
+
middleware(options?: WebhookHandlerOptions): (req: RequestLike, res: ResponseLike, next: (err?: unknown) => void) => void;
|
|
953
|
+
/** Read a Node.js request stream into a single Buffer. */
|
|
954
|
+
private collectBody;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Internal ("shared") configuration that Cosmos Pay maintains on the user's
|
|
959
|
+
* behalf. These are the gateway / infrastructure details an integrator should
|
|
960
|
+
* **not** have to know about — they're pre-filled here so that, in practice, the
|
|
961
|
+
* only credential a user provides is their `apiKey`.
|
|
962
|
+
*
|
|
963
|
+
* Every value is overridable (per-client via {@link ClientOptions}, or globally
|
|
964
|
+
* via {@link Client.shared}) for self-hosting, staging or local development.
|
|
965
|
+
*/
|
|
966
|
+
interface SharedConfig {
|
|
967
|
+
/** Base URL of the Cosmos Pay gateway. */
|
|
968
|
+
baseURL: string;
|
|
969
|
+
/** API version segment prefixed to every route (`/v1/...`). */
|
|
970
|
+
version: string;
|
|
971
|
+
/**
|
|
972
|
+
* Shared gateway secret (`X-Gateway-Secret`). Only used when talking to the
|
|
973
|
+
* service directly, bypassing the gateway (local development). Internal.
|
|
974
|
+
*/
|
|
975
|
+
gatewaySecret?: string;
|
|
976
|
+
/**
|
|
977
|
+
* Authenticated consumer username (`X-Consumer-Username`). Paired with
|
|
978
|
+
* `gatewaySecret` for direct service access. Internal.
|
|
979
|
+
*/
|
|
980
|
+
consumerUsername?: string;
|
|
981
|
+
/**
|
|
982
|
+
* Default webhook signing secret used by the webhook listener
|
|
983
|
+
* (`client.webhooks.process` / handlers) when no secret is passed explicitly.
|
|
984
|
+
*/
|
|
985
|
+
webhookSecret?: string;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* The mutable, process-wide defaults. Cosmos Pay ships sane values here; you can
|
|
989
|
+
* tweak them once at startup (e.g. `Client.shared.baseURL = '...'`) and every
|
|
990
|
+
* client created afterwards inherits them.
|
|
991
|
+
*/
|
|
992
|
+
declare const shared: SharedConfig;
|
|
993
|
+
/** Merge a partial override on top of the current shared defaults. */
|
|
994
|
+
declare function resolveShared(overrides?: Partial<SharedConfig>): SharedConfig;
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Options accepted by the {@link Client} constructor.
|
|
998
|
+
*
|
|
999
|
+
* In practice the only value you provide is `apiKey` — everything else (the
|
|
1000
|
+
* gateway URL, version and other infrastructure details) is pre-filled from the
|
|
1001
|
+
* {@link Client.shared} defaults that Cosmos Pay maintains for you.
|
|
1002
|
+
*/
|
|
1003
|
+
interface ClientOptions {
|
|
1004
|
+
/**
|
|
1005
|
+
* Your Cosmos Pay API key. Sent to the gateway as `Authorization: Bearer
|
|
1006
|
+
* <apiKey>`. The key type determines the network (`dv_` → testnet, `prod_` →
|
|
1007
|
+
* mainnet). This is the only credential a typical integration needs.
|
|
1008
|
+
*/
|
|
1009
|
+
apiKey: string;
|
|
1010
|
+
/**
|
|
1011
|
+
* Default webhook signing secret used by the webhook listener
|
|
1012
|
+
* (`client.webhooks.on(...)` + handlers) when you don't pass one explicitly.
|
|
1013
|
+
*/
|
|
1014
|
+
webhookSecret?: string;
|
|
1015
|
+
/** Per-request timeout in milliseconds (default 30000). */
|
|
1016
|
+
timeout?: number;
|
|
1017
|
+
/** Retries for transient failures — network errors, 429 and 5xx (default 2). */
|
|
1018
|
+
retries?: number;
|
|
1019
|
+
/** Extra headers merged into every request. */
|
|
1020
|
+
headers?: Record<string, string>;
|
|
1021
|
+
/** Custom fetch implementation (e.g. a polyfill on old runtimes). */
|
|
1022
|
+
fetch?: FetchLike;
|
|
1023
|
+
/**
|
|
1024
|
+
* Override the gateway base URL. Defaults to {@link Client.shared}`.baseURL`.
|
|
1025
|
+
* Only needed for self-hosting or a staging gateway.
|
|
1026
|
+
* @internal
|
|
1027
|
+
*/
|
|
1028
|
+
baseURL?: string;
|
|
1029
|
+
/**
|
|
1030
|
+
* Override the API version segment. Defaults to `v1`.
|
|
1031
|
+
* @internal
|
|
1032
|
+
*/
|
|
1033
|
+
version?: string;
|
|
1034
|
+
/**
|
|
1035
|
+
* Shared gateway secret (`X-Gateway-Secret`) for direct, gateway-bypassing
|
|
1036
|
+
* access (local development). Maintained internally.
|
|
1037
|
+
* @internal
|
|
1038
|
+
*/
|
|
1039
|
+
gatewaySecret?: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Consumer username (`X-Consumer-Username`) for direct access. Internal.
|
|
1042
|
+
* @internal
|
|
1043
|
+
*/
|
|
1044
|
+
consumerUsername?: string;
|
|
1045
|
+
}
|
|
1046
|
+
/** Payloads emitted by the {@link Client} for observability. */
|
|
1047
|
+
interface ClientEvents {
|
|
1048
|
+
request: [{
|
|
1049
|
+
method: string;
|
|
1050
|
+
url: string;
|
|
1051
|
+
attempt: number;
|
|
1052
|
+
}];
|
|
1053
|
+
response: [{
|
|
1054
|
+
method: string;
|
|
1055
|
+
url: string;
|
|
1056
|
+
status: number;
|
|
1057
|
+
attempt: number;
|
|
1058
|
+
}];
|
|
1059
|
+
rateLimited: [{
|
|
1060
|
+
method: string;
|
|
1061
|
+
url: string;
|
|
1062
|
+
attempt: number;
|
|
1063
|
+
}];
|
|
1064
|
+
debug: [message: string];
|
|
1065
|
+
}
|
|
1066
|
+
interface Client {
|
|
1067
|
+
on<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => void): this;
|
|
1068
|
+
once<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => void): this;
|
|
1069
|
+
off<E extends keyof ClientEvents>(event: E, listener: (...args: ClientEvents[E]) => void): this;
|
|
1070
|
+
emit<E extends keyof ClientEvents>(event: E, ...args: ClientEvents[E]): boolean;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* The main entry point of the SDK — a single, atomic client that exposes every
|
|
1074
|
+
* resource through its own manager, in the style of discord.js.
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
* import { Client } from '@cosmosapp/pay_sdk';
|
|
1078
|
+
*
|
|
1079
|
+
* // The user only provides their API key — the gateway is handled for them.
|
|
1080
|
+
* const client = new Client({ apiKey: process.env.COSMOS_PAY_API_KEY });
|
|
1081
|
+
*
|
|
1082
|
+
* const intent = await client.paymentIntents.createPay({ destination: 'G...', amount: '10' });
|
|
1083
|
+
* console.log(intent.uri);
|
|
1084
|
+
*/
|
|
1085
|
+
declare class Client extends EventEmitter {
|
|
1086
|
+
/** Library version. */
|
|
1087
|
+
static readonly version = "1.0.0";
|
|
1088
|
+
/**
|
|
1089
|
+
* Process-wide shared defaults maintained by Cosmos Pay (gateway URL, version,
|
|
1090
|
+
* internal secrets). Mutate once at startup to change them for every client:
|
|
1091
|
+
* `Client.shared.baseURL = 'https://staging.cosmospay.io'`.
|
|
1092
|
+
*/
|
|
1093
|
+
static readonly shared: SharedConfig;
|
|
1094
|
+
/** Resolved shared configuration for this client instance. */
|
|
1095
|
+
readonly shared: SharedConfig;
|
|
1096
|
+
/** Default webhook signing secret for the webhook listener (if configured). */
|
|
1097
|
+
webhookSecret: string | undefined;
|
|
1098
|
+
/** The underlying HTTP layer. Shared by every manager. */
|
|
1099
|
+
readonly rest: REST;
|
|
1100
|
+
/** Stellar payment intents — create/list/fetch/update/delete/validate. */
|
|
1101
|
+
readonly paymentIntents: PaymentIntentManager;
|
|
1102
|
+
/** Webhook endpoints, delivery audit trail, and the event listener. */
|
|
1103
|
+
readonly webhooks: WebhookManager;
|
|
1104
|
+
/** Products / prices. */
|
|
1105
|
+
readonly products: ProductManager;
|
|
1106
|
+
/** Customers. */
|
|
1107
|
+
readonly customers: CustomerManager;
|
|
1108
|
+
/** Read-only analytics (summary, balances, logs). */
|
|
1109
|
+
readonly analytics: AnalyticsManager;
|
|
1110
|
+
/** Service health probes (public). */
|
|
1111
|
+
readonly health: HealthManager;
|
|
1112
|
+
constructor(options: ClientOptions);
|
|
1113
|
+
/** Update the API key used for subsequent requests. */
|
|
1114
|
+
setApiKey(apiKey: string): this;
|
|
1115
|
+
/** Set the default webhook signing secret for the webhook listener. */
|
|
1116
|
+
setWebhookSecret(secret: string): this;
|
|
1117
|
+
/** Set direct-access gateway credentials (internal / local dev usage). */
|
|
1118
|
+
setGatewayCredentials(secret: string, consumerUsername: string): this;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Error thrown when the Cosmos Pay API responds with a non-2xx status.
|
|
1123
|
+
*
|
|
1124
|
+
* Carries the HTTP status, the parsed response body and the request context so
|
|
1125
|
+
* callers can branch on `error.status` (e.g. 404 → not found, 403 → gateway).
|
|
1126
|
+
*/
|
|
1127
|
+
declare class CosmosPayAPIError extends Error {
|
|
1128
|
+
/** HTTP status code returned by the API. */
|
|
1129
|
+
readonly status: number;
|
|
1130
|
+
/** HTTP method of the failed request. */
|
|
1131
|
+
readonly method: string;
|
|
1132
|
+
/** Absolute URL of the failed request. */
|
|
1133
|
+
readonly url: string;
|
|
1134
|
+
/** Parsed response body (object when JSON, string otherwise, or null). */
|
|
1135
|
+
readonly body: unknown;
|
|
1136
|
+
/** Machine-readable error code extracted from the body when present. */
|
|
1137
|
+
readonly code: string | undefined;
|
|
1138
|
+
constructor(options: {
|
|
1139
|
+
status: number;
|
|
1140
|
+
method: string;
|
|
1141
|
+
url: string;
|
|
1142
|
+
body: unknown;
|
|
1143
|
+
});
|
|
1144
|
+
private static resolveMessage;
|
|
1145
|
+
private static resolveCode;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Error thrown when a request never reaches the API: network failure, abort or
|
|
1149
|
+
* timeout. Distinct from {@link CosmosPayAPIError}, which always has a status.
|
|
1150
|
+
*/
|
|
1151
|
+
declare class CosmosPayRequestError extends Error {
|
|
1152
|
+
readonly method: string;
|
|
1153
|
+
readonly url: string;
|
|
1154
|
+
readonly cause: unknown;
|
|
1155
|
+
constructor(options: {
|
|
1156
|
+
method: string;
|
|
1157
|
+
url: string;
|
|
1158
|
+
cause: unknown;
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/** Options for {@link Webhooks.verify} / {@link Webhooks.constructEvent}. */
|
|
1163
|
+
interface VerifyWebhookOptions {
|
|
1164
|
+
/**
|
|
1165
|
+
* Tolerance in seconds between the signed timestamp and now. Protects against
|
|
1166
|
+
* replay attacks. Defaults to 300 (5 minutes). Pass 0 to disable the check.
|
|
1167
|
+
*/
|
|
1168
|
+
toleranceSeconds?: number;
|
|
1169
|
+
/** Override "now" (unix seconds) — useful for testing. */
|
|
1170
|
+
now?: number;
|
|
1171
|
+
}
|
|
1172
|
+
/** Thrown when a webhook signature fails verification. */
|
|
1173
|
+
declare class WebhookSignatureError extends Error {
|
|
1174
|
+
constructor(message: string);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Stateless helpers to verify the HMAC signatures the Cosmos Pay dispatcher
|
|
1178
|
+
* sends with each webhook delivery, and to safely parse the event body.
|
|
1179
|
+
*
|
|
1180
|
+
* The dispatcher signs each POST with:
|
|
1181
|
+
* `X-Cosmos-Signature: t=<unixSeconds>,v1=<hexHmacSha256>`
|
|
1182
|
+
* where the HMAC-SHA256 is computed over `${t}.${rawBody}` using the endpoint's
|
|
1183
|
+
* `whsec_...` secret.
|
|
1184
|
+
*
|
|
1185
|
+
* @example
|
|
1186
|
+
* // Express raw-body handler
|
|
1187
|
+
* app.post('/hooks', express.raw({ type: '*/*' }), (req, res) => {
|
|
1188
|
+
* try {
|
|
1189
|
+
* const event = Webhooks.constructEvent(
|
|
1190
|
+
* req.body, // the RAW body (Buffer/string)
|
|
1191
|
+
* req.header('X-Cosmos-Signature'),
|
|
1192
|
+
* process.env.WEBHOOK_SECRET,
|
|
1193
|
+
* );
|
|
1194
|
+
* // event.type, event.data ...
|
|
1195
|
+
* res.sendStatus(200);
|
|
1196
|
+
* } catch {
|
|
1197
|
+
* res.sendStatus(400);
|
|
1198
|
+
* }
|
|
1199
|
+
* });
|
|
1200
|
+
*/
|
|
1201
|
+
declare const Webhooks: {
|
|
1202
|
+
/** Header name the dispatcher uses for the signature. */
|
|
1203
|
+
SIGNATURE_HEADER: string;
|
|
1204
|
+
/**
|
|
1205
|
+
* Verify a webhook signature. Returns `true` on success, throws
|
|
1206
|
+
* {@link WebhookSignatureError} on any failure (so it never silently passes).
|
|
1207
|
+
*/
|
|
1208
|
+
verify(rawBody: string | Uint8Array, signatureHeader: string | null | undefined, secret: string, options?: VerifyWebhookOptions): boolean;
|
|
1209
|
+
/**
|
|
1210
|
+
* Verify the signature and return the parsed {@link WebhookEvent}. Throws
|
|
1211
|
+
* {@link WebhookSignatureError} if verification fails.
|
|
1212
|
+
*/
|
|
1213
|
+
constructEvent<T = unknown>(rawBody: string | Uint8Array, signatureHeader: string | null | undefined, secret: string, options?: VerifyWebhookOptions): WebhookEvent<T>;
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
/** Library version, kept in sync with package.json. */
|
|
1217
|
+
declare const version = "1.0.0";
|
|
1218
|
+
/**
|
|
1219
|
+
* Default base URL of the Cosmos Pay gateway. Maintained by Cosmos Pay — users
|
|
1220
|
+
* never need to set this; it's part of the {@link shared} configuration. Override
|
|
1221
|
+
* only when self-hosting or pointing at a staging gateway.
|
|
1222
|
+
*/
|
|
1223
|
+
declare const DEFAULT_BASE_URL = "https://api.cosmospay.io";
|
|
1224
|
+
/** Default API version segment prefixed to every route (`/v1/...`). */
|
|
1225
|
+
declare const DEFAULT_VERSION = "v1";
|
|
1226
|
+
/** Default request timeout in milliseconds. */
|
|
1227
|
+
declare const DEFAULT_TIMEOUT = 30000;
|
|
1228
|
+
/** Default number of retries for transient failures (network / 429 / 5xx). */
|
|
1229
|
+
declare const DEFAULT_RETRIES = 2;
|
|
1230
|
+
/** Default HMAC signature header sent by the Cosmos Pay webhook dispatcher. */
|
|
1231
|
+
declare const SIGNATURE_HEADER = "x-cosmos-signature";
|
|
1232
|
+
/**
|
|
1233
|
+
* Client debug/telemetry events. The {@link Client} extends EventEmitter and
|
|
1234
|
+
* emits these for observability — mirroring discord.js's `debug`/`rateLimit`.
|
|
1235
|
+
*/
|
|
1236
|
+
declare const Events: {
|
|
1237
|
+
readonly Debug: "debug";
|
|
1238
|
+
readonly Request: "request";
|
|
1239
|
+
readonly Response: "response";
|
|
1240
|
+
readonly RateLimited: "rateLimited";
|
|
1241
|
+
};
|
|
1242
|
+
type ClientEvent = (typeof Events)[keyof typeof Events];
|
|
1243
|
+
|
|
1244
|
+
export { type AnalyticsBalanceEntry, type AnalyticsBalancesData, AnalyticsManager, type AnalyticsRecentRow, type AnalyticsSeriesPoint, type AnalyticsSummaryData, type AnalyticsVolumeEntry, type ApiLogRow, type ApiLogsData, Base, BaseManager, Client, type ClientEvent, type ClientEvents, type ClientOptions, CosmosPayAPIError, CosmosPayRequestError, type CreateCustomerOptions, type CreatePayPaymentIntentOptions, type CreateProductOptions, type CreateTxPaymentIntentOptions, type CreateWebhookEndpointOptions, Customer, type CustomerData, type CustomerListData, CustomerManager, DEFAULT_BASE_URL, DEFAULT_RETRIES, DEFAULT_TIMEOUT, DEFAULT_VERSION, type DeletedData, Events, type FetchLike, type HealthCheckData, HealthManager, type ListPaymentIntentsOptions, type ListWebhookDeliveriesOptions, PaymentIntent, type PaymentIntentData, PaymentIntentKind, type PaymentIntentListData, PaymentIntentManager, type PaymentIntentPage, PaymentIntentStatus, Product, type ProductData, ProductKind, ProductManager, REST, type RESTOptions, type RequestOptions, SIGNATURE_HEADER, type SharedConfig, type UpdateCustomerOptions, type UpdatePaymentIntentOptions, type UpdateProductOptions, type UpdateWebhookEndpointOptions, type ValidatePaymentIntentOptions, type ValidationOutcome, type ValidationOutcomeData, type VerifyWebhookOptions, WebhookDelivery, type WebhookDeliveryData, type WebhookDeliveryListData, type WebhookDeliveryPage, WebhookDeliveryStatus, WebhookEndpoint, type WebhookEndpointData, type WebhookEndpointWithSecretData, type WebhookEvent, WebhookEventType, type WebhookHandlerOptions, type WebhookListenerEvents, type WebhookLogRow, type WebhookLogsData, WebhookManager, type WebhookPingData, type WebhookProcessOptions, WebhookSignatureError, Webhooks, resolveShared, shared, version };
|