@funnelfox/billing 0.9.3-ffb-apple-pay-continue-button.33 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,14 +93,40 @@ export interface CheckoutConfig extends PrimerCheckoutConfig {
123
93
  enableTax?: boolean;
124
94
  onTaxChange?: (info: TaxInfo) => void;
125
95
  onTaxError?: (error: Error) => void;
96
+ onTaxPending?: () => void;
126
97
  }
127
98
 
128
99
  export interface TaxInfo {
129
100
  /** Minor units; the total the customer pays. */
130
101
  amountTotal: number;
131
- /** 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. */
132
103
  taxAmount: number;
133
104
  currency: string;
105
+ taxBehavior?: TaxBehavior;
106
+ taxRate?: number;
107
+ taxBreakdown?: TaxBreakdownEntry[];
108
+ }
109
+
110
+ export type TaxBehavior = 'inclusive' | 'exclusive';
111
+
112
+ export interface TaxBreakdownEntry {
113
+ amount: string;
114
+ percentage: string;
115
+ inclusive: boolean;
116
+ taxType?: string | null;
117
+ country?: string | null;
118
+ subdivision?: string | null;
119
+ taxabilityReason?: string | null;
120
+ }
121
+
122
+ export interface TaxBreakdownEntryResponse {
123
+ amount: string;
124
+ percentage: string;
125
+ inclusive: boolean;
126
+ tax_type?: string | null;
127
+ country?: string | null;
128
+ subdivision?: string | null;
129
+ taxability_reason?: string | null;
134
130
  }
135
131
 
136
132
  export interface PaymentButtonSelectors {
@@ -139,11 +135,7 @@ export interface PaymentButtonSelectors {
139
135
  applePay: string;
140
136
  }
141
137
 
142
- export interface CheckoutOptions extends Omit<
143
- Partial<HeadlessUniversalCheckoutOptions>,
144
- 'applePay'
145
- > {
146
- applePay?: BillingApplePayOptions;
138
+ export interface CheckoutOptions extends Partial<HeadlessUniversalCheckoutOptions> {
147
139
  onTokenizeSuccess: OnTokenizeSuccess;
148
140
  onResumeSuccess: OnResumeSuccess;
149
141
  onAvailablePaymentMethodsLoad?: (items: PaymentMethod[]) => void;
@@ -298,6 +290,8 @@ export interface APIError extends FunnefoxSDKError {
298
290
  errorType: string | null;
299
291
  requestId: string | null;
300
292
  response: unknown;
293
+ declineCode: string | null;
294
+ declineCodeSource: DeclineCodeSource | null;
301
295
  }
302
296
 
303
297
  export interface PrimerError extends FunnefoxSDKError {
@@ -384,13 +378,12 @@ export interface InitMethodOptions
384
378
  Partial<
385
379
  Pick<
386
380
  HeadlessUniversalCheckoutOptions,
387
- 'style' | 'card' | 'paypal' | 'googlePay'
381
+ 'style' | 'card' | 'applePay' | 'paypal' | 'googlePay'
388
382
  >
389
383
  >,
390
384
  'card'
391
385
  >,
392
386
  InitMethodCallbacks {
393
- applePay?: BillingApplePayOptions;
394
387
  card?: BillingCardOptions;
395
388
  orgId: string;
396
389
  baseUrl?: string;
@@ -400,16 +393,26 @@ export interface InitMethodOptions
400
393
  meta?: MetadataType;
401
394
  }
402
395
 
396
+ export type DeclineCodeSource = ('primer' | 'stripe' | 'adyen') | (string & {});
397
+
398
+ export type PaymentFailure = Error & {
399
+ declineCode?: string | null;
400
+ declineCodeSource?: DeclineCodeSource | null;
401
+ };
402
+
403
403
  export interface InitMethodCallbacks {
404
404
  onRenderSuccess?: () => void;
405
405
  onRenderError?: (err: PaymentMethod) => void;
406
406
  onPaymentSuccess?: () => void;
407
- onPaymentFail?: (err: Error) => void;
407
+ onPaymentFail?: (err: PaymentFailure) => void;
408
408
  onPaymentCancel?: () => void;
409
409
  onErrorMessageChange?: (msg: string) => void;
410
410
  onLoaderChange?: (state: boolean) => void;
411
411
  onPaymentStarted?: (method: PaymentMethod) => void;
412
412
  onMethodsAvailable?: (methods: PaymentMethod[]) => void;
413
+ onTaxChange?: (info: TaxInfo) => void;
414
+ onTaxError?: (error: Error) => void;
415
+ onTaxPending?: () => void;
413
416
  }
414
417
 
415
418
  export declare function initMethod(
@@ -435,7 +438,7 @@ export declare function getAvailablePaymentMethods(params: {
435
438
  export interface StripeCardFormOptions
436
439
  extends
437
440
  CreateClientSessionOptions,
438
- Omit<InitMethodCallbacks, 'onPaymentSuccess'> {
441
+ Omit<InitMethodCallbacks, 'onPaymentSuccess' | 'onTaxPending'> {
439
442
  onPaymentSuccess?: (
440
443
  paymentMethod: import('@stripe/stripe-js').PaymentMethod,
441
444
  orderId: string
@@ -452,12 +455,16 @@ export interface StripeCardFormOptions
452
455
  export interface StripeWalletOptions
453
456
  extends
454
457
  CreateClientSessionOptions,
455
- Omit<InitMethodCallbacks, 'onPaymentSuccess'> {
458
+ Omit<
459
+ InitMethodCallbacks,
460
+ 'onPaymentSuccess' | 'onTaxPending' | 'onTaxError'
461
+ > {
456
462
  onPaymentSuccess?: (
457
463
  paymentMethod: import('@stripe/stripe-js').PaymentMethod,
458
464
  orderId: string
459
465
  ) => void;
460
466
  totalLabel?: string;
467
+ onTaxChange?: (info: TaxInfo) => void;
461
468
  }
462
469
 
463
470
  export interface StripeCardForm {
@@ -571,6 +578,9 @@ export interface CreateClientSessionResponse {
571
578
  // Session tax estimate (detected-country) in minor units — for showing tax on mount and in the
572
579
  // wallet sheet, and (Stripe-direct) collecting it via the wallet.
573
580
  tax_amount?: number;
581
+ tax_inclusive_amount?: number;
582
+ tax_behavior?: TaxBehavior;
583
+ tax_breakdown?: TaxBreakdownEntryResponse[];
574
584
  amount_total?: number;
575
585
  currency?: string;
576
586
  tax_calculation_id?: string;
@@ -598,6 +608,9 @@ export interface TaxRecalculationData {
598
608
  tax_calculation_id: string;
599
609
  amount_total: number;
600
610
  tax_amount: number;
611
+ tax_inclusive_amount?: number;
612
+ tax_behavior?: TaxBehavior;
613
+ tax_breakdown?: TaxBreakdownEntryResponse[];
601
614
  currency: string;
602
615
  }
603
616
 
@@ -616,6 +629,8 @@ export interface PaymentResponseData {
616
629
  action_required_token: string;
617
630
  checkout_status: 'processing' | 'succeeded' | 'failed' | 'cancelled';
618
631
  failed_message_for_user: string;
632
+ decline_code?: string | null;
633
+ decline_code_source?: DeclineCodeSource | null;
619
634
  order_id: string;
620
635
  }
621
636