stripe-pwa-elements 3.2.0 → 4.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 (237) 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-Cd2VI_N2.js} +216 -77
  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 +41 -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 +129 -72
  12. package/dist/cjs/stripe-currency-selector.cjs.entry.js +20 -10
  13. package/dist/cjs/stripe-elements.cjs.js +31 -5
  14. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +32 -22
  15. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +20 -10
  16. package/dist/cjs/stripe-payment-element.cjs.entry.js +283 -167
  17. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +30 -18
  18. package/dist/collection/collection-manifest.json +6 -5
  19. package/dist/collection/components/stripe-address-element/stripe-address-element.js +36 -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 +62 -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 +17 -6
  24. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +35 -20
  25. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +19 -7
  26. package/dist/collection/components/stripe-modal/stripe-modal.js +18 -7
  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 +162 -162
  29. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +48 -19
  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 +27 -10
  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-VTa1Gc94.js} +216 -77
  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 +41 -26
  76. package/dist/esm/stripe-card-element-modal.entry.js +6 -7
  77. package/dist/esm/stripe-card-element_2.entry.js +129 -72
  78. package/dist/esm/stripe-currency-selector.entry.js +20 -10
  79. package/dist/esm/stripe-elements.js +32 -6
  80. package/dist/esm/stripe-express-checkout-element.entry.js +32 -22
  81. package/dist/esm/stripe-link-authentication-element.entry.js +20 -10
  82. package/dist/esm/stripe-payment-element.entry.js +283 -167
  83. package/dist/esm/stripe-payment-request-button.entry.js +27 -15
  84. package/dist/stripe-elements/index.esm.js +0 -2
  85. package/dist/stripe-elements/p-1bd46766.entry.js +1 -0
  86. package/dist/stripe-elements/p-1c6e0a45.entry.js +1 -0
  87. package/dist/stripe-elements/p-3f42ca0c.entry.js +1 -0
  88. package/dist/stripe-elements/p-5cf62945.entry.js +1 -0
  89. package/dist/stripe-elements/p-74de1556.entry.js +1 -0
  90. package/dist/stripe-elements/p-76e57d78.entry.js +1 -0
  91. package/dist/stripe-elements/p-840d499f.entry.js +1 -0
  92. package/dist/stripe-elements/p-C6bbmyga.js +2 -0
  93. package/dist/stripe-elements/p-CBXaOfXU.js +1 -0
  94. package/dist/stripe-elements/p-CrjrbGJ3.js +1 -0
  95. package/dist/stripe-elements/p-DQuL1Twl.js +1 -2
  96. package/dist/stripe-elements/p-XRfh5Wrs.js +1 -2
  97. package/dist/stripe-elements/p-ae0c336e.entry.js +1 -0
  98. package/dist/stripe-elements/p-cfd8e081.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-address-element/stripe-address-element.d.ts +6 -0
  102. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +11 -1
  103. package/dist/types/components/stripe-card-element/stripe-card-element.helpers.d.ts +29 -0
  104. package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +4 -4
  105. package/dist/types/components/stripe-currency-selector/stripe-currency-selector.d.ts +6 -0
  106. package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +6 -0
  107. package/dist/types/components/stripe-link-authentication-element/stripe-link-authentication-element.d.ts +6 -0
  108. package/dist/types/components/stripe-modal/stripe-modal.d.ts +1 -0
  109. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +20 -2
  110. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +54 -0
  111. package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +14 -1
  112. package/dist/types/components.d.ts +139 -29
  113. package/dist/types/index.d.ts +1 -0
  114. package/dist/types/services/interfaces.d.ts +4 -3
  115. package/dist/types/services/stripe-service.d.ts +8 -4
  116. package/dist/types/stencil-public-runtime.d.ts +110 -5
  117. package/package.json +50 -30
  118. package/readme.md +386 -133
  119. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  120. package/dist/cjs/error-FFC4kSs5.js.map +0 -1
  121. package/dist/cjs/factory-CbbbSvkg.js.map +0 -1
  122. package/dist/cjs/index-BXVW_rzh.js +0 -1932
  123. package/dist/cjs/index-BXVW_rzh.js.map +0 -1
  124. package/dist/cjs/index-Ba1pBePA.js.map +0 -1
  125. package/dist/cjs/index.cjs.js.map +0 -1
  126. package/dist/cjs/ion-icon.entry.cjs.js.map +0 -1
  127. package/dist/cjs/loader.cjs.js.map +0 -1
  128. package/dist/cjs/stripe-address-element.entry.cjs.js.map +0 -1
  129. package/dist/cjs/stripe-card-element-modal.entry.cjs.js.map +0 -1
  130. package/dist/cjs/stripe-card-element.stripe-modal.entry.cjs.js.map +0 -1
  131. package/dist/cjs/stripe-currency-selector.entry.cjs.js.map +0 -1
  132. package/dist/cjs/stripe-elements.cjs.js.map +0 -1
  133. package/dist/cjs/stripe-express-checkout-element.entry.cjs.js.map +0 -1
  134. package/dist/cjs/stripe-link-authentication-element.entry.cjs.js.map +0 -1
  135. package/dist/cjs/stripe-payment-element.entry.cjs.js.map +0 -1
  136. package/dist/cjs/stripe-payment-request-button.entry.cjs.js.map +0 -1
  137. package/dist/collection/components/stripe-address-element/stripe-address-element.js.map +0 -1
  138. package/dist/collection/components/stripe-card-element/stripe-card-element.js.map +0 -1
  139. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js.map +0 -1
  140. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js.map +0 -1
  141. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js.map +0 -1
  142. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js.map +0 -1
  143. package/dist/collection/components/stripe-modal/stripe-modal.js.map +0 -1
  144. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js.map +0 -1
  145. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js.map +0 -1
  146. package/dist/collection/index.js.map +0 -1
  147. package/dist/collection/interfaces.js.map +0 -1
  148. package/dist/collection/services/address-element-manager.js.map +0 -1
  149. package/dist/collection/services/card-element-manager.js.map +0 -1
  150. package/dist/collection/services/currency-selector-element-manager.js.map +0 -1
  151. package/dist/collection/services/express-checkout-element-manager.js.map +0 -1
  152. package/dist/collection/services/factory.js.map +0 -1
  153. package/dist/collection/services/interfaces.js.map +0 -1
  154. package/dist/collection/services/link-authentication-element-manager.js.map +0 -1
  155. package/dist/collection/services/payment-element-manager.js.map +0 -1
  156. package/dist/collection/services/stripe-service.js.map +0 -1
  157. package/dist/collection/utils/element-finder.js.map +0 -1
  158. package/dist/collection/utils/error.js.map +0 -1
  159. package/dist/collection/utils/i18n.js.map +0 -1
  160. package/dist/collection/utils/platform.js.map +0 -1
  161. package/dist/collection/utils/test-setup.js.map +0 -1
  162. package/dist/collection/utils/utils.js.map +0 -1
  163. package/dist/components/error.js.map +0 -1
  164. package/dist/components/factory.js.map +0 -1
  165. package/dist/components/icon.js.map +0 -1
  166. package/dist/components/index.js.map +0 -1
  167. package/dist/components/index2.js.map +0 -1
  168. package/dist/components/ion-icon.js.map +0 -1
  169. package/dist/components/stripe-address-element.js.map +0 -1
  170. package/dist/components/stripe-card-element-modal.js.map +0 -1
  171. package/dist/components/stripe-card-element.js.map +0 -1
  172. package/dist/components/stripe-card-element2.js.map +0 -1
  173. package/dist/components/stripe-currency-selector.js.map +0 -1
  174. package/dist/components/stripe-express-checkout-element.js.map +0 -1
  175. package/dist/components/stripe-link-authentication-element.js.map +0 -1
  176. package/dist/components/stripe-modal.js.map +0 -1
  177. package/dist/components/stripe-modal2.js.map +0 -1
  178. package/dist/components/stripe-payment-element.js.map +0 -1
  179. package/dist/components/stripe-payment-request-button.js.map +0 -1
  180. package/dist/components/stripe-payment-request-button2.js.map +0 -1
  181. package/dist/components/utils.js.map +0 -1
  182. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  183. package/dist/esm/error-XRfh5Wrs.js.map +0 -1
  184. package/dist/esm/factory-Drde6-y7.js.map +0 -1
  185. package/dist/esm/index-BHDCxQOb.js.map +0 -1
  186. package/dist/esm/index-DJwTOfxZ.js +0 -1920
  187. package/dist/esm/index-DJwTOfxZ.js.map +0 -1
  188. package/dist/esm/index.js.map +0 -1
  189. package/dist/esm/ion-icon.entry.js.map +0 -1
  190. package/dist/esm/loader.js.map +0 -1
  191. package/dist/esm/stripe-address-element.entry.js.map +0 -1
  192. package/dist/esm/stripe-card-element-modal.entry.js.map +0 -1
  193. package/dist/esm/stripe-card-element.stripe-modal.entry.js.map +0 -1
  194. package/dist/esm/stripe-currency-selector.entry.js.map +0 -1
  195. package/dist/esm/stripe-elements.js.map +0 -1
  196. package/dist/esm/stripe-express-checkout-element.entry.js.map +0 -1
  197. package/dist/esm/stripe-link-authentication-element.entry.js.map +0 -1
  198. package/dist/esm/stripe-payment-element.entry.js.map +0 -1
  199. package/dist/esm/stripe-payment-request-button.entry.js.map +0 -1
  200. package/dist/stripe-elements/index.esm.js.map +0 -1
  201. package/dist/stripe-elements/ion-icon.entry.esm.js.map +0 -1
  202. package/dist/stripe-elements/loader.esm.js.map +0 -1
  203. package/dist/stripe-elements/p-02f6e421.entry.js +0 -2
  204. package/dist/stripe-elements/p-02f6e421.entry.js.map +0 -1
  205. package/dist/stripe-elements/p-19888fa6.entry.js +0 -2
  206. package/dist/stripe-elements/p-19888fa6.entry.js.map +0 -1
  207. package/dist/stripe-elements/p-4d505729.entry.js +0 -2
  208. package/dist/stripe-elements/p-4d505729.entry.js.map +0 -1
  209. package/dist/stripe-elements/p-7e7ad92a.entry.js +0 -2
  210. package/dist/stripe-elements/p-7e7ad92a.entry.js.map +0 -1
  211. package/dist/stripe-elements/p-8bb4212c.entry.js +0 -2
  212. package/dist/stripe-elements/p-8bb4212c.entry.js.map +0 -1
  213. package/dist/stripe-elements/p-9aee2b6b.entry.js +0 -2
  214. package/dist/stripe-elements/p-9aee2b6b.entry.js.map +0 -1
  215. package/dist/stripe-elements/p-BHDCxQOb.js +0 -2
  216. package/dist/stripe-elements/p-BHDCxQOb.js.map +0 -1
  217. package/dist/stripe-elements/p-DI2vmGaI.js +0 -2
  218. package/dist/stripe-elements/p-DI2vmGaI.js.map +0 -1
  219. package/dist/stripe-elements/p-DJwTOfxZ.js +0 -3
  220. package/dist/stripe-elements/p-DJwTOfxZ.js.map +0 -1
  221. package/dist/stripe-elements/p-DQuL1Twl.js.map +0 -1
  222. package/dist/stripe-elements/p-XRfh5Wrs.js.map +0 -1
  223. package/dist/stripe-elements/p-ba251393.entry.js +0 -2
  224. package/dist/stripe-elements/p-ba251393.entry.js.map +0 -1
  225. package/dist/stripe-elements/p-c649edfc.entry.js +0 -2
  226. package/dist/stripe-elements/p-c649edfc.entry.js.map +0 -1
  227. package/dist/stripe-elements/p-e8bb43ae.entry.js +0 -2
  228. package/dist/stripe-elements/p-e8bb43ae.entry.js.map +0 -1
  229. package/dist/stripe-elements/stripe-address-element.entry.esm.js.map +0 -1
  230. package/dist/stripe-elements/stripe-card-element-modal.entry.esm.js.map +0 -1
  231. package/dist/stripe-elements/stripe-card-element.stripe-modal.entry.esm.js.map +0 -1
  232. package/dist/stripe-elements/stripe-currency-selector.entry.esm.js.map +0 -1
  233. package/dist/stripe-elements/stripe-elements.esm.js.map +0 -1
  234. package/dist/stripe-elements/stripe-express-checkout-element.entry.esm.js.map +0 -1
  235. package/dist/stripe-elements/stripe-link-authentication-element.entry.esm.js.map +0 -1
  236. package/dist/stripe-elements/stripe-payment-element.entry.esm.js.map +0 -1
  237. package/dist/stripe-elements/stripe-payment-request-button.entry.esm.js.map +0 -1
