stripe-pwa-elements 3.0.0 → 3.1.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 (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,979 @@
1
+ import { h } from "@stencil/core";
2
+ import { checkPlatform } from "../../utils/utils";
3
+ import { i18n } from "../../utils/i18n";
4
+ import { serviceFactory } from "../../services/factory";
5
+ import { StripeAPIError } from "../../utils/error";
6
+ export class StripePaymentElement {
7
+ /**
8
+ * Get Stripe.js, and initialize elements
9
+ * @param publishableKey
10
+ * @param options
11
+ * @example
12
+ * ```
13
+ * const stripeElement = document.createElement('stripe-payment-element');
14
+ * customElements
15
+ * .whenDefined('stripe-payment-element')
16
+ * .then(() => {
17
+ * stripeElement.initStripe('pk_test_XXXXXXXXX')
18
+ * })
19
+ * ```
20
+ */
21
+ async initStripe(publishableKey, options) {
22
+ await this.stripeService.initialize(publishableKey, {
23
+ stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
24
+ applicationName: this.applicationName,
25
+ });
26
+ // If already successfully loaded, initialize elements immediately
27
+ if (this.stripeService.state.loadStripeStatus === 'success') {
28
+ await this.initElement();
29
+ this.stripeLoadedEventHandler();
30
+ }
31
+ else {
32
+ // Otherwise, wait for successful load
33
+ const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
34
+ if (newState !== 'success') {
35
+ return;
36
+ }
37
+ await this.initElement();
38
+ this.stripeLoadedEventHandler();
39
+ unsubscribe(); // Clean up listener after first success
40
+ });
41
+ }
42
+ }
43
+ /**
44
+ * Get Stripe.js and initialize with Checkout Session mode
45
+ * Use this method when you have a Checkout Session client secret instead of Payment/Setup Intent
46
+ * @param publishableKey - Your Stripe publishable API key
47
+ * @param checkoutSessionClientSecret - The client secret from Checkout Session
48
+ * @param options - Optional configuration
49
+ * @example
50
+ * ```
51
+ * const stripeElement = document.createElement('stripe-payment-element');
52
+ * customElements
53
+ * .whenDefined('stripe-payment-element')
54
+ * .then(() => {
55
+ * stripeElement.initStripeWithCheckoutSession(
56
+ * 'pk_test_XXXXXXXXX',
57
+ * 'cs_xxx_secret_xxx'
58
+ * )
59
+ * })
60
+ * ```
61
+ */
62
+ async initStripeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, options) {
63
+ await this.stripeService.initializeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, {
64
+ stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
65
+ applicationName: this.applicationName,
66
+ elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
67
+ });
68
+ // If already successfully loaded, initialize elements immediately
69
+ if (this.stripeService.state.loadStripeStatus === 'success') {
70
+ await this.initElement();
71
+ this.stripeLoadedEventHandler();
72
+ }
73
+ else {
74
+ // Otherwise, wait for successful load
75
+ const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
76
+ if (newState !== 'success') {
77
+ return;
78
+ }
79
+ await this.initElement();
80
+ this.stripeLoadedEventHandler();
81
+ unsubscribe(); // Clean up listener after first success
82
+ });
83
+ }
84
+ }
85
+ /**
86
+ * Update the form submit progress
87
+ * @param progress
88
+ * @returns
89
+ * @example
90
+ * ```
91
+ * const stripeElement = document.createElement('stripe-payment-element');
92
+ * customElements
93
+ * .whenDefined('stripe-payment-element')
94
+ * .then(() => {
95
+ * stripeElement.updateProgress('success')
96
+ * })
97
+ * ```
98
+ */
99
+ async updateProgress(progress) {
100
+ this.progress = progress;
101
+ return this;
102
+ }
103
+ /**
104
+ * Set error message
105
+ * @param errorMessage string
106
+ * @returns
107
+ * @example
108
+ * ```
109
+ * const stripeElement = document.createElement('stripe-payment-element');
110
+ * customElements
111
+ * .whenDefined('stripe-payment-element')
112
+ * .then(() => {
113
+ * stripeElement.setErrorMessage('Payment failed')
114
+ * })
115
+ * ```
116
+ */
117
+ async setErrorMessage(errorMessage) {
118
+ this.paymentElementManager.setError(errorMessage);
119
+ return this;
120
+ }
121
+ updatePublishableKey(publishableKey) {
122
+ const options = {};
123
+ options.stripeAccount = this.stripeService.state.stripeAccount;
124
+ const hasOptionValue = Object.values(options).filter(Boolean).length > 0;
125
+ this.initStripe(publishableKey, hasOptionValue ? options : undefined);
126
+ }
127
+ updateStripeAccountId(stripeAccount) {
128
+ this.initStripe(this.stripeService.state.publishableKey, {
129
+ stripeAccount: stripeAccount,
130
+ });
131
+ }
132
+ async updateIntentClientSecret() {
133
+ // Re-initialize the payment element when client secret changes
134
+ if (this.stripeService.state.loadStripeStatus === 'success') {
135
+ await this.initElement();
136
+ }
137
+ }
138
+ async updateCheckoutSessionClientSecret(newValue) {
139
+ // Re-initialize with checkout session when client secret changes
140
+ if (this.publishableKey && newValue) {
141
+ await this.initStripeWithCheckoutSession(this.publishableKey, newValue, {
142
+ stripeAccount: this.stripeAccount,
143
+ });
144
+ }
145
+ }
146
+ stripeLoadedEventHandler() {
147
+ const event = {
148
+ stripe: this.stripeService.getStripe(),
149
+ };
150
+ if (this.stripeDidLoaded) {
151
+ this.stripeDidLoaded(event);
152
+ }
153
+ this.stripeLoaded.emit(event);
154
+ }
155
+ async formSubmitEventHandler() {
156
+ const stripe = this.stripeService.getStripe();
157
+ const isCheckoutSession = this.stripeService.state.isCheckoutSession;
158
+ if (!stripe) {
159
+ console.error('Stripe not properly initialized');
160
+ return;
161
+ }
162
+ const eventData = {
163
+ stripe,
164
+ };
165
+ if (isCheckoutSession) {
166
+ // Checkout Session mode
167
+ const checkout = this.stripeService.getCheckout();
168
+ if (!checkout) {
169
+ console.error('Checkout not properly initialized');
170
+ return;
171
+ }
172
+ eventData.checkout = checkout;
173
+ eventData.checkoutSessionClientSecret = this.checkoutSessionClientSecret;
174
+ }
175
+ else {
176
+ // Payment Intent / Setup Intent mode
177
+ const elements = this.stripeService.getElements();
178
+ if (!elements) {
179
+ console.error('Elements not properly initialized');
180
+ return;
181
+ }
182
+ eventData.elements = elements;
183
+ eventData.intentClientSecret = this.intentClientSecret;
184
+ }
185
+ this.formSubmit.emit(eventData);
186
+ }
187
+ async defaultFormSubmitResultHandler(result) {
188
+ this.defaultFormSubmitResult.emit(result);
189
+ }
190
+ async checkoutSessionConfirmResultHandler(result) {
191
+ this.checkoutSessionConfirmResult.emit(result);
192
+ }
193
+ componentWillRender() {
194
+ if (!this.stripeService.state.publishableKey) {
195
+ return;
196
+ }
197
+ if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
198
+ return;
199
+ }
200
+ this.initStripe(this.stripeService.state.publishableKey, {
201
+ stripeAccount: this.stripeService.state.stripeAccount,
202
+ });
203
+ }
204
+ /**
205
+ * Default form submit action for Payment Intent / Setup Intent mode
206
+ * Calls confirmPayment or confirmSetup based on intentType
207
+ * If you don't want use it, please set `should-use-default-form-submit-action="false"`
208
+ * @param event
209
+ * @param param1
210
+ */
211
+ async defaultFormSubmitAction(event, { stripe, elements }) {
212
+ event.preventDefault();
213
+ try {
214
+ const { intentType } = this;
215
+ // Get current page URL for return_url
216
+ const returnUrl = window.location.href;
217
+ const result = await (() => {
218
+ if (intentType === 'payment') {
219
+ return stripe.confirmPayment({
220
+ elements,
221
+ confirmParams: {
222
+ return_url: returnUrl,
223
+ },
224
+ redirect: 'if_required',
225
+ });
226
+ }
227
+ return stripe.confirmSetup({
228
+ elements,
229
+ confirmParams: {
230
+ return_url: returnUrl,
231
+ },
232
+ redirect: 'if_required',
233
+ });
234
+ })();
235
+ if (result.error) {
236
+ throw new StripeAPIError(result.error);
237
+ }
238
+ this.defaultFormSubmitResultHandler(result);
239
+ }
240
+ catch (e) {
241
+ console.error(e);
242
+ this.defaultFormSubmitResultHandler(e);
243
+ throw e;
244
+ }
245
+ }
246
+ /**
247
+ * Checkout Session form submit action
248
+ * Uses checkout.loadActions().confirm() to confirm the payment
249
+ * @param event
250
+ * @param checkout - The Stripe Checkout instance
251
+ */
252
+ async checkoutSessionFormSubmitAction(event, checkout) {
253
+ var _a;
254
+ event.preventDefault();
255
+ try {
256
+ // Load actions from the checkout session
257
+ const loadActionsResult = await checkout.loadActions();
258
+ if (loadActionsResult.type === 'error') {
259
+ // Create a StripeError-compatible object from the Checkout Session error
260
+ const stripeError = {
261
+ type: 'api_error',
262
+ code: loadActionsResult.error.code || 'checkout_session_error',
263
+ message: loadActionsResult.error.message,
264
+ };
265
+ throw new StripeAPIError(stripeError);
266
+ }
267
+ const { actions } = loadActionsResult;
268
+ // Get current page URL for return_url
269
+ const returnUrl = window.location.href;
270
+ // Confirm the payment using checkout session actions
271
+ const result = await actions.confirm({
272
+ returnUrl,
273
+ redirect: 'if_required',
274
+ });
275
+ if (result.type === 'error') {
276
+ // Create a StripeError-compatible object from the confirm error
277
+ const stripeError = {
278
+ type: 'card_error',
279
+ code: result.error.code || 'payment_failed',
280
+ message: result.error.message,
281
+ decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
282
+ };
283
+ throw new StripeAPIError(stripeError);
284
+ }
285
+ this.checkoutSessionConfirmResultHandler(result);
286
+ }
287
+ catch (e) {
288
+ console.error(e);
289
+ this.checkoutSessionConfirmResultHandler(e instanceof Error ? e : new Error(String(e)));
290
+ throw e;
291
+ }
292
+ }
293
+ constructor() {
294
+ /**
295
+ * Default submit handle type.
296
+ * If you want to use `setupIntent`, should update this attribute.
297
+ */
298
+ this.intentType = 'payment';
299
+ /**
300
+ * Payment sheet title
301
+ * By default we recommended to use these string
302
+ * - 'Add your payment information' -> PaymentSheet / PaymentFlow(Android)
303
+ * - 'Add a card' -> PaymentFlow(iOS)
304
+ * These strings will translated automatically by this library.
305
+ */
306
+ this.sheetTitle = 'Add your payment information';
307
+ /**
308
+ * Submit button label
309
+ * By default we recommended to use these string
310
+ * - 'Pay' -> PaymentSheet
311
+ * - 'Add' -> PaymentFlow(Android)
312
+ * - 'Add card' -> PaymentFlow(iOS)
313
+ * - 'Add a card' -> PaymentFlow(iOS)
314
+ * These strings will translated automatically by this library.
315
+ */
316
+ this.buttonLabel = 'Pay';
317
+ /**
318
+ * The progress status of the checkout process
319
+ */
320
+ this.progress = '';
321
+ /**
322
+ * Overwrite the application name that registered
323
+ * For wrapper library (like Capacitor)
324
+ */
325
+ this.applicationName = 'stripe-pwa-elements';
326
+ /**
327
+ * The component will provide a function to call the `stripe.confirmPayment` API.
328
+ * If you want to customize the behavior, should set false.
329
+ * And listen the 'formSubmit' event on the element
330
+ */
331
+ this.shouldUseDefaultFormSubmitAction = true;
332
+ // Dependency Injection via factory
333
+ this.stripeService = serviceFactory.createStripeService();
334
+ this.paymentElementManager = serviceFactory.createPaymentElementManager(this.stripeService);
335
+ if (this.publishableKey) {
336
+ this.initStripe(this.publishableKey, {
337
+ stripeAccount: this.stripeAccount,
338
+ });
339
+ }
340
+ }
341
+ /**
342
+ * Initialize Component using Stripe Element
343
+ */
344
+ async initElement() {
345
+ // Initialize payment element
346
+ await this.paymentElementManager.initialize(this.el);
347
+ // Add form submit listener scoped to this component instance
348
+ const formElement = this.el.querySelector('#stripe-payment-element');
349
+ if (!formElement) {
350
+ console.error('Form element #stripe-payment-element not found');
351
+ return;
352
+ }
353
+ // Remove existing listener if present to prevent duplicates
354
+ if (this._submitHandler) {
355
+ formElement.removeEventListener('submit', this._submitHandler);
356
+ }
357
+ // Create and store the submit handler
358
+ this._submitHandler = async (e) => {
359
+ const stripe = this.stripeService.getStripe();
360
+ const isCheckoutSession = this.stripeService.state.isCheckoutSession;
361
+ if (!stripe) {
362
+ console.error('Stripe not properly initialized');
363
+ return;
364
+ }
365
+ // Build submit event props based on mode
366
+ const submitEventProps = {
367
+ stripe,
368
+ };
369
+ if (isCheckoutSession) {
370
+ // Checkout Session mode
371
+ const checkout = this.stripeService.getCheckout();
372
+ if (!checkout) {
373
+ console.error('Checkout not properly initialized');
374
+ return;
375
+ }
376
+ submitEventProps.checkout = checkout;
377
+ submitEventProps.checkoutSessionClientSecret = this.checkoutSessionClientSecret;
378
+ }
379
+ else {
380
+ // Payment Intent / Setup Intent mode
381
+ const elements = this.stripeService.getElements();
382
+ if (!elements) {
383
+ console.error('Elements not properly initialized');
384
+ return;
385
+ }
386
+ submitEventProps.elements = elements;
387
+ submitEventProps.intentClientSecret = this.intentClientSecret;
388
+ }
389
+ this.progress = 'loading';
390
+ try {
391
+ if (this.handleSubmit) {
392
+ await this.handleSubmit(e, submitEventProps);
393
+ }
394
+ else if (this.shouldUseDefaultFormSubmitAction === true) {
395
+ if (isCheckoutSession && submitEventProps.checkout) {
396
+ // Use Checkout Session confirmation
397
+ await this.checkoutSessionFormSubmitAction(e, submitEventProps.checkout);
398
+ }
399
+ else if (this.intentClientSecret) {
400
+ // Use Payment Intent / Setup Intent confirmation
401
+ await this.defaultFormSubmitAction(e, submitEventProps);
402
+ }
403
+ else {
404
+ e.preventDefault();
405
+ }
406
+ }
407
+ else {
408
+ e.preventDefault();
409
+ }
410
+ await this.formSubmitEventHandler();
411
+ if (this.handleSubmit || this.shouldUseDefaultFormSubmitAction === true) {
412
+ this.progress = 'success';
413
+ }
414
+ }
415
+ catch (err) {
416
+ const errorMessage = err instanceof Error ? err.message : String(err);
417
+ this.paymentElementManager.setError(errorMessage);
418
+ this.progress = 'failure';
419
+ }
420
+ };
421
+ formElement.addEventListener('submit', this._submitHandler);
422
+ }
423
+ componentDidLoad() {
424
+ this.el.classList.add(checkPlatform());
425
+ }
426
+ disconnectedCallback() {
427
+ this.paymentElementManager.unmount();
428
+ // Remove event listener to prevent memory leaks
429
+ if (this._submitHandler) {
430
+ const formElement = this.el.querySelector('#stripe-payment-element');
431
+ if (formElement) {
432
+ formElement.removeEventListener('submit', this._submitHandler);
433
+ }
434
+ }
435
+ }
436
+ render() {
437
+ const { loadStripeStatus, isCheckoutSession } = this.stripeService.state;
438
+ const { errorMessage } = this.paymentElementManager.getState();
439
+ if (loadStripeStatus === 'failure') {
440
+ return h("p", null, i18n.t('Failed to load Stripe'));
441
+ }
442
+ // Determine if button should be disabled
443
+ // For Checkout Session mode: check if checkout is initialized (loadStripeStatus === 'success')
444
+ // For Payment Intent mode: check if intentClientSecret is set
445
+ const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : !!this.intentClientSecret;
446
+ const disabled = this.progress === 'loading' || !hasValidSecret;
447
+ return (h("div", { class: "stripe-payment-sheet-wrap" }, h("form", { id: "stripe-payment-element" }, h("div", { class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", null, h("div", { class: "stripe-section-title" }, i18n.t('Payment information'))), h("div", { class: "payment-info visible" }, h("div", { id: "payment-element" })), h("div", { id: "payment-errors", class: "stripe-element-errors" }, errorMessage), h("div", { style: { marginTop: '32px' } }, h("button", { type: "submit", disabled: disabled }, this.progress === 'loading' ? i18n.t('Loading') : i18n.t(this.buttonLabel))))));
448
+ }
449
+ static get is() { return "stripe-payment-element"; }
450
+ static get originalStyleUrls() {
451
+ return {
452
+ "$": ["stripe-payment-element.scss"]
453
+ };
454
+ }
455
+ static get styleUrls() {
456
+ return {
457
+ "$": ["stripe-payment-element.css"]
458
+ };
459
+ }
460
+ static get properties() {
461
+ return {
462
+ "intentType": {
463
+ "type": "string",
464
+ "mutable": false,
465
+ "complexType": {
466
+ "original": "IntentType",
467
+ "resolved": "\"payment\" | \"setup\"",
468
+ "references": {
469
+ "IntentType": {
470
+ "location": "import",
471
+ "path": "../../interfaces",
472
+ "id": "src/interfaces.ts::IntentType"
473
+ }
474
+ }
475
+ },
476
+ "required": false,
477
+ "optional": false,
478
+ "docs": {
479
+ "tags": [],
480
+ "text": "Default submit handle type.\nIf you want to use `setupIntent`, should update this attribute."
481
+ },
482
+ "getter": false,
483
+ "setter": false,
484
+ "reflect": false,
485
+ "attribute": "intent-type",
486
+ "defaultValue": "'payment'"
487
+ },
488
+ "sheetTitle": {
489
+ "type": "string",
490
+ "mutable": false,
491
+ "complexType": {
492
+ "original": "string",
493
+ "resolved": "string",
494
+ "references": {}
495
+ },
496
+ "required": false,
497
+ "optional": false,
498
+ "docs": {
499
+ "tags": [],
500
+ "text": "Payment sheet title\nBy default we recommended to use these string\n- 'Add your payment information' -> PaymentSheet / PaymentFlow(Android)\n- 'Add a card' -> PaymentFlow(iOS)\nThese strings will translated automatically by this library."
501
+ },
502
+ "getter": false,
503
+ "setter": false,
504
+ "reflect": false,
505
+ "attribute": "sheet-title",
506
+ "defaultValue": "'Add your payment information'"
507
+ },
508
+ "buttonLabel": {
509
+ "type": "string",
510
+ "mutable": false,
511
+ "complexType": {
512
+ "original": "string",
513
+ "resolved": "string",
514
+ "references": {}
515
+ },
516
+ "required": false,
517
+ "optional": false,
518
+ "docs": {
519
+ "tags": [],
520
+ "text": "Submit button label\nBy 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)\nThese strings will translated automatically by this library."
521
+ },
522
+ "getter": false,
523
+ "setter": false,
524
+ "reflect": false,
525
+ "attribute": "button-label",
526
+ "defaultValue": "'Pay'"
527
+ },
528
+ "publishableKey": {
529
+ "type": "string",
530
+ "mutable": false,
531
+ "complexType": {
532
+ "original": "string",
533
+ "resolved": "string",
534
+ "references": {}
535
+ },
536
+ "required": false,
537
+ "optional": false,
538
+ "docs": {
539
+ "tags": [],
540
+ "text": "Your Stripe publishable API key."
541
+ },
542
+ "getter": false,
543
+ "setter": false,
544
+ "reflect": false,
545
+ "attribute": "publishable-key"
546
+ },
547
+ "stripeAccount": {
548
+ "type": "string",
549
+ "mutable": false,
550
+ "complexType": {
551
+ "original": "string",
552
+ "resolved": "string",
553
+ "references": {}
554
+ },
555
+ "required": false,
556
+ "optional": false,
557
+ "docs": {
558
+ "tags": [{
559
+ "name": "info",
560
+ "text": "https://stripe.com/docs/connect/authentication"
561
+ }],
562
+ "text": "Optional. Making API calls for connected accounts"
563
+ },
564
+ "getter": false,
565
+ "setter": false,
566
+ "reflect": false,
567
+ "attribute": "stripe-account"
568
+ },
569
+ "applicationName": {
570
+ "type": "string",
571
+ "mutable": false,
572
+ "complexType": {
573
+ "original": "string",
574
+ "resolved": "string",
575
+ "references": {}
576
+ },
577
+ "required": false,
578
+ "optional": false,
579
+ "docs": {
580
+ "tags": [],
581
+ "text": "Overwrite the application name that registered\nFor wrapper library (like Capacitor)"
582
+ },
583
+ "getter": false,
584
+ "setter": false,
585
+ "reflect": false,
586
+ "attribute": "application-name",
587
+ "defaultValue": "'stripe-pwa-elements'"
588
+ },
589
+ "intentClientSecret": {
590
+ "type": "string",
591
+ "mutable": false,
592
+ "complexType": {
593
+ "original": "string",
594
+ "resolved": "string",
595
+ "references": {}
596
+ },
597
+ "required": false,
598
+ "optional": true,
599
+ "docs": {
600
+ "tags": [{
601
+ "name": "example",
602
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\n .whenDefined('stripe-payment-element')\n .then(() => {\n stripeElement.setAttribute('intent-client-secret', 'pi_xxx_secret_xxx')\n })\n```"
603
+ }, {
604
+ "name": "example",
605
+ "text": "```\n<stripe-payment-element intent-client-secret=\"pi_xxx_secret_xxx\" />\n```"
606
+ }],
607
+ "text": "The client secret from paymentIntent.create or setupIntent.create response\nUse this for Payment Intent / Setup Intent mode"
608
+ },
609
+ "getter": false,
610
+ "setter": false,
611
+ "reflect": false,
612
+ "attribute": "intent-client-secret"
613
+ },
614
+ "checkoutSessionClientSecret": {
615
+ "type": "string",
616
+ "mutable": false,
617
+ "complexType": {
618
+ "original": "string",
619
+ "resolved": "string",
620
+ "references": {}
621
+ },
622
+ "required": false,
623
+ "optional": true,
624
+ "docs": {
625
+ "tags": [{
626
+ "name": "example",
627
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\n .whenDefined('stripe-payment-element')\n .then(() => {\n stripeElement.initStripeWithCheckoutSession('pk_test_xxx', 'cs_xxx_secret_xxx')\n })\n```"
628
+ }],
629
+ "text": "The client secret from checkout session response\nUse this for Checkout Session mode instead of intentClientSecret\nWhen this prop is set, the component will use Checkout Session API"
630
+ },
631
+ "getter": false,
632
+ "setter": false,
633
+ "reflect": false,
634
+ "attribute": "checkout-session-client-secret"
635
+ },
636
+ "shouldUseDefaultFormSubmitAction": {
637
+ "type": "boolean",
638
+ "mutable": false,
639
+ "complexType": {
640
+ "original": "boolean",
641
+ "resolved": "boolean",
642
+ "references": {}
643
+ },
644
+ "required": false,
645
+ "optional": false,
646
+ "docs": {
647
+ "tags": [],
648
+ "text": "The component will provide a function to call the `stripe.confirmPayment` API.\nIf you want to customize the behavior, should set false.\nAnd listen the 'formSubmit' event on the element"
649
+ },
650
+ "getter": false,
651
+ "setter": false,
652
+ "reflect": false,
653
+ "attribute": "should-use-default-form-submit-action",
654
+ "defaultValue": "true"
655
+ },
656
+ "handleSubmit": {
657
+ "type": "unknown",
658
+ "mutable": true,
659
+ "complexType": {
660
+ "original": "PaymentElementSubmitHandler",
661
+ "resolved": "(event: Event, props: PaymentElementSubmitEvent) => Promise<void>",
662
+ "references": {
663
+ "PaymentElementSubmitHandler": {
664
+ "location": "local",
665
+ "path": "/Users/okamotohidetaka/development/oss/stripe-pwa-elements/src/components/stripe-payment-element/stripe-payment-element.tsx",
666
+ "id": "src/components/stripe-payment-element/stripe-payment-element.tsx::PaymentElementSubmitHandler"
667
+ }
668
+ }
669
+ },
670
+ "required": false,
671
+ "optional": false,
672
+ "docs": {
673
+ "tags": [],
674
+ "text": "Form submit event handler"
675
+ },
676
+ "getter": false,
677
+ "setter": false
678
+ },
679
+ "stripeDidLoaded": {
680
+ "type": "unknown",
681
+ "mutable": true,
682
+ "complexType": {
683
+ "original": "StripeDidLoadedHandler",
684
+ "resolved": "(event: StripeLoadedEvent) => Promise<void>",
685
+ "references": {
686
+ "StripeDidLoadedHandler": {
687
+ "location": "import",
688
+ "path": "../../interfaces",
689
+ "id": "src/interfaces.ts::StripeDidLoadedHandler"
690
+ }
691
+ }
692
+ },
693
+ "required": false,
694
+ "optional": true,
695
+ "docs": {
696
+ "tags": [],
697
+ "text": "Stripe.js class loaded handler"
698
+ },
699
+ "getter": false,
700
+ "setter": false
701
+ }
702
+ };
703
+ }
704
+ static get states() {
705
+ return {
706
+ "progress": {}
707
+ };
708
+ }
709
+ static get events() {
710
+ return [{
711
+ "method": "stripeLoaded",
712
+ "name": "stripeLoaded",
713
+ "bubbles": true,
714
+ "cancelable": true,
715
+ "composed": true,
716
+ "docs": {
717
+ "tags": [{
718
+ "name": "example",
719
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\n .whenDefined('stripe-payment-element')\n .then(() => {\n stripeElement\n .addEventListener('stripeLoaded', async ({ detail: {stripe} }) => {\n console.log('Stripe loaded:', stripe);\n });\n })\n```"
720
+ }],
721
+ "text": "Stripe Client loaded event"
722
+ },
723
+ "complexType": {
724
+ "original": "StripeLoadedEvent",
725
+ "resolved": "{ stripe: Stripe; }",
726
+ "references": {
727
+ "StripeLoadedEvent": {
728
+ "location": "import",
729
+ "path": "../../interfaces",
730
+ "id": "src/interfaces.ts::StripeLoadedEvent"
731
+ }
732
+ }
733
+ }
734
+ }, {
735
+ "method": "formSubmit",
736
+ "name": "formSubmit",
737
+ "bubbles": true,
738
+ "cancelable": true,
739
+ "composed": true,
740
+ "docs": {
741
+ "tags": [{
742
+ "name": "example",
743
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\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```"
744
+ }],
745
+ "text": "Form submit event"
746
+ },
747
+ "complexType": {
748
+ "original": "PaymentElementSubmitEvent",
749
+ "resolved": "{ stripe: Stripe; elements?: StripeElements; intentClientSecret?: string; checkout?: StripeCheckout; checkoutSessionClientSecret?: string; }",
750
+ "references": {
751
+ "PaymentElementSubmitEvent": {
752
+ "location": "local",
753
+ "path": "/Users/okamotohidetaka/development/oss/stripe-pwa-elements/src/components/stripe-payment-element/stripe-payment-element.tsx",
754
+ "id": "src/components/stripe-payment-element/stripe-payment-element.tsx::PaymentElementSubmitEvent"
755
+ }
756
+ }
757
+ }
758
+ }, {
759
+ "method": "defaultFormSubmitResult",
760
+ "name": "defaultFormSubmitResult",
761
+ "bubbles": true,
762
+ "cancelable": true,
763
+ "composed": true,
764
+ "docs": {
765
+ "tags": [{
766
+ "name": "example",
767
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\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```"
768
+ }],
769
+ "text": "Receive the result of defaultFormSubmit event\nThis event is emitted when using Payment Intent / Setup Intent mode"
770
+ },
771
+ "complexType": {
772
+ "original": "DefaultFormSubmitResult",
773
+ "resolved": "Error | { paymentIntent: PaymentIntent; error?: undefined; } | { paymentIntent?: undefined; error: StripeError; } | { setupIntent: SetupIntent; error?: undefined; } | { setupIntent?: undefined; error: StripeError; }",
774
+ "references": {
775
+ "DefaultFormSubmitResult": {
776
+ "location": "import",
777
+ "path": "../../interfaces",
778
+ "id": "src/interfaces.ts::DefaultFormSubmitResult"
779
+ }
780
+ }
781
+ }
782
+ }, {
783
+ "method": "checkoutSessionConfirmResult",
784
+ "name": "checkoutSessionConfirmResult",
785
+ "bubbles": true,
786
+ "cancelable": true,
787
+ "composed": true,
788
+ "docs": {
789
+ "tags": [{
790
+ "name": "example",
791
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\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```"
792
+ }],
793
+ "text": "Receive the result of checkout session confirm\nThis event is emitted when using Checkout Session mode"
794
+ },
795
+ "complexType": {
796
+ "original": "CheckoutSessionFormSubmitResult",
797
+ "resolved": "Error | { type: \"error\"; error: ConfirmError; } | { type: \"success\"; session: StripeCheckoutSession; }",
798
+ "references": {
799
+ "CheckoutSessionFormSubmitResult": {
800
+ "location": "local",
801
+ "path": "/Users/okamotohidetaka/development/oss/stripe-pwa-elements/src/components/stripe-payment-element/stripe-payment-element.tsx",
802
+ "id": "src/components/stripe-payment-element/stripe-payment-element.tsx::CheckoutSessionFormSubmitResult"
803
+ }
804
+ }
805
+ }
806
+ }];
807
+ }
808
+ static get methods() {
809
+ return {
810
+ "initStripe": {
811
+ "complexType": {
812
+ "signature": "(publishableKey: string, options?: InitStripeOptions) => Promise<void>",
813
+ "parameters": [{
814
+ "name": "publishableKey",
815
+ "type": "string",
816
+ "docs": ""
817
+ }, {
818
+ "name": "options",
819
+ "type": "{ stripeAccount?: string; }",
820
+ "docs": ""
821
+ }],
822
+ "references": {
823
+ "Promise": {
824
+ "location": "global",
825
+ "id": "global::Promise"
826
+ },
827
+ "InitStripeOptions": {
828
+ "location": "import",
829
+ "path": "../../interfaces",
830
+ "id": "src/interfaces.ts::InitStripeOptions"
831
+ }
832
+ },
833
+ "return": "Promise<void>"
834
+ },
835
+ "docs": {
836
+ "text": "Get Stripe.js, and initialize elements",
837
+ "tags": [{
838
+ "name": "param",
839
+ "text": "publishableKey"
840
+ }, {
841
+ "name": "param",
842
+ "text": "options"
843
+ }, {
844
+ "name": "example",
845
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\n .whenDefined('stripe-payment-element')\n .then(() => {\n stripeElement.initStripe('pk_test_XXXXXXXXX')\n })\n```"
846
+ }]
847
+ }
848
+ },
849
+ "initStripeWithCheckoutSession": {
850
+ "complexType": {
851
+ "signature": "(publishableKey: string, checkoutSessionClientSecret: string, options?: InitCheckoutSessionOptions) => Promise<void>",
852
+ "parameters": [{
853
+ "name": "publishableKey",
854
+ "type": "string",
855
+ "docs": "- Your Stripe publishable API key"
856
+ }, {
857
+ "name": "checkoutSessionClientSecret",
858
+ "type": "string",
859
+ "docs": "- The client secret from Checkout Session"
860
+ }, {
861
+ "name": "options",
862
+ "type": "InitStripeOptions & CheckoutSessionOptions",
863
+ "docs": "- Optional configuration"
864
+ }],
865
+ "references": {
866
+ "Promise": {
867
+ "location": "global",
868
+ "id": "global::Promise"
869
+ },
870
+ "InitCheckoutSessionOptions": {
871
+ "location": "local",
872
+ "path": "/Users/okamotohidetaka/development/oss/stripe-pwa-elements/src/components/stripe-payment-element/stripe-payment-element.tsx",
873
+ "id": "src/components/stripe-payment-element/stripe-payment-element.tsx::InitCheckoutSessionOptions"
874
+ }
875
+ },
876
+ "return": "Promise<void>"
877
+ },
878
+ "docs": {
879
+ "text": "Get Stripe.js and initialize with Checkout Session mode\nUse this method when you have a Checkout Session client secret instead of Payment/Setup Intent",
880
+ "tags": [{
881
+ "name": "param",
882
+ "text": "publishableKey - Your Stripe publishable API key"
883
+ }, {
884
+ "name": "param",
885
+ "text": "checkoutSessionClientSecret - The client secret from Checkout Session"
886
+ }, {
887
+ "name": "param",
888
+ "text": "options - Optional configuration"
889
+ }, {
890
+ "name": "example",
891
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\n .whenDefined('stripe-payment-element')\n .then(() => {\n stripeElement.initStripeWithCheckoutSession(\n 'pk_test_XXXXXXXXX',\n 'cs_xxx_secret_xxx'\n )\n })\n```"
892
+ }]
893
+ }
894
+ },
895
+ "updateProgress": {
896
+ "complexType": {
897
+ "signature": "(progress: ProgressStatus) => Promise<this>",
898
+ "parameters": [{
899
+ "name": "progress",
900
+ "type": "\"\" | \"loading\" | \"success\" | \"failure\"",
901
+ "docs": ""
902
+ }],
903
+ "references": {
904
+ "Promise": {
905
+ "location": "global",
906
+ "id": "global::Promise"
907
+ },
908
+ "ProgressStatus": {
909
+ "location": "import",
910
+ "path": "../../interfaces",
911
+ "id": "src/interfaces.ts::ProgressStatus"
912
+ }
913
+ },
914
+ "return": "Promise<this>"
915
+ },
916
+ "docs": {
917
+ "text": "Update the form submit progress",
918
+ "tags": [{
919
+ "name": "param",
920
+ "text": "progress"
921
+ }, {
922
+ "name": "returns",
923
+ "text": undefined
924
+ }, {
925
+ "name": "example",
926
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\n .whenDefined('stripe-payment-element')\n .then(() => {\n stripeElement.updateProgress('success')\n })\n```"
927
+ }]
928
+ }
929
+ },
930
+ "setErrorMessage": {
931
+ "complexType": {
932
+ "signature": "(errorMessage: string) => Promise<this>",
933
+ "parameters": [{
934
+ "name": "errorMessage",
935
+ "type": "string",
936
+ "docs": "string"
937
+ }],
938
+ "references": {
939
+ "Promise": {
940
+ "location": "global",
941
+ "id": "global::Promise"
942
+ }
943
+ },
944
+ "return": "Promise<this>"
945
+ },
946
+ "docs": {
947
+ "text": "Set error message",
948
+ "tags": [{
949
+ "name": "param",
950
+ "text": "errorMessage string"
951
+ }, {
952
+ "name": "returns",
953
+ "text": undefined
954
+ }, {
955
+ "name": "example",
956
+ "text": "```\nconst stripeElement = document.createElement('stripe-payment-element');\ncustomElements\n .whenDefined('stripe-payment-element')\n .then(() => {\n stripeElement.setErrorMessage('Payment failed')\n })\n```"
957
+ }]
958
+ }
959
+ }
960
+ };
961
+ }
962
+ static get elementRef() { return "el"; }
963
+ static get watchers() {
964
+ return [{
965
+ "propName": "publishableKey",
966
+ "methodName": "updatePublishableKey"
967
+ }, {
968
+ "propName": "stripeAccount",
969
+ "methodName": "updateStripeAccountId"
970
+ }, {
971
+ "propName": "intentClientSecret",
972
+ "methodName": "updateIntentClientSecret"
973
+ }, {
974
+ "propName": "checkoutSessionClientSecret",
975
+ "methodName": "updateCheckoutSessionClientSecret"
976
+ }];
977
+ }
978
+ }
979
+ //# sourceMappingURL=stripe-payment-element.js.map