stripe-pwa-elements 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/cjs/error-FFC4kSs5.js +18 -0
  2. package/dist/cjs/error-FFC4kSs5.js.map +1 -0
  3. package/dist/cjs/factory-Hsw0e7-d.js +3825 -0
  4. package/dist/cjs/factory-Hsw0e7-d.js.map +1 -0
  5. package/dist/cjs/{index-BmB5d_Yj.js → index-Ba1pBePA.js} +4 -4
  6. package/dist/cjs/{index-BmB5d_Yj.js.map → index-Ba1pBePA.js.map} +1 -1
  7. package/dist/cjs/{index-CQkz7IJv.js → index-C1haN5iF.js} +5 -2
  8. package/dist/cjs/index-C1haN5iF.js.map +1 -0
  9. package/dist/cjs/ion-icon.cjs.entry.js +1 -1
  10. package/dist/cjs/loader.cjs.js +2 -2
  11. package/dist/cjs/stripe-address-element.cjs.entry.js +288 -0
  12. package/dist/cjs/stripe-address-element.entry.cjs.js.map +1 -0
  13. package/dist/cjs/stripe-card-element-modal.cjs.entry.js +1 -1
  14. package/dist/cjs/stripe-card-element.stripe-modal.entry.cjs.js.map +1 -1
  15. package/dist/cjs/stripe-card-element_2.cjs.entry.js +48 -3278
  16. package/dist/cjs/stripe-currency-selector.cjs.entry.js +186 -0
  17. package/dist/cjs/stripe-currency-selector.entry.cjs.js.map +1 -0
  18. package/dist/cjs/stripe-elements.cjs.js +2 -2
  19. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +294 -0
  20. package/dist/cjs/stripe-express-checkout-element.entry.cjs.js.map +1 -0
  21. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +222 -0
  22. package/dist/cjs/stripe-link-authentication-element.entry.cjs.js.map +1 -0
  23. package/dist/cjs/stripe-payment-element.cjs.entry.js +469 -0
  24. package/dist/cjs/stripe-payment-element.entry.cjs.js.map +1 -0
  25. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +2 -2
  26. package/dist/collection/collection-manifest.json +5 -0
  27. package/dist/collection/components/stripe-address-element/stripe-address-element.css +73 -0
  28. package/dist/collection/components/stripe-address-element/stripe-address-element.js +711 -0
  29. package/dist/collection/components/stripe-address-element/stripe-address-element.js.map +1 -0
  30. package/dist/collection/components/stripe-card-element/stripe-card-element.css +16 -8
  31. package/dist/collection/components/stripe-card-element/stripe-card-element.js +32 -8
  32. package/dist/collection/components/stripe-card-element/stripe-card-element.js.map +1 -1
  33. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.css +44 -0
  34. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +477 -0
  35. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js.map +1 -0
  36. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.css +36 -0
  37. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +787 -0
  38. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js.map +1 -0
  39. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.css +49 -0
  40. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +545 -0
  41. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js.map +1 -0
  42. package/dist/collection/components/stripe-modal/stripe-modal.css +16 -14
  43. package/dist/collection/components/stripe-modal/stripe-modal.js +3 -2
  44. package/dist/collection/components/stripe-modal/stripe-modal.js.map +1 -1
  45. package/dist/collection/components/stripe-payment-element/stripe-payment-element.css +78 -0
  46. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +979 -0
  47. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js.map +1 -0
  48. package/dist/collection/interfaces.js.map +1 -1
  49. package/dist/collection/services/address-element-manager.js +83 -0
  50. package/dist/collection/services/address-element-manager.js.map +1 -0
  51. package/dist/collection/services/card-element-manager.js +4 -34
  52. package/dist/collection/services/card-element-manager.js.map +1 -1
  53. package/dist/collection/services/currency-selector-element-manager.js +92 -0
  54. package/dist/collection/services/currency-selector-element-manager.js.map +1 -0
  55. package/dist/collection/services/express-checkout-element-manager.js +131 -0
  56. package/dist/collection/services/express-checkout-element-manager.js.map +1 -0
  57. package/dist/collection/services/factory.js +40 -0
  58. package/dist/collection/services/factory.js.map +1 -1
  59. package/dist/collection/services/interfaces.js.map +1 -1
  60. package/dist/collection/services/link-authentication-element-manager.js +93 -0
  61. package/dist/collection/services/link-authentication-element-manager.js.map +1 -0
  62. package/dist/collection/services/payment-element-manager.js +95 -0
  63. package/dist/collection/services/payment-element-manager.js.map +1 -0
  64. package/dist/collection/services/stripe-service.js +51 -2
  65. package/dist/collection/services/stripe-service.js.map +1 -1
  66. package/dist/collection/utils/element-finder.js +32 -0
  67. package/dist/collection/utils/element-finder.js.map +1 -0
  68. package/dist/collection/utils/error.js.map +1 -1
  69. package/dist/collection/utils/i18n.js +2 -2
  70. package/dist/collection/utils/i18n.js.map +1 -1
  71. package/dist/collection/utils/platform.js.map +1 -1
  72. package/dist/collection/utils/utils.js +1 -1
  73. package/dist/collection/utils/utils.js.map +1 -1
  74. package/dist/components/error.js +16 -0
  75. package/dist/components/error.js.map +1 -0
  76. package/dist/components/factory.js +3736 -0
  77. package/dist/components/factory.js.map +1 -0
  78. package/dist/{esm/index-C5QyifTT.js → components/index2.js} +4 -4
  79. package/dist/components/index2.js.map +1 -0
  80. package/dist/components/stripe-address-element.d.ts +11 -0
  81. package/dist/components/stripe-address-element.js +327 -0
  82. package/dist/components/stripe-address-element.js.map +1 -0
  83. package/dist/components/stripe-card-element2.js +37 -3183
  84. package/dist/components/stripe-card-element2.js.map +1 -1
  85. package/dist/components/stripe-currency-selector.d.ts +11 -0
  86. package/dist/components/stripe-currency-selector.js +218 -0
  87. package/dist/components/stripe-currency-selector.js.map +1 -0
  88. package/dist/components/stripe-express-checkout-element.d.ts +11 -0
  89. package/dist/components/stripe-express-checkout-element.js +332 -0
  90. package/dist/components/stripe-express-checkout-element.js.map +1 -0
  91. package/dist/components/stripe-link-authentication-element.d.ts +11 -0
  92. package/dist/components/stripe-link-authentication-element.js +256 -0
  93. package/dist/components/stripe-link-authentication-element.js.map +1 -0
  94. package/dist/components/stripe-modal2.js +4 -3
  95. package/dist/components/stripe-modal2.js.map +1 -1
  96. package/dist/components/stripe-payment-element.d.ts +11 -0
  97. package/dist/components/stripe-payment-element.js +510 -0
  98. package/dist/components/stripe-payment-element.js.map +1 -0
  99. package/dist/components/stripe-payment-request-button2.js +2 -189
  100. package/dist/components/stripe-payment-request-button2.js.map +1 -1
  101. package/dist/components/utils.js.map +1 -1
  102. package/dist/esm/error-XRfh5Wrs.js +16 -0
  103. package/dist/esm/error-XRfh5Wrs.js.map +1 -0
  104. package/dist/esm/factory-Li_TGt9P.js +3821 -0
  105. package/dist/esm/factory-Li_TGt9P.js.map +1 -0
  106. package/dist/esm/index-BHDCxQOb.js +192 -0
  107. package/dist/esm/{index-C5QyifTT.js.map → index-BHDCxQOb.js.map} +1 -1
  108. package/dist/esm/{index-DB2hiILr.js → index-Dkis4t79.js} +5 -2
  109. package/dist/esm/index-Dkis4t79.js.map +1 -0
  110. package/dist/esm/ion-icon.entry.js +1 -1
  111. package/dist/esm/loader.js +3 -3
  112. package/dist/esm/stripe-address-element.entry.js +286 -0
  113. package/dist/esm/stripe-address-element.entry.js.map +1 -0
  114. package/dist/esm/stripe-card-element-modal.entry.js +1 -1
  115. package/dist/esm/stripe-card-element.stripe-modal.entry.js.map +1 -1
  116. package/dist/esm/stripe-card-element_2.entry.js +41 -3271
  117. package/dist/esm/stripe-currency-selector.entry.js +184 -0
  118. package/dist/esm/stripe-currency-selector.entry.js.map +1 -0
  119. package/dist/esm/stripe-elements.js +3 -3
  120. package/dist/esm/stripe-express-checkout-element.entry.js +292 -0
  121. package/dist/esm/stripe-express-checkout-element.entry.js.map +1 -0
  122. package/dist/esm/stripe-link-authentication-element.entry.js +220 -0
  123. package/dist/esm/stripe-link-authentication-element.entry.js.map +1 -0
  124. package/dist/esm/stripe-payment-element.entry.js +467 -0
  125. package/dist/esm/stripe-payment-element.entry.js.map +1 -0
  126. package/dist/esm/stripe-payment-request-button.entry.js +2 -2
  127. package/dist/stripe-elements/{p-b598431f.entry.js → p-01d63033.entry.js} +2 -2
  128. package/dist/stripe-elements/p-1b8f9c7f.entry.js +2 -0
  129. package/dist/stripe-elements/p-1b8f9c7f.entry.js.map +1 -0
  130. package/dist/stripe-elements/{p-5beb3870.entry.js → p-37008853.entry.js} +2 -2
  131. package/dist/stripe-elements/p-5d152193.entry.js +2 -0
  132. package/dist/stripe-elements/p-5d152193.entry.js.map +1 -0
  133. package/dist/stripe-elements/p-623f13e6.entry.js +2 -0
  134. package/dist/stripe-elements/p-623f13e6.entry.js.map +1 -0
  135. package/dist/stripe-elements/p-809c9f2f.entry.js +2 -0
  136. package/dist/stripe-elements/p-809c9f2f.entry.js.map +1 -0
  137. package/dist/stripe-elements/{p-C5QyifTT.js → p-BHDCxQOb.js} +2 -2
  138. package/dist/stripe-elements/{p-C5QyifTT.js.map → p-BHDCxQOb.js.map} +1 -1
  139. package/dist/stripe-elements/p-Dkis4t79.js +3 -0
  140. package/dist/stripe-elements/p-Dkis4t79.js.map +1 -0
  141. package/dist/stripe-elements/p-WnA32N4v.js +2 -0
  142. package/dist/stripe-elements/p-WnA32N4v.js.map +1 -0
  143. package/dist/stripe-elements/p-XRfh5Wrs.js +2 -0
  144. package/dist/stripe-elements/p-XRfh5Wrs.js.map +1 -0
  145. package/dist/stripe-elements/p-ba41e196.entry.js +2 -0
  146. package/dist/stripe-elements/p-ba41e196.entry.js.map +1 -0
  147. package/dist/stripe-elements/{p-bb923a08.entry.js → p-bb1bc49a.entry.js} +2 -2
  148. package/dist/stripe-elements/p-f21ea941.entry.js +2 -0
  149. package/dist/stripe-elements/p-f21ea941.entry.js.map +1 -0
  150. package/dist/stripe-elements/stripe-address-element.entry.esm.js.map +1 -0
  151. package/dist/stripe-elements/stripe-card-element.stripe-modal.entry.esm.js.map +1 -1
  152. package/dist/stripe-elements/stripe-currency-selector.entry.esm.js.map +1 -0
  153. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  154. package/dist/stripe-elements/stripe-express-checkout-element.entry.esm.js.map +1 -0
  155. package/dist/stripe-elements/stripe-link-authentication-element.entry.esm.js.map +1 -0
  156. package/dist/stripe-elements/stripe-payment-element.entry.esm.js.map +1 -0
  157. package/dist/types/components/stripe-address-element/stripe-address-element.d.ts +195 -0
  158. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +3 -1
  159. package/dist/types/components/stripe-currency-selector/stripe-currency-selector.d.ts +127 -0
  160. package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +232 -0
  161. package/dist/types/components/stripe-link-authentication-element/stripe-link-authentication-element.d.ts +143 -0
  162. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +295 -0
  163. package/dist/types/components.d.ts +836 -6
  164. package/dist/types/interfaces.d.ts +23 -1
  165. package/dist/types/services/address-element-manager.d.ts +44 -0
  166. package/dist/types/services/card-element-manager.d.ts +0 -8
  167. package/dist/types/services/currency-selector-element-manager.d.ts +45 -0
  168. package/dist/types/services/express-checkout-element-manager.d.ts +50 -0
  169. package/dist/types/services/factory.d.ts +26 -1
  170. package/dist/types/services/interfaces.d.ts +263 -2
  171. package/dist/types/services/link-authentication-element-manager.d.ts +51 -0
  172. package/dist/types/services/payment-element-manager.d.ts +46 -0
  173. package/dist/types/services/stripe-service.d.ts +17 -3
  174. package/dist/types/utils/element-finder.d.ts +8 -0
  175. package/dist/types/utils/error.d.ts +1 -1
  176. package/dist/types/utils/platform.d.ts +2 -2
  177. package/package.json +12 -3
  178. package/dist/cjs/index-CQkz7IJv.js.map +0 -1
  179. package/dist/esm/index-DB2hiILr.js.map +0 -1
  180. package/dist/stripe-elements/p-263cf51d.entry.js +0 -2
  181. package/dist/stripe-elements/p-263cf51d.entry.js.map +0 -1
  182. package/dist/stripe-elements/p-DB2hiILr.js +0 -3
  183. package/dist/stripe-elements/p-DB2hiILr.js.map +0 -1
  184. /package/dist/stripe-elements/{p-b598431f.entry.js.map → p-01d63033.entry.js.map} +0 -0
  185. /package/dist/stripe-elements/{p-5beb3870.entry.js.map → p-37008853.entry.js.map} +0 -0
  186. /package/dist/stripe-elements/{p-bb923a08.entry.js.map → p-bb1bc49a.entry.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripe-payment-element.js","sourceRoot":"","sources":["../../../src/components/stripe-payment-element/stripe-payment-element.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAgB,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AASlD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAmCnD,MAAM,OAAO,oBAAoB;IAoC/B;;;;;;;;;;;;;OAaG;IAEI,KAAK,CAAC,UAAU,CAAC,cAAsB,EAAE,OAA2B;QACzE,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,cAAc,EAAE;YAClD,aAAa,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa;YACrC,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAC;QAEH,kEAAkE;QAClE,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YAC5D,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACzB,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,sCAAsC;YACtC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,kBAAkB,EAAE,KAAK,EAAC,QA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P,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h, State, Method, EventEmitter, Event, Element, Watch } from '@stencil/core';\nimport { checkPlatform } from '../../utils/utils';\nimport {\n StripeDidLoadedHandler,\n StripeLoadedEvent,\n ProgressStatus,\n IntentType,\n DefaultFormSubmitResult,\n InitStripeOptions,\n} from '../../interfaces';\nimport { i18n } from '../../utils/i18n';\nimport { serviceFactory } from '../../services/factory';\nimport type { IStripeService, IPaymentElementManager, CheckoutSessionOptions } from '../../services/interfaces';\nimport { StripeAPIError } from '../../utils/error';\n\nimport type { Stripe, StripeElements, StripeCheckout, StripeCheckoutConfirmResult } from '@stripe/stripe-js';\n\n/**\n * Payment Element submit event\n */\nexport type PaymentElementSubmitEvent = {\n stripe: Stripe;\n elements?: StripeElements;\n intentClientSecret?: string;\n checkout?: StripeCheckout;\n checkoutSessionClientSecret?: string;\n};\n\n/**\n * Checkout Session submit event result\n */\nexport type CheckoutSessionFormSubmitResult = StripeCheckoutConfirmResult | Error;\n\n/**\n * Payment Element submit handler\n */\nexport type PaymentElementSubmitHandler = (event: Event, props: PaymentElementSubmitEvent) => Promise<void>;\n\n/**\n * Checkout Session initialization options\n */\nexport type InitCheckoutSessionOptions = InitStripeOptions & CheckoutSessionOptions;\n\n@Component({\n tag: 'stripe-payment-element',\n styleUrl: 'stripe-payment-element.scss',\n shadow: false,\n})\nexport class StripePaymentElement {\n @Element() el: HTMLStripePaymentElementElement;\n\n // Injected dependencies\n private stripeService: IStripeService;\n private paymentElementManager: IPaymentElementManager;\n\n // Form submit handler (bound to this instance)\n private _submitHandler: (e: Event) => Promise<void>;\n\n /**\n * Default submit handle type.\n * If you want to use `setupIntent`, should update this attribute.\n */\n @Prop() readonly intentType: IntentType = 'payment';\n\n /**\n * Payment sheet title\n * By default we recommended to use these string\n * - 'Add your payment information' -> PaymentSheet / PaymentFlow(Android)\n * - 'Add a card' -> PaymentFlow(iOS)\n * These strings will translated automatically by this library.\n */\n @Prop() readonly sheetTitle: string = 'Add your payment information';\n\n /**\n * Submit button label\n * By default we recommended to use these string\n * - 'Pay' -> PaymentSheet\n * - 'Add' -> PaymentFlow(Android)\n * - 'Add card' -> PaymentFlow(iOS)\n * - 'Add a card' -> PaymentFlow(iOS)\n * These strings will translated automatically by this library.\n */\n @Prop() readonly buttonLabel: string = 'Pay';\n\n /**\n * Get Stripe.js, and initialize elements\n * @param publishableKey\n * @param options\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.initStripe('pk_test_XXXXXXXXX')\n * })\n * ```\n */\n @Method()\n public async initStripe(publishableKey: string, options?: InitStripeOptions) {\n await this.stripeService.initialize(publishableKey, {\n stripeAccount: options?.stripeAccount,\n applicationName: this.applicationName,\n });\n\n // If already successfully loaded, initialize elements immediately\n if (this.stripeService.state.loadStripeStatus === 'success') {\n await this.initElement();\n this.stripeLoadedEventHandler();\n } else {\n // Otherwise, wait for successful load\n const unsubscribe = this.stripeService.onChange('loadStripeStatus', async newState => {\n if (newState !== 'success') {\n return;\n }\n\n await this.initElement();\n this.stripeLoadedEventHandler();\n unsubscribe(); // Clean up listener after first success\n });\n }\n }\n\n /**\n * Get Stripe.js and initialize with Checkout Session mode\n * Use this method when you have a Checkout Session client secret instead of Payment/Setup Intent\n * @param publishableKey - Your Stripe publishable API key\n * @param checkoutSessionClientSecret - The client secret from Checkout Session\n * @param options - Optional configuration\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.initStripeWithCheckoutSession(\n * 'pk_test_XXXXXXXXX',\n * 'cs_xxx_secret_xxx'\n * )\n * })\n * ```\n */\n @Method()\n public async initStripeWithCheckoutSession(publishableKey: string, checkoutSessionClientSecret: string, options?: InitCheckoutSessionOptions) {\n await this.stripeService.initializeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, {\n stripeAccount: options?.stripeAccount,\n applicationName: this.applicationName,\n elementsOptions: options?.elementsOptions,\n });\n\n // If already successfully loaded, initialize elements immediately\n if (this.stripeService.state.loadStripeStatus === 'success') {\n await this.initElement();\n this.stripeLoadedEventHandler();\n } else {\n // Otherwise, wait for successful load\n const unsubscribe = this.stripeService.onChange('loadStripeStatus', async newState => {\n if (newState !== 'success') {\n return;\n }\n\n await this.initElement();\n this.stripeLoadedEventHandler();\n unsubscribe(); // Clean up listener after first success\n });\n }\n }\n\n /**\n * The progress status of the checkout process\n */\n @State() progress: ProgressStatus = '';\n\n /**\n * Update the form submit progress\n * @param progress\n * @returns\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.updateProgress('success')\n * })\n * ```\n */\n @Method()\n public async updateProgress(progress: ProgressStatus) {\n this.progress = progress;\n return this;\n }\n\n /**\n * Set error message\n * @param errorMessage string\n * @returns\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.setErrorMessage('Payment failed')\n * })\n * ```\n */\n @Method()\n public async setErrorMessage(errorMessage: string) {\n this.paymentElementManager.setError(errorMessage);\n return this;\n }\n\n /**\n * Your Stripe publishable API key.\n */\n @Prop() readonly publishableKey: string;\n\n @Watch('publishableKey')\n updatePublishableKey(publishableKey: string) {\n const options: InitStripeOptions = {};\n\n options.stripeAccount = this.stripeService.state.stripeAccount;\n const hasOptionValue = Object.values(options).filter(Boolean).length > 0;\n\n this.initStripe(publishableKey, hasOptionValue ? options : undefined);\n }\n\n /**\n * Optional. Making API calls for connected accounts\n * @info https://stripe.com/docs/connect/authentication\n */\n @Prop() readonly stripeAccount: string;\n\n @Watch('stripeAccount')\n updateStripeAccountId(stripeAccount: string) {\n this.initStripe(this.stripeService.state.publishableKey, {\n stripeAccount: stripeAccount,\n });\n }\n\n /**\n * Overwrite the application name that registered\n * For wrapper library (like Capacitor)\n */\n @Prop() readonly applicationName: string = 'stripe-pwa-elements';\n\n /**\n * The client secret from paymentIntent.create or setupIntent.create response\n * Use this for Payment Intent / Setup Intent mode\n *\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.setAttribute('intent-client-secret', 'pi_xxx_secret_xxx')\n * })\n * ```\n *\n * @example\n * ```\n * <stripe-payment-element intent-client-secret=\"pi_xxx_secret_xxx\" />\n * ```\n */\n @Prop() readonly intentClientSecret?: string;\n\n @Watch('intentClientSecret')\n async updateIntentClientSecret() {\n // Re-initialize the payment element when client secret changes\n if (this.stripeService.state.loadStripeStatus === 'success') {\n await this.initElement();\n }\n }\n\n /**\n * The client secret from checkout session response\n * Use this for Checkout Session mode instead of intentClientSecret\n * When this prop is set, the component will use Checkout Session API\n *\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.initStripeWithCheckoutSession('pk_test_xxx', 'cs_xxx_secret_xxx')\n * })\n * ```\n */\n @Prop() readonly checkoutSessionClientSecret?: string;\n\n @Watch('checkoutSessionClientSecret')\n async updateCheckoutSessionClientSecret(newValue: string) {\n // Re-initialize with checkout session when client secret changes\n if (this.publishableKey && newValue) {\n await this.initStripeWithCheckoutSession(this.publishableKey, newValue, {\n stripeAccount: this.stripeAccount,\n });\n }\n }\n\n /**\n * The component will provide a function to call the `stripe.confirmPayment` API.\n * If you want to customize the behavior, should set false.\n * And listen the 'formSubmit' event on the element\n */\n @Prop() readonly shouldUseDefaultFormSubmitAction: boolean = true;\n\n /**\n * Form submit event handler\n */\n @Prop({\n mutable: true,\n })\n handleSubmit: PaymentElementSubmitHandler;\n\n /**\n * Stripe.js class loaded handler\n */\n @Prop({\n mutable: true,\n })\n stripeDidLoaded?: StripeDidLoadedHandler;\n\n /**\n * Stripe Client loaded event\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement\n * .addEventListener('stripeLoaded', async ({ detail: {stripe} }) => {\n * console.log('Stripe loaded:', stripe);\n * });\n * })\n * ```\n */\n @Event() stripeLoaded: EventEmitter<StripeLoadedEvent>;\n\n private stripeLoadedEventHandler() {\n const event: StripeLoadedEvent = {\n stripe: this.stripeService.getStripe(),\n };\n\n if (this.stripeDidLoaded) {\n this.stripeDidLoaded(event);\n }\n\n this.stripeLoaded.emit(event);\n }\n\n /**\n * Form submit event\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement\n * .addEventListener('formSubmit', async props => {\n * const { detail: { stripe, elements } } = props;\n * console.log('Form submitted', stripe, elements);\n * })\n * })\n * ```\n */\n @Event() formSubmit: EventEmitter<PaymentElementSubmitEvent>;\n\n private async formSubmitEventHandler() {\n const stripe = this.stripeService.getStripe();\n const isCheckoutSession = this.stripeService.state.isCheckoutSession;\n\n if (!stripe) {\n console.error('Stripe not properly initialized');\n return;\n }\n\n const eventData: PaymentElementSubmitEvent = {\n stripe,\n };\n\n if (isCheckoutSession) {\n // Checkout Session mode\n const checkout = this.stripeService.getCheckout();\n\n if (!checkout) {\n console.error('Checkout not properly initialized');\n return;\n }\n\n eventData.checkout = checkout;\n eventData.checkoutSessionClientSecret = this.checkoutSessionClientSecret;\n } else {\n // Payment Intent / Setup Intent mode\n const elements = this.stripeService.getElements();\n\n if (!elements) {\n console.error('Elements not properly initialized');\n return;\n }\n\n eventData.elements = elements;\n eventData.intentClientSecret = this.intentClientSecret;\n }\n\n this.formSubmit.emit(eventData);\n }\n\n /**\n * Receive the result of defaultFormSubmit event\n * This event is emitted when using Payment Intent / Setup Intent mode\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.addEventListener('defaultFormSubmitResult', async ({detail}) => {\n * if (detail instanceof Error) {\n * console.error(detail)\n * } else {\n * console.log(detail)\n * }\n * })\n * })\n * ```\n */\n @Event() defaultFormSubmitResult: EventEmitter<DefaultFormSubmitResult>;\n\n private async defaultFormSubmitResultHandler(result: DefaultFormSubmitResult) {\n this.defaultFormSubmitResult.emit(result);\n }\n\n /**\n * Receive the result of checkout session confirm\n * This event is emitted when using Checkout Session mode\n * @example\n * ```\n * const stripeElement = document.createElement('stripe-payment-element');\n * customElements\n * .whenDefined('stripe-payment-element')\n * .then(() => {\n * stripeElement.addEventListener('checkoutSessionConfirmResult', async ({detail}) => {\n * if (detail instanceof Error) {\n * console.error(detail)\n * } else if (detail.type === 'success') {\n * console.log('Payment successful:', detail.session)\n * } else {\n * console.error('Payment failed:', detail.error)\n * }\n * })\n * })\n * ```\n */\n @Event() checkoutSessionConfirmResult: EventEmitter<CheckoutSessionFormSubmitResult>;\n\n private async checkoutSessionConfirmResultHandler(result: CheckoutSessionFormSubmitResult) {\n this.checkoutSessionConfirmResult.emit(result);\n }\n\n componentWillRender() {\n if (!this.stripeService.state.publishableKey) {\n return;\n }\n\n if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {\n return;\n }\n\n this.initStripe(this.stripeService.state.publishableKey, {\n stripeAccount: this.stripeService.state.stripeAccount,\n });\n }\n\n /**\n * Default form submit action for Payment Intent / Setup Intent mode\n * Calls confirmPayment or confirmSetup based on intentType\n * If you don't want use it, please set `should-use-default-form-submit-action=\"false\"`\n * @param event\n * @param param1\n */\n private async defaultFormSubmitAction(event: Event, { stripe, elements }: PaymentElementSubmitEvent) {\n event.preventDefault();\n try {\n const { intentType } = this;\n\n // Get current page URL for return_url\n const returnUrl = window.location.href;\n\n const result = await (() => {\n if (intentType === 'payment') {\n return stripe.confirmPayment({\n elements,\n confirmParams: {\n return_url: returnUrl,\n },\n redirect: 'if_required',\n });\n }\n\n return stripe.confirmSetup({\n elements,\n confirmParams: {\n return_url: returnUrl,\n },\n redirect: 'if_required',\n });\n })();\n\n if (result.error) {\n throw new StripeAPIError(result.error);\n }\n\n this.defaultFormSubmitResultHandler(result);\n } catch (e) {\n console.error(e);\n this.defaultFormSubmitResultHandler(e);\n throw e;\n }\n }\n\n /**\n * Checkout Session form submit action\n * Uses checkout.loadActions().confirm() to confirm the payment\n * @param event\n * @param checkout - The Stripe Checkout instance\n */\n private async checkoutSessionFormSubmitAction(event: Event, checkout: StripeCheckout) {\n event.preventDefault();\n try {\n // Load actions from the checkout session\n const loadActionsResult = await checkout.loadActions();\n\n if (loadActionsResult.type === 'error') {\n // Create a StripeError-compatible object from the Checkout Session error\n const stripeError = {\n type: 'api_error' as const,\n code: loadActionsResult.error.code || 'checkout_session_error',\n message: loadActionsResult.error.message,\n };\n\n throw new StripeAPIError(stripeError);\n }\n\n const { actions } = loadActionsResult;\n\n // Get current page URL for return_url\n const returnUrl = window.location.href;\n\n // Confirm the payment using checkout session actions\n const result = await actions.confirm({\n returnUrl,\n redirect: 'if_required',\n });\n\n if (result.type === 'error') {\n // Create a StripeError-compatible object from the confirm error\n const stripeError = {\n type: 'card_error' as const,\n code: result.error.code || 'payment_failed',\n message: result.error.message,\n decline_code: result.error.code === 'paymentFailed' ? (result.error as { paymentFailed?: { declineCode?: string } }).paymentFailed?.declineCode : undefined,\n };\n\n throw new StripeAPIError(stripeError);\n }\n\n this.checkoutSessionConfirmResultHandler(result);\n } catch (e) {\n console.error(e);\n this.checkoutSessionConfirmResultHandler(e instanceof Error ? e : new Error(String(e)));\n throw e;\n }\n }\n\n constructor() {\n // Dependency Injection via factory\n this.stripeService = serviceFactory.createStripeService();\n this.paymentElementManager = serviceFactory.createPaymentElementManager(this.stripeService);\n\n if (this.publishableKey) {\n this.initStripe(this.publishableKey, {\n stripeAccount: this.stripeAccount,\n });\n }\n }\n\n /**\n * Initialize Component using Stripe Element\n */\n private async initElement() {\n // Initialize payment element\n await this.paymentElementManager.initialize(this.el);\n\n // Add form submit listener scoped to this component instance\n const formElement = this.el.querySelector('#stripe-payment-element');\n\n if (!formElement) {\n console.error('Form element #stripe-payment-element not found');\n return;\n }\n\n // Remove existing listener if present to prevent duplicates\n if (this._submitHandler) {\n formElement.removeEventListener('submit', this._submitHandler);\n }\n\n // Create and store the submit handler\n this._submitHandler = async (e: Event) => {\n const stripe = this.stripeService.getStripe();\n const isCheckoutSession = this.stripeService.state.isCheckoutSession;\n\n if (!stripe) {\n console.error('Stripe not properly initialized');\n return;\n }\n\n // Build submit event props based on mode\n const submitEventProps: PaymentElementSubmitEvent = {\n stripe,\n };\n\n if (isCheckoutSession) {\n // Checkout Session mode\n const checkout = this.stripeService.getCheckout();\n\n if (!checkout) {\n console.error('Checkout not properly initialized');\n return;\n }\n\n submitEventProps.checkout = checkout;\n submitEventProps.checkoutSessionClientSecret = this.checkoutSessionClientSecret;\n } else {\n // Payment Intent / Setup Intent mode\n const elements = this.stripeService.getElements();\n\n if (!elements) {\n console.error('Elements not properly initialized');\n return;\n }\n\n submitEventProps.elements = elements;\n submitEventProps.intentClientSecret = this.intentClientSecret;\n }\n\n this.progress = 'loading';\n try {\n if (this.handleSubmit) {\n await this.handleSubmit(e, submitEventProps);\n } else if (this.shouldUseDefaultFormSubmitAction === true) {\n if (isCheckoutSession && submitEventProps.checkout) {\n // Use Checkout Session confirmation\n await this.checkoutSessionFormSubmitAction(e, submitEventProps.checkout);\n } else if (this.intentClientSecret) {\n // Use Payment Intent / Setup Intent confirmation\n await this.defaultFormSubmitAction(e, submitEventProps);\n } else {\n e.preventDefault();\n }\n } else {\n e.preventDefault();\n }\n\n await this.formSubmitEventHandler();\n if (this.handleSubmit || this.shouldUseDefaultFormSubmitAction === true) {\n this.progress = 'success';\n }\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n\n this.paymentElementManager.setError(errorMessage);\n this.progress = 'failure';\n }\n };\n\n formElement.addEventListener('submit', this._submitHandler);\n }\n\n componentDidLoad() {\n this.el.classList.add(checkPlatform());\n }\n\n disconnectedCallback() {\n this.paymentElementManager.unmount();\n\n // Remove event listener to prevent memory leaks\n if (this._submitHandler) {\n const formElement = this.el.querySelector('#stripe-payment-element');\n\n if (formElement) {\n formElement.removeEventListener('submit', this._submitHandler);\n }\n }\n }\n\n render() {\n const { loadStripeStatus, isCheckoutSession } = this.stripeService.state;\n const { errorMessage } = this.paymentElementManager.getState();\n\n if (loadStripeStatus === 'failure') {\n return <p>{i18n.t('Failed to load Stripe')}</p>;\n }\n\n // Determine if button should be disabled\n // For Checkout Session mode: check if checkout is initialized (loadStripeStatus === 'success')\n // For Payment Intent mode: check if intentClientSecret is set\n const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : !!this.intentClientSecret;\n const disabled = this.progress === 'loading' || !hasValidSecret;\n\n return (\n <div class=\"stripe-payment-sheet-wrap\">\n <form id=\"stripe-payment-element\">\n <div class=\"stripe-heading\">{i18n.t(this.sheetTitle)}</div>\n <div>\n <div class=\"stripe-section-title\">{i18n.t('Payment information')}</div>\n </div>\n <div class=\"payment-info visible\">\n <div id=\"payment-element\" />\n </div>\n <div id=\"payment-errors\" class=\"stripe-element-errors\">\n {errorMessage}\n </div>\n <div style={{ marginTop: '32px' }}>\n <button type=\"submit\" disabled={disabled}>\n {this.progress === 'loading' ? i18n.t('Loading') : i18n.t(this.buttonLabel)}\n </button>\n </div>\n </form>\n </div>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Stripe,\n StripeCardCvcElement,\n StripeCardExpiryElement,\n StripeCardNumberElement,\n PaymentRequestPaymentMethodEvent,\n PaymentRequestShippingOptionEvent,\n PaymentRequestShippingAddressEvent,\n PaymentRequestOptions,\n PaymentIntentResult,\n SetupIntentResult,\n} from '@stripe/stripe-js';\n\n/**\n * Internal util types\n */\nexport type StringifyBoolean = 'true' | 'false';\n\n/**\n * Event object of `formSubmit` event\n */\nexport type FormSubmitEvent = {\n stripe: Stripe;\n cardNumberElement: StripeCardNumberElement;\n cardExpiryElement: StripeCardExpiryElement;\n cardCVCElement: StripeCardCvcElement;\n intentClientSecret?: string;\n zipCode?: string;\n};\n/**\n * Handler function of the `formSubmit` event\n */\nexport type FormSubmitHandler = (event: Event, props: FormSubmitEvent) => Promise<void>;\n\n/**\n * Event object of `stripeLoaded` event\n */\nexport type StripeLoadedEvent = {\n stripe: Stripe;\n};\n/**\n * Handler function of the `stripeLoaded` event\n */\nexport type StripeDidLoadedHandler = (event: StripeLoadedEvent) => Promise<void>;\n\n/**\n * Activity progress status\n */\nexport type ProgressStatus = '' | 'loading' | 'success' | 'failure';\n\n/**\n * PaymentRequest Button API handlers\n */\nexport type PaymentRequestPaymentMethodEventHandler = (event: PaymentRequestPaymentMethodEvent, stripe: Stripe) => Promise<void>;\nexport type PaymentRequestShippingOptionEventHandler = (event: PaymentRequestShippingOptionEvent, stripe: Stripe) => Promise<void>;\nexport type PaymentRequestShippingAddressEventHandler = (event: PaymentRequestShippingAddressEvent, stripe: Stripe) => Promise<void>;\n\n/**\n * PaymentRequest Button options\n */\nexport type PaymentRequestButtonOption = PaymentRequestOptions & {\n paymentRequestPaymentMethodHandler?: PaymentRequestPaymentMethodEventHandler;\n paymentRequestShippingAddressChangeHandler?: PaymentRequestShippingAddressEventHandler;\n paymentRequestShippingOptionChangeHandler?: PaymentRequestShippingOptionEventHandler;\n};\n\n/**\n * Stripe XXXIntent types\n */\nexport type IntentType = 'setup' | 'payment';\nexport type DefaultFormSubmitResult = Error | PaymentIntentResult | SetupIntentResult;\n\n/**\n * Stripe.js client options\n * @see https://stripe.com/docs/js/initializing#init_stripe_js-options\n */\nexport type InitStripeOptions = {\n stripeAccount?: string;\n}"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Stripe,\n StripeCardCvcElement,\n StripeCardExpiryElement,\n StripeCardNumberElement,\n StripeLinkAuthenticationElement,\n PaymentRequestPaymentMethodEvent,\n PaymentRequestShippingOptionEvent,\n PaymentRequestShippingAddressEvent,\n PaymentRequestOptions,\n PaymentIntentResult,\n SetupIntentResult,\n} from '@stripe/stripe-js';\n\n/**\n * Internal util types\n */\nexport type StringifyBoolean = 'true' | 'false';\n\n/**\n * Event object of `formSubmit` event\n */\nexport type FormSubmitEvent = {\n stripe: Stripe;\n cardNumberElement: StripeCardNumberElement;\n cardExpiryElement: StripeCardExpiryElement;\n cardCVCElement: StripeCardCvcElement;\n intentClientSecret?: string;\n zipCode?: string;\n};\n/**\n * Handler function of the `formSubmit` event\n */\nexport type FormSubmitHandler = (event: Event, props: FormSubmitEvent) => Promise<void>;\n\n/**\n * Event object of `stripeLoaded` event\n */\nexport type StripeLoadedEvent = {\n stripe: Stripe;\n};\n/**\n * Handler function of the `stripeLoaded` event\n */\nexport type StripeDidLoadedHandler = (event: StripeLoadedEvent) => Promise<void>;\n\n/**\n * Activity progress status\n */\nexport type ProgressStatus = '' | 'loading' | 'success' | 'failure';\n\n/**\n * PaymentRequest Button API handlers\n */\nexport type PaymentRequestPaymentMethodEventHandler = (event: PaymentRequestPaymentMethodEvent, stripe: Stripe) => Promise<void>;\nexport type PaymentRequestShippingOptionEventHandler = (event: PaymentRequestShippingOptionEvent, stripe: Stripe) => Promise<void>;\nexport type PaymentRequestShippingAddressEventHandler = (event: PaymentRequestShippingAddressEvent, stripe: Stripe) => Promise<void>;\n\n/**\n * PaymentRequest Button options\n */\nexport type PaymentRequestButtonOption = PaymentRequestOptions & {\n paymentRequestPaymentMethodHandler?: PaymentRequestPaymentMethodEventHandler;\n paymentRequestShippingAddressChangeHandler?: PaymentRequestShippingAddressEventHandler;\n paymentRequestShippingOptionChangeHandler?: PaymentRequestShippingOptionEventHandler;\n};\n\n/**\n * Stripe XXXIntent types\n */\nexport type IntentType = 'setup' | 'payment';\nexport type DefaultFormSubmitResult = Error | PaymentIntentResult | SetupIntentResult;\n\n/**\n * Stripe.js client options\n * @see https://stripe.com/docs/js/initializing#init_stripe_js-options\n */\nexport type InitStripeOptions = {\n stripeAccount?: string;\n};\n\n/**\n * Event object of Link Authentication Element 'change' event\n */\nexport type LinkAuthenticationElementChangeEvent = {\n stripe: Stripe;\n linkAuthenticationElement: StripeLinkAuthenticationElement;\n email?: string;\n};\n\n/**\n * Handler function of the Link Authentication Element 'change' event\n */\nexport type LinkAuthenticationElementChangeHandler = (event: LinkAuthenticationElementChangeEvent) => Promise<void> | void;\n\n/**\n * Currency Selector Element change event data\n */\nexport type CurrencySelectorChangeEvent = {\n currency: string;\n};\n\n/**\n * Currency Selector Element change handler\n */\nexport type CurrencySelectorChangeHandler = (props: CurrencySelectorChangeEvent) => Promise<void>;\n"]}
@@ -0,0 +1,83 @@
1
+ import { createStore } from "@stencil/store";
2
+ import { findElement } from "../utils/element-finder";
3
+ /**
4
+ * Address Element Manager
5
+ * Manages Stripe Address Element
6
+ * with dependency injection of StripeService
7
+ */
8
+ export class AddressElementManager {
9
+ /**
10
+ * Constructor with dependency injection
11
+ * @param stripeService - Injected Stripe service instance
12
+ */
13
+ constructor(stripeService) {
14
+ this.stripeService = stripeService;
15
+ this.store = createStore({
16
+ errorMessage: '',
17
+ isComplete: false,
18
+ });
19
+ }
20
+ /**
21
+ * Get current address element state (reactive)
22
+ */
23
+ getState() {
24
+ return this.store.state;
25
+ }
26
+ /**
27
+ * Initialize and mount address element to DOM
28
+ * @param containerElement - Parent element containing mount point
29
+ * @param options - Address element options
30
+ * @returns Promise resolving to address element instance
31
+ */
32
+ async initialize(containerElement, options) {
33
+ const elements = this.stripeService.getElements();
34
+ if (!elements) {
35
+ throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
36
+ }
37
+ // Unmount if already initialized
38
+ if (this.addressElement) {
39
+ this.unmount();
40
+ }
41
+ // Create and mount address element
42
+ this.addressElement = elements.create('address', options || { mode: 'billing' });
43
+ const addressElementContainer = await findElement(containerElement, '#address-element');
44
+ this.addressElement.mount(addressElementContainer);
45
+ // Listen for changes
46
+ this.addressElement.on('change', event => {
47
+ // StripeAddressElementChangeEvent doesn't have an error property
48
+ // Errors are handled through the complete property and validation
49
+ this.store.set('errorMessage', '');
50
+ this.store.set('isComplete', event.complete);
51
+ });
52
+ return this.addressElement;
53
+ }
54
+ /**
55
+ * Get mounted address element instance
56
+ */
57
+ getElement() {
58
+ return this.addressElement;
59
+ }
60
+ /**
61
+ * Set error message (triggers reactivity)
62
+ */
63
+ setError(message) {
64
+ this.store.set('errorMessage', message);
65
+ }
66
+ /**
67
+ * Clear error message (triggers reactivity)
68
+ */
69
+ clearError() {
70
+ this.store.set('errorMessage', '');
71
+ }
72
+ /**
73
+ * Unmount address element
74
+ */
75
+ unmount() {
76
+ if (!this.addressElement) {
77
+ return;
78
+ }
79
+ this.addressElement.unmount();
80
+ this.addressElement = undefined;
81
+ }
82
+ }
83
+ //# sourceMappingURL=address-element-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-element-manager.js","s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C,cAAc,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAe;QACtB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;IAClC,CAAC;CACF","sourcesContent":["import type { IAddressElementManager, IStripeService, AddressElementState } from './interfaces';\nimport { StripeAddressElement } from '@stripe/stripe-js';\nimport { createStore } from '@stencil/store';\nimport { findElement } from '../utils/element-finder';\n\n/**\n * Address Element Manager\n * Manages Stripe Address Element\n * with dependency injection of StripeService\n */\nexport class AddressElementManager implements IAddressElementManager {\n private addressElement?: StripeAddressElement;\n private store = createStore<AddressElementState>({\n errorMessage: '',\n isComplete: false,\n });\n\n /**\n * Constructor with dependency injection\n * @param stripeService - Injected Stripe service instance\n */\n constructor(private stripeService: IStripeService) {}\n\n /**\n * Get current address element state (reactive)\n */\n getState(): AddressElementState {\n return this.store.state;\n }\n\n /**\n * Initialize and mount address element to DOM\n * @param containerElement - Parent element containing mount point\n * @param options - Address element options\n * @returns Promise resolving to address element instance\n */\n async initialize(containerElement: HTMLElement, options?: import('@stripe/stripe-js').StripeAddressElementOptions): Promise<StripeAddressElement> {\n const elements = this.stripeService.getElements();\n\n if (!elements) {\n throw new Error('StripeService not initialized. Call StripeService.initialize() first.');\n }\n\n // Unmount if already initialized\n if (this.addressElement) {\n this.unmount();\n }\n\n // Create and mount address element\n this.addressElement = elements.create('address', options || { mode: 'billing' });\n\n const addressElementContainer = await findElement(containerElement, '#address-element');\n\n this.addressElement.mount(addressElementContainer);\n\n // Listen for changes\n this.addressElement.on('change', event => {\n // StripeAddressElementChangeEvent doesn't have an error property\n // Errors are handled through the complete property and validation\n this.store.set('errorMessage', '');\n this.store.set('isComplete', event.complete);\n });\n\n return this.addressElement;\n }\n\n /**\n * Get mounted address element instance\n */\n getElement(): StripeAddressElement | undefined {\n return this.addressElement;\n }\n\n /**\n * Set error message (triggers reactivity)\n */\n setError(message: string): void {\n this.store.set('errorMessage', message);\n }\n\n /**\n * Clear error message (triggers reactivity)\n */\n clearError(): void {\n this.store.set('errorMessage', '');\n }\n\n /**\n * Unmount address element\n */\n unmount(): void {\n if (!this.addressElement) {\n return;\n }\n\n this.addressElement.unmount();\n this.addressElement = undefined;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { i18n } from "../utils/i18n";
2
2
  import { createStore } from "@stencil/store";
3
+ import { findElement } from "../utils/element-finder";
3
4
  /**
4
5
  * Card Element Manager
5
6
  * Manages Stripe Card Elements (cardNumber, cardExpiry, cardCvc)
@@ -41,17 +42,17 @@ export class CardElementManager {
41
42
  const cardNumber = elements.create('cardNumber', {
42
43
  placeholder: i18n.t('Card Number'),
43
44
  });
44
- const cardNumberElement = await this.findElement(containerElement, '#card-number');
45
+ const cardNumberElement = await findElement(containerElement, '#card-number');
45
46
  cardNumber.mount(cardNumberElement);
46
47
  cardNumber.on('change', this.handleCardError('cardNumber'));
47
48
  // Create and mount card expiry element
48
49
  const cardExpiry = elements.create('cardExpiry');
49
- const cardExpiryElement = await this.findElement(containerElement, '#card-expiry');
50
+ const cardExpiryElement = await findElement(containerElement, '#card-expiry');
50
51
  cardExpiry.mount(cardExpiryElement);
51
52
  cardExpiry.on('change', this.handleCardError('cardExpiry'));
52
53
  // Create and mount card CVC element
53
54
  const cardCVC = elements.create('cardCvc');
54
- const cardCVCElement = await this.findElement(containerElement, '#card-cvc');
55
+ const cardCVCElement = await findElement(containerElement, '#card-cvc');
55
56
  cardCVC.mount(cardCVCElement);
56
57
  cardCVC.on('change', this.handleCardError('cardCvc'));
57
58
  this.cardElements = {
@@ -112,36 +113,5 @@ export class CardElementManager {
112
113
  }
113
114
  };
114
115
  }
115
- /**
116
- * Wait for an element to appear in the DOM
117
- * @param containerElement - Parent element to search in
118
- * @param selector - CSS selector
119
- * @param timeout - Timeout in milliseconds (default: 5000ms)
120
- * @returns Promise that resolves to the found element or rejects on timeout
121
- */
122
- findElement(containerElement, selector, timeout = 5000) {
123
- return new Promise((resolve, reject) => {
124
- const elem = containerElement.querySelector(selector);
125
- if (elem) {
126
- return resolve(elem);
127
- }
128
- const timeoutId = setTimeout(() => {
129
- observer.disconnect();
130
- reject(new Error(`Element "${selector}" not found within ${timeout}ms`));
131
- }, timeout);
132
- const observer = new MutationObserver(() => {
133
- const elem = containerElement.querySelector(selector);
134
- if (elem) {
135
- clearTimeout(timeoutId);
136
- observer.disconnect();
137
- resolve(elem);
138
- }
139
- });
140
- observer.observe(containerElement, {
141
- childList: true,
142
- subtree: true,
143
- });
144
- });
145
- }
146
116
  }
