@funnelfox/billing 0.9.3-feat-defer-session-on-interaction.34 → 0.10.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/src/types.d.ts CHANGED
@@ -74,40 +74,10 @@ export interface BillingCardOptions extends CheckoutCardOptions {
74
74
  emailAddress?: BillingCardEmailAddressOptions;
75
75
  }
76
76
 
77
- /**
78
- * Apple Pay button types (https://developer.apple.com/documentation/applepayontheweb/applepaybuttontype).
79
- *
80
- * The legacy 7 values (Primer's union) render through Primer's CSS approach.
81
- * The newer values (e.g. 'continue') cannot be rendered by WebKit via CSS, so
82
- * the SDK overlays Apple's official <apple-pay-button> element on top of the
83
- * Primer button and forwards clicks (see utils/apple-pay-native-button.ts,
84
- * PRD-1426). Payment flow stays fully Primer-driven either way.
85
- */
86
- export type ApplePayButtonType =
87
- | NonNullable<ApplePayOptions['buttonType']>
88
- | 'add-money'
89
- | 'continue'
90
- | 'contribute'
91
- | 'order'
92
- | 'pay'
93
- | 'reload'
94
- | 'rent'
95
- | 'support'
96
- | 'tip'
97
- | 'top-up';
98
-
99
- export type BillingApplePayOptions = Omit<
100
- ApplePayOptions,
101
- 'container' | 'buttonType'
102
- > & {
103
- buttonType?: ApplePayButtonType;
104
- };
105
-
106
77
  export interface PrimerCheckoutConfig extends Pick<
107
78
  Partial<HeadlessUniversalCheckoutOptions>,
