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