147
117
  //# sourceMappingURL=card-element-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"card-element-manager.js","sourceRoot":"","sources":["../../src/services/card-element-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAO7B;;;OAGG;IACH,YAAoB,aAA6B;QAA7B,kBAAa,GAAb,aAAa,CAAgB;QATzC,UAAK,GAAG,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O,CAAC,IAAmB,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE;gBACjC,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { ICardElementManager, IStripeService, CardElementInstances, CardElementState } from './interfaces';\nimport { i18n } from '../utils/i18n';\nimport { createStore } from '@stencil/store';\n\n/**\n * Card Element Manager\n * Manages Stripe Card Elements (cardNumber, cardExpiry, cardCvc)\n * with dependency injection of StripeService\n */\nexport class CardElementManager implements ICardElementManager {\n private cardElements?: CardElementInstances;\n private store = createStore<CardElementState>({\n errorMessage: '',\n errorSource: undefined,\n });\n\n /**\n * Constructor with dependency injection\n * @param stripeService - Injected Stripe service instance\n */\n constructor(private stripeService: IStripeService) {}\n\n /**\n * Get current card element state (reactive)\n */\n getState(): CardElementState {\n return this.store.state;\n }\n\n /**\n * Initialize and mount card elements to DOM\n * @param containerElement - Parent element containing mount points\n * @returns Promise resolving to card element instances\n */\n async initialize(containerElement: HTMLElement): Promise<CardElementInstances> {\n const elements = this.stripeService.getElements();\n\n if (!elements) {\n throw new Error('StripeService not initialized. Call StripeService.initialize() first.');\n }\n\n // Unmount if already initialized\n if (this.cardElements) {\n this.unmount();\n }\n\n // Create and mount card number element\n const cardNumber = elements.create('cardNumber', {\n placeholder: i18n.t('Card Number'),\n });\n const cardNumberElement = await this.findElement(containerElement, '#card-number');\n cardNumber.mount(cardNumberElement);\n cardNumber.on('change', this.handleCardError('cardNumber'));\n\n // Create and mount card expiry element\n const cardExpiry = elements.create('cardExpiry');\n const cardExpiryElement = await this.findElement(containerElement, '#card-expiry');\n cardExpiry.mount(cardExpiryElement);\n cardExpiry.on('change', this.handleCardError('cardExpiry'));\n\n // Create and mount card CVC element\n const cardCVC = elements.create('cardCvc');\n const cardCVCElement = await this.findElement(containerElement, '#card-cvc');\n cardCVC.mount(cardCVCElement);\n cardCVC.on('change', this.handleCardError('cardCvc'));\n\n this.cardElements = {\n cardNumber,\n cardExpiry,\n cardCVC,\n };\n\n return this.cardElements;\n }\n\n /**\n * Get mounted card element instances\n */\n getElements(): CardElementInstances | undefined {\n return this.cardElements;\n }\n\n /**\n * Set error message (triggers reactivity)\n */\n setError(message: string): void {\n this.store.set('errorMessage', message);\n }\n\n /**\n * Clear error message (triggers reactivity)\n */\n clearError(): void {\n this.store.set('errorMessage', '');\n this.store.set('errorSource', undefined);\n }\n\n /**\n * Unmount all card elements\n */\n unmount(): void {\n if (!this.cardElements) {\n return;\n }\n\n this.cardElements.cardNumber?.unmount();\n this.cardElements.cardExpiry?.unmount();\n this.cardElements.cardCVC?.unmount();\n\n this.cardElements = undefined;\n }\n\n /**\n * Handle card element errors\n * Only clears error if it's from the same element type\n * Uses store.set() to trigger reactivity\n */\n private handleCardError(elementType: 'cardNumber' | 'cardExpiry' | 'cardCvc') {\n return ({ error }) => {\n if (error) {\n this.store.set('errorMessage', error.message);\n this.store.set('errorSource', elementType);\n return;\n }\n\n // Only clear error if it originated from the same element\n if (this.store.state.errorSource === elementType) {\n this.store.set('errorMessage', '');\n this.store.set('errorSource', undefined);\n }\n };\n }\n\n /**\n * Wait for an element to appear in the DOM\n * @param containerElement - Parent element to search in\n * @param selector - CSS selector\n * @param timeout - Timeout in milliseconds (default: 5000ms)\n * @returns Promise that resolves to the found element or rejects on timeout\n */\n private findElement(containerElement: HTMLElement, selector: string, timeout = 5000): Promise<HTMLElement> {\n return new Promise((resolve, reject) => {\n const elem = containerElement.querySelector(selector);\n if (elem) {\n return resolve(elem as HTMLElement);\n }\n\n const timeoutId = setTimeout(() => {\n observer.disconnect();\n reject(new Error(`Element \"${selector}\" not found within ${timeout}ms`));\n }, timeout);\n\n const observer = new MutationObserver(() => {\n const elem = containerElement.querySelector(selector);\n if (elem) {\n clearTimeout(timeoutId);\n observer.disconnect();\n resolve(elem as HTMLElement);\n }\n });\n\n observer.observe(containerElement, {\n childList: true,\n subtree: true,\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"card-element-manager.js","sourceRoot":"","sources":["../../src/services/card-element-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAO7B;;;OAGG;IACH,YAAoB,aAA6B;QAA7B,kBAAa,GAAb,aAAa,CAAgB;QATzC,UAAK,GAAG,WAAW,CAAmB;YAC5C,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,SAAS;SACvB,CAAC,CAAC;IAMiD,CAAC;IAErD;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,gBAA6B;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;QAElD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;QAC3F,CAAC;QAED,iCAAiC;QACjC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;QAED,uCAAuC;QACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE;YAC/C,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC;SACnC,CAAC,CAAC;QACH,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAE9E,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACpC,UAAU,CAAC,EAAE,CAAC,QAAQ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OAAO;QACT,CAAC;QAED,MAAA,IAAI,CAAC,YAAY,CAAC,UAAU,0CAAE,OAAO,EAAE,CAAC;QACxC,MAAA,IAAI,CAAC,YAAY,CAAC,UAAU,0CAAE,OAAO,EAAE,CAAC;QACxC,MAAA,IAAI,CAAC,YAAY,CAAC,OAAO,0CAAE,OAAO,EAAE,CAAC;QAErC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACK,eAAe,CAAC,WAAoD;QAC1E,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;YACnB,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC9C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;gBAC3C,OAAO;YACT,CAAC;YAED,0DAA0D;YAC1D,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;gBACjD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;gBACnC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { ICardElementManager, IStripeService, CardElementInstances, CardElementState } from './interfaces';\nimport { i18n } from '../utils/i18n';\nimport { createStore } from '@stencil/store';\nimport { findElement } from '../utils/element-finder';\n\n/**\n * Card Element Manager\n * Manages Stripe Card Elements (cardNumber, cardExpiry, cardCvc)\n * with dependency injection of StripeService\n */\nexport class CardElementManager implements ICardElementManager {\n private cardElements?: CardElementInstances;\n private store = createStore<CardElementState>({\n errorMessage: '',\n errorSource: undefined,\n });\n\n /**\n * Constructor with dependency injection\n * @param stripeService - Injected Stripe service instance\n */\n constructor(private stripeService: IStripeService) {}\n\n /**\n * Get current card element state (reactive)\n */\n getState(): CardElementState {\n return this.store.state;\n }\n\n /**\n * Initialize and mount card elements to DOM\n * @param containerElement - Parent element containing mount points\n * @returns Promise resolving to card element instances\n */\n async initialize(containerElement: HTMLElement): Promise<CardElementInstances> {\n const elements = this.stripeService.getElements();\n\n if (!elements) {\n throw new Error('StripeService not initialized. Call StripeService.initialize() first.');\n }\n\n // Unmount if already initialized\n if (this.cardElements) {\n this.unmount();\n }\n\n // Create and mount card number element\n const cardNumber = elements.create('cardNumber', {\n placeholder: i18n.t('Card Number'),\n });\n const cardNumberElement = await findElement(containerElement, '#card-number');\n\n cardNumber.mount(cardNumberElement);\n cardNumber.on('change', this.handleCardError('cardNumber'));\n\n // Create and mount card expiry element\n const cardExpiry = elements.create('cardExpiry');\n const cardExpiryElement = await findElement(containerElement, '#card-expiry');\n\n cardExpiry.mount(cardExpiryElement);\n cardExpiry.on('change', this.handleCardError('cardExpiry'));\n\n // Create and mount card CVC element\n const cardCVC = elements.create('cardCvc');\n const cardCVCElement = await findElement(containerElement, '#card-cvc');\n\n cardCVC.mount(cardCVCElement);\n cardCVC.on('change', this.handleCardError('cardCvc'));\n\n this.cardElements = {\n cardNumber,\n cardExpiry,\n cardCVC,\n };\n\n return this.cardElements;\n }\n\n /**\n * Get mounted card element instances\n */\n getElements(): CardElementInstances | undefined {\n return this.cardElements;\n }\n\n /**\n * Set error message (triggers reactivity)\n */\n setError(message: string): void {\n this.store.set('errorMessage', message);\n }\n\n /**\n * Clear error message (triggers reactivity)\n */\n clearError(): void {\n this.store.set('errorMessage', '');\n this.store.set('errorSource', undefined);\n }\n\n /**\n * Unmount all card elements\n */\n unmount(): void {\n if (!this.cardElements) {\n return;\n }\n\n this.cardElements.cardNumber?.unmount();\n this.cardElements.cardExpiry?.unmount();\n this.cardElements.cardCVC?.unmount();\n\n this.cardElements = undefined;\n }\n\n /**\n * Handle card element errors\n * Only clears error if it's from the same element type\n * Uses store.set() to trigger reactivity\n */\n private handleCardError(elementType: 'cardNumber' | 'cardExpiry' | 'cardCvc') {\n return ({ error }) => {\n if (error) {\n this.store.set('errorMessage', error.message);\n this.store.set('errorSource', elementType);\n return;\n }\n\n // Only clear error if it originated from the same element\n if (this.store.state.errorSource === elementType) {\n this.store.set('errorMessage', '');\n this.store.set('errorSource', undefined);\n }\n };\n }\n}\n"]}