108
- 'paypal' | 'googlePay' | 'style'
79
+ 'paypal' | 'applePay' | 'googlePay' | 'style'
109
80
  > {
110
- applePay?: BillingApplePayOptions;
111
81
  card?: BillingCardOptions;
112
82
  cardSelectors?: CardInputSelectors;
113
83
  paymentButtonSelectors?: PaymentButtonSelectors;
@@ -123,29 +93,27 @@ export interface CheckoutConfig extends PrimerCheckoutConfig {
123
93
  enableTax?: boolean;
124
94
  onTaxChange?: (info: TaxInfo) => void;
125
95
  onTaxError?: (error: Error) => void;
126
- /** See InitMethodOptions.sessionCreation. Wallet buttons only. */
127
- sessionCreation?: SessionCreationMode;
96
+ onTaxPending?: () => void;
128
97
  }
129
98
 
130
99
  export interface TaxInfo {
131
100
  /** Minor units; the total the customer pays. */
132
101
  amountTotal: number;
133
- /** Minor units; tax ADDED on top of the price — 0 for tax-inclusive pricing and non-taxed locations. */
102
+ /** Minor units; the tax to show the buyer — added on top when exclusive, already inside the price when inclusive, 0 when unknown. */
134
103
  taxAmount: number;
135
104
  currency: string;
105
+ taxBehavior?: TaxBehavior;
136
106
  }
137
107
 
108
+ export type TaxBehavior = 'inclusive' | 'exclusive';
109
+
138
110
  export interface PaymentButtonSelectors {
139
111
  paypal: string;
140
112
  googlePay: string;
141
113
  applePay: string;
142
114
  }
143
115
 
144
- export interface CheckoutOptions extends Omit<
145
- Partial<HeadlessUniversalCheckoutOptions>,
146
- 'applePay'
147
- > {
148
- applePay?: BillingApplePayOptions;
116
+ export interface CheckoutOptions extends Partial<HeadlessUniversalCheckoutOptions> {
149
117
  onTokenizeSuccess: OnTokenizeSuccess;
150
118
  onResumeSuccess: OnResumeSuccess;
151
119
  onAvailablePaymentMethodsLoad?: (items: PaymentMethod[]) => void;
@@ -300,6 +268,8 @@ export interface APIError extends FunnefoxSDKError {
300
268
  errorType: string | null;
301
269
  requestId: string | null;
302
270
  response: unknown;
271
+ declineCode: string | null;
272
+ declineCodeSource: DeclineCodeSource | null;
303
273
  }
304
274
 
305
275
  export interface PrimerError extends FunnefoxSDKError {
@@ -386,13 +356,12 @@ export interface InitMethodOptions
386
356
  Partial<
387
357
  Pick<
388
358
  HeadlessUniversalCheckoutOptions,
389
- 'style' | 'card' | 'paypal' | 'googlePay'
359
+ 'style' | 'card' | 'applePay' | 'paypal' | 'googlePay'
390
360
  >
391
361
  >,
392
362
  'card'
393
363
  >,
394
364
  InitMethodCallbacks {
395
- applePay?: BillingApplePayOptions;
396
365
  card?: BillingCardOptions;
397
366
  orgId: string;
398
367
  baseUrl?: string;
@@ -400,29 +369,28 @@ export interface InitMethodOptions
400
369
  externalId: string;
401
370
  email?: string;
402
371
  meta?: MetadataType;
403
- /**
404
- * When to create the client session for wallet buttons.
405
- * 'onMount' (default) creates it immediately — one session per page render.
406
- * 'onInteraction' renders Apple's native button first and creates the
407
- * session on the visitor's first interaction, so bounced and prerendered
408
- * views cost nothing. Requires a native-only Apple Pay buttonType; falls
409
- * back to 'onMount' when Apple's SDK is unavailable.
410
- */
411
- sessionCreation?: SessionCreationMode;
412
372
  }
413
373
 
414
- export type SessionCreationMode = 'onMount' | 'onInteraction';
374
+ export type DeclineCodeSource = ('primer' | 'stripe' | 'adyen') | (string & {});
375
+
376
+ export type PaymentFailure = Error & {
377
+ declineCode?: string | null;
378
+ declineCodeSource?: DeclineCodeSource | null;
379
+ };
415
380
 
416
381
  export interface InitMethodCallbacks {
417
382
  onRenderSuccess?: () => void;
418
383
  onRenderError?: (err: PaymentMethod) => void;
419
384
  onPaymentSuccess?: () => void;
420
- onPaymentFail?: (err: Error) => void;
385
+ onPaymentFail?: (err: PaymentFailure) => void;
421
386
  onPaymentCancel?: () => void;
422
387
  onErrorMessageChange?: (msg: string) => void;
423
388
  onLoaderChange?: (state: boolean) => void;
424
389
  onPaymentStarted?: (method: PaymentMethod) => void;
425
390
  onMethodsAvailable?: (methods: PaymentMethod[]) => void;
391
+ onTaxChange?: (info: TaxInfo) => void;
392
+ onTaxError?: (error: Error) => void;
393
+ onTaxPending?: () => void;
426
394
  }
427
395
 
428
396
  export declare function initMethod(
@@ -448,7 +416,7 @@ export declare function getAvailablePaymentMethods(params: {
448
416
  export interface StripeCardFormOptions
449
417
  extends
450
418
  CreateClientSessionOptions,
451
- Omit<InitMethodCallbacks, 'onPaymentSuccess'> {
419
+ Omit<InitMethodCallbacks, 'onPaymentSuccess' | 'onTaxPending'> {
452
420
  onPaymentSuccess?: (
453
421
  paymentMethod: import('@stripe/stripe-js').PaymentMethod,
454
422
  orderId: string
@@ -465,12 +433,16 @@ export interface StripeCardFormOptions
465
433
  export interface StripeWalletOptions
466
434
  extends
467
435
  CreateClientSessionOptions,
468
- Omit<InitMethodCallbacks, 'onPaymentSuccess'> {
436
+ Omit<
437
+ InitMethodCallbacks,
438
+ 'onPaymentSuccess' | 'onTaxPending' | 'onTaxError'
439
+ > {
469
440
  onPaymentSuccess?: (
470
441
  paymentMethod: import('@stripe/stripe-js').PaymentMethod,
471
442
  orderId: string
472
443
  ) => void;
473
444
  totalLabel?: string;
445
+ onTaxChange?: (info: TaxInfo) => void;
474
446
  }
475
447
 
476
448
  export interface StripeCardForm {
@@ -584,6 +556,8 @@ export interface CreateClientSessionResponse {
584
556
  // Session tax estimate (detected-country) in minor units — for showing tax on mount and in the
585
557
  // wallet sheet, and (Stripe-direct) collecting it via the wallet.
586
558
  tax_amount?: number;
559
+ tax_inclusive_amount?: number;
560
+ tax_behavior?: TaxBehavior;
587
561
  amount_total?: number;
588
562
  currency?: string;
589
563
  tax_calculation_id?: string;
@@ -611,6 +585,8 @@ export interface TaxRecalculationData {
611
585
  tax_calculation_id: string;
612
586
  amount_total: number;
613
587
  tax_amount: number;
588
+ tax_inclusive_amount?: number;
589
+ tax_behavior?: TaxBehavior;
614
590
  currency: string;
615
591
  }
616
592
 
@@ -629,6 +605,8 @@ export interface PaymentResponseData {
629
605
  action_required_token: string;
630
606
  checkout_status: 'processing' | 'succeeded' | 'failed' | 'cancelled';
631
607
  failed_message_for_user: string;
608
+ decline_code?: string | null;
609
+ decline_code_source?: DeclineCodeSource | null;
632
610
  order_id: string;
633
611
  }
634
612