@@ -123,7 +123,7 @@ export class StripeExpressCheckoutElement {
123
123
  const event = {
124
124
  stripe: this.stripeService.getStripe(),
125
125
  };
126
- if (this.stripeDidLoaded) {
126
+ if (this.stripeDidLoaded != null) {
127
127
  this.stripeDidLoaded(event);
128
128
  }
129
129
  this.stripeLoaded.emit(event);
@@ -155,14 +155,21 @@ export class StripeExpressCheckoutElement {
155
155
  // Dependency Injection via factory
156
156
  this.stripeService = serviceFactory.createStripeService();
157
157
  this.expressCheckoutManager = serviceFactory.createExpressCheckoutElementManager(this.stripeService);
158
- if (this.publishableKey) {
158
+ }
159
+ /**
160
+ * Props are not yet populated inside the constructor when the component is registered via
161
+ * the custom-elements build (`dist/components/*`), so initialization that depends on them
162
+ * must run in `componentWillLoad`, where both the lazy and custom-elements builds have them set.
163
+ */
164
+ componentWillLoad() {
165
+ if (this.publishableKey != null && this.publishableKey !== '') {
159
166
  this.initStripe(this.publishableKey, {
160
167
  stripeAccount: this.stripeAccount,
161
168
  });
162
169
  }
163
170
  }
164
171
  componentWillUpdate() {
165
- if (!this.stripeService.state.publishableKey) {
172
+ if (this.stripeService.state.publishableKey == null || this.stripeService.state.publishableKey === '') {
166
173
  return;
167
174
  }
168
175
  if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
@@ -182,10 +189,10 @@ export class StripeExpressCheckoutElement {
182
189
  this.progress = 'loading';
183
190
  const stripe = this.stripeService.getStripe();
184
191
  const { intentType, clientSecret } = this;
185
- if (!stripe) {
192
+ if (stripe == null) {
186
193
  throw new Error('Stripe not initialized');
187
194
  }
188
- if (!clientSecret) {
195
+ if (clientSecret == null || clientSecret === '') {
189
196
  throw new Error('Client secret is required');
190
197
  }
191
198
  const result = await (() => {
@@ -208,7 +215,7 @@ export class StripeExpressCheckoutElement {
208
215
  redirect: 'if_required',
209
216
  });
210
217
  })();
211
- if (result.error) {
218
+ if (result.error != null) {
212
219
  throw new StripeAPIError(result.error);
213
220
  }
214
221
  // Complete the payment in the Express Checkout Element
@@ -237,10 +244,10 @@ export class StripeExpressCheckoutElement {
237
244
  if (this.amount !== undefined) {
238
245
  elementOptions.amount = this.amount;
239
246
  }
240
- if (this.currency) {
247
+ if (this.currency != null && this.currency !== '') {
241
248
  elementOptions.currency = this.currency;
242
249
  }
243
- if (this.buttonHeight) {
250
+ if (this.buttonHeight != null && this.buttonHeight !== '') {
244
251
  // Convert string like "48px" to number for Stripe API
245
252
  if (typeof this.buttonHeight === 'string') {
246
253
  const height = parseInt(this.buttonHeight.replace('px', ''), 10);
@@ -256,7 +263,7 @@ export class StripeExpressCheckoutElement {
256
263
  await this.expressCheckoutManager.initialize(this.el, elementOptions, {
257
264
  onConfirm: async (event) => {
258
265
  this.confirm.emit(event);
259
- if (this.shouldUseDefaultConfirmAction && this.clientSecret) {
266
+ if (this.shouldUseDefaultConfirmAction && this.clientSecret != null && this.clientSecret !== '') {
260
267
  await this.defaultConfirmAction(event);
261
268
  }
262
269
  },
@@ -309,7 +316,8 @@ export class StripeExpressCheckoutElement {
309
316
  "IntentType": {
310
317
  "location": "import",
311
318
  "path": "../../interfaces",
312
- "id": "src/interfaces.ts::IntentType"
319
+ "id": "src/interfaces.ts::IntentType",
320
+ "referenceLocation": "IntentType"
313
321
  }
314
322
  }
315
323
  },
@@ -495,7 +503,8 @@ export class StripeExpressCheckoutElement {
495
503
  "StripeDidLoadedHandler": {
496
504
  "location": "import",
497
505
  "path": "../../interfaces",
498
- "id": "src/interfaces.ts::StripeDidLoadedHandler"
506
+ "id": "src/interfaces.ts::StripeDidLoadedHandler",
507
+ "referenceLocation": "StripeDidLoadedHandler"
499
508
  }
500
509
  }
501
510
  },
@@ -536,7 +545,8 @@ export class StripeExpressCheckoutElement {
536
545
  "StripeLoadedEvent": {
537
546
  "location": "import",
538
547
  "path": "../../interfaces",
539
- "id": "src/interfaces.ts::StripeLoadedEvent"
548
+ "id": "src/interfaces.ts::StripeLoadedEvent",
549
+ "referenceLocation": "StripeLoadedEvent"
540
550
  }
541
551
  }
542
552
  }
@@ -560,7 +570,8 @@ export class StripeExpressCheckoutElement {
560
570
  "StripeExpressCheckoutElementConfirmEvent": {
561
571
  "location": "import",
562
572
  "path": "@stripe/stripe-js",
563
- "id": "node_modules::StripeExpressCheckoutElementConfirmEvent"
573
+ "id": "node_modules::StripeExpressCheckoutElementConfirmEvent",
574
+ "referenceLocation": "StripeExpressCheckoutElementConfirmEvent"
564
575
  }
565
576
  }
566
577
  }
@@ -584,7 +595,8 @@ export class StripeExpressCheckoutElement {
584
595
  "StripeExpressCheckoutElementClickEvent": {
585
596
  "location": "import",
586
597
  "path": "@stripe/stripe-js",
587
- "id": "node_modules::StripeExpressCheckoutElementClickEvent"
598
+ "id": "node_modules::StripeExpressCheckoutElementClickEvent",
599
+ "referenceLocation": "StripeExpressCheckoutElementClickEvent"
588
600
  }
589
601
  }
590
602
  }
@@ -623,7 +635,8 @@ export class StripeExpressCheckoutElement {
623
635
  "DefaultFormSubmitResult": {
624
636
  "location": "import",
625
637
  "path": "../../interfaces",
626
- "id": "src/interfaces.ts::DefaultFormSubmitResult"
638
+ "id": "src/interfaces.ts::DefaultFormSubmitResult",
639
+ "referenceLocation": "DefaultFormSubmitResult"
627
640
  }
628
641
  }
629
642
  }
@@ -647,7 +660,8 @@ export class StripeExpressCheckoutElement {
647
660
  "ProgressStatus": {
648
661
  "location": "import",
649
662
  "path": "../../interfaces",
650
- "id": "src/interfaces.ts::ProgressStatus"
663
+ "id": "src/interfaces.ts::ProgressStatus",
664
+ "referenceLocation": "ProgressStatus"
651
665
  }
652
666
  },
653
667
  "return": "Promise<this>"
@@ -716,7 +730,8 @@ export class StripeExpressCheckoutElement {
716
730
  "InitStripeOptions": {
717
731
  "location": "import",
718
732
  "path": "../../interfaces",
719
- "id": "src/interfaces.ts::InitStripeOptions"
733
+ "id": "src/interfaces.ts::InitStripeOptions",
734
+ "referenceLocation": "InitStripeOptions"
720
735
  }
721
736
  },
722
737
  "return": "Promise<void>"
@@ -740,7 +755,7 @@ export class StripeExpressCheckoutElement {
740
755
  "signature": "(options: Partial<ExpressCheckoutElementOptions>) => Promise<this>",
741
756
  "parameters": [{
742
757
  "name": "options",
743
- "type": "{ mode?: \"payment\" | \"subscription\" | \"setup\"; amount?: number; currency?: string; paymentMethods?: { applePay?: \"auto\" | \"always\" | \"never\"; googlePay?: \"auto\" | \"always\" | \"never\"; link?: \"auto\" | \"always\" | \"never\"; paypal?: \"auto\" | \"always\" | \"never\"; amazonPay?: \"auto\" | \"always\" | \"never\"; }; buttonType?: { applePay?: \"book\" | \"buy\" | \"check-out\" | \"donate\" | \"plain\" | \"subscribe\"; googlePay?: \"order\" | \"book\" | \"buy\" | \"donate\" | \"plain\" | \"subscribe\" | \"checkout\" | \"pay\"; }; buttonTheme?: { applePay?: \"black\" | \"white\" | \"white-outline\"; googlePay?: \"black\" | \"white\"; }; buttonHeight?: string | number; layout?: { maxColumns?: number; maxRows?: number; overflow?: \"auto\" | \"never\"; }; }",
758
+ "type": "{ mode?: \"setup\" | \"payment\" | \"subscription\"; amount?: number; currency?: string; paymentMethods?: { applePay?: \"never\" | \"always\" | \"auto\"; googlePay?: \"never\" | \"always\" | \"auto\"; link?: \"never\" | \"always\" | \"auto\"; paypal?: \"never\" | \"always\" | \"auto\"; amazonPay?: \"never\" | \"always\" | \"auto\"; }; buttonType?: { applePay?: \"buy\" | \"donate\" | \"plain\" | \"book\" | \"check-out\" | \"subscribe\"; googlePay?: \"checkout\" | \"buy\" | \"donate\" | \"plain\" | \"book\" | \"subscribe\" | \"order\" | \"pay\"; }; buttonTheme?: { applePay?: \"black\" | \"white\" | \"white-outline\"; googlePay?: \"black\" | \"white\"; }; buttonHeight?: string | number; layout?: { maxColumns?: number; maxRows?: number; overflow?: \"never\" | \"auto\"; }; }",
744
759
  "docs": "- Partial options to update"
745
760
  }],
746
761
  "references": {
@@ -755,7 +770,8 @@ export class StripeExpressCheckoutElement {
755
770
  "ExpressCheckoutElementOptions": {
756
771
  "location": "import",
757
772
  "path": "../../services/interfaces",
758
- "id": "src/services/interfaces.ts::ExpressCheckoutElementOptions"
773
+ "id": "src/services/interfaces.ts::ExpressCheckoutElementOptions",
774
+ "referenceLocation": "ExpressCheckoutElementOptions"
759
775
  }
760
776
  },
761
777
  "return": "Promise<this>"
@@ -784,4 +800,3 @@ export class StripeExpressCheckoutElement {
784
800
  }];
785
801
  }
786
802
  }
787
- //# sourceMappingURL=stripe-express-checkout-element.js.map
@@ -163,6 +163,13 @@ export class StripeLinkAuthenticationElement {
163
163
  // Dependency Injection via factory
164
164
  this.stripeService = serviceFactory.createStripeService();
165
165
  this.linkAuthenticationElementManager = serviceFactory.createLinkAuthenticationElementManager(this.stripeService);
166
+ }
167
+ /**
168
+ * Props are not yet populated inside the constructor when the component is registered via
169
+ * the custom-elements build (`dist/components/*`), so initialization that depends on them
170
+ * must run in `componentWillLoad`, where both the lazy and custom-elements builds have them set.
171
+ */
172
+ componentWillLoad() {
166
173
  if (this.publishableKey) {
167
174
  this.initStripe(this.publishableKey, {
168
175
  stripeAccount: this.stripeAccount,
@@ -306,7 +313,8 @@ export class StripeLinkAuthenticationElement {
306
313
  "LinkAuthenticationElementChangeHandler": {
307
314
  "location": "import",
308
315
  "path": "../../interfaces",
309
- "id": "src/interfaces.ts::LinkAuthenticationElementChangeHandler"
316
+ "id": "src/interfaces.ts::LinkAuthenticationElementChangeHandler",
317
+ "referenceLocation": "LinkAuthenticationElementChangeHandler"
310
318
  }
311
319
  }
312
320
  },
@@ -329,7 +337,8 @@ export class StripeLinkAuthenticationElement {
329
337
  "StripeDidLoadedHandler": {
330
338
  "location": "import",
331
339
  "path": "../../interfaces",
332
- "id": "src/interfaces.ts::StripeDidLoadedHandler"
340
+ "id": "src/interfaces.ts::StripeDidLoadedHandler",
341
+ "referenceLocation": "StripeDidLoadedHandler"
333
342
  }
334
343
  }
335
344
  },
@@ -370,7 +379,8 @@ export class StripeLinkAuthenticationElement {
370
379
  "StripeLoadedEvent": {
371
380
  "location": "import",
372
381
  "path": "../../interfaces",
373
- "id": "src/interfaces.ts::StripeLoadedEvent"
382
+ "id": "src/interfaces.ts::StripeLoadedEvent",
383
+ "referenceLocation": "StripeLoadedEvent"
374
384
  }
375
385
  }
376
386
  }
@@ -394,7 +404,8 @@ export class StripeLinkAuthenticationElement {
394
404
  "LinkAuthenticationElementChangeEvent": {
395
405
  "location": "import",
396
406
  "path": "../../interfaces",
397
- "id": "src/interfaces.ts::LinkAuthenticationElementChangeEvent"
407
+ "id": "src/interfaces.ts::LinkAuthenticationElementChangeEvent",
408
+ "referenceLocation": "LinkAuthenticationElementChangeEvent"
398
409
  }
399
410
  }
400
411
  }
@@ -422,7 +433,8 @@ export class StripeLinkAuthenticationElement {
422
433
  "InitStripeOptions": {
423
434
  "location": "import",
424
435
  "path": "../../interfaces",
425
- "id": "src/interfaces.ts::InitStripeOptions"
436
+ "id": "src/interfaces.ts::InitStripeOptions",
437
+ "referenceLocation": "InitStripeOptions"
426
438
  }
427
439
  },
428
440
  "return": "Promise<void>"
@@ -457,7 +469,8 @@ export class StripeLinkAuthenticationElement {
457
469
  "ProgressStatus": {
458
470
  "location": "import",
459
471
  "path": "../../interfaces",
460
- "id": "src/interfaces.ts::ProgressStatus"
472
+ "id": "src/interfaces.ts::ProgressStatus",
473
+ "referenceLocation": "ProgressStatus"
461
474
  }
462
475
  },
463
476
  "return": "Promise<this>"
@@ -542,4 +555,3 @@ export class StripeLinkAuthenticationElement {
542
555
  }];
543
556
  }
544
557
  }
545
- //# sourceMappingURL=stripe-link-authentication-element.js.map
@@ -17,6 +17,15 @@ export class StripeModal {
17
17
  */
18
18
  this.renderedOpen = false;
19
19
  }
20
+ onOpenChange(open) {
21
+ if (open) {
22
+ this.openModalAnimation();
23
+ }
24
+ else {
25
+ this.renderedOpen = false;
26
+ this.close.emit();
27
+ }
28
+ }
20
29
  /**
21
30
  * Toggle modal state
22
31
  */
@@ -28,15 +37,12 @@ export class StripeModal {
28
37
  */
29
38
  async openModal() {
30
39
  this.open = true;
31
- this.openModalAnimation();
32
40
  }
33
41
  /**
34
42
  * Close the modal
35
43
  */
36
44
  async closeModal() {
37
45
  this.open = false;
38
- this.renderedOpen = false;
39
- this.close.emit();
40
46
  }
41
47
  componentDidLoad() {
42
48
  const platformName = checkPlatform();
@@ -60,12 +66,12 @@ export class StripeModal {
60
66
  modalChild.classList.remove('loading');
61
67
  }, { once: true });
62
68
  requestAnimationFrame(() => {
63
- this.renderedOpen = true;
69
+ this.renderedOpen = this.open;
64
70
  });
65
71
  }
66
72
  render() {
67
73
  const { renderedOpen, showCloseButton } = this;
68
- return (h(Host, { key: 'dee14229db3c17744ae5013e5f9aab813a77880b' }, h("div", { key: 'c82f4f18286a3d341932bacf09973da80ee2acdd', class: `modal-row${renderedOpen ? ' open' : ''}`, onClick: () => this.closeModal() }, h("div", { key: '20b5dc2db1509486e74ff2f6049f5c27de4d4793', class: "modal-child", onClick: e => e.stopPropagation() }, showCloseButton ? (h("div", { class: "modal-close-button-wrap" }, h("ion-icon", { name: "close", size: "large", class: "modal-close-button", onClick: () => this.closeModal() }))) : null, h("div", { key: '863c6285045ad9dcbfeb286ee8ffa8aa1581f90e', class: "modal-loading" }, h("svg", { key: 'ba5d9e80236600f4b64a7fa735d49241eb1c3f29', version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 2400 2400" }, h("g", { key: '290f7a2e79dc54f36603fa4a6b7d3922e4d1f432', "stroke-width": "200", "stroke-linecap": "round", stroke: "currentColor", fill: "none", id: "spinner" }, h("line", { key: '92cafdfad5a2631046bdd5f1fb6431b623808961', x1: "1200", y1: "600", x2: "1200", y2: "100" }), h("line", { key: '8b6e7260dcc41f969c7bac0fec073928e8e146a7', opacity: "0.5", x1: "1200", y1: "2300", x2: "1200", y2: "1800" }), h("line", { key: 'a5eb02131aa60cd6126a2be5f874e8f3bf3b6d5f', opacity: "0.917", x1: "900", y1: "680.4", x2: "650", y2: "247.4" }), h("line", { key: '1052903918a67fc53c0df06af43ad564fc9180f7', opacity: "0.417", x1: "1750", y1: "2152.6", x2: "1500", y2: "1719.6" }), h("line", { key: 'ac37ac0104a2738375b8f71481b826ae63730dce', opacity: "0.833", x1: "680.4", y1: "900", x2: "247.4", y2: "650" }), h("line", { key: '0623f6448f636a6f5f65cb68387ab81381a56acf', opacity: "0.333", x1: "2152.6", y1: "1750", x2: "1719.6", y2: "1500" }), h("line", { key: 'f3dbc37979ad51676728ac79eccab6d7be4d9192', opacity: "0.75", x1: "600", y1: "1200", x2: "100", y2: "1200" }), h("line", { key: 'c5d92ff42dbe24d6c2136b24cdf2d57835f11b76', opacity: "0.25", x1: "2300", y1: "1200", x2: "1800", y2: "1200" }), h("line", { key: '3339f4fefcc7222050da34aa7b8b60c9ac511aea', opacity: "0.667", x1: "680.4", y1: "1500", x2: "247.4", y2: "1750" }), h("line", { key: '7ddc8d68d7f7deb0fe377b508180bc0b1123bf7f', opacity: "0.167", x1: "2152.6", y1: "650", x2: "1719.6", y2: "900" }), h("line", { key: '8825e19d81b7ade6d1ee327ac7b8bc24607a7c47', opacity: "0.583", x1: "900", y1: "1719.6", x2: "650", y2: "2152.6" }), h("line", { key: '9562d8c1dcc59a4884cff618edc35e951b19794c', opacity: "0.083", x1: "1750", y1: "247.4", x2: "1500", y2: "680.4" }), h("animateTransform", { key: '648f2a04edef2c2908782aa2296e4dba2b27d7b1', attributeName: "transform", attributeType: "XML", type: "rotate", keyTimes: "0;0.08333;0.16667;0.25;0.33333;0.41667;0.5;0.58333;0.66667;0.75;0.83333;0.91667", values: "0 1199 1199;30 1199 1199;60 1199 1199;90 1199 1199;120 1199 1199;150 1199 1199;180 1199 1199;210 1199 1199;240 1199 1199;270 1199 1199;300 1199 1199;330 1199 1199", dur: "0.83333s", begin: "0s", repeatCount: "indefinite", calcMode: "discrete" })))), h("div", { key: 'a86fb232eb5df0737c870e0e788c0c1e230b434e', class: "modal-content" }, h("slot", { key: 'b5ee41fc9dd113c3e2716f01350641fc2adebd7b' }))))));
74
+ return (h(Host, { key: '38fb86acf7cf5887a426c67b1a1271f7fae7048c' }, h("div", { key: 'f751d92c327ee2e564edfcd4d18f4dca43c20c37', class: `modal-row${renderedOpen ? ' open' : ''}`, onClick: () => this.closeModal() }, h("div", { key: '11519ccd44a5069df3247c530a2c1e114eab7aef', class: "modal-child", onClick: e => e.stopPropagation() }, showCloseButton ? (h("div", { class: "modal-close-button-wrap" }, h("ion-icon", { name: "close", size: "large", class: "modal-close-button", onClick: () => this.closeModal() }))) : null, h("div", { key: 'a41f7f263b488b5bbc2a999cbabf6b9e407bca85', class: "modal-loading" }, h("svg", { key: '0b3b25cb2812bc4d837fb4b7e6af4a5f42f0247e', version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 2400 2400" }, h("g", { key: '10a9f9ec59699e6d2988b9c65cd02da1754fd760', "stroke-width": "200", "stroke-linecap": "round", stroke: "currentColor", fill: "none", id: "spinner" }, h("line", { key: 'ed271fa584b930ceed5397c271b31e0d48c72f72', x1: "1200", y1: "600", x2: "1200", y2: "100" }), h("line", { key: '3cf855a84f3ab58b914b7aeb784fbc5b95d8ae94', opacity: "0.5", x1: "1200", y1: "2300", x2: "1200", y2: "1800" }), h("line", { key: '2cce4b62a276399235509e94f47a63acf9c69a0f', opacity: "0.917", x1: "900", y1: "680.4", x2: "650", y2: "247.4" }), h("line", { key: '64c175ef068591417b043f7630a44d34eae7cb59', opacity: "0.417", x1: "1750", y1: "2152.6", x2: "1500", y2: "1719.6" }), h("line", { key: '0856a654e3aa756dfb1e9fc316b8b379fa9d5a4e', opacity: "0.833", x1: "680.4", y1: "900", x2: "247.4", y2: "650" }), h("line", { key: 'c60f1f8495df9b8cdcc8941255d08c01a0e1c02f', opacity: "0.333", x1: "2152.6", y1: "1750", x2: "1719.6", y2: "1500" }), h("line", { key: '204bc2a7765e43b86f91c3fb9b1e72a3a39bb323', opacity: "0.75", x1: "600", y1: "1200", x2: "100", y2: "1200" }), h("line", { key: '7584b272f9efd7f746c1bcc5c8a5576098b02381', opacity: "0.25", x1: "2300", y1: "1200", x2: "1800", y2: "1200" }), h("line", { key: '7a053e9eb5f0da3fbf6fb7c9680bf73073bb126d', opacity: "0.667", x1: "680.4", y1: "1500", x2: "247.4", y2: "1750" }), h("line", { key: 'f8b817095143d739589e45c99b03c7afbdfc8293', opacity: "0.167", x1: "2152.6", y1: "650", x2: "1719.6", y2: "900" }), h("line", { key: 'aae0e36dbdfff44196f9758c8a5ed2337139ebe0', opacity: "0.583", x1: "900", y1: "1719.6", x2: "650", y2: "2152.6" }), h("line", { key: '3a257b30cb289f29ba386ccca7519bcdc22c3786', opacity: "0.083", x1: "1750", y1: "247.4", x2: "1500", y2: "680.4" }), h("animateTransform", { key: 'c6b8e73025589403dd3d08f84b02eb824763d056', attributeName: "transform", attributeType: "XML", type: "rotate", keyTimes: "0;0.08333;0.16667;0.25;0.33333;0.41667;0.5;0.58333;0.66667;0.75;0.83333;0.91667", values: "0 1199 1199;30 1199 1199;60 1199 1199;90 1199 1199;120 1199 1199;150 1199 1199;180 1199 1199;210 1199 1199;240 1199 1199;270 1199 1199;300 1199 1199;330 1199 1199", dur: "0.83333s", begin: "0s", repeatCount: "indefinite", calcMode: "discrete" })))), h("div", { key: 'da5ef8031e5b826d854a065d8172389cdd84fbf0', class: "modal-content" }, h("slot", { key: 'fbe97a3a4d5489de5ae6f49342c58d537b317842' }))))));
69
75
  }
70
76
  static get is() { return "stripe-modal"; }
71
77
  static get encapsulation() { return "shadow"; }
@@ -103,7 +109,7 @@ export class StripeModal {
103
109
  },
104
110
  "open": {
105
111
  "type": "boolean",
106
- "mutable": false,
112
+ "mutable": true,
107
113
  "complexType": {
108
114
  "original": "boolean",
109
115
  "resolved": "boolean",
@@ -202,5 +208,10 @@ export class StripeModal {
202
208
  };
203
209
  }
204
210
  static get elementRef() { return "el"; }
211
+ static get watchers() {
212
+ return [{
213
+ "propName": "open",
214
+ "methodName": "onOpenChange"
215
+ }];
216
+ }
205
217
  }
206
- //# sourceMappingURL=stripe-modal.js.map
@@ -0,0 +1,114 @@
1
+ import { StripeAPIError } from "../../utils/error";
2
+ /**
3
+ * Determine whether the submit button should be disabled.
4
+ * For Checkout Session mode: the checkout is ready once Stripe finished loading.
5
+ * For Payment Intent / Setup Intent mode: an intent client secret must be present.
6
+ * @param params progress / loading state and the current mode information
7
+ * @returns true when the submit button should be disabled
8
+ */
9
+ export const isSubmitButtonDisabled = (params) => {
10
+ const { progress, isCheckoutSession, loadStripeStatus, intentClientSecret } = params;
11
+ const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : intentClientSecret != null && intentClientSecret !== '';
12
+ return progress === 'loading' || !hasValidSecret;
13
+ };
14
+ /**
15
+ * Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
16
+ * Calls `confirmPayment` or `confirmSetup` depending on the intent type.
17
+ * @param stripe the loaded Stripe.js instance
18
+ * @param elements the Stripe Elements instance bound to the payment element
19
+ * @param intentType the configured intent type
20
+ * @param returnUrl the URL Stripe should redirect back to when required
21
+ * @returns the confirmation result
22
+ * @throws StripeAPIError when Stripe returns an error
23
+ */
24
+ export const confirmPaymentOrSetup = async (stripe, elements, intentType, returnUrl) => {
25
+ const result = await (() => {
26
+ if (intentType === 'payment') {
27
+ return stripe.confirmPayment({
28
+ elements,
29
+ confirmParams: {
30
+ return_url: returnUrl,
31
+ },
32
+ redirect: 'if_required',
33
+ });
34
+ }
35
+ return stripe.confirmSetup({
36
+ elements,
37
+ confirmParams: {
38
+ return_url: returnUrl,
39
+ },
40
+ redirect: 'if_required',
41
+ });
42
+ })();
43
+ if (result.error) {
44
+ throw new StripeAPIError(result.error);
45
+ }
46
+ return result;
47
+ };
48
+ /**
49
+ * Confirm a Checkout Session payment using the checkout actions.
50
+ * @param checkout the Stripe Checkout instance
51
+ * @param returnUrl the URL Stripe should redirect back to when required
52
+ * @returns the confirmation result
53
+ * @throws StripeAPIError when loading actions or confirming fails
54
+ */
55
+ export const confirmCheckoutSession = async (checkout, returnUrl) => {
56
+ var _a;
57
+ // Load actions from the checkout session
58
+ const loadActionsResult = await checkout.loadActions();
59
+ if (loadActionsResult.type === 'error') {
60
+ // Create a StripeError-compatible object from the Checkout Session error
61
+ const stripeError = {
62
+ type: 'api_error',
63
+ code: loadActionsResult.error.code || 'checkout_session_error',
64
+ message: loadActionsResult.error.message,
65
+ };
66
+ throw new StripeAPIError(stripeError);
67
+ }
68
+ const { actions } = loadActionsResult;
69
+ // Confirm the payment using checkout session actions
70
+ const result = await actions.confirm({
71
+ returnUrl,
72
+ redirect: 'if_required',
73
+ });
74
+ if (result.type === 'error') {
75
+ // Create a StripeError-compatible object from the confirm error
76
+ const stripeError = {
77
+ type: 'card_error',
78
+ code: result.error.code || 'payment_failed',
79
+ message: result.error.message,
80
+ decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
81
+ };
82
+ throw new StripeAPIError(stripeError);
83
+ }
84
+ return result;
85
+ };
86
+ /**
87
+ * Resolve the mode-specific properties for a submit event.
88
+ * Picks the Checkout or Elements payload depending on the active mode and
89
+ * reports a descriptive error string when the required instance is missing.
90
+ * @param params the resolved Stripe instances and client secrets for the current mode
91
+ * @returns the submit event props, or an error message when an instance is missing
92
+ */
93
+ export const buildSubmitEventProps = (params) => {
94
+ const { stripe, isCheckoutSession, checkout, checkoutSessionClientSecret, elements, intentClientSecret } = params;
95
+ const props = {
96
+ stripe,
97
+ };
98
+ if (isCheckoutSession) {
99
+ // Checkout Session mode
100
+ if (checkout == null) {
101
+ return { error: 'Checkout not properly initialized' };
102
+ }
103
+ props.checkout = checkout;
104
+ props.checkoutSessionClientSecret = checkoutSessionClientSecret;
105
+ return { props };
106
+ }
107
+ // Payment Intent / Setup Intent mode
108
+ if (elements == null) {
109
+ return { error: 'Elements not properly initialized' };
110
+ }
111
+ props.elements = elements;
112
+ props.intentClientSecret = intentClientSecret;
113
+ return { props };
114
+ };