@@ -0,0 +1,92 @@
1
+ import { createStore } from "@stencil/store";
2
+ import { findElement } from "../utils/element-finder";
3
+ /**
4
+ * Currency Selector Element Manager
5
+ * Manages Stripe Currency Selector Element
6
+ * with dependency injection of StripeService
7
+ */
8
+ export class CurrencySelectorElementManager {
9
+ /**
10
+ * Constructor with dependency injection
11
+ * @param stripeService - Injected Stripe service instance
12
+ */
13
+ constructor(stripeService) {
14
+ this.stripeService = stripeService;
15
+ this.store = createStore({
16
+ errorMessage: '',
17
+ selectedCurrency: undefined,
18
+ });
19
+ }
20
+ /**
21
+ * Get current currency selector element state (reactive)
22
+ */
23
+ getState() {
24
+ return this.store.state;
25
+ }
26
+ /**
27
+ * Initialize and mount currency selector element to DOM
28
+ * @param containerElement - Parent element containing mount point
29
+ * @param options - Currency selector element options
30
+ * @returns Promise resolving to currency selector element instance
31
+ * Note: StripeCurrencySelectorElementOptions is not yet exported in @stripe/stripe-js v8.6.0
32
+ */
33
+ async initialize(containerElement, options) {
34
+ const elements = this.stripeService.getElements();
35
+ if (!elements) {
36
+ throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
37
+ }
38
+ // Unmount if already initialized
39
+ if (this.currencySelectorElement) {
40
+ this.unmount();
41
+ }
42
+ // Find mount point first to avoid element leak if findElement throws
43
+ const currencySelectorElementContainer = await findElement(containerElement, '#currency-selector');
44
+ // Create and mount currency selector element
45
+ // Note: 'currencySelector' type is not yet in @stripe/stripe-js v8.6.0 type definitions
46
+ // but is documented in Stripe's Currency Selector Element documentation
47
+ this.currencySelectorElement = elements.create('currencySelector', options || {});
48
+ this.currencySelectorElement.mount(currencySelectorElementContainer);
49
+ // Listen for changes
50
+ // Note: The 'change' event type is not yet in @stripe/stripe-js type definitions
51
+ // but is documented in Stripe's Currency Selector Element documentation
52
+ this.currencySelectorElement.on('change', (event) => {
53
+ var _a;
54
+ // Clear error on change
55
+ this.store.set('errorMessage', '');
56
+ // Update selected currency if available
57
+ if ((_a = event === null || event === void 0 ? void 0 : event.value) === null || _a === void 0 ? void 0 : _a.currency) {
58
+ this.store.set('selectedCurrency', event.value.currency);
59
+ }
60
+ });
61
+ return this.currencySelectorElement;
62
+ }
63
+ /**
64
+ * Get mounted currency selector element instance
65
+ */
66
+ getElement() {
67
+ return this.currencySelectorElement;
68
+ }
69
+ /**
70
+ * Set error message (triggers reactivity)
71
+ */
72
+ setError(message) {
73
+ this.store.set('errorMessage', message);
74
+ }
75
+ /**
76
+ * Clear error message (triggers reactivity)
77
+ */
78
+ clearError() {
79
+ this.store.set('errorMessage', '');
80
+ }
81
+ /**
82
+ * Unmount currency selector element
83
+ */
84
+ unmount() {
85
+ if (!this.currencySelectorElement) {
86
+ return;
87
+ }
88
+ this.currencySelectorElement.unmount();
89
+ this.currencySelectorElement = undefined;
90
+ }
91
+ }
92
+ //# sourceMappingURL=currency-selector-element-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency-selector-element-manager.js","sourceRoot":"","sources":["../../src/services/currency-selector-element-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,OAAO,8BAA8B;IAOzC;;;OAGG;IACH,YAAoB,aAA6B;QAA7B,kBAAa,GAAb,aAAa,CAAgB;QATzC,UAAK,GAAG,WAAW,CAA+B;YACxD,YAAY,EAAE,EAAE;YAChB,gBAAgB,EAAE,SAAS;SAC5B,CAAC,CAAC;IAMiD,CAAC;IAErD;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC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CAAC,uBAAuB,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAe;QACtB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAClC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import type { ICurrencySelectorElementManager, IStripeService, CurrencySelectorElementState } from './interfaces';\nimport { StripeCurrencySelectorElement } from '@stripe/stripe-js';\nimport { createStore } from '@stencil/store';\nimport { findElement } from '../utils/element-finder';\n\n/**\n * Currency Selector Element Manager\n * Manages Stripe Currency Selector Element\n * with dependency injection of StripeService\n */\nexport class CurrencySelectorElementManager implements ICurrencySelectorElementManager {\n private currencySelectorElement?: StripeCurrencySelectorElement;\n private store = createStore<CurrencySelectorElementState>({\n errorMessage: '',\n selectedCurrency: undefined,\n });\n\n /**\n * Constructor with dependency injection\n * @param stripeService - Injected Stripe service instance\n */\n constructor(private stripeService: IStripeService) {}\n\n /**\n * Get current currency selector element state (reactive)\n */\n getState(): CurrencySelectorElementState {\n return this.store.state;\n }\n\n /**\n * Initialize and mount currency selector element to DOM\n * @param containerElement - Parent element containing mount point\n * @param options - Currency selector element options\n * @returns Promise resolving to currency selector element instance\n * Note: StripeCurrencySelectorElementOptions is not yet exported in @stripe/stripe-js v8.6.0\n */\n async initialize(containerElement: HTMLElement, options?: any): Promise<StripeCurrencySelectorElement> {\n const elements = this.stripeService.getElements();\n\n if (!elements) {\n throw new Error('StripeService not initialized. Call StripeService.initialize() first.');\n }\n\n // Unmount if already initialized\n if (this.currencySelectorElement) {\n this.unmount();\n }\n\n // Find mount point first to avoid element leak if findElement throws\n const currencySelectorElementContainer = await findElement(containerElement, '#currency-selector');\n\n // Create and mount currency selector element\n // Note: 'currencySelector' type is not yet in @stripe/stripe-js v8.6.0 type definitions\n // but is documented in Stripe's Currency Selector Element documentation\n this.currencySelectorElement = (elements as any).create('currencySelector', options || {}) as StripeCurrencySelectorElement;\n\n this.currencySelectorElement.mount(currencySelectorElementContainer);\n\n // Listen for changes\n // Note: The 'change' event type is not yet in @stripe/stripe-js type definitions\n // but is documented in Stripe's Currency Selector Element documentation\n (this.currencySelectorElement as any).on('change', (event: any) => {\n // Clear error on change\n this.store.set('errorMessage', '');\n\n // Update selected currency if available\n if (event?.value?.currency) {\n this.store.set('selectedCurrency', event.value.currency);\n }\n });\n\n return this.currencySelectorElement;\n }\n\n /**\n * Get mounted currency selector element instance\n */\n getElement(): StripeCurrencySelectorElement | undefined {\n return this.currencySelectorElement;\n }\n\n /**\n * Set error message (triggers reactivity)\n */\n setError(message: string): void {\n this.store.set('errorMessage', message);\n }\n\n /**\n * Clear error message (triggers reactivity)\n */\n clearError(): void {\n this.store.set('errorMessage', '');\n }\n\n /**\n * Unmount currency selector element\n */\n unmount(): void {\n if (!this.currencySelectorElement) {\n return;\n }\n\n this.currencySelectorElement.unmount();\n this.currencySelectorElement = undefined;\n }\n}\n"]}
@@ -0,0 +1,131 @@
1
+ import { createStore } from "@stencil/store";
2
+ import { findElement } from "../utils/element-finder";
3
+ /**
4
+ * Express Checkout Element Manager
5
+ * Manages Stripe Express Checkout Element
6
+ * with dependency injection of StripeService
7
+ */
8
+ export class ExpressCheckoutElementManager {
9
+ /**
10
+ * Constructor with dependency injection
11
+ * @param stripeService - Injected Stripe service instance
12
+ */
13
+ constructor(stripeService) {
14
+ this.stripeService = stripeService;
15
+ this.store = createStore({
16
+ errorMessage: '',
17
+ isReady: false,
18
+ });
19
+ }
20
+ /**
21
+ * Get current express checkout element state (reactive)
22
+ */
23
+ getState() {
24
+ return this.store.state;
25
+ }
26
+ /**
27
+ * Initialize and mount express checkout element to DOM
28
+ * @param containerElement - Parent element containing mount point
29
+ * @param options - Express Checkout Element configuration options
30
+ * @param eventHandlers - Event handlers for element events
31
+ * @returns Promise resolving to express checkout element instance
32
+ */
33
+ async initialize(containerElement, options, eventHandlers) {
34
+ const elements = this.stripeService.getElements();
35
+ if (!elements) {
36
+ throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
37
+ }
38
+ // Unmount if already initialized
39
+ if (this.expressCheckoutElement) {
40
+ this.unmount();
41
+ }
42
+ // Convert buttonHeight from string to number if present
43
+ const createOptions = Object.assign({}, options);
44
+ if (createOptions.buttonHeight && typeof createOptions.buttonHeight === 'string') {
45
+ const height = parseInt(createOptions.buttonHeight.replace('px', ''), 10);
46
+ if (!isNaN(height)) {
47
+ createOptions.buttonHeight = height;
48
+ }
49
+ }
50
+ // Create express checkout element
51
+ // Note: 'expressCheckout' is not yet in the official Stripe type definitions
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ const expressCheckout = elements.create('expressCheckout', createOptions);
54
+ // Find the mount point
55
+ const mountPoint = await findElement(containerElement, '#express-checkout-element');
56
+ // Set up event handlers before mounting
57
+ if (eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onConfirm) {
58
+ expressCheckout.on('confirm', eventHandlers.onConfirm);
59
+ }
60
+ if (eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onClick) {
61
+ expressCheckout.on('click', eventHandlers.onClick);
62
+ }
63
+ if (eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onCancel) {
64
+ expressCheckout.on('cancel', eventHandlers.onCancel);
65
+ }
66
+ if (eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onShippingAddressChange) {
67
+ expressCheckout.on('shippingaddresschange', eventHandlers.onShippingAddressChange);
68
+ }
69
+ if (eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onShippingRateChange) {
70
+ expressCheckout.on('shippingratechange', eventHandlers.onShippingRateChange);
71
+ }
72
+ // Add ready event handler
73
+ expressCheckout.on('ready', () => {
74
+ this.store.set('isReady', true);
75
+ });
76
+ // Mount the element
77
+ expressCheckout.mount(mountPoint);
78
+ this.expressCheckoutElement = expressCheckout;
79
+ return this.expressCheckoutElement;
80
+ }
81
+ /**
82
+ * Get mounted express checkout element instance
83
+ */
84
+ getElement() {
85
+ return this.expressCheckoutElement;
86
+ }
87
+ /**
88
+ * Update element options dynamically
89
+ * @param options - Partial options to update
90
+ */
91
+ update(options) {
92
+ if (!this.expressCheckoutElement) {
93
+ console.warn('Express Checkout Element not initialized. Cannot update options.');
94
+ return;
95
+ }
96
+ // Convert buttonHeight from string to number if present
97
+ const updateOptions = Object.assign({}, options);
98
+ if (updateOptions.buttonHeight && typeof updateOptions.buttonHeight === 'string') {
99
+ const height = parseInt(updateOptions.buttonHeight.replace('px', ''), 10);
100
+ if (!isNaN(height)) {
101
+ updateOptions.buttonHeight = height;
102
+ }
103
+ }
104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+ this.expressCheckoutElement.update(updateOptions);
106
+ }
107
+ /**
108
+ * Set error message (triggers reactivity)
109
+ */
110
+ setError(message) {
111
+ this.store.set('errorMessage', message);
112
+ }
113
+ /**
114
+ * Clear error message (triggers reactivity)
115
+ */
116
+ clearError() {
117
+ this.store.set('errorMessage', '');
118
+ }
119
+ /**
120
+ * Unmount express checkout element
121
+ */
122
+ unmount() {
123
+ if (!this.expressCheckoutElement) {
124
+ return;
125
+ }
126
+ this.expressCheckoutElement.unmount();
127
+ this.expressCheckoutElement = undefined;
128
+ this.store.set('isReady', false);
129
+ }
130
+ }
131
+ //# sourceMappingURL=express-checkout-element-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express-checkout-element-manager.js","sourceRoot":"","sources":["../../src/services/express-checkout-element-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,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import type { IExpressCheckoutElementManager, IStripeService, ExpressCheckoutElementOptions, ExpressCheckoutElementState, ExpressCheckoutElementEventHandlers } from './interfaces';\nimport { StripeExpressCheckoutElement } from '@stripe/stripe-js';\nimport { createStore } from '@stencil/store';\nimport { findElement } from '../utils/element-finder';\n\n/**\n * Express Checkout Element Manager\n * Manages Stripe Express Checkout Element\n * with dependency injection of StripeService\n */\nexport class ExpressCheckoutElementManager implements IExpressCheckoutElementManager {\n private expressCheckoutElement?: StripeExpressCheckoutElement;\n private store = createStore<ExpressCheckoutElementState>({\n errorMessage: '',\n isReady: false,\n });\n\n /**\n * Constructor with dependency injection\n * @param stripeService - Injected Stripe service instance\n */\n constructor(private stripeService: IStripeService) {}\n\n /**\n * Get current express checkout element state (reactive)\n */\n getState(): ExpressCheckoutElementState {\n return this.store.state;\n }\n\n /**\n * Initialize and mount express checkout element to DOM\n * @param containerElement - Parent element containing mount point\n * @param options - Express Checkout Element configuration options\n * @param eventHandlers - Event handlers for element events\n * @returns Promise resolving to express checkout element instance\n */\n async initialize(\n containerElement: HTMLElement,\n options: ExpressCheckoutElementOptions,\n eventHandlers?: ExpressCheckoutElementEventHandlers,\n ): Promise<StripeExpressCheckoutElement> {\n const elements = this.stripeService.getElements();\n\n if (!elements) {\n throw new Error('StripeService not initialized. Call StripeService.initialize() first.');\n }\n\n // Unmount if already initialized\n if (this.expressCheckoutElement) {\n this.unmount();\n }\n\n // Convert buttonHeight from string to number if present\n const createOptions: any = { ...options };\n\n if (createOptions.buttonHeight && typeof createOptions.buttonHeight === 'string') {\n const height = parseInt(createOptions.buttonHeight.replace('px', ''), 10);\n\n if (!isNaN(height)) {\n createOptions.buttonHeight = height;\n }\n }\n\n // Create express checkout element\n // Note: 'expressCheckout' is not yet in the official Stripe type definitions\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const expressCheckout = elements.create('expressCheckout' as any, createOptions as any) as unknown as StripeExpressCheckoutElement;\n\n // Find the mount point\n const mountPoint = await findElement(containerElement, '#express-checkout-element');\n\n // Set up event handlers before mounting\n if (eventHandlers?.onConfirm) {\n expressCheckout.on('confirm', eventHandlers.onConfirm);\n }\n\n if (eventHandlers?.onClick) {\n expressCheckout.on('click', eventHandlers.onClick);\n }\n\n if (eventHandlers?.onCancel) {\n expressCheckout.on('cancel', eventHandlers.onCancel);\n }\n\n if (eventHandlers?.onShippingAddressChange) {\n expressCheckout.on('shippingaddresschange', eventHandlers.onShippingAddressChange);\n }\n\n if (eventHandlers?.onShippingRateChange) {\n expressCheckout.on('shippingratechange', eventHandlers.onShippingRateChange);\n }\n\n // Add ready event handler\n expressCheckout.on('ready', () => {\n this.store.set('isReady', true);\n });\n\n // Mount the element\n expressCheckout.mount(mountPoint);\n\n this.expressCheckoutElement = expressCheckout;\n\n return this.expressCheckoutElement;\n }\n\n /**\n * Get mounted express checkout element instance\n */\n getElement(): StripeExpressCheckoutElement | undefined {\n return this.expressCheckoutElement;\n }\n\n /**\n * Update element options dynamically\n * @param options - Partial options to update\n */\n update(options: Partial<ExpressCheckoutElementOptions>): void {\n if (!this.expressCheckoutElement) {\n console.warn('Express Checkout Element not initialized. Cannot update options.');\n return;\n }\n\n // Convert buttonHeight from string to number if present\n const updateOptions: any = { ...options };\n\n if (updateOptions.buttonHeight && typeof updateOptions.buttonHeight === 'string') {\n const height = parseInt(updateOptions.buttonHeight.replace('px', ''), 10);\n\n if (!isNaN(height)) {\n updateOptions.buttonHeight = height;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.expressCheckoutElement.update(updateOptions as any);\n }\n\n /**\n * Set error message (triggers reactivity)\n */\n setError(message: string): void {\n this.store.set('errorMessage', message);\n }\n\n /**\n * Clear error message (triggers reactivity)\n */\n clearError(): void {\n this.store.set('errorMessage', '');\n }\n\n /**\n * Unmount express checkout element\n */\n unmount(): void {\n if (!this.expressCheckoutElement) {\n return;\n }\n\n this.expressCheckoutElement.unmount();\n this.expressCheckoutElement = undefined;\n this.store.set('isReady', false);\n }\n}\n"]}
@@ -1,5 +1,10 @@
1
1
  import { StripeServiceClass } from "./stripe-service";
