stripe-pwa-elements 3.2.0 → 4.0.0

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 (232) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -3
  2. package/dist/cjs/error-FFC4kSs5.js +0 -3
  3. package/dist/cjs/{factory-CbbbSvkg.js → factory-da3xAKkz.js} +194 -73
  4. package/dist/cjs/{index-Ba1pBePA.js → index-CYbA1N_k.js} +24 -6
  5. package/dist/cjs/index-Dkb0SxZc.js +4694 -0
  6. package/dist/cjs/index.cjs.js +0 -1
  7. package/dist/cjs/ion-icon.cjs.entry.js +22 -13
  8. package/dist/cjs/loader.cjs.js +2 -3
  9. package/dist/cjs/stripe-address-element.cjs.entry.js +34 -26
  10. package/dist/cjs/stripe-card-element-modal.cjs.entry.js +6 -7
  11. package/dist/cjs/stripe-card-element_2.cjs.entry.js +106 -67
  12. package/dist/cjs/stripe-currency-selector.cjs.entry.js +13 -10
  13. package/dist/cjs/stripe-elements.cjs.js +31 -5
  14. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +25 -22
  15. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +13 -10
  16. package/dist/cjs/stripe-payment-element.cjs.entry.js +190 -131
  17. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +12 -7
  18. package/dist/collection/collection-manifest.json +3 -2
  19. package/dist/collection/components/stripe-address-element/stripe-address-element.js +29 -21
  20. package/dist/collection/components/stripe-card-element/stripe-card-element.helpers.js +57 -0
  21. package/dist/collection/components/stripe-card-element/stripe-card-element.js +55 -68
  22. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +15 -11
  23. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +10 -6
  24. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +28 -20
  25. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +12 -7
  26. package/dist/collection/components/stripe-modal/stripe-modal.js +0 -1
  27. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +114 -0
  28. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +69 -126
  29. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +34 -12
  30. package/dist/collection/index.js +0 -1
  31. package/dist/collection/interfaces.js +0 -1
  32. package/dist/collection/services/address-element-manager.js +3 -4
  33. package/dist/collection/services/card-element-manager.js +3 -4
  34. package/dist/collection/services/currency-selector-element-manager.js +3 -4
  35. package/dist/collection/services/express-checkout-element-manager.js +9 -10
  36. package/dist/collection/services/factory.js +0 -1
  37. package/dist/collection/services/interfaces.js +0 -1
  38. package/dist/collection/services/link-authentication-element-manager.js +3 -4
  39. package/dist/collection/services/payment-element-manager.js +4 -5
  40. package/dist/collection/services/stripe-service.js +5 -6
  41. package/dist/collection/utils/element-finder.js +2 -3
  42. package/dist/collection/utils/error.js +0 -1
  43. package/dist/collection/utils/i18n.js +0 -1
  44. package/dist/collection/utils/platform.js +0 -1
  45. package/dist/collection/utils/test-setup.js +0 -1
  46. package/dist/collection/utils/utils.js +2 -3
  47. package/dist/components/error.js +1 -16
  48. package/dist/components/factory.js +1 -3736
  49. package/dist/components/icon.js +1 -459
  50. package/dist/components/index.d.ts +2 -0
  51. package/dist/components/index.js +1 -4
  52. package/dist/components/index2.js +1 -192
  53. package/dist/components/ion-icon.js +1 -9
  54. package/dist/components/stripe-address-element.js +1 -327
  55. package/dist/components/stripe-card-element-modal.js +1 -174
  56. package/dist/components/stripe-card-element.js +1 -9
  57. package/dist/components/stripe-card-element2.js +1 -440
  58. package/dist/components/stripe-currency-selector.js +1 -218
  59. package/dist/components/stripe-express-checkout-element.js +1 -332
  60. package/dist/components/stripe-link-authentication-element.js +1 -256
  61. package/dist/components/stripe-modal.js +1 -9
  62. package/dist/components/stripe-modal2.js +1 -112
  63. package/dist/components/stripe-payment-element.js +1 -510
  64. package/dist/components/stripe-payment-request-button.js +1 -9
  65. package/dist/components/stripe-payment-request-button2.js +1 -224
  66. package/dist/components/utils.js +1 -89
  67. package/dist/esm/app-globals-DQuL1Twl.js +0 -3
  68. package/dist/esm/error-XRfh5Wrs.js +0 -3
  69. package/dist/esm/{factory-Drde6-y7.js → factory-DeqoYLf_.js} +194 -73
  70. package/dist/esm/index-C6bbmyga.js +4677 -0
  71. package/dist/esm/{index-BHDCxQOb.js → index-CBXaOfXU.js} +24 -6
  72. package/dist/esm/index.js +0 -1
  73. package/dist/esm/ion-icon.entry.js +22 -13
  74. package/dist/esm/loader.js +3 -4
  75. package/dist/esm/stripe-address-element.entry.js +34 -26
  76. package/dist/esm/stripe-card-element-modal.entry.js +6 -7
  77. package/dist/esm/stripe-card-element_2.entry.js +106 -67
  78. package/dist/esm/stripe-currency-selector.entry.js +13 -10
  79. package/dist/esm/stripe-elements.js +32 -6
  80. package/dist/esm/stripe-express-checkout-element.entry.js +25 -22
  81. package/dist/esm/stripe-link-authentication-element.entry.js +13 -10
  82. package/dist/esm/stripe-payment-element.entry.js +190 -131
  83. package/dist/esm/stripe-payment-request-button.entry.js +12 -7
  84. package/dist/stripe-elements/index.esm.js +0 -2
  85. package/dist/stripe-elements/p--sA2m1ad.js +1 -0
  86. package/dist/stripe-elements/p-38e7b187.entry.js +1 -0
  87. package/dist/stripe-elements/p-44495284.entry.js +1 -0
  88. package/dist/stripe-elements/p-4ba675fa.entry.js +1 -0
  89. package/dist/stripe-elements/p-5cf62945.entry.js +1 -0
  90. package/dist/stripe-elements/p-C6bbmyga.js +2 -0
  91. package/dist/stripe-elements/p-CBXaOfXU.js +1 -0
  92. package/dist/stripe-elements/p-DQuL1Twl.js +1 -2
  93. package/dist/stripe-elements/p-XRfh5Wrs.js +1 -2
  94. package/dist/stripe-elements/p-c24ae181.entry.js +1 -0
  95. package/dist/stripe-elements/p-d9e86451.entry.js +1 -0
  96. package/dist/stripe-elements/p-f09c86a0.entry.js +1 -0
  97. package/dist/stripe-elements/p-f64f394d.entry.js +1 -0
  98. package/dist/stripe-elements/p-f6d2425e.entry.js +1 -0
  99. package/dist/stripe-elements/stripe-elements.esm.js +1 -2
  100. package/dist/stripe-elements/svg/.gitignore +4 -0
  101. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +5 -1
  102. package/dist/types/components/stripe-card-element/stripe-card-element.helpers.d.ts +29 -0
  103. package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +4 -4
  104. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +2 -2
  105. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +54 -0
  106. package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +8 -0
  107. package/dist/types/components.d.ts +139 -29
  108. package/dist/types/index.d.ts +1 -0
  109. package/dist/types/services/interfaces.d.ts +3 -3
  110. package/dist/types/services/stripe-service.d.ts +2 -2
  111. package/dist/types/stencil-public-runtime.d.ts +110 -5
  112. package/package.json +50 -30
  113. package/readme.md +386 -133
  114. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  115. package/dist/cjs/error-FFC4kSs5.js.map +0 -1
  116. package/dist/cjs/factory-CbbbSvkg.js.map +0 -1
  117. package/dist/cjs/index-BXVW_rzh.js +0 -1932
  118. package/dist/cjs/index-BXVW_rzh.js.map +0 -1
  119. package/dist/cjs/index-Ba1pBePA.js.map +0 -1
  120. package/dist/cjs/index.cjs.js.map +0 -1
  121. package/dist/cjs/ion-icon.entry.cjs.js.map +0 -1
  122. package/dist/cjs/loader.cjs.js.map +0 -1
  123. package/dist/cjs/stripe-address-element.entry.cjs.js.map +0 -1
  124. package/dist/cjs/stripe-card-element-modal.entry.cjs.js.map +0 -1
  125. package/dist/cjs/stripe-card-element.stripe-modal.entry.cjs.js.map +0 -1
  126. package/dist/cjs/stripe-currency-selector.entry.cjs.js.map +0 -1
  127. package/dist/cjs/stripe-elements.cjs.js.map +0 -1
  128. package/dist/cjs/stripe-express-checkout-element.entry.cjs.js.map +0 -1
  129. package/dist/cjs/stripe-link-authentication-element.entry.cjs.js.map +0 -1
  130. package/dist/cjs/stripe-payment-element.entry.cjs.js.map +0 -1
  131. package/dist/cjs/stripe-payment-request-button.entry.cjs.js.map +0 -1
  132. package/dist/collection/components/stripe-address-element/stripe-address-element.js.map +0 -1
  133. package/dist/collection/components/stripe-card-element/stripe-card-element.js.map +0 -1
  134. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js.map +0 -1
  135. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js.map +0 -1
  136. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js.map +0 -1
  137. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js.map +0 -1
  138. package/dist/collection/components/stripe-modal/stripe-modal.js.map +0 -1
  139. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js.map +0 -1
  140. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js.map +0 -1
  141. package/dist/collection/index.js.map +0 -1
  142. package/dist/collection/interfaces.js.map +0 -1
  143. package/dist/collection/services/address-element-manager.js.map +0 -1
  144. package/dist/collection/services/card-element-manager.js.map +0 -1
  145. package/dist/collection/services/currency-selector-element-manager.js.map +0 -1
  146. package/dist/collection/services/express-checkout-element-manager.js.map +0 -1
  147. package/dist/collection/services/factory.js.map +0 -1
  148. package/dist/collection/services/interfaces.js.map +0 -1
  149. package/dist/collection/services/link-authentication-element-manager.js.map +0 -1
  150. package/dist/collection/services/payment-element-manager.js.map +0 -1
  151. package/dist/collection/services/stripe-service.js.map +0 -1
  152. package/dist/collection/utils/element-finder.js.map +0 -1
  153. package/dist/collection/utils/error.js.map +0 -1
  154. package/dist/collection/utils/i18n.js.map +0 -1
  155. package/dist/collection/utils/platform.js.map +0 -1
  156. package/dist/collection/utils/test-setup.js.map +0 -1
  157. package/dist/collection/utils/utils.js.map +0 -1
  158. package/dist/components/error.js.map +0 -1
  159. package/dist/components/factory.js.map +0 -1
  160. package/dist/components/icon.js.map +0 -1
  161. package/dist/components/index.js.map +0 -1
  162. package/dist/components/index2.js.map +0 -1
  163. package/dist/components/ion-icon.js.map +0 -1
  164. package/dist/components/stripe-address-element.js.map +0 -1
  165. package/dist/components/stripe-card-element-modal.js.map +0 -1
  166. package/dist/components/stripe-card-element.js.map +0 -1
  167. package/dist/components/stripe-card-element2.js.map +0 -1
  168. package/dist/components/stripe-currency-selector.js.map +0 -1
  169. package/dist/components/stripe-express-checkout-element.js.map +0 -1
  170. package/dist/components/stripe-link-authentication-element.js.map +0 -1
  171. package/dist/components/stripe-modal.js.map +0 -1
  172. package/dist/components/stripe-modal2.js.map +0 -1
  173. package/dist/components/stripe-payment-element.js.map +0 -1
  174. package/dist/components/stripe-payment-request-button.js.map +0 -1
  175. package/dist/components/stripe-payment-request-button2.js.map +0 -1
  176. package/dist/components/utils.js.map +0 -1
  177. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  178. package/dist/esm/error-XRfh5Wrs.js.map +0 -1
  179. package/dist/esm/factory-Drde6-y7.js.map +0 -1
  180. package/dist/esm/index-BHDCxQOb.js.map +0 -1
  181. package/dist/esm/index-DJwTOfxZ.js +0 -1920
  182. package/dist/esm/index-DJwTOfxZ.js.map +0 -1
  183. package/dist/esm/index.js.map +0 -1
  184. package/dist/esm/ion-icon.entry.js.map +0 -1
  185. package/dist/esm/loader.js.map +0 -1
  186. package/dist/esm/stripe-address-element.entry.js.map +0 -1
  187. package/dist/esm/stripe-card-element-modal.entry.js.map +0 -1
  188. package/dist/esm/stripe-card-element.stripe-modal.entry.js.map +0 -1
  189. package/dist/esm/stripe-currency-selector.entry.js.map +0 -1
  190. package/dist/esm/stripe-elements.js.map +0 -1
  191. package/dist/esm/stripe-express-checkout-element.entry.js.map +0 -1
  192. package/dist/esm/stripe-link-authentication-element.entry.js.map +0 -1
  193. package/dist/esm/stripe-payment-element.entry.js.map +0 -1
  194. package/dist/esm/stripe-payment-request-button.entry.js.map +0 -1
  195. package/dist/stripe-elements/index.esm.js.map +0 -1
  196. package/dist/stripe-elements/ion-icon.entry.esm.js.map +0 -1
  197. package/dist/stripe-elements/loader.esm.js.map +0 -1
  198. package/dist/stripe-elements/p-02f6e421.entry.js +0 -2
  199. package/dist/stripe-elements/p-02f6e421.entry.js.map +0 -1
  200. package/dist/stripe-elements/p-19888fa6.entry.js +0 -2
  201. package/dist/stripe-elements/p-19888fa6.entry.js.map +0 -1
  202. package/dist/stripe-elements/p-4d505729.entry.js +0 -2
  203. package/dist/stripe-elements/p-4d505729.entry.js.map +0 -1
  204. package/dist/stripe-elements/p-7e7ad92a.entry.js +0 -2
  205. package/dist/stripe-elements/p-7e7ad92a.entry.js.map +0 -1
  206. package/dist/stripe-elements/p-8bb4212c.entry.js +0 -2
  207. package/dist/stripe-elements/p-8bb4212c.entry.js.map +0 -1
  208. package/dist/stripe-elements/p-9aee2b6b.entry.js +0 -2
  209. package/dist/stripe-elements/p-9aee2b6b.entry.js.map +0 -1
  210. package/dist/stripe-elements/p-BHDCxQOb.js +0 -2
  211. package/dist/stripe-elements/p-BHDCxQOb.js.map +0 -1
  212. package/dist/stripe-elements/p-DI2vmGaI.js +0 -2
  213. package/dist/stripe-elements/p-DI2vmGaI.js.map +0 -1
  214. package/dist/stripe-elements/p-DJwTOfxZ.js +0 -3
  215. package/dist/stripe-elements/p-DJwTOfxZ.js.map +0 -1
  216. package/dist/stripe-elements/p-DQuL1Twl.js.map +0 -1
  217. package/dist/stripe-elements/p-XRfh5Wrs.js.map +0 -1
  218. package/dist/stripe-elements/p-ba251393.entry.js +0 -2
  219. package/dist/stripe-elements/p-ba251393.entry.js.map +0 -1
  220. package/dist/stripe-elements/p-c649edfc.entry.js +0 -2
  221. package/dist/stripe-elements/p-c649edfc.entry.js.map +0 -1
  222. package/dist/stripe-elements/p-e8bb43ae.entry.js +0 -2
  223. package/dist/stripe-elements/p-e8bb43ae.entry.js.map +0 -1
  224. package/dist/stripe-elements/stripe-address-element.entry.esm.js.map +0 -1
  225. package/dist/stripe-elements/stripe-card-element-modal.entry.esm.js.map +0 -1
  226. package/dist/stripe-elements/stripe-card-element.stripe-modal.entry.esm.js.map +0 -1
  227. package/dist/stripe-elements/stripe-currency-selector.entry.esm.js.map +0 -1
  228. package/dist/stripe-elements/stripe-elements.esm.js.map +0 -1
  229. package/dist/stripe-elements/stripe-express-checkout-element.entry.esm.js.map +0 -1
  230. package/dist/stripe-elements/stripe-link-authentication-element.entry.esm.js.map +0 -1
  231. package/dist/stripe-elements/stripe-payment-element.entry.esm.js.map +0 -1
  232. package/dist/stripe-elements/stripe-payment-request-button.entry.esm.js.map +0 -1
