stripe-pwa-elements 4.0.1 → 4.0.3

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.
Files changed (107) hide show
  1. package/dist/cjs/factory-Cm6zUD7R.js +1206 -0
  2. package/dist/cjs/{factory-Cd2VI_N2.js → i18n-lBbOeQt4.js} +12 -1149
  3. package/dist/cjs/ion-icon_2.cjs.entry.js +725 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/stripe-address-element.cjs.entry.js +5 -4
  6. package/dist/cjs/stripe-card-element-modal.cjs.entry.js +3 -2
  7. package/dist/cjs/{stripe-card-element_2.cjs.entry.js → stripe-card-element.cjs.entry.js} +8 -93
  8. package/dist/cjs/stripe-currency-selector.cjs.entry.js +4 -3
  9. package/dist/cjs/stripe-elements.cjs.js +1 -1
  10. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +24 -5
  11. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +4 -3
  12. package/dist/cjs/stripe-payment-element.cjs.entry.js +12 -124
  13. package/dist/cjs/stripe-payment-element.helpers-CvAhIqLt.js +119 -0
  14. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +2 -2
  15. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +987 -0
  16. package/dist/collection/collection-manifest.json +2 -1
  17. package/dist/collection/components/stripe-address-element/stripe-address-element.js +2 -2
  18. package/dist/collection/components/stripe-card-element/stripe-card-element.js +3 -2
  19. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +4 -3
  20. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +18 -0
  21. package/dist/collection/components/stripe-modal/stripe-modal.css +27 -1
  22. package/dist/collection/components/stripe-modal/stripe-modal.js +132 -1
  23. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +4 -7
  24. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +4 -4
  25. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +3 -3
  26. package/dist/collection/components/stripe-payment-sheet/payment-sheet-state.js +193 -0
  27. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +94 -0
  28. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.css +68 -0
  29. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.helpers.js +274 -0
  30. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +763 -0
  31. package/dist/collection/services/express-checkout-element-manager.js +36 -2
  32. package/dist/collection/services/link-authentication-element-manager.js +5 -0
  33. package/dist/collection/services/stripe-service.js +20 -6
  34. package/dist/collection/utils/focus.js +76 -0
  35. package/dist/collection/utils/i18n.js +12 -0
  36. package/dist/components/factory.js +1 -1
  37. package/dist/components/i18n.js +1 -0
  38. package/dist/components/stripe-address-element.js +1 -1
  39. package/dist/components/stripe-card-element-modal.js +1 -1
  40. package/dist/components/stripe-card-element2.js +1 -1
  41. package/dist/components/stripe-currency-selector.js +1 -1
  42. package/dist/components/stripe-express-checkout-element.js +1 -1
  43. package/dist/components/stripe-link-authentication-element.js +1 -1
  44. package/dist/components/stripe-modal2.js +1 -1
  45. package/dist/components/stripe-payment-element.helpers.js +1 -0
  46. package/dist/components/stripe-payment-element.js +1 -1
  47. package/dist/components/stripe-payment-request-button2.js +1 -1
  48. package/dist/components/stripe-payment-sheet.d.ts +11 -0
  49. package/dist/components/stripe-payment-sheet.js +1 -0
  50. package/dist/esm/factory-BaGv8K_i.js +1203 -0
  51. package/dist/esm/{factory-VTa1Gc94.js → i18n-CL5n3bOb.js} +13 -1149
  52. package/dist/esm/ion-icon_2.entry.js +722 -0
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/stripe-address-element.entry.js +2 -1
  55. package/dist/esm/stripe-card-element-modal.entry.js +3 -2
  56. package/dist/esm/{stripe-card-element_2.entry.js → stripe-card-element.entry.js} +6 -90
  57. package/dist/esm/stripe-currency-selector.entry.js +2 -1
  58. package/dist/esm/stripe-elements.js +1 -1
  59. package/dist/esm/stripe-express-checkout-element.entry.js +20 -1
  60. package/dist/esm/stripe-link-authentication-element.entry.js +2 -1
  61. package/dist/esm/stripe-payment-element.entry.js +4 -116
  62. package/dist/esm/stripe-payment-element.helpers-Bu9RfxS4.js +114 -0
  63. package/dist/esm/stripe-payment-request-button.entry.js +2 -2
  64. package/dist/esm/stripe-payment-sheet.entry.js +985 -0
  65. package/dist/stripe-elements/p-2e41699e.entry.js +1 -0
  66. package/dist/stripe-elements/p-3fc4583a.entry.js +1 -0
  67. package/dist/stripe-elements/{p-ae0c336e.entry.js → p-4891edf0.entry.js} +1 -1
  68. package/dist/stripe-elements/p-7e826964.entry.js +1 -0
  69. package/dist/stripe-elements/p-BhKXGROE.js +1 -0
  70. package/dist/stripe-elements/p-CL5n3bOb.js +1 -0
  71. package/dist/stripe-elements/p-DlMEZwSe.js +1 -0
  72. package/dist/stripe-elements/p-a395a5d1.entry.js +1 -0
  73. package/dist/stripe-elements/p-b62c9dae.entry.js +1 -0
  74. package/dist/stripe-elements/p-b7c20e8e.entry.js +1 -0
  75. package/dist/stripe-elements/p-ba791c8f.entry.js +1 -0
  76. package/dist/stripe-elements/p-bec62526.entry.js +1 -0
  77. package/dist/stripe-elements/p-f5552c81.entry.js +1 -0
  78. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  79. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +2 -1
  80. package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +2 -1
  81. package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +5 -0
  82. package/dist/types/components/stripe-modal/stripe-modal.d.ts +43 -0
  83. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +7 -2
  84. package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +1 -1
  85. package/dist/types/components/stripe-payment-sheet/payment-sheet-state.d.ts +121 -0
  86. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +39 -0
  87. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +157 -0
  88. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.helpers.d.ts +153 -0
  89. package/dist/types/components.d.ts +182 -10
  90. package/dist/types/index.d.ts +2 -0
  91. package/dist/types/services/interfaces.d.ts +3 -0
  92. package/dist/types/services/stripe-service.d.ts +7 -2
  93. package/dist/types/utils/focus.d.ts +15 -0
  94. package/package.json +7 -3
  95. package/readme.md +59 -6
  96. package/dist/cjs/ion-icon.cjs.entry.js +0 -431
  97. package/dist/components/utils.js +0 -1
  98. package/dist/esm/ion-icon.entry.js +0 -429
  99. package/dist/stripe-elements/p-1bd46766.entry.js +0 -1
  100. package/dist/stripe-elements/p-1c6e0a45.entry.js +0 -1
  101. package/dist/stripe-elements/p-3f42ca0c.entry.js +0 -1
  102. package/dist/stripe-elements/p-5cf62945.entry.js +0 -1
  103. package/dist/stripe-elements/p-74de1556.entry.js +0 -1
  104. package/dist/stripe-elements/p-76e57d78.entry.js +0 -1
  105. package/dist/stripe-elements/p-840d499f.entry.js +0 -1
  106. package/dist/stripe-elements/p-CrjrbGJ3.js +0 -1
  107. package/dist/stripe-elements/p-cfd8e081.entry.js +0 -1
