@funnelfox/billing 0.13.1 → 0.13.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelfox/billing",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "license": "MIT",
5
5
  "author": "Funnelfox",
6
6
  "description": "JavaScript SDK for Funnelfox billing with Primer integration",
@@ -26,7 +26,7 @@
26
26
  "scripts": {
27
27
  "build": "rm -rf dist && rollup -c",
28
28
  "build:watch": "rollup -c -w",
29
- "build:examples": "npm run build && npm pack && npm i ./funnelfox-billing-0.13.1.tgz --prefix examples/basic && npm run build --prefix examples/basic",
29
+ "build:examples": "npm run build && npm pack && npm i ./funnelfox-billing-0.13.2.tgz --prefix examples/basic && npm run build --prefix examples/basic",
30
30
  "version": "node scripts/sync-version.js",
31
31
  "release:patch": "npm version patch --no-git-tag-version",
32
32
  "release:minor": "npm version minor --no-git-tag-version",
package/src/types.d.ts CHANGED
@@ -308,17 +308,19 @@ export interface PrimerHandler {
308
308
  }
309
309
 
310
310
  // Error types
311
- export interface FunnefoxSDKError extends Error {
311
+ export declare class FunnefoxSDKError extends Error {
312
312
  code: string;
313
313
  details: unknown;
314
+ constructor(message: string, code?: string, details?: unknown);
314
315
  }
315
316
 
316
- export interface ValidationError extends FunnefoxSDKError {
317
+ export declare class ValidationError extends FunnefoxSDKError {
317
318
  field: string;
318
319
  value: unknown;
320
+ constructor(field: string, message: string, value?: unknown);
319
321
  }
320
322
 
321
- export interface APIError extends FunnefoxSDKError {
323
+ export declare class APIError extends FunnefoxSDKError {
322
324
  statusCode: number | null;
323
325
  errorCode: string | null;
324
326
  errorType: string | null;
@@ -326,21 +328,37 @@ export interface APIError extends FunnefoxSDKError {
326
328
  response: unknown;
327
329
  declineCode: string | null;
328
330
  declineCodeSource: DeclineCodeSource | null;
331
+ constructor(
332
+ message: string,
333
+ statusCode?: number | null,
334
+ options?: {
335
+ errorCode?: string | null;
336
+ errorType?: string | null;
337
+ requestId?: string | null;
338
+ response?: unknown;
339
+ declineCode?: string | null;
340
+ declineCodeSource?: DeclineCodeSource | null;
341
+ }
342
+ );
329
343
  }
330
344
 
331
- export interface PrimerError extends FunnefoxSDKError {
345
+ export declare class PrimerError extends FunnefoxSDKError {
332
346
  primerError: unknown;
347
+ constructor(message: string, primerError?: unknown);
333
348
  }
334
349
 
335
- export interface CheckoutError extends FunnefoxSDKError {
350
+ export declare class CheckoutError extends FunnefoxSDKError {
336
351
  phase: string | null;
352
+ constructor(message: string, phase?: string | null);
337
353
  }
338
354
 
339
- //eslint-disable-next-line @typescript-eslint/no-empty-object-type
340
- export interface ConfigurationError extends FunnefoxSDKError {}
355
+ export declare class ConfigurationError extends FunnefoxSDKError {
356
+ constructor(message: string);
357
+ }
341
358
 
342
- export interface NetworkError extends FunnefoxSDKError {
359
+ export declare class NetworkError extends FunnefoxSDKError {
343
360
  originalError: unknown;
361
+ constructor(message: string, originalError?: unknown);
344
362
  }
345
363
 
346
364
  // Function signatures
@@ -477,17 +495,19 @@ export interface SilentPurchaseDetailedOptions extends SilentPurchaseOptions {
477
495
  /** Opt-in: run 3DS when the bank asks for it and resolve with a detailed result. */
478
496
  handle3DS: true;
479
497
  /**
480
- * Fired once when the one-click response carries a non-empty `action_required_token`,
481
- * before the challenge (keep the upsell button disabled until the promise resolves).
498
+ * Fired once when the 3DS window becomes visible to the customer (keep the upsell button
499
+ * disabled until the promise resolves). Primer cannot tell a frictionless check from a
500
+ * challenge, so the window stays hidden for the first 6 s of the 3DS step; a check that
501
+ * finishes within that time fires no hooks.
482
502
  */
483
503
  onThreeDSStart?: (info: { orderId: string }) => void;
484
504
  /** Fired exactly once per `onThreeDSStart`, after the 3DS step and before the promise resolves. */
485
505
  onThreeDSEnd?: (info: { result: ThreeDSResult }) => void;
486
506
  /**
487
- * Give up on the 3DS step after this many ms. Default 600000. Resolves `3ds_abandoned` if the
488
- * challenge was shown; `error` if it ran out before the challenge was shown (with
489
- * `failedRequest: 'create_client_session'` while that request was pending). Never aborts a
490
- * request that is already sent.
507
+ * Give up on the 3DS step after this many ms. Default 600000. Once the 3DS window is due, the
508
+ * count restarts when it is shown and ends in `3ds_abandoned`. Runs out before that as `error`
509
+ * (with `failedRequest: 'create_client_session'` while that request was pending). Never aborts
510
+ * a request that is already sent.
491
511
  */
492
512
  threeDSTimeoutMs?: number;
493
513
  }
@@ -509,9 +529,12 @@ export type OneClickFailedRequest =
509
529
 
510
530
  export interface OneClickResult {
511
531
  outcome: OneClickOutcome;
512
- /** `null` only when no order was created (error before/at one_click). */
532
+ /**
533
+ * `null` when no order is known: an error before or at one_click, or `processing` after
534
+ * `one_click` retries ran out (`error` and `failedRequest` are set then).
535
+ */
513
536
  orderId: string | null;
514
- /** The backend returned a non-empty `action_required_token`. */
537
+ /** The 3DS window was shown to the customer (`onThreeDSStart` fired). */
515
538
  threeDSChallenged: boolean;
516
539
  failedMessageForUser?: string | null;
517
540
  declineCode?: string | null;
@@ -744,6 +767,8 @@ export interface PaymentResponseData {
744
767
  decline_code?: string | null;
745
768
  decline_code_source?: DeclineCodeSource | null;
746
769
  order_id: string;
770
+ /** `one_click` only: the idempotency key was seen before, nothing new was charged. */
771
+ idempotent_replay?: boolean;
747
772
  }
748
773
 
749
774
  export interface CreatePaymentResponse {
@@ -812,4 +837,5 @@ export interface OneClickRequest {
812
837
  initiation_type?: 'cit' | 'mit';
813
838
  cit_card_networks?: string[];
814
839
  cit_google_pay_pan_only?: boolean;
840
+ idempotency_key?: string;
815
841
  }