2
2
  import { CardElementManager } from "./card-element-manager";
3
+ import { PaymentElementManager } from "./payment-element-manager";
4
+ import { AddressElementManager } from "./address-element-manager";
5
+ import { LinkAuthenticationElementManager } from "./link-authentication-element-manager";
6
+ import { CurrencySelectorElementManager } from "./currency-selector-element-manager";
7
+ import { ExpressCheckoutElementManager } from "./express-checkout-element-manager";
3
8
  /**
4
9
  * Service Factory
5
10
  * Creates service instances with proper dependency injection
@@ -19,6 +24,41 @@ export class ServiceFactory {
19
24
  createCardElementManager(stripeService) {
20
25
  return new CardElementManager(stripeService);
21
26
  }
27
+ /**
28
+ * Create a new PaymentElementManager instance
29
+ * @param stripeService - Injected StripeService dependency
30
+ */
31
+ createPaymentElementManager(stripeService) {
32
+ return new PaymentElementManager(stripeService);
33
+ }
34
+ /**
35
+ * Create a new AddressElementManager instance
36
+ * @param stripeService - Injected StripeService dependency
37
+ */
38
+ createAddressElementManager(stripeService) {
39
+ return new AddressElementManager(stripeService);
40
+ }
41
+ /**
42
+ * Create a new LinkAuthenticationElementManager instance
43
+ * @param stripeService - Injected StripeService dependency
44
+ */
45
+ createLinkAuthenticationElementManager(stripeService) {
46
+ return new LinkAuthenticationElementManager(stripeService);
47
+ }
48
+ /**
49
+ * Create a new CurrencySelectorElementManager instance
50
+ * @param stripeService - Injected StripeService dependency
51
+ */
52
+ createCurrencySelectorElementManager(stripeService) {
53
+ return new CurrencySelectorElementManager(stripeService);
54
+ }
55
+ /**
56
+ * Create a new ExpressCheckoutElementManager instance
57
+ * @param stripeService - Injected StripeService dependency
58
+ */
59
+ createExpressCheckoutElementManager(stripeService) {
60
+ return new ExpressCheckoutElementManager(stripeService);
61
+ }
22
62
  }
