@funnelfox/billing 0.9.0 → 0.9.3-feat-defer-session-on-interaction.34

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,10 +74,40 @@ 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
+
77
106
  export interface PrimerCheckoutConfig extends Pick<
78
107
  Partial<HeadlessUniversalCheckoutOptions>,
79
- 'paypal' | 'applePay' | 'googlePay' | 'style'
108
+ 'paypal' | 'googlePay' | 'style'
80
109
  > {
110
+ applePay?: BillingApplePayOptions;
81
111
  card?: BillingCardOptions;
82
112
  cardSelectors?: CardInputSelectors;
83
113
  paymentButtonSelectors?: PaymentButtonSelectors;
@@ -93,6 +123,8 @@ export interface CheckoutConfig extends PrimerCheckoutConfig {
93
123
  enableTax?: boolean;
94
124
  onTaxChange?: (info: TaxInfo) => void;
95
125
  onTaxError?: (error: Error) => void;
126
+ /** See InitMethodOptions.sessionCreation. Wallet buttons only. */
127
+ sessionCreation?: SessionCreationMode;
96
128
  }
97
129
 
98
130
  export interface TaxInfo {
@@ -109,7 +141,11 @@ export interface PaymentButtonSelectors {
109
141
  applePay: string;
110
142
  }
111
143
 
112
- export interface CheckoutOptions extends Partial<HeadlessUniversalCheckoutOptions> {
144
+ export interface CheckoutOptions extends Omit<
145
+ Partial<HeadlessUniversalCheckoutOptions>,
146
+ 'applePay'
147
+ > {
148
+ applePay?: BillingApplePayOptions;
113
149
  onTokenizeSuccess: OnTokenizeSuccess;
114
150
  onResumeSuccess: OnResumeSuccess;
115
151
  onAvailablePaymentMethodsLoad?: (items: PaymentMethod[]) => void;
@@ -350,12 +386,13 @@ export interface InitMethodOptions
350
386
  Partial<
351
387
  Pick<
352
388
  HeadlessUniversalCheckoutOptions,
353
- 'style' | 'card' | 'applePay' | 'paypal' | 'googlePay'
389
+ 'style' | 'card' | 'paypal' | 'googlePay'
354
390
  >
355
391
  >,
356
392
  'card'
357
393
  >,
358
394
  InitMethodCallbacks {
395
+ applePay?: BillingApplePayOptions;
359
396
  card?: BillingCardOptions;
360
397
  orgId: string;
361
398
  baseUrl?: string;
@@ -363,7 +400,18 @@ export interface InitMethodOptions
363
400
  externalId: string;
364
401
  email?: string;
365
402
  meta?: MetadataType;
366
- }
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
+ }
413
+
414
+ export type SessionCreationMode = 'onMount' | 'onInteraction';
367
415
 
368
416
  export interface InitMethodCallbacks {
369
417
  onRenderSuccess?: () => void;