@@ -1,6 +1,3 @@
1
- import { S as StencilCore } from './index-C6bbmyga.js';
2
- import { l as loadStripe } from './index-CBXaOfXU.js';
3
-
4
1
  const getPlatforms = (win) => setupPlatforms(win);
5
2
  const setupPlatforms = (win = window) => {
6
3
  if (typeof win === 'undefined') {
@@ -2790,6 +2787,14 @@ instance.use(Browser).init({
2790
2787
  'CVC': 'セキュリティコード(CVC)',
2791
2788
  'Country or region': '地域',
2792
2789
  'Postal Code': '郵便番号',
2790
+ 'Close': '閉じる',
2791
+ 'Loading': '読み込み中',
2792
+ 'Payment information': '支払情報',
2793
+ 'Billing address': '請求先住所',
2794
+ 'Save': '保存',
2795
+ 'Please complete your billing address.': '請求先住所を入力してください。',
2796
+ 'Please enter your email address.': 'メールアドレスを入力してください。',
2797
+ 'Please enter a valid email address.': '有効なメールアドレスを入力してください。',
2793
2798
  },
2794
2799
  },
2795
2800
  'pt-BR': {
@@ -2806,1155 +2811,14 @@ instance.use(Browser).init({
2806
2811
  'CVC': 'Número de Segurança(CVC)',
2807
2812
  'Country or region': 'País ou região',
2808
2813
  'Postal Code': 'Cep',
2814
+ 'Close': 'Fechar',
2815
+ 'Please complete your billing address.': 'Preencha seu endereço de cobrança.',
2816
+ 'Please enter your email address.': 'Informe seu endereço de e-mail.',
2817
+ 'Please enter a valid email address.': 'Informe um endereço de e-mail válido.',
2809
2818
  },
2810
2819
  },
2811
2820
  },
2812
2821
  });
2813
2822
  const i18n = instance;
2814
2823
 