23
63
  /**
24
64
  * Default factory instance
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/services/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACzB;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,wBAAwB,CAAC,aAA6B;QACpD,OAAO,IAAI,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import type { IStripeService, ICardElementManager } from './interfaces';\nimport { StripeServiceClass } from './stripe-service';\nimport { CardElementManager } from './card-element-manager';\n\n/**\n * Service Factory\n * Creates service instances with proper dependency injection\n * Can be mocked in tests for better testability\n */\nexport class ServiceFactory {\n /**\n * Create a new StripeService instance\n */\n createStripeService(): IStripeService {\n return new StripeServiceClass();\n }\n\n /**\n * Create a new CardElementManager instance\n * @param stripeService - Injected StripeService dependency\n */\n createCardElementManager(stripeService: IStripeService): ICardElementManager {\n return new CardElementManager(stripeService);\n }\n}\n\n/**\n * Default factory instance\n * Can be replaced with a mock in tests\n */\nexport const serviceFactory = new ServiceFactory();\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/services/factory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACzB;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,wBAAwB,CAAC,aAA6B;QACpD,OAAO,IAAI,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,2BAA2B,CAAC,aAA6B;QACvD,OAAO,IAAI,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACH,2BAA2B,CAAC,aAA6B;QACvD,OAAO,IAAI,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACH,sCAAsC,CAAC,aAA6B;QAClE,OAAO,IAAI,gCAAgC,CAAC,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACH,oCAAoC,CAAC,aAA6B;QAChE,OAAO,IAAI,8BAA8B,CAAC,aAAa,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,mCAAmC,CAAC,aAA6B;QAC/D,OAAO,IAAI,6BAA6B,CAAC,aAAa,CAAC,CAAC;IAC1D,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import type {\n IStripeService,\n ICardElementManager,\n IPaymentElementManager,\n IAddressElementManager,\n ILinkAuthenticationElementManager,\n ICurrencySelectorElementManager,\n IExpressCheckoutElementManager,\n} from './interfaces';\nimport { StripeServiceClass } from './stripe-service';\nimport { CardElementManager } from './card-element-manager';\nimport { PaymentElementManager } from './payment-element-manager';\nimport { AddressElementManager } from './address-element-manager';\nimport { LinkAuthenticationElementManager } from './link-authentication-element-manager';\nimport { CurrencySelectorElementManager } from './currency-selector-element-manager';\nimport { ExpressCheckoutElementManager } from './express-checkout-element-manager';\n\n/**\n * Service Factory\n * Creates service instances with proper dependency injection\n * Can be mocked in tests for better testability\n */\nexport class ServiceFactory {\n /**\n * Create a new StripeService instance\n */\n createStripeService(): IStripeService {\n return new StripeServiceClass();\n }\n\n /**\n * Create a new CardElementManager instance\n * @param stripeService - Injected StripeService dependency\n */\n createCardElementManager(stripeService: IStripeService): ICardElementManager {\n return new CardElementManager(stripeService);\n }\n\n /**\n * Create a new PaymentElementManager instance\n * @param stripeService - Injected StripeService dependency\n */\n createPaymentElementManager(stripeService: IStripeService): IPaymentElementManager {\n return new PaymentElementManager(stripeService);\n }\n\n /**\n * Create a new AddressElementManager instance\n * @param stripeService - Injected StripeService dependency\n */\n createAddressElementManager(stripeService: IStripeService): IAddressElementManager {\n return new AddressElementManager(stripeService);\n }\n\n /**\n * Create a new LinkAuthenticationElementManager instance\n * @param stripeService - Injected StripeService dependency\n */\n createLinkAuthenticationElementManager(stripeService: IStripeService): ILinkAuthenticationElementManager {\n return new LinkAuthenticationElementManager(stripeService);\n }\n\n /**\n * Create a new CurrencySelectorElementManager instance\n * @param stripeService - Injected StripeService dependency\n */\n createCurrencySelectorElementManager(stripeService: IStripeService): ICurrencySelectorElementManager {\n return new CurrencySelectorElementManager(stripeService);\n }\n\n /**\n * Create a new ExpressCheckoutElementManager instance\n * @param stripeService - Injected StripeService dependency\n */\n createExpressCheckoutElementManager(stripeService: IStripeService): IExpressCheckoutElementManager {\n return new ExpressCheckoutElementManager(stripeService);\n }\n}\n\n/**\n * Default factory instance\n * Can be replaced with a mock in tests\n */\nexport const serviceFactory = new ServiceFactory();\n"]}