paysafe-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.
@@ -0,0 +1,1211 @@
1
+ /** Selects which Paysafe environment a client talks to. */
2
+ type Environment = "test" | "production";
3
+ /** Local token-bucket rate limit applied before every outbound request. */
4
+ interface RateLimitConfig {
5
+ /** Maximum number of requests allowed within `windowMs`. */
6
+ limit: number;
7
+ /** Window, in milliseconds, over which `limit` applies. */
8
+ windowMs: number;
9
+ }
10
+ /**
11
+ * `fetch`-compatible function signature. Defaults to `globalThis.fetch`;
12
+ * override for testing or to inject a custom transport (proxying,
13
+ * connection pooling, request signing middleware, etc.).
14
+ */
15
+ type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
16
+ interface PaysafeClientOptions {
17
+ /** API username from the Paysafe Business Portal. */
18
+ username: string;
19
+ /** API password from the Paysafe Business Portal. */
20
+ password: string;
21
+ /** Test or Production. Defaults to `"test"`. */
22
+ environment?: Environment;
23
+ /** Default account ID used when a resource call doesn't specify one. */
24
+ accountId?: string;
25
+ /** Overrides the environment-derived base URL entirely (e.g. a mock server in tests). */
26
+ baseUrlOverride?: string;
27
+ /** Overall per-request timeout, in milliseconds. Defaults to 30_000. */
28
+ timeoutMs?: number;
29
+ /** Maximum number of retries on transient failures. Defaults to 3. */
30
+ maxRetries?: number;
31
+ /** Base delay, in milliseconds, for exponential backoff between retries. Defaults to 500. */
32
+ retryBaseDelayMs?: number;
33
+ /** Local token-bucket rate limit. Defaults to 100 requests / 1000ms. */
34
+ rateLimit?: RateLimitConfig;
35
+ /** Custom `fetch` implementation. Defaults to `globalThis.fetch`. */
36
+ fetch?: FetchLike;
37
+ /** Metric/event name prefix emitted by telemetry hooks. Defaults to `"paysafe"`. */
38
+ telemetryPrefix?: string;
39
+ }
40
+ /** Fully-resolved, validated configuration used internally by the SDK. */
41
+ declare class ResolvedConfig {
42
+ readonly username: string;
43
+ readonly password: string;
44
+ readonly environment: Environment;
45
+ readonly accountId?: string;
46
+ readonly baseUrlOverride?: string;
47
+ readonly timeoutMs: number;
48
+ readonly maxRetries: number;
49
+ readonly retryBaseDelayMs: number;
50
+ readonly rateLimit: RateLimitConfig;
51
+ readonly fetchImpl: FetchLike;
52
+ readonly telemetryPrefix: string;
53
+ constructor(opts: PaysafeClientOptions);
54
+ private validate;
55
+ baseUrl(): string;
56
+ paymentsUrl(): string;
57
+ schedulerUrl(): string;
58
+ applicationsUrl(): string;
59
+ fxRatesUrl(): string;
60
+ bankAccountValidatorUrl(): string;
61
+ customerIdentificationUrl(): string;
62
+ /** Computes the Base64-encoded HTTP Basic Auth header value. */
63
+ authHeader(): string;
64
+ /** Returns `override` if non-empty, otherwise the configured default account ID. */
65
+ resolveAccountId(override?: string): string;
66
+ }
67
+
68
+ /**
69
+ * Lightweight, dependency-free instrumentation hooks around every
70
+ * outbound Paysafe API call. Attach a {@link TelemetryHook} to observe
71
+ * start/stop/exception events for logging, metrics, or tracing.
72
+ */
73
+ interface TelemetryStartMeta {
74
+ prefix: string;
75
+ api: string;
76
+ method: string;
77
+ path: string;
78
+ operation: string;
79
+ }
80
+ interface TelemetryStopMeta extends TelemetryStartMeta {
81
+ durationMs: number;
82
+ httpStatus: number;
83
+ ok: boolean;
84
+ error?: unknown;
85
+ }
86
+ interface TelemetryExceptionMeta extends TelemetryStartMeta {
87
+ durationMs: number;
88
+ reason: unknown;
89
+ }
90
+ /**
91
+ * Receives telemetry events. All methods are optional — implement only
92
+ * what you need; the SDK checks for each method's presence before
93
+ * calling it.
94
+ */
95
+ interface TelemetryHook {
96
+ onStart?: (meta: TelemetryStartMeta) => void;
97
+ onStop?: (meta: TelemetryStopMeta) => void;
98
+ onException?: (meta: TelemetryExceptionMeta) => void;
99
+ }
100
+
101
+ /**
102
+ * Manages one token bucket per key (typically the API username), so
103
+ * multiple clients sharing a process don't starve each other's budget.
104
+ */
105
+ declare class RateLimiter {
106
+ private readonly buckets;
107
+ private bucketFor;
108
+ /**
109
+ * Checks (and, if permitted, consumes) one token for `key`. Throws a
110
+ * {@link PaysafeError} with `kind === "rate_limited"` if the bucket is
111
+ * exhausted.
112
+ */
113
+ allow(key: string, limit: number, windowMs: number): void;
114
+ }
115
+
116
+ /**
117
+ * Shared low-level transport used by every resource (payment handles,
118
+ * payments, plans, subscriptions, ...). Resources depend on this rather
119
+ * than calling `fetch` directly.
120
+ */
121
+
122
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
123
+ interface RequestOptions {
124
+ /** Bounded-context API name for telemetry, e.g. `"payments"`, `"scheduler"`. */
125
+ api: string;
126
+ /** Dotted operation name for telemetry, e.g. `"payments.create"`. */
127
+ operation: string;
128
+ method: HttpMethod;
129
+ url: string;
130
+ body?: unknown;
131
+ /** Caller-supplied abort signal, composed with the client's own timeout. */
132
+ signal?: AbortSignal;
133
+ }
134
+ /**
135
+ * The shared transport: rate limiting, retry with exponential backoff +
136
+ * jitter, telemetry spans, and JSON encode/decode all happen here so
137
+ * every resource method stays a thin one-liner.
138
+ */
139
+ declare class HttpTransport {
140
+ private readonly cfg;
141
+ private readonly limiter;
142
+ private readonly hook?;
143
+ constructor(cfg: ResolvedConfig, limiter: RateLimiter, hook?: TelemetryHook | undefined);
144
+ /**
145
+ * Performs the HTTP round trip and returns the raw response body as
146
+ * text. Used directly for endpoints with no JSON object response body
147
+ * (e.g. `DELETE`).
148
+ */
149
+ raw(options: RequestOptions): Promise<string>;
150
+ /**
151
+ * Performs the HTTP round trip and decodes the JSON response body as
152
+ * `T`. This is the common case used by nearly every resource method.
153
+ */
154
+ do<T>(options: RequestOptions): Promise<T>;
155
+ private doWithRetry;
156
+ private doOnce;
157
+ }
158
+
159
+ /** A HATEOAS-style link returned by the Paysafe API. */
160
+ interface PaysafeLink {
161
+ rel: string;
162
+ href: string;
163
+ }
164
+ /** Returns the href of the first link whose `rel` matches, or `undefined`. */
165
+ declare function findLinkByRel(links: PaysafeLink[] | undefined, rel: string): string | undefined;
166
+
167
+ type HandleStatus = "INITIATED" | "PAYABLE" | "PROCESSING" | "COMPLETED" | "EXPIRED" | "FAILED" | "CANCELLED" | "ERROR";
168
+ type HandleAction = "NONE" | "REDIRECT";
169
+ /** Distinguishes single-use tokens (SUT) from multi-use tokens (MUT). */
170
+ type HandleUsage = "SINGLE_USE" | "MULTI_USE";
171
+ /** Whether the payment instrument completes synchronously or via webhook. */
172
+ type ExecutionMode = "SYNCHRONOUS" | "ASYNCHRONOUS";
173
+ /** Selects which downstream resource a Payment Handle may be used against. */
174
+ type TransactionType = "PAYMENT" | "STANDALONE_CREDIT" | "ORIGINAL_CREDIT" | "VERIFICATION";
175
+ interface CardExpiry {
176
+ month: number;
177
+ year: number;
178
+ }
179
+ /** A network-tokenized card (Visa/Mastercard network tokens, Click to Pay). */
180
+ interface NetworkToken {
181
+ token: string;
182
+ cryptogram?: string;
183
+ eci?: string;
184
+ expiry: CardExpiry;
185
+ /** Response-only: `"ACTIVE" | "SUSPENDED" | "DELETED"`. */
186
+ status?: string;
187
+ }
188
+ /**
189
+ * The card payment instrument object accepted by Payment Handles. Either
190
+ * `cardNum` or `networkToken` should be populated, not both.
191
+ */
192
+ interface Card {
193
+ cardNum?: string;
194
+ cardExpiry?: CardExpiry;
195
+ cvv?: string;
196
+ holderName?: string;
197
+ /** e.g. `"NETWORK_TOKEN"`. */
198
+ tokenType?: string;
199
+ networkToken?: NetworkToken;
200
+ cardType?: string;
201
+ cardBin?: string;
202
+ lastDigits?: string;
203
+ status?: string;
204
+ }
205
+ interface BillingDetails {
206
+ street?: string;
207
+ street2?: string;
208
+ city?: string;
209
+ state?: string;
210
+ country?: string;
211
+ zip?: string;
212
+ phone?: string;
213
+ }
214
+ /** A lightweight customer profile attached inline to a Payment Handle. */
215
+ interface InlineProfile {
216
+ firstName?: string;
217
+ lastName?: string;
218
+ email?: string;
219
+ phone?: string;
220
+ locale?: string;
221
+ }
222
+ /** 3-D Secure authentication parameters/results. Shape varies by payment method. */
223
+ type ThreeDS = Record<string, unknown>;
224
+ /**
225
+ * Request body for creating a Payment Handle. Only `merchantRefNum`,
226
+ * `amount`, `currencyCode`, `paymentType`, and `transactionType` are
227
+ * required by the API; the rest depend on the chosen payment method.
228
+ */
229
+ interface CreatePaymentHandleRequest {
230
+ accountId?: string;
231
+ merchantRefNum: string;
232
+ /** Amount in minor currency units (e.g. cents). */
233
+ amount: number;
234
+ currencyCode: string;
235
+ paymentType: string;
236
+ transactionType: TransactionType;
237
+ card?: Card;
238
+ threeDs?: ThreeDS;
239
+ billingDetails?: BillingDetails;
240
+ profile?: InlineProfile;
241
+ returnLinks?: PaysafeLink[];
242
+ merchantDescriptor?: Record<string, unknown>;
243
+ customerIp?: string;
244
+ deviceFingerprintingId?: string;
245
+ settleWithAuth?: boolean;
246
+ singleUseCustomerToken?: string;
247
+ }
248
+ interface PaymentHandle {
249
+ id: string;
250
+ merchantRefNum: string;
251
+ amount: number;
252
+ currencyCode: string;
253
+ status: HandleStatus;
254
+ paymentType: string;
255
+ paymentHandleToken: string;
256
+ action: HandleAction;
257
+ usage: HandleUsage;
258
+ executionMode: ExecutionMode;
259
+ timeToLiveSeconds: number;
260
+ transactionType: TransactionType;
261
+ links: PaysafeLink[];
262
+ returnLinks: PaysafeLink[];
263
+ card?: Card;
264
+ }
265
+ type PaymentStatus = "PROCESSING" | "COMPLETED" | "FAILED" | "CANCELLED" | "PENDING";
266
+ interface CreatePaymentRequest {
267
+ merchantRefNum: string;
268
+ amount: number;
269
+ currencyCode: string;
270
+ paymentHandleToken: string;
271
+ settleWithAuth?: boolean;
272
+ description?: string;
273
+ /**
274
+ * Enables the Partial Authorization Service (PAS) to mitigate error
275
+ * 3022 (insufficient funds). Supported for Visa/Mastercard on
276
+ * UK/EEA-acquired merchants and must be pre-enabled on the account.
277
+ */
278
+ allowPartialAuth?: boolean;
279
+ groupId?: string;
280
+ }
281
+ interface SettlementSummary {
282
+ id: string;
283
+ amount: number;
284
+ status: string;
285
+ }
286
+ interface Payment {
287
+ id: string;
288
+ merchantRefNum: string;
289
+ amount: number;
290
+ currencyCode: string;
291
+ status: PaymentStatus;
292
+ settleWithAuth: boolean;
293
+ txnTime: string;
294
+ cardType?: string;
295
+ cardBin?: string;
296
+ lastDigits?: string;
297
+ authentication?: Record<string, unknown>;
298
+ settlements?: SettlementSummary[];
299
+ error?: Record<string, unknown>;
300
+ availableToSettle?: number;
301
+ availableToRefund?: number;
302
+ }
303
+ interface ListPaymentsFilter {
304
+ merchantRefNum?: string;
305
+ startDate?: string;
306
+ endDate?: string;
307
+ limit?: number;
308
+ offset?: number;
309
+ }
310
+ interface ListPaymentsResponse {
311
+ payments: Payment[];
312
+ }
313
+ type SettlementStatus = "PENDING" | "PROCESSING" | "COMPLETED" | "CANCELLED" | "FAILED";
314
+ /** Amount defaults to the full authorized amount when omitted (partial settlement otherwise). */
315
+ interface CreateSettlementRequest {
316
+ merchantRefNum: string;
317
+ amount?: number;
318
+ }
319
+ interface Settlement {
320
+ id: string;
321
+ merchantRefNum: string;
322
+ amount: number;
323
+ status: SettlementStatus;
324
+ txnTime: string;
325
+ }
326
+ type RefundStatus = "PROCESSING" | "COMPLETED" | "FAILED" | "CANCELLED" | "PENDING";
327
+ /** Amount defaults to the full amount when omitted (partial refunds are allowed). */
328
+ interface CreateRefundRequest {
329
+ merchantRefNum: string;
330
+ amount?: number;
331
+ }
332
+ interface Refund {
333
+ id: string;
334
+ merchantRefNum: string;
335
+ amount: number;
336
+ status: RefundStatus;
337
+ txnTime: string;
338
+ error?: Record<string, unknown>;
339
+ }
340
+ /**
341
+ * Request body for a standalone credit (general payout) or an original
342
+ * credit (iGaming payout). 3DS does not apply to payouts; the Payment
343
+ * Handle must have been created with the matching `transactionType`.
344
+ */
345
+ interface CreatePayoutRequest {
346
+ accountId?: string;
347
+ merchantRefNum: string;
348
+ amount: number;
349
+ currencyCode: string;
350
+ paymentHandleToken: string;
351
+ }
352
+ /**
353
+ * A standalone credit or original credit response. The API does not
354
+ * share one documented schema across both resources, so extra fields
355
+ * pass through untyped via index access.
356
+ */
357
+ interface Payout {
358
+ id: string;
359
+ merchantRefNum: string;
360
+ amount: number;
361
+ currencyCode: string;
362
+ status: string;
363
+ txnTime: string;
364
+ error?: Record<string, unknown>;
365
+ }
366
+ interface CreateVerificationRequest {
367
+ merchantRefNum: string;
368
+ paymentHandleToken: string;
369
+ currencyCode?: string;
370
+ amount?: number;
371
+ }
372
+ interface Verification {
373
+ id: string;
374
+ merchantRefNum: string;
375
+ status: string;
376
+ txnTime: string;
377
+ error?: Record<string, unknown>;
378
+ }
379
+
380
+ /**
381
+ * Payment Handle operations: the entry point for every payment, payout,
382
+ * and verification transaction. A Payment Handle tokenizes a payment
383
+ * instrument (card, wallet, bank redirect, etc.) before it's used.
384
+ */
385
+ declare class PaymentHandlesResource {
386
+ private readonly cfg;
387
+ private readonly transport;
388
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
389
+ /**
390
+ * Tokenizes a payment instrument, returning a Payment Handle. If
391
+ * `req.accountId` is omitted, the client's default account ID is used.
392
+ */
393
+ create(req: CreatePaymentHandleRequest, signal?: AbortSignal): Promise<PaymentHandle>;
394
+ /**
395
+ * Retrieves a Payment Handle by ID. Useful for polling status if
396
+ * webhooks are not received; always verify via `get` after receiving a
397
+ * webhook before trusting the status.
398
+ */
399
+ get(paymentHandleId: string, signal?: AbortSignal): Promise<PaymentHandle>;
400
+ }
401
+ /**
402
+ * Returns the URL the customer should be sent to when
403
+ * `handle.action === "REDIRECT"`, and `undefined` otherwise.
404
+ */
405
+ declare function paymentHandleRedirectUrl(handle: PaymentHandle): string | undefined;
406
+ /** Whether the caller must redirect the customer before proceeding. */
407
+ declare function paymentHandleRequiresAction(handle: PaymentHandle): boolean;
408
+
409
+ /**
410
+ * Payment operations: the final transaction step after a Payment Handle
411
+ * has reached `PAYABLE` status.
412
+ */
413
+ declare class PaymentsResource {
414
+ private readonly cfg;
415
+ private readonly transport;
416
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
417
+ /** Creates a payment using a `paymentHandleToken` from a `PAYABLE` Payment Handle. */
418
+ create(req: CreatePaymentRequest, signal?: AbortSignal): Promise<Payment>;
419
+ /** Retrieves a payment by ID. */
420
+ get(paymentId: string, signal?: AbortSignal): Promise<Payment>;
421
+ /** Returns payments matching the given filter. */
422
+ list(filter?: ListPaymentsFilter, signal?: AbortSignal): Promise<Payment[]>;
423
+ /** Cancels an authorized (not-yet-settled) payment. */
424
+ cancel(paymentId: string, signal?: AbortSignal): Promise<Payment>;
425
+ }
426
+
427
+ /**
428
+ * Settlement operations: capturing an authorized payment, including
429
+ * partial settlement and cancellation of a pending settlement.
430
+ */
431
+ declare class SettlementsResource {
432
+ private readonly cfg;
433
+ private readonly transport;
434
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
435
+ /** Settles (captures) an authorized payment by payment ID. */
436
+ create(paymentId: string, req: CreateSettlementRequest, signal?: AbortSignal): Promise<Settlement>;
437
+ /** Retrieves a settlement by ID. */
438
+ get(settlementId: string, signal?: AbortSignal): Promise<Settlement>;
439
+ /** Cancels a pending settlement. */
440
+ cancel(settlementId: string, signal?: AbortSignal): Promise<Settlement>;
441
+ }
442
+
443
+ /**
444
+ * Refund operations.
445
+ *
446
+ * Refunds are addressed by *settlement* ID, not payment ID. If
447
+ * `settleWithAuth` was `true` on the original payment, the settlement ID
448
+ * equals the payment ID — pass it directly. Otherwise pass the
449
+ * settlement ID returned by `SettlementsResource.create`. Don't mix
450
+ * refund paths on the same transaction: once a refund has been issued
451
+ * against a settlement ID, stick to that same ID for any further refunds
452
+ * on that transaction.
453
+ */
454
+ declare class RefundsResource {
455
+ private readonly cfg;
456
+ private readonly transport;
457
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
458
+ /** Issues a refund for a completed payment or settlement. */
459
+ create(settlementId: string, req: CreateRefundRequest, signal?: AbortSignal): Promise<Refund>;
460
+ /** Retrieves a refund by ID. */
461
+ get(refundId: string, signal?: AbortSignal): Promise<Refund>;
462
+ /** Cancels a pending refund. */
463
+ cancel(refundId: string, signal?: AbortSignal): Promise<Refund>;
464
+ }
465
+
466
+ /**
467
+ * Payout (credit) operations: standalone credits (general payouts) and
468
+ * original credits (iGaming-sector payouts). 3DS does not apply to
469
+ * payouts.
470
+ */
471
+ declare class PayoutsResource {
472
+ private readonly cfg;
473
+ private readonly transport;
474
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
475
+ /**
476
+ * Creates a standalone credit (payout for non-iGaming merchants). The
477
+ * Payment Handle must have `transactionType: "STANDALONE_CREDIT"`.
478
+ */
479
+ standaloneCredit(req: CreatePayoutRequest, signal?: AbortSignal): Promise<Payout>;
480
+ /**
481
+ * Creates an original credit (payout for iGaming merchants). The
482
+ * Payment Handle must have `transactionType: "ORIGINAL_CREDIT"`.
483
+ */
484
+ originalCredit(req: CreatePayoutRequest, signal?: AbortSignal): Promise<Payout>;
485
+ /** Retrieves a standalone credit by ID. */
486
+ getStandaloneCredit(creditId: string, signal?: AbortSignal): Promise<Payout>;
487
+ /** Retrieves an original credit by ID. */
488
+ getOriginalCredit(creditId: string, signal?: AbortSignal): Promise<Payout>;
489
+ /** Cancels a standalone credit. */
490
+ cancelStandaloneCredit(creditId: string, signal?: AbortSignal): Promise<Payout>;
491
+ }
492
+
493
+ /**
494
+ * Card verification: a zero-value authorization check used to validate a
495
+ * card without charging it. The Payment Handle must have
496
+ * `transactionType: "VERIFICATION"`.
497
+ */
498
+ declare class VerificationsResource {
499
+ private readonly cfg;
500
+ private readonly transport;
501
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
502
+ /** Creates a card verification. */
503
+ create(req: CreateVerificationRequest, signal?: AbortSignal): Promise<Verification>;
504
+ /** Retrieves a verification by ID. */
505
+ get(verificationId: string, signal?: AbortSignal): Promise<Verification>;
506
+ }
507
+
508
+ interface DateOfBirth {
509
+ year: number;
510
+ month: number;
511
+ day: number;
512
+ }
513
+ interface Address {
514
+ street?: string;
515
+ street2?: string;
516
+ city?: string;
517
+ state?: string;
518
+ country?: string;
519
+ zip?: string;
520
+ nickName?: string;
521
+ defaultShippingAddressIndicator?: boolean;
522
+ }
523
+ interface CreateCustomerRequest {
524
+ accountId?: string;
525
+ merchantCustomerId: string;
526
+ locale?: string;
527
+ firstName?: string;
528
+ lastName?: string;
529
+ email?: string;
530
+ phone?: string;
531
+ dateOfBirth?: DateOfBirth;
532
+ gender?: string;
533
+ nationality?: string;
534
+ addresses?: Address[];
535
+ }
536
+ /** Only the fields set here are changed server-side; unset fields are left untouched. */
537
+ interface UpdateCustomerRequest {
538
+ firstName?: string;
539
+ lastName?: string;
540
+ email?: string;
541
+ phone?: string;
542
+ locale?: string;
543
+ dateOfBirth?: DateOfBirth;
544
+ }
545
+ /** Summarizes a card stored against a Customer Vault profile. */
546
+ interface SavedCard {
547
+ id?: string;
548
+ cardBin?: string;
549
+ lastDigits?: string;
550
+ cardType?: string;
551
+ status?: string;
552
+ }
553
+ interface Customer {
554
+ id: string;
555
+ merchantCustomerId: string;
556
+ firstName?: string;
557
+ lastName?: string;
558
+ email?: string;
559
+ phone?: string;
560
+ locale?: string;
561
+ cards?: SavedCard[];
562
+ }
563
+ /**
564
+ * Converts a single-use token (SUT) from an initial payment into a
565
+ * multi-use token (MUT) attached to the customer's saved profile.
566
+ */
567
+ interface CreateCustomerPaymentHandleRequest {
568
+ merchantRefNum: string;
569
+ paymentHandleTokenFrom: string;
570
+ }
571
+ interface ListPaymentHandlesResponse {
572
+ paymentHandles: Record<string, unknown>[];
573
+ }
574
+ /**
575
+ * Response from tokenizing a customer's entire saved profile (cards,
576
+ * addresses, bank mandates) into one short-lived token, valid for 900
577
+ * seconds.
578
+ */
579
+ interface SingleUseCustomerToken {
580
+ singleUseCustomerToken: string;
581
+ timeToLiveSeconds: number;
582
+ }
583
+
584
+ /**
585
+ * Customer Vault profile and saved-instrument management. Base path is
586
+ * flat (`/paymenthub/v1/customers` — no account ID in the URL).
587
+ */
588
+ declare class CustomersResource {
589
+ private readonly cfg;
590
+ private readonly transport;
591
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
592
+ /** Creates a customer profile in the vault. */
593
+ create(req: CreateCustomerRequest, signal?: AbortSignal): Promise<Customer>;
594
+ /** Retrieves a customer profile by Paysafe's customer ID. */
595
+ get(customerId: string, signal?: AbortSignal): Promise<Customer>;
596
+ /** Retrieves a customer profile by your own `merchantCustomerId`. */
597
+ getByMerchantCustomerId(merchantCustomerId: string, signal?: AbortSignal): Promise<Customer>;
598
+ /** Updates a customer profile. Only the fields set in `req` are changed server-side. */
599
+ update(customerId: string, req: UpdateCustomerRequest, signal?: AbortSignal): Promise<Customer>;
600
+ /** Deletes a customer profile. */
601
+ delete(customerId: string, signal?: AbortSignal): Promise<void>;
602
+ /**
603
+ * Converts a single-use token (SUT) returned from an initial payment
604
+ * into a multi-use token (MUT) attached to the customer profile,
605
+ * enabling saved-card/recurring flows.
606
+ */
607
+ createPaymentHandle(customerId: string, req: CreateCustomerPaymentHandleRequest, signal?: AbortSignal): Promise<Record<string, unknown>>;
608
+ /** Lists all saved payment handles (saved instruments) for a customer. */
609
+ listPaymentHandles(customerId: string, signal?: AbortSignal): Promise<Record<string, unknown>[]>;
610
+ /** Deletes a specific saved payment handle for a customer. */
611
+ deletePaymentHandle(customerId: string, handleId: string, signal?: AbortSignal): Promise<void>;
612
+ /**
613
+ * Tokenizes the customer's entire saved profile — profile details,
614
+ * saved cards, addresses, and bank mandates — into one short-lived
615
+ * token valid for 900 seconds. Used to display a returning customer's
616
+ * saved instruments, or to re-collect a one-time CVV for a saved card.
617
+ */
618
+ createSingleUseCustomerToken(customerId: string, signal?: AbortSignal): Promise<SingleUseCustomerToken>;
619
+ }
620
+
621
+ type ApplicationStatus = "DRAFT" | "SUBMITTED" | "APPROVED" | "DECLINED" | "IN_REVIEW";
622
+ interface ApplicationContact {
623
+ firstName?: string;
624
+ lastName?: string;
625
+ email?: string;
626
+ phone?: string;
627
+ }
628
+ /**
629
+ * Request body for creating a draft merchant application. The full
630
+ * parameter set varies by country and business type; this captures the
631
+ * common subset.
632
+ */
633
+ interface CreateApplicationRequest {
634
+ merchantDescriptor?: string;
635
+ currencyCode?: string;
636
+ contact?: ApplicationContact;
637
+ }
638
+ interface Application {
639
+ id: string;
640
+ status: ApplicationStatus;
641
+ }
642
+ /**
643
+ * Request body for attaching a supporting document to an application
644
+ * (e.g. requested by a credit underwriter during review).
645
+ */
646
+ interface UploadDocumentRequest {
647
+ documentType: string;
648
+ /** Base64-encoded file content. */
649
+ fileContent: string;
650
+ fileName: string;
651
+ }
652
+
653
+ /**
654
+ * Merchant onboarding Application operations.
655
+ *
656
+ * Workflow: `create` -> `update` (optional, pre-submission) ->
657
+ * `uploadDocument` (optional) -> `getTermsAndConditions` -> `submit`.
658
+ * After `submit` succeeds, the application can no longer be modified via
659
+ * the API; subscribe to webhooks for status updates rather than polling.
660
+ */
661
+ declare class ApplicationsResource {
662
+ private readonly cfg;
663
+ private readonly transport;
664
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
665
+ /** Creates a draft merchant application. */
666
+ create(req: CreateApplicationRequest, signal?: AbortSignal): Promise<Application>;
667
+ /** Retrieves an application by ID. */
668
+ get(applicationId: string, signal?: AbortSignal): Promise<Application>;
669
+ /** Updates a draft application. Only possible before `submit` is called. */
670
+ update(applicationId: string, req: CreateApplicationRequest, signal?: AbortSignal): Promise<Application>;
671
+ /**
672
+ * Sends the application to Paysafe for review. After this call
673
+ * succeeds, the application can no longer be modified via the API.
674
+ */
675
+ submit(applicationId: string, signal?: AbortSignal): Promise<Application>;
676
+ /** Retrieves the terms the merchant must accept before processing can begin. */
677
+ getTermsAndConditions(applicationId: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
678
+ /**
679
+ * Attaches a supporting document to an application (e.g. requested by
680
+ * a credit underwriter during review). Documents can be uploaded before
681
+ * or after submission.
682
+ */
683
+ uploadDocument(applicationId: string, req: UploadDocumentRequest, signal?: AbortSignal): Promise<Record<string, unknown>>;
684
+ }
685
+
686
+ type BillingCycle = "DAILY" | "WEEKLY" | "BI_WEEKLY" | "MONTHLY" | "QUARTERLY" | "SEMI_ANNUALLY" | "ANNUALLY";
687
+ type PlanStatus = "ACTIVE" | "INACTIVE" | "DISCONTINUED";
688
+ /** Binds a Plan or Subscription to the payment instrument used for recurring billing. */
689
+ interface PaymentMethodDetails {
690
+ paymentType?: string;
691
+ paymentHandleToken?: string;
692
+ }
693
+ interface CreatePlanRequest {
694
+ name: string;
695
+ amount: number;
696
+ currencyCode: string;
697
+ interval: BillingCycle;
698
+ numPayments?: number;
699
+ startDate?: string;
700
+ trialAmount?: number;
701
+ trialPeriod?: number;
702
+ maxFailedPayments?: number;
703
+ retryPaymentAmount?: number;
704
+ paymentMethodDetails?: PaymentMethodDetails;
705
+ }
706
+ /** Keep amount increases below 20% to comply with card scheme guidelines. */
707
+ interface UpdatePlanRequest {
708
+ name?: string;
709
+ amount?: number;
710
+ numPayments?: number;
711
+ maxFailedPayments?: number;
712
+ retryPaymentAmount?: number;
713
+ }
714
+ interface Plan {
715
+ id: string;
716
+ name: string;
717
+ amount: number;
718
+ currencyCode: string;
719
+ billingCycle: BillingCycle;
720
+ numPayments?: number;
721
+ status: PlanStatus;
722
+ }
723
+ interface ListPlansResponse {
724
+ plans: Plan[];
725
+ }
726
+ type SubscriptionStatus = "ACTIVE" | "INACTIVE" | "SUSPENDED" | "CANCELLED" | "EXPIRED" | "FUTURE" | "COMPLETED";
727
+ /** Binds a customer (via multi-use token) to a Plan. */
728
+ interface CreateSubscriptionRequest {
729
+ planId: string;
730
+ merchantCustomerId: string;
731
+ paymentHandleToken: string;
732
+ merchantRefNum: string;
733
+ amount?: number;
734
+ startDate?: string;
735
+ numPayments?: number;
736
+ trialAmount?: number;
737
+ initialAmount?: number;
738
+ }
739
+ /**
740
+ * Mutable Subscription fields, including status transitions. Prefer the
741
+ * `cancel`/`suspend`/`reactivate` convenience methods over setting
742
+ * `status` directly.
743
+ */
744
+ interface UpdateSubscriptionRequest {
745
+ status?: SubscriptionStatus;
746
+ numCycles?: number;
747
+ discountAmount?: number;
748
+ discountNumPayments?: number;
749
+ amount?: number;
750
+ }
751
+ interface Subscription {
752
+ id: string;
753
+ planId: string;
754
+ merchantCustomerId: string;
755
+ amount: number;
756
+ currencyCode: string;
757
+ status: SubscriptionStatus;
758
+ nextPaymentDate?: string;
759
+ numPaymentsRemaining?: number;
760
+ }
761
+ interface ListSubscriptionsFilter {
762
+ planId?: string;
763
+ status?: string;
764
+ merchantCustomerId?: string;
765
+ limit?: number;
766
+ offset?: number;
767
+ }
768
+ interface ListSubscriptionsResponse {
769
+ subscriptions: Subscription[];
770
+ }
771
+
772
+ /** Recurring billing Plan operations. */
773
+ declare class PlansResource {
774
+ private readonly cfg;
775
+ private readonly transport;
776
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
777
+ /**
778
+ * Creates a recurring billing plan under `accountId` (or the client's
779
+ * default account ID if `accountId` is omitted).
780
+ */
781
+ create(accountId: string | undefined, req: CreatePlanRequest, signal?: AbortSignal): Promise<Plan>;
782
+ /** Retrieves a plan by ID. */
783
+ get(accountId: string | undefined, planId: string, signal?: AbortSignal): Promise<Plan>;
784
+ /** Lists all billing plans for an account. */
785
+ list(accountId: string | undefined, signal?: AbortSignal): Promise<Plan[]>;
786
+ /**
787
+ * Updates a plan's mutable fields. Keep amount increases below 20% to
788
+ * comply with card scheme guidelines. Discontinuing a plan prevents new
789
+ * subscriptions but does not affect existing ones.
790
+ */
791
+ update(accountId: string | undefined, planId: string, req: UpdatePlanRequest, signal?: AbortSignal): Promise<Plan>;
792
+ /** Discontinues a plan. */
793
+ delete(accountId: string | undefined, planId: string, signal?: AbortSignal): Promise<void>;
794
+ }
795
+
796
+ /**
797
+ * Subscription operations: binding a customer (via multi-use token) to a
798
+ * Plan to create a recurring billing schedule.
799
+ */
800
+ declare class SubscriptionsResource {
801
+ private readonly cfg;
802
+ private readonly transport;
803
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
804
+ /** Creates a subscription for a customer under a plan. */
805
+ create(accountId: string | undefined, req: CreateSubscriptionRequest, signal?: AbortSignal): Promise<Subscription>;
806
+ /** Retrieves a subscription by ID. */
807
+ get(accountId: string | undefined, subscriptionId: string, signal?: AbortSignal): Promise<Subscription>;
808
+ /** Lists subscriptions matching the given filter. */
809
+ list(accountId: string | undefined, filter?: ListSubscriptionsFilter, signal?: AbortSignal): Promise<Subscription[]>;
810
+ /**
811
+ * Updates a subscription: extend cycles (`numCycles`), apply a discount
812
+ * (`discountAmount`/`discountNumPayments`), or change `status` directly.
813
+ * Prefer `cancel`/`suspend`/`reactivate` for status transitions.
814
+ */
815
+ update(accountId: string | undefined, subscriptionId: string, req: UpdateSubscriptionRequest, signal?: AbortSignal): Promise<Subscription>;
816
+ /** Cancels a subscription immediately. */
817
+ cancel(accountId: string | undefined, subscriptionId: string, signal?: AbortSignal): Promise<Subscription>;
818
+ /** Pauses billing on a subscription; it can later be reactivated. */
819
+ suspend(accountId: string | undefined, subscriptionId: string, signal?: AbortSignal): Promise<Subscription>;
820
+ /**
821
+ * Re-activates a suspended subscription. The last failed payment is
822
+ * retried; subsequent cycles resume on their original schedule.
823
+ */
824
+ reactivate(accountId: string | undefined, subscriptionId: string, signal?: AbortSignal): Promise<Subscription>;
825
+ }
826
+
827
+ /** Requests a guaranteed exchange rate quote. Available for Europe & UK merchants. */
828
+ interface GetFxRateRequest {
829
+ fromCurrency: string;
830
+ toCurrency: string;
831
+ amount?: number;
832
+ }
833
+ interface FxRate {
834
+ id: string;
835
+ fromCurrency: string;
836
+ toCurrency: string;
837
+ rate: number;
838
+ expiry?: string;
839
+ }
840
+ /**
841
+ * Outcome of a Customer Identity check.
842
+ *
843
+ * - `SUCCESS`: the customer passed.
844
+ * - `ERROR`: a downstream provider issue occurred — retry with `rerun()`.
845
+ * - `FAIL`: the customer failed the check outright; do not rerun.
846
+ * - `OUTSORT`: inconclusive; the merchant should manually verify via documents.
847
+ */
848
+ type IdentityDecision = "SUCCESS" | "ERROR" | "FAIL" | "OUTSORT";
849
+ /** String-typed DOB shape used by the Customer Identity API. */
850
+ interface IdentityDateOfBirth {
851
+ day: string;
852
+ month: string;
853
+ year: string;
854
+ }
855
+ interface IdentityAddress {
856
+ street?: string;
857
+ street2?: string;
858
+ city?: string;
859
+ state?: string;
860
+ country?: string;
861
+ zip?: string;
862
+ monthsAtAddress?: string;
863
+ phone?: string;
864
+ }
865
+ interface IdentityProfileInput {
866
+ firstName: string;
867
+ lastName: string;
868
+ email?: string;
869
+ currentAddress?: IdentityAddress;
870
+ dateOfBirth?: IdentityDateOfBirth;
871
+ }
872
+ interface VerifyIdentityRequest {
873
+ merchantRefNum: string;
874
+ profile: IdentityProfileInput;
875
+ customerIp?: string;
876
+ vendorCheck?: string;
877
+ workflowId?: string;
878
+ }
879
+ interface IdentityProfile {
880
+ id: string;
881
+ merchantRefNum: string;
882
+ decision: IdentityDecision;
883
+ providerResponses?: Record<string, unknown>;
884
+ }
885
+ type BankVerificationStatus = "INITIATED" | "COMPLETED" | "FAILED" | "CANCELLED" | "EXPIRED";
886
+ /** The minimal customer profile required to start a Bank Account Validation session. */
887
+ interface BankVerificationProfile {
888
+ firstName: string;
889
+ middleName?: string;
890
+ lastName: string;
891
+ locale?: string;
892
+ }
893
+ /**
894
+ * Request body for starting a Bank Account Validation redirect session.
895
+ * Available for Canada and the United States.
896
+ */
897
+ interface CreateBankVerificationRequest {
898
+ merchantRefNum: string;
899
+ profile: BankVerificationProfile;
900
+ accountTypes?: string[];
901
+ currencyCodes?: string[];
902
+ returnLinks?: PaysafeLink[];
903
+ bankscheme?: string;
904
+ }
905
+ /**
906
+ * Request body for starting an Interac AML Assist Verification
907
+ * (VerifiedMe) redirect session. Available only in Canada.
908
+ */
909
+ interface CreateInteracVerificationRequest {
910
+ merchantRefNum: string;
911
+ accountId?: string;
912
+ locale?: string;
913
+ returnLinks?: PaysafeLink[];
914
+ metadata?: Record<string, unknown>;
915
+ }
916
+ /**
917
+ * A Bank Account Validation or Interac Verification Service session.
918
+ * Both products share this redirect-based shape.
919
+ */
920
+ interface BankVerification {
921
+ id: string;
922
+ merchantRefNum?: string;
923
+ sessionId?: string;
924
+ status: BankVerificationStatus;
925
+ bankScheme?: string;
926
+ accountTypes?: string[];
927
+ currencyCodes?: string[];
928
+ links?: PaysafeLink[];
929
+ }
930
+
931
+ /**
932
+ * FX Rates API operations: guaranteed exchange rate quotes with expiry
933
+ * timestamps. Available for Europe & UK merchants.
934
+ *
935
+ * The exact request/response JSON shape could not be confirmed against a
936
+ * concrete example at the time this client was written — the base path
937
+ * (`/fxrates/v1`) and account-scoped URL pattern are consistent with
938
+ * every other Payments API resource, but double-check field names
939
+ * against the current API reference before relying on this in
940
+ * production.
941
+ */
942
+ declare class FxRatesResource {
943
+ private readonly cfg;
944
+ private readonly transport;
945
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
946
+ /** Gets a guaranteed FX rate for a currency pair. */
947
+ getRate(accountId: string | undefined, req: GetFxRateRequest, signal?: AbortSignal): Promise<FxRate>;
948
+ /** Retrieves a specific FX rate by quote ID. */
949
+ getQuote(accountId: string | undefined, quoteId: string, signal?: AbortSignal): Promise<FxRate>;
950
+ }
951
+
952
+ /**
953
+ * Customer Identity (KYC) API: AML/KYC identity verification in a single
954
+ * API request. Available globally (CA, EU/UK, US). Base path is flat —
955
+ * not nested under `/accounts/{accountId}` like most other Payments API
956
+ * resources.
957
+ */
958
+ declare class CustomerIdentityResource {
959
+ private readonly cfg;
960
+ private readonly transport;
961
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
962
+ /** Submits an identity verification request. */
963
+ verify(req: VerifyIdentityRequest, signal?: AbortSignal): Promise<IdentityProfile>;
964
+ /** Retrieves a previously submitted identity profile by ID. */
965
+ get(profileId: string, signal?: AbortSignal): Promise<IdentityProfile>;
966
+ /**
967
+ * Reruns a failed identity check. Only rerun a check whose `decision`
968
+ * was `"ERROR"` — this indicates a transient downstream provider
969
+ * issue. Do not rerun a check whose `decision` was `"FAIL"`;
970
+ * resubmitting returns the same `"FAIL"` result again.
971
+ */
972
+ rerun(profileId: string, signal?: AbortSignal): Promise<IdentityProfile>;
973
+ }
974
+
975
+ /**
976
+ * Bank Account Validation API: a redirect-based open-banking flow that
977
+ * lets a customer verify bank account ownership before payouts are sent
978
+ * to that account. Available for Canada and the United States.
979
+ */
980
+ declare class BankAccountValidationResource {
981
+ private readonly cfg;
982
+ private readonly transport;
983
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
984
+ /**
985
+ * Starts a bank account verification session. Redirect the customer to
986
+ * {@link bankVerificationRedirectUrl} to complete the flow; there is no
987
+ * synchronous result.
988
+ */
989
+ create(accountId: string | undefined, req: CreateBankVerificationRequest, signal?: AbortSignal): Promise<BankVerification>;
990
+ /**
991
+ * Looks up a bank account verification by ID. Returns validated
992
+ * account details and a single-use payment token once the customer has
993
+ * completed the redirect flow.
994
+ */
995
+ get(verificationId: string, signal?: AbortSignal): Promise<BankVerification>;
996
+ }
997
+ /**
998
+ * Interac Verification Service (VerifiedMe): AML Assist Verification via
999
+ * the customer's bank login credentials, through the Interac digital
1000
+ * identity network. Available only in Canada. Shares the
1001
+ * `/bankaccountvalidator/v1` base path with Bank Account Validation,
1002
+ * under `/verifiedme`.
1003
+ */
1004
+ declare class InteracVerificationResource {
1005
+ private readonly cfg;
1006
+ private readonly transport;
1007
+ constructor(cfg: ResolvedConfig, transport: HttpTransport);
1008
+ /** Starts an Interac AML Assist verification session. */
1009
+ create(accountId: string | undefined, req: CreateInteracVerificationRequest, signal?: AbortSignal): Promise<BankVerification>;
1010
+ /**
1011
+ * Fetches the user's verified information once they have completed the
1012
+ * redirect flow on Interac's bank page.
1013
+ */
1014
+ get(verificationId: string, signal?: AbortSignal): Promise<BankVerification>;
1015
+ }
1016
+ /**
1017
+ * Returns the URL the customer should be sent to in order to complete
1018
+ * the bank validation or Interac flow.
1019
+ */
1020
+ declare function bankVerificationRedirectUrl(verification: BankVerification): string | undefined;
1021
+
1022
+ /** Categorises a webhook event by the resource it concerns. */
1023
+ type WebhookTopic = "payment_handle" | "payment" | "settlement" | "refund" | "payout" | "subscription" | "account_updater" | "unknown";
1024
+ /** A decoded and verified Paysafe webhook event. */
1025
+ interface PaysafeWebhookEvent {
1026
+ eventName: string;
1027
+ eventType?: string;
1028
+ eventDate?: string;
1029
+ type?: string;
1030
+ resourceId?: string;
1031
+ attemptNumber?: string;
1032
+ payload?: Record<string, unknown>;
1033
+ links?: unknown[];
1034
+ }
1035
+
1036
+ /**
1037
+ * Verifies HMAC-SHA256 webhook signatures and parses event payloads.
1038
+ * Stateless and safe for concurrent use; construct once per HMAC key (or
1039
+ * once and pass the key per call).
1040
+ */
1041
+ declare class WebhooksResource {
1042
+ /**
1043
+ * Verifies the HMAC-SHA256 signature of `rawBody` against `signature`
1044
+ * using `hmacKey`, then decodes the payload into a
1045
+ * {@link PaysafeWebhookEvent}.
1046
+ *
1047
+ * @param rawBody - The exact, unmodified request body bytes/text as received.
1048
+ * @param signature - The value of the `Signature` HTTP header.
1049
+ * @param hmacKey - The merchant's webhook HMAC key from the Paysafe portal.
1050
+ *
1051
+ * Verification uses a constant-time comparison to prevent timing
1052
+ * attacks.
1053
+ */
1054
+ verifyAndParse(rawBody: string | Uint8Array, signature: string, hmacKey: string): Promise<PaysafeWebhookEvent>;
1055
+ /**
1056
+ * Verifies the webhook signature without parsing the body. Resolves on
1057
+ * success, or throws a {@link PaysafeError} with
1058
+ * `kind === "webhook_signature_mismatch"` on failure.
1059
+ */
1060
+ verifySignature(rawBody: string | Uint8Array, signature: string, hmacKey: string): Promise<void>;
1061
+ /**
1062
+ * Decodes a webhook body that has already been verified (e.g. by a
1063
+ * signature-checking middleware) into a {@link PaysafeWebhookEvent}.
1064
+ */
1065
+ parse(rawBody: string | Uint8Array): PaysafeWebhookEvent;
1066
+ /**
1067
+ * Parses an already-decoded object into a {@link PaysafeWebhookEvent},
1068
+ * useful when the caller's web framework has already deserialized the
1069
+ * JSON body.
1070
+ */
1071
+ parseObject(obj: Record<string, unknown>): PaysafeWebhookEvent;
1072
+ }
1073
+ /** Classifies `event` by its `eventName` prefix. */
1074
+ declare function webhookTopic(event: PaysafeWebhookEvent): WebhookTopic;
1075
+ /**
1076
+ * Extracts the payment-handle lifecycle status implied by `event`'s
1077
+ * name, or `undefined` for non-payment-handle events.
1078
+ */
1079
+ declare function webhookPaymentHandleStatus(event: PaysafeWebhookEvent): string | undefined;
1080
+
1081
+ /**
1082
+ * The top-level Paysafe SDK client. Construct one with `new
1083
+ * PaysafeClient(options)` or {@link PaysafeClient.fromEnv}, then call
1084
+ * operations through its resource properties (`paymentHandles`,
1085
+ * `payments`, `customers`, `plans`, `subscriptions`, `applications`,
1086
+ * `webhooks`, ...).
1087
+ *
1088
+ * A `PaysafeClient` is safe for concurrent use across multiple requests.
1089
+ *
1090
+ * @example
1091
+ * ```ts
1092
+ * const client = new PaysafeClient({
1093
+ * username: "1001062690",
1094
+ * password: "B-qa2-0-...",
1095
+ * environment: "test",
1096
+ * accountId: "1009688230",
1097
+ * });
1098
+ *
1099
+ * const handle = await client.paymentHandles.create({
1100
+ * merchantRefNum: "order-1",
1101
+ * amount: 5000,
1102
+ * currencyCode: "USD",
1103
+ * paymentType: "CARD",
1104
+ * transactionType: "PAYMENT",
1105
+ * card: {
1106
+ * cardNum: "4111111111111111",
1107
+ * cardExpiry: { month: 12, year: 2030 },
1108
+ * cvv: "123",
1109
+ * holderName: "Jane Doe",
1110
+ * },
1111
+ * billingDetails: { street: "123 Main St", city: "New York", state: "NY", country: "US", zip: "10001" },
1112
+ * });
1113
+ *
1114
+ * const payment = await client.payments.create({
1115
+ * merchantRefNum: "payment-001",
1116
+ * amount: 5000,
1117
+ * currencyCode: "USD",
1118
+ * paymentHandleToken: handle.paymentHandleToken,
1119
+ * });
1120
+ * ```
1121
+ */
1122
+ declare class PaysafeClient {
1123
+ private readonly cfg;
1124
+ readonly paymentHandles: PaymentHandlesResource;
1125
+ readonly payments: PaymentsResource;
1126
+ readonly settlements: SettlementsResource;
1127
+ readonly refunds: RefundsResource;
1128
+ readonly payouts: PayoutsResource;
1129
+ readonly verifications: VerificationsResource;
1130
+ readonly customers: CustomersResource;
1131
+ readonly plans: PlansResource;
1132
+ readonly subscriptions: SubscriptionsResource;
1133
+ readonly applications: ApplicationsResource;
1134
+ readonly fxRates: FxRatesResource;
1135
+ readonly customerIdentity: CustomerIdentityResource;
1136
+ readonly bankAccountValidation: BankAccountValidationResource;
1137
+ readonly interacVerification: InteracVerificationResource;
1138
+ readonly webhooks: WebhooksResource;
1139
+ constructor(options: PaysafeClientOptions, telemetryHook?: TelemetryHook);
1140
+ /**
1141
+ * Builds a `PaysafeClient` from `PAYSAFE_USERNAME`, `PAYSAFE_PASSWORD`,
1142
+ * `PAYSAFE_ENVIRONMENT`, and `PAYSAFE_ACCOUNT_ID` environment variables
1143
+ * (Node.js only), merged with any additional `overrides` (last-wins).
1144
+ */
1145
+ static fromEnv(overrides?: Partial<PaysafeClientOptions>, telemetryHook?: TelemetryHook): PaysafeClient;
1146
+ /** The client's configured default account ID, if set. */
1147
+ get accountId(): string | undefined;
1148
+ /** The client's configured environment (`"test"` or `"production"`). */
1149
+ get environment(): Environment;
1150
+ /** The resolved base URL the client sends requests to. */
1151
+ get baseUrl(): string;
1152
+ }
1153
+
1154
+ /**
1155
+ * Structured error taxonomy for the Paysafe SDK, mirroring the reference
1156
+ * Go and Elixir implementations so callers can branch reliably.
1157
+ */
1158
+ /** Classifies the failure mode of a {@link PaysafeError}. */
1159
+ type PaysafeErrorKind = "api_error" | "http_error" | "rate_limited" | "timeout" | "invalid_config" | "invalid_params" | "webhook_signature_mismatch" | "decode_error" | "context_canceled";
1160
+ /** A single field-level validation error returned by the Paysafe API. */
1161
+ interface PaysafeFieldError {
1162
+ field: string;
1163
+ error: string;
1164
+ }
1165
+ interface PaysafeErrorInit {
1166
+ kind: PaysafeErrorKind;
1167
+ message: string;
1168
+ code?: string;
1169
+ httpStatus?: number;
1170
+ fieldErrors?: PaysafeFieldError[];
1171
+ details?: Record<string, unknown>;
1172
+ retryable?: boolean;
1173
+ cause?: unknown;
1174
+ }
1175
+ /**
1176
+ * The structured error type thrown by every Paysafe SDK operation.
1177
+ * Every rejected promise from this SDK rejects with an instance of
1178
+ * `PaysafeError` (never a bare string or plain object).
1179
+ *
1180
+ * @example
1181
+ * ```ts
1182
+ * try {
1183
+ * await client.payments.create(req);
1184
+ * } catch (err) {
1185
+ * if (err instanceof PaysafeError) {
1186
+ * console.error(err.kind, err.code, err.message, err.fieldErrors);
1187
+ * }
1188
+ * }
1189
+ * ```
1190
+ */
1191
+ declare class PaysafeError extends Error {
1192
+ readonly kind: PaysafeErrorKind;
1193
+ readonly code?: string;
1194
+ readonly httpStatus?: number;
1195
+ readonly fieldErrors: PaysafeFieldError[];
1196
+ readonly details?: Record<string, unknown>;
1197
+ readonly retryable: boolean;
1198
+ constructor(init: PaysafeErrorInit);
1199
+ /** Whether the SDK's retry policy should attempt this request again. */
1200
+ isRetryable(): boolean;
1201
+ static fromApiResponse(body: Record<string, unknown>, httpStatus: number): PaysafeError;
1202
+ static httpError(cause: unknown, timedOut: boolean): PaysafeError;
1203
+ static rateLimited(): PaysafeError;
1204
+ static invalidParams(message: string): PaysafeError;
1205
+ static invalidConfig(message: string): PaysafeError;
1206
+ static webhookMismatch(): PaysafeError;
1207
+ static decodeError(cause: unknown): PaysafeError;
1208
+ static contextCanceled(cause: unknown): PaysafeError;
1209
+ }
1210
+
1211
+ export { type Address, type Application, type ApplicationContact, type ApplicationStatus, ApplicationsResource, BankAccountValidationResource, type BankVerification, type BankVerificationProfile, type BankVerificationStatus, type BillingCycle, type BillingDetails, type Card, type CardExpiry, type CreateApplicationRequest, type CreateBankVerificationRequest, type CreateCustomerPaymentHandleRequest, type CreateCustomerRequest, type CreateInteracVerificationRequest, type CreatePaymentHandleRequest, type CreatePaymentRequest, type CreatePayoutRequest, type CreatePlanRequest, type CreateRefundRequest, type CreateSettlementRequest, type CreateSubscriptionRequest, type CreateVerificationRequest, type Customer, CustomerIdentityResource, CustomersResource, type DateOfBirth, type Environment, type ExecutionMode, type FetchLike, type FxRate, FxRatesResource, type GetFxRateRequest, type HandleAction, type HandleStatus, type HandleUsage, type IdentityAddress, type IdentityDateOfBirth, type IdentityDecision, type IdentityProfile, type IdentityProfileInput, type InlineProfile, InteracVerificationResource, type ListPaymentHandlesResponse, type ListPaymentsFilter, type ListPaymentsResponse, type ListPlansResponse, type ListSubscriptionsFilter, type ListSubscriptionsResponse, type NetworkToken, type Payment, type PaymentHandle, PaymentHandlesResource, type PaymentMethodDetails, type PaymentStatus, PaymentsResource, type Payout, PayoutsResource, PaysafeClient, type PaysafeClientOptions, PaysafeError, type PaysafeErrorInit, type PaysafeErrorKind, type PaysafeFieldError, type PaysafeLink, type PaysafeWebhookEvent, type Plan, type PlanStatus, PlansResource, type RateLimitConfig, type Refund, type RefundStatus, RefundsResource, type SavedCard, type Settlement, type SettlementStatus, type SettlementSummary, SettlementsResource, type SingleUseCustomerToken, type Subscription, type SubscriptionStatus, SubscriptionsResource, type TelemetryExceptionMeta, type TelemetryHook, type TelemetryStartMeta, type TelemetryStopMeta, type ThreeDS, type TransactionType, type UpdateCustomerRequest, type UpdatePlanRequest, type UpdateSubscriptionRequest, type UploadDocumentRequest, type Verification, VerificationsResource, type VerifyIdentityRequest, type WebhookTopic, WebhooksResource, bankVerificationRedirectUrl, findLinkByRel, paymentHandleRedirectUrl, paymentHandleRequiresAction, webhookPaymentHandleStatus, webhookTopic };