2815
- const appendToMap = (map, propName, value) => {
2816
- let refs = map.get(propName);
2817
- if (!refs) {
2818
- refs = [];
2819
- map.set(propName, refs);
2820
- }
2821
- if (!refs.some((ref) => ref.deref() === value)) {
2822
- refs.push(new WeakRef(value));
2823
- }
2824
- };
2825
- const debounce = (fn, ms) => {
2826
- let timeoutId;
2827
- return (...args) => {
2828
- if (timeoutId) {
2829
- clearTimeout(timeoutId);
2830
- }
2831
- timeoutId = setTimeout(() => {
2832
- timeoutId = 0;
2833
- fn(...args);
2834
- }, ms);
2835
- };
2836
- };
2837
-
2838
- /**
2839
- * Check if a possible element isConnected.
2840
- * The property might not be there, so we check for it.
2841
- *
2842
- * We want it to return true if isConnected is not a property,
2843
- * otherwise we would remove these elements and would not update.
2844
- *
2845
- * Better leak in Edge than to be useless.
2846
- */
2847
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
2848
- const cleanupElements = debounce((map) => {
2849
- for (let key of map.keys()) {
2850
- const refs = map.get(key).filter((ref) => {
2851
- const elm = ref.deref();
2852
- return elm && isConnected(elm);
2853
- });
2854
- map.set(key, refs);
2855
- }
2856
- }, 2_000);
2857
- const core = StencilCore;
2858
- const forceUpdate = core.forceUpdate;
2859
- const getRenderingRef = core.getRenderingRef;
2860
- const stencilSubscription = () => {
2861
- if (typeof getRenderingRef !== 'function' || typeof forceUpdate !== 'function') {
2862
- // If we are not in a stencil project, we do nothing.
2863
- // This function is not really exported by @stencil/core.
2864
- return {};
2865
- }
2866
- const ensureForceUpdate = forceUpdate;
2867
- const ensureGetRenderingRef = getRenderingRef;
2868
- const elmsToUpdate = new Map();
2869
- return {
2870
- dispose: () => elmsToUpdate.clear(),
2871
- get: (propName) => {
2872
- const elm = ensureGetRenderingRef();
2873
- if (elm) {
2874
- appendToMap(elmsToUpdate, propName, elm);
2875
- }
2876
- },
2877
- set: (propName) => {
2878
- const refs = elmsToUpdate.get(propName);
2879
- if (refs) {
2880
- const nextRefs = refs.filter((ref) => {
2881
- const elm = ref.deref();
2882
- if (!elm)
2883
- return false;
2884
- return ensureForceUpdate(elm);
2885
- });
2886
- elmsToUpdate.set(propName, nextRefs);
2887
- }
2888
- cleanupElements(elmsToUpdate);
2889
- },
2890
- reset: () => {
2891
- elmsToUpdate.forEach((refs) => {
2892
- refs.forEach((ref) => {
2893
- const elm = ref.deref();
2894
- if (elm)
2895
- ensureForceUpdate(elm);
2896
- });
2897
- });
2898
- cleanupElements(elmsToUpdate);
2899
- },
2900
- };
2901
- };
2902
-
2903
- const unwrap = (val) => (typeof val === 'function' ? val() : val);
2904
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
2905
- const resolveDefaultState = () => (unwrap(defaultState) ?? {});
2906
- const initialState = resolveDefaultState();
2907
- let states = new Map(Object.entries(initialState));
2908
- const proxyAvailable = typeof Proxy !== 'undefined';
2909
- const plainState = proxyAvailable ? null : {};
2910
- const handlers = {
2911
- dispose: [],
2912
- get: [],
2913
- set: [],
2914
- reset: [],
2915
- };
2916
- // Track onChange listeners to enable removeListener functionality
2917
- const changeListeners = new Map();
2918
- const reset = () => {
2919
- // When resetting the state, the default state may be a function - unwrap it to invoke it.
2920
- // otherwise, the state won't be properly reset
2921
- states = new Map(Object.entries(resolveDefaultState()));
2922
- if (!proxyAvailable) {
2923
- syncPlainStateKeys();
2924
- }
2925
- handlers.reset.forEach((cb) => cb());
2926
- };
2927
- const dispose = () => {
2928
- // Call first dispose as resetting the state would
2929
- // cause less updates ;)
2930
- handlers.dispose.forEach((cb) => cb());
2931
- reset();
2932
- };
2933
- const get = (propName) => {
2934
- handlers.get.forEach((cb) => cb(propName));
2935
- return states.get(propName);
2936
- };
2937
- const set = (propName, value) => {
2938
- const oldValue = states.get(propName);
2939
- if (shouldUpdate(value, oldValue, propName)) {
2940
- states.set(propName, value);
2941
- if (!proxyAvailable) {
2942
- ensurePlainProperty(propName);
2943
- }
2944
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
2945
- }
2946
- };
2947
- const state = (proxyAvailable
2948
- ? new Proxy(initialState, {
2949
- get(_, propName) {
2950
- return get(propName);
2951
- },
2952
- ownKeys(_) {
2953
- return Array.from(states.keys());
2954
- },
2955
- getOwnPropertyDescriptor() {
2956
- return {
2957
- enumerable: true,
2958
- configurable: true,
2959
- };
2960
- },
2961
- has(_, propName) {
2962
- return states.has(propName);
2963
- },
2964
- set(_, propName, value) {
2965
- set(propName, value);
2966
- return true;
2967
- },
2968
- })
2969
- : (() => {
2970
- syncPlainStateKeys();
2971
- return plainState;
2972
- })());
2973
- const on = (eventName, callback) => {
2974
- handlers[eventName].push(callback);
2975
- return () => {
2976
- removeFromArray(handlers[eventName], callback);
2977
- };
2978
- };
2979
- const onChange = (propName, cb) => {
2980
- const setHandler = (key, newValue) => {
2981
- if (key === propName) {
2982
- cb(newValue);
2983
- }
2984
- };
2985
- const resetHandler = () => {
2986
- const snapshot = resolveDefaultState();
2987
- cb(snapshot[propName]);
2988
- };
2989
- // Register the handlers
2990
- const unSet = on('set', setHandler);
2991
- const unReset = on('reset', resetHandler);
2992
- // Track the relationship between the user callback and internal handlers
2993
- changeListeners.set(cb, { setHandler, resetHandler, propName });
2994
- return () => {
2995
- unSet();
2996
- unReset();
2997
- changeListeners.delete(cb);
2998
- };
2999
- };
3000
- const use = (...subscriptions) => {
3001
- const unsubs = subscriptions.reduce((unsubs, subscription) => {
3002
- if (subscription.set) {
3003
- unsubs.push(on('set', subscription.set));
3004
- }
3005
- if (subscription.get) {
3006
- unsubs.push(on('get', subscription.get));
3007
- }
3008
- if (subscription.reset) {
3009
- unsubs.push(on('reset', subscription.reset));
3010
- }
3011
- if (subscription.dispose) {
3012
- unsubs.push(on('dispose', subscription.dispose));
3013
- }
3014
- return unsubs;
3015
- }, []);
3016
- return () => unsubs.forEach((unsub) => unsub());
3017
- };
3018
- const forceUpdate = (key) => {
3019
- const oldValue = states.get(key);
3020
- handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
3021
- };
3022
- const removeListener = (propName, listener) => {
3023
- const listenerInfo = changeListeners.get(listener);
3024
- if (listenerInfo && listenerInfo.propName === propName) {
3025
- // Remove the specific handlers that were created for this listener
3026
- removeFromArray(handlers.set, listenerInfo.setHandler);
3027
- removeFromArray(handlers.reset, listenerInfo.resetHandler);
3028
- changeListeners.delete(listener);
3029
- }
3030
- };
3031
- function ensurePlainProperty(key) {
3032
- if (proxyAvailable || !plainState) {
3033
- return;
3034
- }
3035
- if (Object.prototype.hasOwnProperty.call(plainState, key)) {
3036
- return;
3037
- }
3038
- Object.defineProperty(plainState, key, {
3039
- configurable: true,
3040
- enumerable: true,
3041
- get() {
3042
- return get(key);
3043
- },
3044
- set(value) {
3045
- set(key, value);
3046
- },
3047
- });
3048
- }
3049
- function syncPlainStateKeys() {
3050
- if (proxyAvailable || !plainState) {
3051
- return;
3052
- }
3053
- const knownKeys = new Set(states.keys());
3054
- for (const key of Object.keys(plainState)) {
3055
- if (!knownKeys.has(key)) {
3056
- delete plainState[key];
3057
- }
3058
- }
3059
- for (const key of knownKeys) {
3060
- ensurePlainProperty(key);
3061
- }
3062
- }
3063
- return {
3064
- state,
3065
- get,
3066
- set,
3067
- on,
3068
- onChange,
3069
- use,
3070
- dispose,
3071
- reset,
3072
- forceUpdate,
3073
- removeListener,
3074
- };
3075
- };
3076
- const removeFromArray = (array, item) => {
3077
- const index = array.indexOf(item);
3078
- if (index >= 0) {
3079
- array[index] = array[array.length - 1];
3080
- array.length--;
3081
- }
3082
- };
3083
-
3084
- const createStore = (defaultState, shouldUpdate) => {
3085
- const map = createObservableMap(defaultState, shouldUpdate);
3086
- map.use(stencilSubscription());
3087
- return map;
3088
- };
3089
-
3090
- /**
3091
- * Core Stripe Service
3092
- * Manages Stripe.js initialization and Elements instance only
3093
- * Does NOT manage specific element types (Card, Payment, etc.)
3094
- */
3095
- class StripeServiceClass {
3096
- constructor() {
3097
- this.store = createStore({
3098
- loadStripeStatus: '',
3099
- applicationName: 'stripe-pwa-elements',
3100
- isCheckoutSession: false,
3101
- });
3102
- /** Incremented on every init so that a slower, older call cannot overwrite newer state */
3103
- this.initGeneration = 0;
3104
- this.changeListeners = new Map();
3105
- }
3106
- /**
3107
- * Get the reactive state object
3108
- * Components can use this directly in render() for automatic reactivity
3109
- */
3110
- get state() {
3111
- return this.store.state;
3112
- }
3113
- /**
3114
- * Register a callback for when a specific state property changes
3115
- * @param key - The state property to watch
3116
- * @param callback - Function to call when the property changes
3117
- * @returns Unsubscribe function
3118
- */
3119
- onChange(key, callback) {
3120
- const dispose = this.store.onChange(key, callback);
3121
- // Track listeners for cleanup
3122
- if (!this.changeListeners.has(key)) {
3123
- this.changeListeners.set(key, []);
3124
- }
3125
- this.changeListeners.get(key).push(dispose);
3126
- return dispose;
3127
- }
3128
- /**
3129
- * Initialize Stripe.js client with Payment Intent mode
3130
- * @param publishableKey - Your Stripe publishable API key
3131
- * @param options - Optional configuration (`clientSecret` is the PaymentIntent / SetupIntent client secret)
3132
- */
3133
- async initialize(publishableKey, options) {
3134
- const generation = ++this.initGeneration;
3135
- // Capture the previous config before overwriting it, so we can detect real changes
3136
- const isUpToDate = this.store.state.stripe != null &&
3137
- !this.store.state.isCheckoutSession &&
3138
- this.store.state.publishableKey === publishableKey &&
3139
- this.store.state.stripeAccount === (options === null || options === void 0 ? void 0 : options.stripeAccount) &&
3140
- this.intentClientSecret === (options === null || options === void 0 ? void 0 : options.clientSecret);
3141
- // Update configuration
3142
- this.store.state.publishableKey = publishableKey;
3143
- this.store.state.isCheckoutSession = false;
3144
- this.intentClientSecret = options === null || options === void 0 ? void 0 : options.clientSecret;
3145
- if ((options === null || options === void 0 ? void 0 : options.stripeAccount) != null && (options === null || options === void 0 ? void 0 : options.stripeAccount) !== '') {
3146
- this.store.state.stripeAccount = options.stripeAccount;
3147
- }
3148
- if ((options === null || options === void 0 ? void 0 : options.applicationName) != null && (options === null || options === void 0 ? void 0 : options.applicationName) !== '') {
3149
- this.store.state.applicationName = options.applicationName;
3150
- }
3151
- // If Stripe.js already loaded with same config, do nothing
3152
- if (isUpToDate) {
3153
- return;
3154
- }
3155
- this.store.state.loadStripeStatus = 'loading';
3156
- try {
3157
- const stripe = await loadStripe(publishableKey, {
3158
- stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
3159
- });
3160
- if (generation !== this.initGeneration) {
3161
- return;
3162
- }
3163
- // Register app info
3164
- stripe.registerAppInfo({
3165
- name: this.store.state.applicationName,
3166
- });
3167
- this.store.state.stripe = stripe;
3168
- // Payment Element requires the client secret at Elements creation time
3169
- this.store.state.elements = (options === null || options === void 0 ? void 0 : options.clientSecret) != null && options.clientSecret !== '' ? stripe.elements({ clientSecret: options.clientSecret }) : stripe.elements();
3170
- this.store.state.checkout = undefined;
3171
- this.store.state.loadStripeStatus = 'success';
3172
- }
3173
- catch (e) {
3174
- console.error('Failed to load Stripe.js:', e);
3175
- this.store.state.loadStripeStatus = 'failure';
3176
- }
3177
- }
3178
- /**
3179
- * Initialize Stripe.js client with Checkout Session mode
3180
- * @param publishableKey - Your Stripe publishable API key
3181
- * @param checkoutSessionClientSecret - The client secret from Checkout Session
3182
- * @param options - Optional configuration (`clientSecret` is the PaymentIntent / SetupIntent client secret)
3183
- */
3184
- async initializeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, options) {
3185
- const generation = ++this.initGeneration;
3186
- // Update configuration
3187
- this.store.state.publishableKey = publishableKey;
3188
- this.store.state.isCheckoutSession = true;
3189
- if ((options === null || options === void 0 ? void 0 : options.stripeAccount) != null && (options === null || options === void 0 ? void 0 : options.stripeAccount) !== '') {
3190
- this.store.state.stripeAccount = options.stripeAccount;
3191
- }
3192
- if ((options === null || options === void 0 ? void 0 : options.applicationName) != null && (options === null || options === void 0 ? void 0 : options.applicationName) !== '') {
3193
- this.store.state.applicationName = options.applicationName;
3194
- }
3195
- this.store.state.loadStripeStatus = 'loading';
3196
- try {
3197
- const stripe = await loadStripe(publishableKey, {
3198
- stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
3199
- });
3200
- if (generation !== this.initGeneration) {
3201
- return;
3202
- }
3203
- // Register app info
3204
- stripe.registerAppInfo({
3205
- name: this.store.state.applicationName,
3206
- });
3207
- this.store.state.stripe = stripe;
3208
- // Initialize Checkout instance instead of Elements
3209
- const checkout = stripe.initCheckoutElementsSdk({
3210
- clientSecret: checkoutSessionClientSecret,
3211
- elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
3212
- });
3213
- this.store.state.checkout = checkout;
3214
- this.store.state.elements = undefined;
3215
- this.store.state.loadStripeStatus = 'success';
3216
- }
3217
- catch (e) {
3218
- console.error('Failed to initialize Stripe Checkout:', e);
3219
- this.store.state.loadStripeStatus = 'failure';
3220
- }
3221
- }
3222
- /**
3223
- * Get the current Stripe instance
3224
- */
3225
- getStripe() {
3226
- return this.store.state.stripe;
3227
- }
3228
- /**
3229
- * Get the current Elements instance
3230
- */
3231
- getElements() {
3232
- return this.store.state.elements;
3233
- }
3234
- /**
3235
- * Get the current Checkout instance (for Checkout Session mode)
3236
- */
3237
- getCheckout() {
3238
- return this.store.state.checkout;
3239
- }
3240
- /**
3241
- * Reset the service to initial state
3242
- * Useful for testing and cleanup
3243
- */
3244
- reset() {
3245
- this.store.reset();
3246
- }
3247
- /**
3248
- * Dispose of all listeners and reset state
3249
- * Should be called in test cleanup
3250
- */
3251
- dispose() {
3252
- // Dispose all onChange listeners
3253
- this.changeListeners.forEach(listeners => {
3254
- listeners.forEach(dispose => dispose());
3255
- });
3256
- this.changeListeners.clear();
3257
- // Dispose the store
3258
- this.store.dispose();
3259
- }
3260
- }
3261
- /**
3262
- * Singleton instance of StripeService (for backward compatibility)
3263
- * New code should use ServiceFactory for better testability
3264
- *
3265
- * @deprecated Use ServiceFactory.createStripeService() for better DI support
3266
- */
3267
- new StripeServiceClass();
3268
-
3269
- /**
3270
- * Wait for an element to appear in the DOM
3271
- * @param containerElement - Parent element to search in
3272
- * @param selector - CSS selector
3273
- * @param timeout - Timeout in milliseconds (default: 5000ms)
3274
- * @returns Promise that resolves to the found element or rejects on timeout
3275
- */
3276
- function findElement(containerElement, selector, timeout = 5000) {
3277
- return new Promise((resolve, reject) => {
3278
- const elem = containerElement.querySelector(selector);
3279
- if (elem != null) {
3280
- return resolve(elem);
3281
- }
3282
- const timeoutId = setTimeout(() => {
3283
- observer.disconnect();
3284
- reject(new Error(`Element "${selector}" not found within ${timeout}ms`));
3285
- }, timeout);
3286
- const observer = new MutationObserver(() => {
3287
- const elem = containerElement.querySelector(selector);
3288
- if (elem != null) {
3289
- clearTimeout(timeoutId);
3290
- observer.disconnect();
3291
- resolve(elem);
3292
- }
3293
- });
3294
- observer.observe(containerElement, {
3295
- childList: true,
3296
- subtree: true,
3297
- });
3298
- });
3299
- }
3300
-
3301
- /**
3302
- * Card Element Manager
3303
- * Manages Stripe Card Elements (cardNumber, cardExpiry, cardCvc)
3304
- * with dependency injection of StripeService
3305
- */
3306
- class CardElementManager {
3307
- /**
3308
- * Constructor with dependency injection
3309
- * @param stripeService - Injected Stripe service instance
3310
- */
3311
- constructor(stripeService) {
3312
- this.stripeService = stripeService;
3313
- this.store = createStore({
3314
- errorMessage: '',
3315
- errorSource: undefined,
3316
- });
3317
- }
3318
- /**
3319
- * Get current card element state (reactive)
3320
- */
3321
- getState() {
3322
- return this.store.state;
3323
- }
3324
- /**
3325
- * Initialize and mount card elements to DOM
3326
- * @param containerElement - Parent element containing mount points
3327
- * @returns Promise resolving to card element instances
3328
- */
3329
- async initialize(containerElement) {
3330
- const elements = this.stripeService.getElements();
3331
- if (elements == null) {
3332
- throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
3333
- }
3334
- // Unmount if already initialized
3335
- if (this.cardElements != null) {
3336
- this.unmount();
3337
- }
3338
- // Create and mount card number element
3339
- const cardNumber = elements.create('cardNumber', {
3340
- placeholder: i18n.t('Card Number'),
3341
- });
3342
- const cardNumberElement = await findElement(containerElement, '#card-number');
3343
- cardNumber.mount(cardNumberElement);
3344
- cardNumber.on('change', this.handleCardError('cardNumber'));
3345
- // Create and mount card expiry element
3346
- const cardExpiry = elements.create('cardExpiry');
3347
- const cardExpiryElement = await findElement(containerElement, '#card-expiry');
3348
- cardExpiry.mount(cardExpiryElement);
3349
- cardExpiry.on('change', this.handleCardError('cardExpiry'));
3350
- // Create and mount card CVC element
3351
- const cardCVC = elements.create('cardCvc');
3352
- const cardCVCElement = await findElement(containerElement, '#card-cvc');
3353
- cardCVC.mount(cardCVCElement);
3354
- cardCVC.on('change', this.handleCardError('cardCvc'));
3355
- this.cardElements = {
3356
- cardNumber,
3357
- cardExpiry,
3358
- cardCVC,
3359
- };
3360
- return this.cardElements;
3361
- }
3362
- /**
3363
- * Get mounted card element instances
3364
- */
3365
- getElements() {
3366
- return this.cardElements;
3367
- }
3368
- /**
3369
- * Set error message (triggers reactivity)
3370
- */
3371
- setError(message) {
3372
- this.store.set('errorMessage', message);
3373
- }
3374
- /**
3375
- * Clear error message (triggers reactivity)
3376
- */
3377
- clearError() {
3378
- this.store.set('errorMessage', '');
3379
- this.store.set('errorSource', undefined);
3380
- }
3381
- /**
3382
- * Unmount all card elements
3383
- */
3384
- unmount() {
3385
- var _a, _b, _c;
3386
- if (this.cardElements == null) {
3387
- return;
3388
- }
3389
- (_a = this.cardElements.cardNumber) === null || _a === void 0 ? void 0 : _a.unmount();
3390
- (_b = this.cardElements.cardExpiry) === null || _b === void 0 ? void 0 : _b.unmount();
3391
- (_c = this.cardElements.cardCVC) === null || _c === void 0 ? void 0 : _c.unmount();
3392
- this.cardElements = undefined;
3393
- }
3394
- /**
3395
- * Handle card element errors
3396
- * Only clears error if it's from the same element type
3397
- * Uses store.set() to trigger reactivity
3398
- */
3399
- handleCardError(elementType) {
3400
- return ({ error }) => {
3401
- if (error) {
3402
- this.store.set('errorMessage', error.message);
3403
- this.store.set('errorSource', elementType);
3404
- return;
3405
- }
3406
- // Only clear error if it originated from the same element
3407
- if (this.store.state.errorSource === elementType) {
3408
- this.store.set('errorMessage', '');
3409
- this.store.set('errorSource', undefined);
3410
- }
3411
- };
3412
- }
3413
- }
3414
-
3415
- /**
3416
- * Payment Element Manager
3417
- * Manages Stripe Payment Element (unified payment form)
3418
- * with dependency injection of StripeService
3419
- * Supports both Payment Intent mode and Checkout Session mode
3420
- */
3421
- class PaymentElementManager {
3422
- /**
3423
- * Constructor with dependency injection
3424
- * @param stripeService - Injected Stripe service instance
3425
- */
3426
- constructor(stripeService) {
3427
- this.stripeService = stripeService;
3428
- this.store = createStore({
3429
- errorMessage: '',
3430
- });
3431
- }
3432
- /**
3433
- * Get current payment element state (reactive)
3434
- */
3435
- getState() {
3436
- return this.store.state;
3437
- }
3438
- /**
3439
- * Initialize and mount payment element to DOM
3440
- * Supports both Payment Intent mode and Checkout Session mode
3441
- * @param containerElement - Parent element containing mount point
3442
- * @param options - Optional payment element options
3443
- * @returns Promise resolving to payment element instance
3444
- */
3445
- async initialize(containerElement, options) {
3446
- const isCheckoutSession = this.stripeService.state.isCheckoutSession;
3447
- // Unmount if already initialized
3448
- if (this.paymentElement != null) {
3449
- this.unmount();
3450
- }
3451
- if (isCheckoutSession) {
3452
- // Checkout Session mode: use checkout.createPaymentElement()
3453
- const checkout = this.stripeService.getCheckout();
3454
- if (checkout == null) {
3455
- throw new Error('StripeService not initialized with Checkout Session. Call StripeService.initializeWithCheckoutSession() first.');
3456
- }
3457
- // Create payment element using Checkout instance
3458
- this.paymentElement = checkout.createPaymentElement(options);
3459
- }
3460
- else {
3461
- // Payment Intent mode: use elements.create('payment')
3462
- const elements = this.stripeService.getElements();
3463
- if (elements == null) {
3464
- throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
3465
- }
3466
- // Create payment element with options
3467
- const elementOptions = options || {};
3468
- // Create the payment element
3469
- this.paymentElement = elements.create('payment', elementOptions);
3470
- }
3471
- // Find mount point and mount
3472
- const paymentElementContainer = await findElement(containerElement, '#payment-element');
3473
- this.paymentElement.mount(paymentElementContainer);
3474
- // Note: Payment Element errors are handled during submission
3475
- // Use setError() method to manually set errors if needed
3476
- return this.paymentElement;
3477
- }
3478
- /**
3479
- * Get mounted payment element instance
3480
- */
3481
- getElement() {
3482
- return this.paymentElement;
3483
- }
3484
- /**
3485
- * Set error message (triggers reactivity)
3486
- */
3487
- setError(message) {
3488
- this.store.set('errorMessage', message);
3489
- }
3490
- /**
3491
- * Clear error message (triggers reactivity)
3492
- */
3493
- clearError() {
3494
- this.store.set('errorMessage', '');
3495
- }
3496
- /**
3497
- * Unmount payment element
3498
- */
3499
- unmount() {
3500
- if (this.paymentElement == null) {
3501
- return;
3502
- }
3503
- this.paymentElement.unmount();
3504
- this.paymentElement = undefined;
3505
- }
3506
- }
3507
-
3508
- /**
3509
- * Address Element Manager
3510
- * Manages Stripe Address Element
3511
- * with dependency injection of StripeService
3512
- */
3513
- class AddressElementManager {
3514
- /**
3515
- * Constructor with dependency injection
3516
- * @param stripeService - Injected Stripe service instance
3517
- */
3518
- constructor(stripeService) {
3519
- this.stripeService = stripeService;
3520
- this.store = createStore({
3521
- errorMessage: '',
3522
- isComplete: false,
3523
- });
3524
- }
3525
- /**
3526
- * Get current address element state (reactive)
3527
- */
3528
- getState() {
3529
- return this.store.state;
3530
- }
3531
- /**
3532
- * Initialize and mount address element to DOM
3533
- * @param containerElement - Parent element containing mount point
3534
- * @param options - Address element options
3535
- * @returns Promise resolving to address element instance
3536
- */
3537
- async initialize(containerElement, options) {
3538
- const elements = this.stripeService.getElements();
3539
- if (elements == null) {
3540
- throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
3541
- }
3542
- // Unmount if already initialized
3543
- if (this.addressElement != null) {
3544
- this.unmount();
3545
- }
3546
- // Create and mount address element
3547
- this.addressElement = elements.create('address', options || { mode: 'billing' });
3548
- const addressElementContainer = await findElement(containerElement, '#address-element');
3549
- this.addressElement.mount(addressElementContainer);
3550
- // Listen for changes
3551
- this.addressElement.on('change', event => {
3552
- // StripeAddressElementChangeEvent doesn't have an error property
3553
- // Errors are handled through the complete property and validation
3554
- this.store.set('errorMessage', '');
3555
- this.store.set('isComplete', event.complete);
3556
- });
3557
- return this.addressElement;
3558
- }
3559
- /**
3560
- * Get mounted address element instance
3561
- */
3562
- getElement() {
3563
- return this.addressElement;
3564
- }
3565
- /**
3566
- * Set error message (triggers reactivity)
3567
- */
3568
- setError(message) {
3569
- this.store.set('errorMessage', message);
3570
- }
3571
- /**
3572
- * Clear error message (triggers reactivity)
3573
- */
3574
- clearError() {
3575
- this.store.set('errorMessage', '');
3576
- }
3577
- /**
3578
- * Unmount address element
3579
- */
3580
- unmount() {
3581
- if (this.addressElement == null) {
3582
- return;
3583
- }
3584
- this.addressElement.unmount();
3585
- this.addressElement = undefined;
3586
- }
3587
- }
3588
-
3589
- /**
3590
- * Link Authentication Element Manager
3591
- * Manages Stripe Link Authentication Element for email collection and Link authentication
3592
- * with dependency injection of StripeService
3593
- */
3594
- class LinkAuthenticationElementManager {
3595
- /**
3596
- * Constructor with dependency injection
3597
- * @param stripeService - Injected Stripe service instance
3598
- */
3599
- constructor(stripeService) {
3600
- this.stripeService = stripeService;
3601
- this.store = createStore({
3602
- errorMessage: '',
3603
- email: undefined,
3604
- });
3605
- }
3606
- /**
3607
- * Get current link authentication element state (reactive)
3608
- */
3609
- getState() {
3610
- return this.store.state;
3611
- }
3612
- /**
3613
- * Register state change listener
3614
- * @param key - State property to watch
3615
- * @param callback - Callback function invoked when property changes
3616
- * @returns Unsubscribe function
3617
- */
3618
- onChange(key, callback) {
3619
- return this.store.onChange(key, callback);
3620
- }
3621
- /**
3622
- * Initialize and mount link authentication element to DOM
3623
- * @param containerElement - Parent element containing mount point
3624
- * @param options - Optional configuration for Link Authentication Element
3625
- * @returns Promise resolving to link authentication element instance
3626
- */
3627
- async initialize(containerElement, options) {
3628
- const elements = this.stripeService.getElements();
3629
- if (elements == null) {
3630
- throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
3631
- }
3632
- // Unmount if already initialized
3633
- if (this.linkAuthenticationElement != null) {
3634
- this.unmount();
3635
- }
3636
- // Create link authentication element
3637
- const linkAuthentication = elements.create('linkAuthentication', options);
3638
- const linkAuthenticationElementDiv = await findElement(containerElement, '#link-authentication-element');
3639
- linkAuthentication.mount(linkAuthenticationElementDiv);
3640
- // Listen for change events
3641
- linkAuthentication.on('change', event => {
3642
- var _a;
3643
- // Unconditionally set email from event.value.email
3644
- // This handles all cases: valid email, empty string, or undefined
3645
- this.store.set('email', (_a = event.value) === null || _a === void 0 ? void 0 : _a.email);
3646
- });
3647
- this.linkAuthenticationElement = linkAuthentication;
3648
- return this.linkAuthenticationElement;
3649
- }
3650
- /**
3651
- * Get mounted link authentication element instance
3652
- */
3653
- getElement() {
3654
- return this.linkAuthenticationElement;
3655
- }
3656
- /**
3657
- * Set error message (triggers reactivity)
3658
- */
3659
- setError(message) {
3660
- this.store.set('errorMessage', message);
3661
- }
3662
- /**
3663
- * Clear error message (triggers reactivity)
3664
- */
3665
- clearError() {
3666
- this.store.set('errorMessage', '');
3667
- }
3668
- /**
3669
- * Unmount link authentication element
3670
- */
3671
- unmount() {
3672
- if (this.linkAuthenticationElement == null) {
3673
- return;
3674
- }
3675
- this.linkAuthenticationElement.unmount();
3676
- this.linkAuthenticationElement = undefined;
3677
- }
3678
- }
3679
-
3680
- /**
3681
- * Currency Selector Element Manager
3682
- * Manages Stripe Currency Selector Element
3683
- * with dependency injection of StripeService
3684
- */
3685
- class CurrencySelectorElementManager {
3686
- /**
3687
- * Constructor with dependency injection
3688
- * @param stripeService - Injected Stripe service instance
3689
- */
3690
- constructor(stripeService) {
3691
- this.stripeService = stripeService;
3692
- this.store = createStore({
3693
- errorMessage: '',
3694
- selectedCurrency: undefined,
3695
- });
3696
- }
3697
- /**
3698
- * Get current currency selector element state (reactive)
3699
- */
3700
- getState() {
3701
- return this.store.state;
3702
- }
3703
- /**
3704
- * Initialize and mount currency selector element to DOM
3705
- * @param containerElement - Parent element containing mount point
3706
- * @param options - Currency selector element options
3707
- * @returns Promise resolving to currency selector element instance
3708
- * Note: StripeCurrencySelectorElementOptions is not yet exported in @stripe/stripe-js v8.6.0
3709
- */
3710
- async initialize(containerElement, options) {
3711
- const elements = this.stripeService.getElements();
3712
- if (elements == null) {
3713
- throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
3714
- }
3715
- // Unmount if already initialized
3716
- if (this.currencySelectorElement != null) {
3717
- this.unmount();
3718
- }
3719
- // Find mount point first to avoid element leak if findElement throws
3720
- const currencySelectorElementContainer = await findElement(containerElement, '#currency-selector');
3721
- // Create and mount currency selector element
3722
- // Note: 'currencySelector' type is not yet in @stripe/stripe-js v8.6.0 type definitions
3723
- // but is documented in Stripe's Currency Selector Element documentation
3724
- this.currencySelectorElement = elements.create('currencySelector', options || {});
3725
- this.currencySelectorElement.mount(currencySelectorElementContainer);
3726
- // Listen for changes
3727
- // Note: The 'change' event type is not yet in @stripe/stripe-js type definitions
3728
- // but is documented in Stripe's Currency Selector Element documentation
3729
- this.currencySelectorElement.on('change', (event) => {
3730
- var _a;
3731
- // Clear error on change
3732
- this.store.set('errorMessage', '');
3733
- // Update selected currency if available
3734
- if ((_a = event === null || event === void 0 ? void 0 : event.value) === null || _a === void 0 ? void 0 : _a.currency) {
3735
- this.store.set('selectedCurrency', event.value.currency);
3736
- }
3737
- });
3738
- return this.currencySelectorElement;
3739
- }
3740
- /**
3741
- * Get mounted currency selector element instance
3742
- */
3743
- getElement() {
3744
- return this.currencySelectorElement;
3745
- }
3746
- /**
3747
- * Set error message (triggers reactivity)
3748
- */
3749
- setError(message) {
3750
- this.store.set('errorMessage', message);
3751
- }
3752
- /**
3753
- * Clear error message (triggers reactivity)
3754
- */
3755
- clearError() {
3756
- this.store.set('errorMessage', '');
3757
- }
3758
- /**
3759
- * Unmount currency selector element
3760
- */
3761
- unmount() {
3762
- if (this.currencySelectorElement == null) {
3763
- return;
3764
- }
3765
- this.currencySelectorElement.unmount();
3766
- this.currencySelectorElement = undefined;
3767
- }
3768
- }
3769
-
3770
- /**
3771
- * Express Checkout Element Manager
3772
- * Manages Stripe Express Checkout Element
3773
- * with dependency injection of StripeService
3774
- */
3775
- class ExpressCheckoutElementManager {
3776
- /**
3777
- * Constructor with dependency injection
3778
- * @param stripeService - Injected Stripe service instance
3779
- */
3780
- constructor(stripeService) {
3781
- this.stripeService = stripeService;
3782
- this.store = createStore({
3783
- errorMessage: '',
3784
- isReady: false,
3785
- });
3786
- }
3787
- /**
3788
- * Get current express checkout element state (reactive)
3789
- */
3790
- getState() {
3791
- return this.store.state;
3792
- }
3793
- /**
3794
- * Initialize and mount express checkout element to DOM
3795
- * @param containerElement - Parent element containing mount point
3796
- * @param options - Express Checkout Element configuration options
3797
- * @param eventHandlers - Event handlers for element events
3798
- * @returns Promise resolving to express checkout element instance
3799
- */
3800
- async initialize(containerElement, options, eventHandlers) {
3801
- const elements = this.stripeService.getElements();
3802
- if (elements == null) {
3803
- throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
3804
- }
3805
- // Unmount if already initialized
3806
- if (this.expressCheckoutElement != null) {
3807
- this.unmount();
3808
- }
3809
- // Convert buttonHeight from string to number if present
3810
- const createOptions = Object.assign({}, options);
3811
- if (createOptions.buttonHeight && typeof createOptions.buttonHeight === 'string') {
3812
- const height = parseInt(createOptions.buttonHeight.replace('px', ''), 10);
3813
- if (!isNaN(height)) {
3814
- createOptions.buttonHeight = height;
3815
- }
3816
- }
3817
- // Create express checkout element
3818
- // Note: 'expressCheckout' is not yet in the official Stripe type definitions
3819
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3820
- const expressCheckout = elements.create('expressCheckout', createOptions);
3821
- // Find the mount point
3822
- const mountPoint = await findElement(containerElement, '#express-checkout-element');
3823
- // Set up event handlers before mounting
3824
- if ((eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onConfirm) != null) {
3825
- expressCheckout.on('confirm', eventHandlers.onConfirm);
3826
- }
3827
- if ((eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onClick) != null) {
3828
- expressCheckout.on('click', eventHandlers.onClick);
3829
- }
3830
- if ((eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onCancel) != null) {
3831
- expressCheckout.on('cancel', eventHandlers.onCancel);
3832
- }
3833
- if ((eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onShippingAddressChange) != null) {
3834
- expressCheckout.on('shippingaddresschange', eventHandlers.onShippingAddressChange);
3835
- }
3836
- if ((eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onShippingRateChange) != null) {
3837
- expressCheckout.on('shippingratechange', eventHandlers.onShippingRateChange);
3838
- }
3839
- // Add ready event handler
3840
- expressCheckout.on('ready', () => {
3841
- this.store.set('isReady', true);
3842
- });
3843
- // Mount the element
3844
- expressCheckout.mount(mountPoint);
3845
- this.expressCheckoutElement = expressCheckout;
3846
- return this.expressCheckoutElement;
3847
- }
3848
- /**
3849
- * Get mounted express checkout element instance
3850
- */
3851
- getElement() {
3852
- return this.expressCheckoutElement;
3853
- }
3854
- /**
3855
- * Update element options dynamically
3856
- * @param options - Partial options to update
3857
- */
3858
- update(options) {
3859
- if (this.expressCheckoutElement == null) {
3860
- console.warn('Express Checkout Element not initialized. Cannot update options.');
3861
- return;
3862
- }
3863
- // Convert buttonHeight from string to number if present
3864
- const updateOptions = Object.assign({}, options);
3865
- if (updateOptions.buttonHeight && typeof updateOptions.buttonHeight === 'string') {
3866
- const height = parseInt(updateOptions.buttonHeight.replace('px', ''), 10);
3867
- if (!isNaN(height)) {
3868
- updateOptions.buttonHeight = height;
3869
- }
3870
- }
3871
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3872
- this.expressCheckoutElement.update(updateOptions);
3873
- }
3874
- /**
3875
- * Set error message (triggers reactivity)
3876
- */
3877
- setError(message) {
3878
- this.store.set('errorMessage', message);
3879
- }
3880
- /**
3881
- * Clear error message (triggers reactivity)
3882
- */
3883
- clearError() {
3884
- this.store.set('errorMessage', '');
3885
- }
3886
- /**
3887
- * Unmount express checkout element
3888
- */
3889
- unmount() {
3890
- if (this.expressCheckoutElement == null) {
3891
- return;
3892
- }
3893
- this.expressCheckoutElement.unmount();
3894
- this.expressCheckoutElement = undefined;
3895
- this.store.set('isReady', false);
3896
- }
3897
- }
3898
-
3899
- /**
3900
- * Service Factory
3901
- * Creates service instances with proper dependency injection
3902
- * Can be mocked in tests for better testability
3903
- */
3904
- class ServiceFactory {
3905
- /**
3906
- * Create a new StripeService instance
3907
- */
3908
- createStripeService() {
3909
- return new StripeServiceClass();
3910
- }
3911
- /**
3912
- * Create a new CardElementManager instance
3913
- * @param stripeService - Injected StripeService dependency
3914
- */
3915
- createCardElementManager(stripeService) {
3916
- return new CardElementManager(stripeService);
3917
- }
3918
- /**
3919
- * Create a new PaymentElementManager instance
3920
- * @param stripeService - Injected StripeService dependency
3921
- */
3922
- createPaymentElementManager(stripeService) {
3923
- return new PaymentElementManager(stripeService);
3924
- }
3925
- /**
3926
- * Create a new AddressElementManager instance
3927
- * @param stripeService - Injected StripeService dependency
3928
- */
3929
- createAddressElementManager(stripeService) {
3930
- return new AddressElementManager(stripeService);
3931
- }
3932
- /**
3933
- * Create a new LinkAuthenticationElementManager instance
3934
- * @param stripeService - Injected StripeService dependency
3935
- */
3936
- createLinkAuthenticationElementManager(stripeService) {
3937
- return new LinkAuthenticationElementManager(stripeService);
3938
- }
3939
- /**
3940
- * Create a new CurrencySelectorElementManager instance
3941
- * @param stripeService - Injected StripeService dependency
3942
- */
3943
- createCurrencySelectorElementManager(stripeService) {
3944
- return new CurrencySelectorElementManager(stripeService);
3945
- }
3946
- /**
3947
- * Create a new ExpressCheckoutElementManager instance
3948
- * @param stripeService - Injected StripeService dependency
3949
- */
3950
- createExpressCheckoutElementManager(stripeService) {
3951
- return new ExpressCheckoutElementManager(stripeService);
3952
- }
3953
- }
3954
- /**
3955
- * Default factory instance
3956
- * Can be replaced with a mock in tests
3957
- */
3958
- const serviceFactory = new ServiceFactory();
3959
-
3960
- export { checkPlatform as c, i18n as i, serviceFactory as s };
2824
+ export { checkPlatform as c, i18n as i };