package/readme.md CHANGED
@@ -1,172 +1,333 @@
1
+ [![npm version](https://img.shields.io/npm/v/stripe-pwa-elements.svg)](https://www.npmjs.com/package/stripe-pwa-elements)
2
+ [![CI](https://github.com/hideokamoto/stripe-pwa-elements/actions/workflows/ci.yml/badge.svg)](https://github.com/hideokamoto/stripe-pwa-elements/actions/workflows/ci.yml)
3
+ [![license](https://img.shields.io/npm/l/stripe-pwa-elements.svg)](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/LICENSE)
4
+ [![npm downloads](https://img.shields.io/npm/dm/stripe-pwa-elements.svg)](https://www.npmjs.com/package/stripe-pwa-elements)
1
5
  ![Built With Stencil](https://img.shields.io/badge/-Built%20With%20Stencil-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square)
2
6
 
3
7
  # stripe-pwa-elements
4
8
 
9
+ Framework-agnostic Stripe payment components built with Web Components. Works with any web framework — React, Vue, Angular, Svelte, or plain HTML.
5
10
 
6
- ## Maintainers
11
+ > **Note:** The current npm package is **`stripe-pwa-elements`** (this repo).
12
+ > The old package `@stripe-elements/stripe-elements` (v2.0.2) is deprecated and superseded — please use `stripe-pwa-elements` instead.
7
13
 
8
- | Maintainer | GitHub | Social |
9
- | --- | --- | --- |
10
- | Hidetaka Okamoto | [Hidetaka Okamoto](https://github.com/hideokamoto) | [@hide__dev](https://twitter.com/hide__dev) |
11
- | Masaki Hirano | [hirano](https://github.com/contiki9) | [@maki_saki](https://twitter.com/maki_saki) |
12
- | Masahiko Sakakibara | [rdlabo](https://github.com/rdlabo) | [@rdlabo](https://twitter.com/rdlabo) |
14
+ ## Used in production
15
+
16
+ [![capacitor-community/stripe](https://img.shields.io/badge/capacitor--community%2Fstripe-4000%2B%20weekly%20downloads-brightgreen)](https://github.com/capacitor-community/stripe)
17
+
18
+ This library powers the Web implementation of [`@capacitor-community/stripe`](https://github.com/capacitor-community/stripe), which receives 4,000+ weekly downloads. If you use Capacitor for cross-platform apps, `stripe-pwa-elements` handles all Stripe UI on the web layer.
19
+
20
+ > **Manual follow-up (external repo):** Add a reciprocal link in the [capacitor-community/stripe README](https://github.com/capacitor-community/stripe) pointing back to this package.
21
+
22
+ ## Why stripe-pwa-elements?
23
+
24
+ Integrating Stripe from scratch requires wiring up several moving parts. This library collapses all of that into a single HTML element.
25
+
26
+ ### Before — raw `@stripe/stripe-js` (≈ 40 lines)
27
+
28
+ ```html
29
+ <div id="payment-element"></div>
30
+ <button id="pay" disabled>Pay</button>
31
+
32
+ <script type="module">
33
+ import { loadStripe } from 'https://esm.sh/@stripe/stripe-js';
34
+
35
+ // 1. Load Stripe.js
36
+ const stripe = await loadStripe('pk_test_xxxxx');
37
+
38
+ // 2. Create an Elements instance with your PaymentIntent client secret
39
+ const elements = stripe.elements({
40
+ clientSecret: 'pi_xxxxx_secret_xxxxx',
41
+ });
42
+
43
+ // 3. Create and mount the Payment Element
44
+ const paymentElement = elements.create('payment');
45
+ paymentElement.mount('#payment-element');
46
+
47
+ // 4. Enable the button once the element is ready
48
+ paymentElement.on('ready', () => {
49
+ document.getElementById('pay').disabled = false;
50
+ });
51
+
52
+ // 5. Handle form submission
53
+ document.getElementById('pay').addEventListener('click', async e => {
54
+ e.preventDefault();
55
+
56
+ // 6. Validate the payment details before confirming
57
+ const { error: submitError } = await elements.submit();
58
+ if (submitError) {
59
+ console.error(submitError.message);
60
+ return;
61
+ }
62
+
63
+ // 7. Confirm the payment (redirects on success)
64
+ const { error } = await stripe.confirmPayment({
65
+ elements,
66
+ confirmParams: {
67
+ return_url: window.location.href,
68
+ },
69
+ });
70
+
71
+ if (error) {
72
+ console.error(error.message);
73
+ }
74
+ });
75
+ </script>
76
+ ```
77
+
78
+ ### After — stripe-pwa-elements (≈ 5 lines)
79
+
80
+ ```html
81
+ <!-- One CDN line registers the custom element -->
82
+ <script type="module" src="https://unpkg.com/stripe-pwa-elements/dist/stripe-elements/stripe-elements.esm.js"></script>
83
+
84
+ <!-- Drop in the element — Stripe.js loading, Elements creation, mounting,
85
+ form submission, and confirmPayment are all handled for you -->
86
+ <stripe-payment-element
87
+ publishable-key="pk_test_xxxxx"
88
+ intent-client-secret="pi_xxxxx_secret_xxxxx"
89
+ ></stripe-payment-element>
90
+ ```
91
+
92
+ The component emits a `defaultFormSubmitResult` event when the payment completes, so you can react to success or failure without writing any Stripe boilerplate.
93
+
94
+ ### Value props
95
+
96
+ - **Framework-agnostic** — Standard Web Components: drop into React, Vue, Angular, Svelte, or plain HTML with no adapter needed.
97
+ - **No build step — one CDN line** — Load via `<script type="module">` from unpkg; no npm, no bundler, no configuration required.
98
+ - **PCI DSS SAQ-A eligible** — All card data is entered inside Stripe-hosted iframes. Your page never touches raw card numbers, keeping you in the lightest PCI self-assessment tier.
99
+
100
+ ### Trust signal
101
+
102
+ [![capacitor-community/stripe — 4000+ weekly downloads](https://img.shields.io/badge/capacitor--community%2Fstripe-4000%2B%20weekly%20downloads-brightgreen)](https://github.com/capacitor-community/stripe)
103
+
104
+ Used in production as the web layer of [`@capacitor-community/stripe`](https://github.com/capacitor-community/stripe), which sees 4,000+ weekly npm downloads across Capacitor-powered iOS and Android apps.
105
+
106
+ ## Features
107
+
108
+ - **Framework-agnostic** — Standard Web Components that work everywhere
109
+ - **Full Stripe Elements coverage** — Card, Payment, Express Checkout, Address, and more
110
+ - **Multiple payment flows** — PaymentIntent, SetupIntent, and Checkout Session
111
+ - **Apple Pay / Google Pay** — Payment Request Button and Express Checkout support
112
+ - **Internationalization** — Built-in i18n support (English, Japanese, Portuguese)
113
+ - **Lightweight** — Minimal dependencies, lazy-loaded Stripe.js
13
114
 
14
115
  ## Installation
15
116
 
117
+ ```bash
118
+ npm install stripe-pwa-elements
119
+ ```
120
+
121
+ ### Upgrading from Stripe.js 8
122
+
123
+ This package now uses Stripe.js 9 (Dahlia). Component methods and event names are unchanged, but Stripe objects exposed through events follow the [Dahlia breaking changes](https://docs.stripe.com/changelog/dahlia):
124
+
125
+ - Replace direct `stripe.initCheckout()` calls and `StripeCheckout` imports with `initCheckoutElementsSdk()` and `StripeCheckoutElementsSdk`. The component's `initStripeWithCheckoutSession()` handles this internally.
126
+ - Handle the Promise returned by `elements.update()` and replace boolean `layout.radios` options with supported string values.
127
+ - Replace legacy Sources/Intent methods (including `createSource` in older examples) with current Payment Methods/Intent APIs. Direct Embedded Checkout integrations must use `createEmbeddedCheckoutPage()`.
128
+ - The Address component explicitly requests localized values to preserve its existing `getValue()` and submit results. Raw Stripe Address Element change events now return Latin-formatted `address.state` values.
129
+ - If you load Stripe.js manually, use `https://js.stripe.com/dahlia/stripe.js` and align other Stripe.js dependencies to v9. Server API versions are managed separately; on Dahlia, this component's Checkout Sessions use `ui_mode: 'elements'`.
130
+
131
+ ### Script tag
132
+
133
+ ```html
134
+ <script type="module" src="https://unpkg.com/stripe-pwa-elements/dist/stripe-elements/stripe-elements.esm.js"></script>
135
+ ```
136
+
137
+ ### ES Module
138
+
139
+ ```javascript
140
+ import { defineCustomElements } from 'stripe-pwa-elements/loader';
141
+ defineCustomElements();
142
+ ```
143
+
144
+ ### Bundlers (Vite, webpack, Capacitor)
145
+
146
+ When using a bundler — including Capacitor apps built with Vite — import the
147
+ components you need directly from the custom-elements build. Each module
148
+ auto-registers its element on import, so no `defineCustomElements()` call is needed:
149
+
150
+ ```javascript
151
+ import 'stripe-pwa-elements/dist/components/stripe-payment-element';
152
+ ```
153
+
154
+ This avoids the runtime dynamic import the lazy `loader` relies on, which can fail
155
+ with `Failed to fetch dynamically imported module` under Vite. See the
156
+ [Bundler Integration guide](https://stripe-pwa-elements-docs.workers.dev/en/guides/bundler-integration/)
157
+ for Vite/webpack/Rollup and Capacitor setup examples.
16
158
 
17
159
  ## Components
18
160
 
19
161
  ### `<stripe-card-element>`
20
162
 
21
- Provide a Stripe Card form using Stripe Card Elements.
163
+ Stripe Card form with split fields (card number, expiry, CVC).
22
164
 
23
- https://github.com/stripe-elements/stripe-elements/blob/main/src/components/stripe-card-element/readme.md
165
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-card-element/readme.md)
24
166
 
25
- ### `<stripe-modal>`
167
+ ### `<stripe-payment-element>`
26
168
 
27
- Simple modal wrapper for payment components.
169
+ Unified payment form supporting multiple payment methods.
28
170
 
29
- https://github.com/stripe-elements/stripe-elements/blob/main/src/components/stripe-modal/readme.md
171
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-payment-element/readme.md)
30
172
 
31
- ### `<stripe-card-element-modal>`
173
+ ### `<stripe-express-checkout-element>`
32
174
 
33
- Combined component: Card Element with Modal wrapper.
175
+ Express Checkout with Apple Pay, Google Pay, Link, and more.
34
176
 
35
- https://github.com/stripe-elements/stripe-elements/blob/main/src/components/stripe-card-element-modal/readme.md
177
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-express-checkout-element/readme.md)
36
178
 
37
179
  ### `<stripe-payment-request-button>`
38
180
 
39
- (Beta) Payment Request API button component (Apple Pay / Google Pay).
181
+ (Beta) Payment Request API button (Apple Pay / Google Pay).
182
+
183
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-payment-request-button/readme.md)
184
+
185
+ ### `<stripe-address-element>`
186
+
187
+ Address collection form with autocomplete.
188
+
189
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-address-element/readme.md)
190
+
191
+ ### `<stripe-link-authentication-element>`
192
+
193
+ Email collection with Stripe Link one-click checkout.
194
+
195
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-link-authentication-element/readme.md)
196
+
197
+ ### `<stripe-currency-selector>`
198
+
199
+ Currency selection component.
200
+
201
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-currency-selector/readme.md)
202
+
203
+ ### `<stripe-modal>`
204
+
205
+ Modal wrapper for payment components.
40
206
 
41
- https://github.com/stripe-elements/stripe-elements/blob/main/src/components/stripe-payment-request-button/readme.md
207
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-modal/readme.md)
42
208
 
43
- ## Usage
209
+ ### `<stripe-card-element-modal>`
210
+
211
+ Combined Card Element with Modal wrapper.
212
+
213
+ [Documentation](https://github.com/hideokamoto/stripe-pwa-elements/blob/main/src/components/stripe-card-element-modal/readme.md)
214
+
215
+ ## Quick Start
44
216
 
45
217
  ### HTML
46
218
 
47
219
  ```html
48
- <div id="result"></div>
49
-
50
- <stripe-modal open="true">
51
- <stripe-card-element
52
- publishable-key="pk_test_xxxxx"
53
- show-label="false"
54
- intent-client-secret="pi-xxxxxx"
55
- should-use-default-form-submit-action="false"
56
- ></stripe-card-element>
57
- </stripe-modal>
58
-
59
- <script>
60
- customElements.whenDefined('stripe-card-element')
61
- .then(() => {
62
- const elements = document.getElementsByTagName('stripe-card-element')
63
- if (elements.length < 1) return;
64
- const element = elements[0]
65
- element.addEventListener('formSubmit', async props => {
66
- const {
67
- detail: { stripe, cardNumber, event },
68
- } = props;
69
- const result = await stripe.createPaymentMethod({
70
- type: 'card',
71
- card: cardNumber,
72
- });
73
- element.updateProgress('success');
74
-
75
- const resultElement = document.getElementById('result')
76
- resultElement.innerHTML = `<pre><code>${JSON.stringify(result,null,2)}</code></pre>`
77
- });
78
-
79
- })
80
- </script>
81
- ```
82
-
83
- ### JavaScript
220
+ <stripe-card-element
221
+ publishable-key="pk_test_xxxxx"
222
+ intent-client-secret="pi_xxxxx_secret_xxxxx"
223
+ ></stripe-card-element>
224
+
225
+ <script type="module" src="https://unpkg.com/stripe-pwa-elements/dist/stripe-elements/stripe-elements.esm.js"></script>
226
+ <script>
227
+ customElements.whenDefined('stripe-card-element').then(() => {
228
+ const element = document.querySelector('stripe-card-element');
229
+ element.addEventListener('formSubmit', async ({ detail }) => {
230
+ const { stripe, cardNumber } = detail;
231
+ const result = await stripe.createPaymentMethod({
232
+ type: 'card',
233
+ card: cardNumber,
234
+ });
235
+ console.log(result);
236
+ element.updateProgress('success');
237
+ });
238
+ });
239
+ </script>
240
+ ```
84
241
 
242
+ ### React
85
243
 
86
- ```javascript
87
- const stripePublishableAPIKey = 'YOUR_STRIPE_PUBLISHABLE_API_KEY'
88
-
89
- const form = document.getElementById('open-modal-form')
90
- const resultElement = document.getElementById('result')
91
- const errorMessage = document.getElementById('error-message')
92
- const targetElement = document.getElementById('stripe');
93
- const modalElement = document.createElement('stripe-modal');
94
-
95
- /**
96
- * Remove Mounted Stripe Elements when the modal has been closed
97
- **/
98
- customElements.whenDefined('stripe-modal')
99
- .then(() => {
100
- modalElement.addEventListener('close', () => {
101
- modalElement.innerHTML = ''
102
- })
103
- })
104
-
105
- async function launchStripeCardElement (paymentIntentClientSecret) {
106
- if (!stripePublishableAPIKey) {
107
- errorMessage.innerText = 'Stripe Publishable API Key is required'
108
- return
109
- }
110
- if (!paymentIntentClientSecret) {
111
- errorMessage.innerText = 'Payment Intent Client Secret is required'
112
- return
113
- }
114
-
115
- /**
116
- * Define and launch Web Components
117
- **/
118
- const stripeElement = document.createElement('stripe-card-element');
119
- modalElement.appendChild(stripeElement);
120
- targetElement.appendChild(modalElement);
121
-
122
- /**
123
- * Wait for defining these components
124
- **/
125
- await customElements.whenDefined('stripe-modal')
126
- await customElements.whenDefined('stripe-card-element')
127
-
128
- /**
129
- * Load Stripe Client
130
- **/
131
- await stripeElement.initStripe(stripePublishableAPIKey)
132
-
133
-
134
- /**
135
- * Set the payment intent client secret
136
- **/
137
- stripeElement.setAttribute('intent-client-secret', paymentIntentClientSecret)
138
-
139
- /**
140
- * Disable default form submit event
141
- **/
142
- stripeElement.setAttribute('should-use-default-form-submit-action', false);
143
-
144
- /**
145
- * Set custom form submit event manually
146
- **/
147
- stripeElement.addEventListener('formSubmit', async props => {
148
- const {
149
- detail: { stripe, cardNumber, event },
150
- } = props;
151
- const result = await stripe.createPaymentMethod({
152
- type: 'card',
153
- card: cardNumber,
154
- });
155
- resultElement.innerHTML = `<pre><code>${JSON.stringify(result,null,2)}</code></pre>`
156
- stripeElement.updateProgress('success');
157
- await modalElement.closeModal()
158
- });
159
-
160
- /**
161
- * Open modal
162
- **/
163
- modalElement.setAttribute('open', true)
164
- })
244
+ ```jsx
245
+ import { defineCustomElements } from 'stripe-pwa-elements/loader';
246
+
247
+ defineCustomElements();
248
+
249
+ function PaymentForm() {
250
+ const handleFormSubmit = (e) => {
251
+ const { stripe, cardNumber } = e.detail;
252
+ stripe.createPaymentMethod({ type: 'card', card: cardNumber });
253
+ };
254
+
255
+ return (
256
+ <stripe-card-element
257
+ publishable-key="pk_test_xxxxx"
258
+ intent-client-secret="pi_xxxxx_secret_xxxxx"
259
+ onFormSubmit={handleFormSubmit}
260
+ />
261
+ );
262
+ }
263
+ ```
264
+
265
+ ### Vue
266
+
267
+ ```vue
268
+ <template>
269
+ <stripe-card-element
270
+ publishable-key="pk_test_xxxxx"
271
+ intent-client-secret="pi_xxxxx_secret_xxxxx"
272
+ @formSubmit="handleFormSubmit"
273
+ />
274
+ </template>
275
+
276
+ <script setup>
277
+ import { defineCustomElements } from 'stripe-pwa-elements/loader';
278
+
279
+ defineCustomElements();
280
+
281
+ const handleFormSubmit = (e) => {
282
+ const { stripe, cardNumber } = e.detail;
283
+ stripe.createPaymentMethod({ type: 'card', card: cardNumber });
284
+ };
285
+ </script>
165
286
  ```
166
287
 
288
+ ## Use with AI assistants
289
+
290
+ The documentation site publishes machine-readable plain-text files that AI coding assistants (Claude Code, Cursor, GitHub Copilot, etc.) can use to answer questions about this library without hallucinating outdated API details.
291
+
292
+ | File | Purpose |
293
+ | --- | --- |
294
+ | [`/llms.txt`](https://stripe-pwa-elements-docs.workers.dev/llms.txt) | Index — links to the full and compact documentation sets |
295
+ | [`/llms-full.txt`](https://stripe-pwa-elements-docs.workers.dev/llms-full.txt) | Full API reference for all components |
296
+ | [`/llms-small.txt`](https://stripe-pwa-elements-docs.workers.dev/llms-small.txt) | Compact version with non-essential content removed |
297
+
298
+ These files are generated automatically from the documentation source at build time using the [`starlight-llms-txt`](https://github.com/HiDeoo/starlight-llms-txt) plugin and always reflect the latest published docs.
299
+
300
+ ## Examples
301
+
302
+ See the [example/](./example) directory for complete working examples:
303
+
304
+ - [Card Element (dynamic)](./example/index.html) — JavaScript-driven component creation
305
+ - [Card Element (static)](./example/example2.html) — Declarative HTML markup
306
+ - [Payment Element](./example/example3.html) — Unified payment form
307
+ - [Link Authentication](./example/example4.html) — Email + Link checkout
308
+ - [Address Element](./example/address-example.html) — Address collection
309
+ - [Express Checkout](./example/example-express-checkout.html) — Apple Pay, Google Pay, etc.
310
+
311
+ ## Use with Claude Code
312
+
313
+ This repo ships a [Claude Code](https://claude.com/claude-code) skill that teaches
314
+ the assistant how to integrate `stripe-pwa-elements` correctly — picking the right
315
+ component, wiring the publishable key + client secret, and handling the
316
+ submit/confirm flow. Install it as a plugin:
317
+
318
+ ```text
319
+ /plugin marketplace add hideokamoto/stripe-pwa-elements
320
+ /plugin install stripe-pwa-elements@stripe-pwa-elements
321
+ ```
322
+
323
+ Once installed, the skill activates automatically when Claude detects you are
324
+ working with the library, or you can invoke it explicitly with
325
+ `/stripe-pwa-elements:stripe-pwa-elements`.
326
+
167
327
  ## Contribution
168
328
 
169
329
  ### Getting Started
330
+
170
331
  ```bash
171
332
  npm install
172
333
  npm start
@@ -182,4 +343,96 @@ To run the unit tests for the components, run:
182
343
 
183
344
  ```bash
184
345
  npm test
185
- ```
346
+ ```
347
+
348
+ ## Security & PCI DSS SAQ-A
349
+
350
+ Card data **never** passes through this library's DOM, JavaScript state, or network requests.
351
+ All sensitive input fields (card number, expiry, CVC) are rendered inside **Stripe-hosted iframes**,
352
+ meaning your page never has access to raw card data. This architecture keeps integrations
353
+ eligible for the lightest PCI DSS self-assessment questionnaire: **SAQ-A**.
354
+
355
+ ### How iframe isolation works
356
+
357
+ ```
358
+ Your page (your domain)
359
+ ┌─────────────────────────────────────────────────────────┐
360
+ │ <stripe-card-element> │
361
+ │ ┌───────────────────────────────────────────────────┐ │
362
+ │ │ <iframe src="https://js.stripe.com/..."> │ │
363
+ │ │ ┌─────────────────────────────────────────────┐ │ │
364
+ │ │ │ Card number [____ ____ ____ ____] │ │ │
365
+ │ │ │ Expiry [MM/YY] CVC [___] │ │ │
366
+ │ │ │ │ │ │
367
+ │ │ │ (Stripe's origin — cross-origin boundary) │ │ │
368
+ │ │ └─────────────────────────────────────────────┘ │ │
369
+ │ └───────────────────────────────────────────────────┘ │
370
+ │ │
371
+ │ Your JS can call stripe.confirmPayment() but │
372
+ │ CANNOT read card values from the iframe. │
373
+ └─────────────────────────────────────────────────────────┘
374
+ ```
375
+
376
+ - The browser's **same-origin policy** prevents any JavaScript on your page from reading
377
+ input values inside Stripe's iframe.
378
+ - Card data travels directly from the iframe to **Stripe's servers over TLS** — it never
379
+ touches your application server.
380
+ - This library only manages the mounting, styling, and event wiring of those iframes; it
381
+ does not alter Stripe's security model.
382
+
383
+ For a complete explanation see [Stripe's SAQ-A documentation](https://stripe.com/docs/security/stripe#saq-a).
384
+
385
+ For the vulnerability reporting channel and supply-chain notes (npm provenance), see [SECURITY.md](./SECURITY.md).
386
+
387
+ ---
388
+
389
+ ## Sponsors
390
+
391
+ If stripe-pwa-elements saves you time, please consider sponsoring the lead maintainer:
392
+
393
+ [![Sponsor hideokamoto](https://img.shields.io/badge/Sponsor-%E2%9D%A4-ea4aaa?logo=github-sponsors&style=flat-square)](https://github.com/sponsors/hideokamoto)
394
+
395
+ ---
396
+
397
+ ## Public API & TypeScript types
398
+
399
+ All user-facing TypeScript types are exported directly from the package root. Import them using the package name:
400
+
401
+ ```ts
402
+ import type {
403
+ FormSubmitEvent,
404
+ FormSubmitHandler,
405
+ StripeLoadedEvent,
406
+ StripeDidLoadedHandler,
407
+ ProgressStatus,
408
+ IntentType,
409
+ InitStripeOptions,
410
+ LinkAuthenticationElementChangeEvent,
411
+ LinkAuthenticationElementChangeHandler,
412
+ CurrencySelectorChangeEvent,
413
+ CurrencySelectorChangeHandler,
414
+ DefaultFormSubmitResult,
415
+ } from 'stripe-pwa-elements';
416
+ ```
417
+
418
+ The custom-elements entry `stripe-pwa-elements/dist/components/<tag>` is a supported import path for bundler-based setups (see [Bundlers](#bundlers-vite-webpack-capacitor) above). However, **do not** import from internal paths such as `dist/types/interfaces`. Those paths are implementation details and are not part of the public API — they may change without notice across any release.
419
+
420
+ ### Semver policy
421
+
422
+ All types exported from the package root (`stripe-pwa-elements`) are considered **public API** and follow [Semantic Versioning](https://semver.org/). Within the `^3.0.0` range:
423
+
424
+ - No breaking changes will be made to the shape of any publicly exported type.
425
+ - New optional fields may be added to event objects without a major bump.
426
+ - Removals or renames of exported types always require a new major version.
427
+
428
+ ## Maintainers
429
+
430
+ | Maintainer | GitHub | Social |
431
+ | --- | --- | --- |
432
+ | Hidetaka Okamoto | [hideokamoto](https://github.com/hideokamoto) | [@hide__dev](https://twitter.com/hide__dev) |
433
+ | Masaki Hirano | [contiki9](https://github.com/contiki9) | [@maki_saki](https://twitter.com/maki_saki) |
434
+ | Masahiko Sakakibara | [rdlabo](https://github.com/rdlabo) | [@rdlabo](https://twitter.com/rdlabo) |
435
+
436
+ ## License
437
+
438
+ MIT
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-globals-V2Kpy_OQ.js","sources":["@stencil/core/internal/app-globals"],"sourcesContent":["export const globalScripts = () => {};\nexport const globalStyles = \"\";\n"],"names":[],"mappings":";;AAAY,MAAC,aAAa,GAAG,MAAM;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-FFC4kSs5.js","sources":["src/utils/error.ts"],"sourcesContent":["import { StripeError } from '@stripe/stripe-js';\n\nexport class StripeAPIError extends Error {\n code: string;\n docUrl: string;\n message: string;\n param: string;\n requestLogUrl: string;\n type: string;\n\n constructor(error: StripeError) {\n super(error.message);\n this.code = error.code;\n this.docUrl = error.doc_url;\n this.message = error.message;\n this.param = error.param;\n this.requestLogUrl = error.request_log_url;\n this.type = error.type;\n }\n}\n"],"names":[],"mappings":";;AAEM,MAAO,cAAe,SAAQ,KAAK,CAAA;AAQvC,IAAA,WAAA,CAAY,KAAkB,EAAA;AAC5B,QAAA,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;AACpB,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;AACtB,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO;AAC3B,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO;AAC5B,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;AACxB,QAAA,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,eAAe;AAC1C,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;;AAEzB;;;;"}