stripe-pwa-elements 4.0.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.
- package/dist/cjs/{factory-da3xAKkz.js → factory-Cd2VI_N2.js} +22 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stripe-address-element.cjs.entry.js +8 -1
- package/dist/cjs/stripe-card-element-modal.cjs.entry.js +1 -1
- package/dist/cjs/stripe-card-element_2.cjs.entry.js +24 -6
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +8 -1
- package/dist/cjs/stripe-elements.cjs.js +1 -1
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +8 -1
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +8 -1
- package/dist/cjs/stripe-payment-element.cjs.entry.js +95 -38
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +22 -15
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/stripe-address-element/stripe-address-element.js +7 -0
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +7 -0
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +1 -1
- package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +7 -0
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +7 -0
- package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +7 -0
- package/dist/collection/components/stripe-modal/stripe-modal.js +18 -6
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +94 -37
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +15 -8
- package/dist/collection/services/stripe-service.js +22 -4
- package/dist/components/factory.js +1 -1
- package/dist/components/stripe-address-element.js +1 -1
- package/dist/components/stripe-card-element-modal.js +1 -1
- package/dist/components/stripe-card-element2.js +1 -1
- package/dist/components/stripe-currency-selector.js +1 -1
- package/dist/components/stripe-express-checkout-element.js +1 -1
- package/dist/components/stripe-link-authentication-element.js +1 -1
- package/dist/components/stripe-modal2.js +1 -1
- package/dist/components/stripe-payment-element.js +1 -1
- package/dist/components/stripe-payment-request-button2.js +1 -1
- package/dist/esm/{factory-DeqoYLf_.js → factory-VTa1Gc94.js} +22 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stripe-address-element.entry.js +8 -1
- package/dist/esm/stripe-card-element-modal.entry.js +1 -1
- package/dist/esm/stripe-card-element_2.entry.js +24 -6
- package/dist/esm/stripe-currency-selector.entry.js +8 -1
- package/dist/esm/stripe-elements.js +1 -1
- package/dist/esm/stripe-express-checkout-element.entry.js +8 -1
- package/dist/esm/stripe-link-authentication-element.entry.js +8 -1
- package/dist/esm/stripe-payment-element.entry.js +95 -38
- package/dist/esm/stripe-payment-request-button.entry.js +17 -10
- package/dist/stripe-elements/p-1bd46766.entry.js +1 -0
- package/dist/stripe-elements/p-1c6e0a45.entry.js +1 -0
- package/dist/stripe-elements/p-3f42ca0c.entry.js +1 -0
- package/dist/stripe-elements/p-74de1556.entry.js +1 -0
- package/dist/stripe-elements/p-76e57d78.entry.js +1 -0
- package/dist/stripe-elements/p-840d499f.entry.js +1 -0
- package/dist/stripe-elements/{p--sA2m1ad.js → p-CrjrbGJ3.js} +1 -1
- package/dist/stripe-elements/{p-38e7b187.entry.js → p-ae0c336e.entry.js} +1 -1
- package/dist/stripe-elements/p-cfd8e081.entry.js +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -1
- package/dist/types/components/stripe-address-element/stripe-address-element.d.ts +6 -0
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +6 -0
- package/dist/types/components/stripe-currency-selector/stripe-currency-selector.d.ts +6 -0
- package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +6 -0
- package/dist/types/components/stripe-link-authentication-element/stripe-link-authentication-element.d.ts +6 -0
- package/dist/types/components/stripe-modal/stripe-modal.d.ts +1 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +18 -0
- package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +6 -1
- package/dist/types/services/interfaces.d.ts +1 -0
- package/dist/types/services/stripe-service.d.ts +6 -2
- package/package.json +1 -1
- package/readme.md +4 -4
- package/dist/stripe-elements/p-44495284.entry.js +0 -1
- package/dist/stripe-elements/p-4ba675fa.entry.js +0 -1
- package/dist/stripe-elements/p-c24ae181.entry.js +0 -1
- package/dist/stripe-elements/p-d9e86451.entry.js +0 -1
- package/dist/stripe-elements/p-f09c86a0.entry.js +0 -1
- package/dist/stripe-elements/p-f64f394d.entry.js +0 -1
- package/dist/stripe-elements/p-f6d2425e.entry.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, a as createEvent, h, g as getElement } from './index-C6bbmyga.js';
|
|
2
|
-
import { s as serviceFactory, c as checkPlatform, i as i18n } from './factory-
|
|
2
|
+
import { s as serviceFactory, c as checkPlatform, i as i18n } from './factory-VTa1Gc94.js';
|
|
3
3
|
import { S as StripeAPIError } from './error-XRfh5Wrs.js';
|
|
4
4
|
import './index-CBXaOfXU.js';
|
|
5
5
|
|
|
@@ -135,26 +135,14 @@ const StripePaymentElement = class {
|
|
|
135
135
|
* ```
|
|
136
136
|
*/
|
|
137
137
|
async initStripe(publishableKey, options) {
|
|
138
|
+
const generation = ++this.initGeneration;
|
|
138
139
|
await this.stripeService.initialize(publishableKey, {
|
|
139
140
|
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
140
141
|
applicationName: this.applicationName,
|
|
142
|
+
// Payment Element needs the client secret when the Elements group is created
|
|
143
|
+
clientSecret: this.intentClientSecret,
|
|
141
144
|
});
|
|
142
|
-
|
|
143
|
-
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
144
|
-
await this.initElement();
|
|
145
|
-
this.stripeLoadedEventHandler();
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
// Otherwise, wait for successful load
|
|
149
|
-
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
150
|
-
if (newState !== 'success') {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
await this.initElement();
|
|
154
|
-
this.stripeLoadedEventHandler();
|
|
155
|
-
unsubscribe(); // Clean up listener after first success
|
|
156
|
-
});
|
|
157
|
-
}
|
|
145
|
+
await this.mountWhenLoaded(generation);
|
|
158
146
|
}
|
|
159
147
|
/**
|
|
160
148
|
* Get Stripe.js and initialize with Checkout Session mode
|
|
@@ -176,27 +164,13 @@ const StripePaymentElement = class {
|
|
|
176
164
|
* ```
|
|
177
165
|
*/
|
|
178
166
|
async initStripeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, options) {
|
|
167
|
+
const generation = ++this.initGeneration;
|
|
179
168
|
await this.stripeService.initializeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, {
|
|
180
169
|
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
181
170
|
applicationName: this.applicationName,
|
|
182
171
|
elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
|
|
183
172
|
});
|
|
184
|
-
|
|
185
|
-
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
186
|
-
await this.initElement();
|
|
187
|
-
this.stripeLoadedEventHandler();
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
// Otherwise, wait for successful load
|
|
191
|
-
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
192
|
-
if (newState !== 'success') {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
await this.initElement();
|
|
196
|
-
this.stripeLoadedEventHandler();
|
|
197
|
-
unsubscribe(); // Clean up listener after first success
|
|
198
|
-
});
|
|
199
|
-
}
|
|
173
|
+
await this.mountWhenLoaded(generation);
|
|
200
174
|
}
|
|
201
175
|
/**
|
|
202
176
|
* Update the form submit progress
|
|
@@ -238,18 +212,32 @@ const StripePaymentElement = class {
|
|
|
238
212
|
const options = {};
|
|
239
213
|
options.stripeAccount = this.stripeService.state.stripeAccount;
|
|
240
214
|
const hasOptionValue = Object.values(options).filter(value => value != null && value !== '').length > 0;
|
|
215
|
+
if (this.hasCheckoutSessionClientSecret()) {
|
|
216
|
+
this.initStripeWithCheckoutSession(publishableKey, this.checkoutSessionClientSecret, { stripeAccount: options.stripeAccount });
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
241
219
|
this.initStripe(publishableKey, hasOptionValue ? options : undefined);
|
|
242
220
|
}
|
|
243
221
|
updateStripeAccountId(stripeAccount) {
|
|
222
|
+
if (this.hasCheckoutSessionClientSecret()) {
|
|
223
|
+
this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, { stripeAccount });
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
244
226
|
this.initStripe(this.stripeService.state.publishableKey, {
|
|
245
227
|
stripeAccount: stripeAccount,
|
|
246
228
|
});
|
|
247
229
|
}
|
|
248
230
|
async updateIntentClientSecret() {
|
|
249
|
-
//
|
|
250
|
-
if (this.
|
|
251
|
-
|
|
231
|
+
// Checkout Session mode takes precedence (same rule as startStripe); an intent secret must not switch the mode
|
|
232
|
+
if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
|
|
233
|
+
return;
|
|
252
234
|
}
|
|
235
|
+
// The Elements group is bound to its client secret, so it has to be recreated when the secret changes
|
|
236
|
+
const { publishableKey, stripeAccount } = this.stripeService.state;
|
|
237
|
+
if (publishableKey == null || publishableKey === '') {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
await this.initStripe(publishableKey, { stripeAccount });
|
|
253
241
|
}
|
|
254
242
|
async updateCheckoutSessionClientSecret(newValue) {
|
|
255
243
|
// Re-initialize with checkout session when client secret changes
|
|
@@ -303,6 +291,13 @@ const StripePaymentElement = class {
|
|
|
303
291
|
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
304
292
|
return;
|
|
305
293
|
}
|
|
294
|
+
// Retry in the same mode as the initial start
|
|
295
|
+
if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
|
|
296
|
+
this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, {
|
|
297
|
+
stripeAccount: this.stripeService.state.stripeAccount,
|
|
298
|
+
});
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
306
301
|
this.initStripe(this.stripeService.state.publishableKey, {
|
|
307
302
|
stripeAccount: this.stripeService.state.stripeAccount,
|
|
308
303
|
});
|
|
@@ -354,6 +349,8 @@ const StripePaymentElement = class {
|
|
|
354
349
|
this.formSubmit = createEvent(this, "formSubmit", 7);
|
|
355
350
|
this.defaultFormSubmitResult = createEvent(this, "defaultFormSubmitResult", 7);
|
|
356
351
|
this.checkoutSessionConfirmResult = createEvent(this, "checkoutSessionConfirmResult", 7);
|
|
352
|
+
// Incremented on every initStripe call so that a superseded call stops after its awaits
|
|
353
|
+
this.initGeneration = 0;
|
|
357
354
|
/**
|
|
358
355
|
* Default submit handle type.
|
|
359
356
|
* If you want to use `setupIntent`, should update this attribute.
|
|
@@ -395,11 +392,71 @@ const StripePaymentElement = class {
|
|
|
395
392
|
// Dependency Injection via factory
|
|
396
393
|
this.stripeService = serviceFactory.createStripeService();
|
|
397
394
|
this.paymentElementManager = serviceFactory.createPaymentElementManager(this.stripeService);
|
|
398
|
-
|
|
399
|
-
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Props are not yet populated inside the constructor when the component is registered via
|
|
398
|
+
* the custom-elements build (`dist/components/*`), so initialization that depends on them
|
|
399
|
+
* must run in `componentWillLoad`, where both the lazy and custom-elements builds have them set.
|
|
400
|
+
*/
|
|
401
|
+
componentWillLoad() {
|
|
402
|
+
this.startStripe();
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Mount the element once Stripe.js has loaded, unless a newer init call (of either mode) has superseded this one.
|
|
406
|
+
* @param generation - The value of `initGeneration` taken when the init call started
|
|
407
|
+
*/
|
|
408
|
+
async mountWhenLoaded(generation) {
|
|
409
|
+
// A newer init call supersedes this one
|
|
410
|
+
if (generation !== this.initGeneration) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
// If already successfully loaded, initialize elements immediately
|
|
414
|
+
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
415
|
+
await this.initElement();
|
|
416
|
+
if (generation !== this.initGeneration) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
this.stripeLoadedEventHandler();
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
// Otherwise, wait for successful load
|
|
423
|
+
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
424
|
+
if (generation !== this.initGeneration) {
|
|
425
|
+
unsubscribe();
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (newState !== 'success') {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
await this.initElement();
|
|
432
|
+
if (generation !== this.initGeneration) {
|
|
433
|
+
unsubscribe();
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
this.stripeLoadedEventHandler();
|
|
437
|
+
unsubscribe(); // Clean up listener after first success
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
hasCheckoutSessionClientSecret() {
|
|
441
|
+
return this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '';
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Start Stripe.js in the mode that matches the given props.
|
|
445
|
+
* Checkout Session mode when `checkoutSessionClientSecret` is set, PaymentIntent / SetupIntent mode otherwise.
|
|
446
|
+
*/
|
|
447
|
+
startStripe() {
|
|
448
|
+
if (this.publishableKey == null || this.publishableKey === '') {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
|
|
452
|
+
this.initStripeWithCheckoutSession(this.publishableKey, this.checkoutSessionClientSecret, {
|
|
400
453
|
stripeAccount: this.stripeAccount,
|
|
401
454
|
});
|
|
455
|
+
return;
|
|
402
456
|
}
|
|
457
|
+
this.initStripe(this.publishableKey, {
|
|
458
|
+
stripeAccount: this.stripeAccount,
|
|
459
|
+
});
|
|
403
460
|
}
|
|
404
461
|
/**
|
|
405
462
|
* Initialize Component using Stripe Element
|
|
@@ -4,6 +4,16 @@ import { l as loadStripe } from './index-CBXaOfXU.js';
|
|
|
4
4
|
const stripePaymentRequestButtonCss = () => `:host{display:block}`;
|
|
5
5
|
|
|
6
6
|
const StripePaymentRequestButton = class {
|
|
7
|
+
constructor(hostRef) {
|
|
8
|
+
registerInstance(this, hostRef);
|
|
9
|
+
this.stripeLoaded = createEvent(this, "stripeLoaded", 7);
|
|
10
|
+
this.loadStripeStatus = '';
|
|
11
|
+
/**
|
|
12
|
+
* Overwrite the application name that registered
|
|
13
|
+
* For wrapper library (like Capacitor)
|
|
14
|
+
*/
|
|
15
|
+
this.applicationName = 'stripe-pwa-elements';
|
|
16
|
+
}
|
|
7
17
|
/**
|
|
8
18
|
* Check isAvailable ApplePay or GooglePay.
|
|
9
19
|
* If you run this method, you should run before initStripe.
|
|
@@ -56,15 +66,12 @@ const StripePaymentRequestButton = class {
|
|
|
56
66
|
}
|
|
57
67
|
this.stripeLoaded.emit(event);
|
|
58
68
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* For wrapper library (like Capacitor)
|
|
66
|
-
*/
|
|
67
|
-
this.applicationName = 'stripe-pwa-elements';
|
|
69
|
+
/**
|
|
70
|
+
* Props are not yet populated inside the constructor when the component is registered via
|
|
71
|
+
* the custom-elements build (`dist/components/*`), so initialization that depends on them
|
|
72
|
+
* must run in `componentWillLoad`, where both the lazy and custom-elements builds have them set.
|
|
73
|
+
*/
|
|
74
|
+
componentWillLoad() {
|
|
68
75
|
if (this.publishableKey !== undefined && this.paymentRequestOption !== undefined) {
|
|
69
76
|
this.initStripe(this.publishableKey, {
|
|
70
77
|
stripeAccount: this.stripeAccount,
|
|
@@ -185,7 +192,7 @@ const StripePaymentRequestButton = class {
|
|
|
185
192
|
this.stripe = undefined;
|
|
186
193
|
}
|
|
187
194
|
render() {
|
|
188
|
-
return (h(Host, { key: '
|
|
195
|
+
return (h(Host, { key: 'dd3ae348f9e9c798acdeca095ad9c157afd4734f' }, h("div", { key: 'f2e13b6980318ede1812d4f54223b7aeb9cfc51b', id: "payment-request" }, h("div", { key: 'ff6c1218924044d1ffc11354909f25c1745ef254', id: "payment-request-button" })), h("slot", { key: 'ec2131a0503baa15cdcf3571040e9ce6040da708' })));
|
|
189
196
|
}
|
|
190
197
|
get el() { return getElement(this); }
|
|
191
198
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,a as s,h as e,g as i}from"./p-C6bbmyga.js";import{s as r,c as o,i as n}from"./p-CrjrbGJ3.js";import{S as a}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const c=class{updatePublishableKey(t){const s={};s.stripeAccount=this.stripeService.state.stripeAccount;const e=Object.values(s).filter(Boolean).length>0;this.initStripe(t,e?s:void 0)}updateStripeAccountId(t){this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.expressCheckoutManager.setError(t),this}async initStripe(t,s){if(await this.stripeService.initialize(t,{stripeAccount:null==s?void 0:s.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async s=>{"success"===s&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateElementOptions(t){return this.expressCheckoutManager.update(t),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async defaultConfirmResultHandler(t){this.defaultConfirmResult.emit(t)}constructor(e){t(this,e),this.stripeLoaded=s(this,"stripeLoaded",7),this.confirm=s(this,"confirm",7),this.expressCheckoutClick=s(this,"expressCheckoutClick",7),this.cancel=s(this,"cancel",7),this.defaultConfirmResult=s(this,"defaultConfirmResult",7),this.intentType="payment",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultConfirmAction=!0,this.progress="",this.stripeService=r.createStripeService(),this.expressCheckoutManager=r.createExpressCheckoutElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}componentWillUpdate(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}async defaultConfirmAction(t){try{this.progress="loading";const s=this.stripeService.getStripe(),{intentType:e,clientSecret:i}=this;if(null==s)throw new Error("Stripe not initialized");if(null==i||""===i)throw new Error("Client secret is required");const r=await(()=>"payment"===e?s.confirmPayment({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}):s.confirmSetup({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}))();if(null!=r.error)throw new a(r.error);t.complete("success"),this.progress="success",this.defaultConfirmResultHandler(r)}catch(s){console.error(s),t.complete("fail"),this.expressCheckoutManager.setError(s.message),this.progress="failure",this.defaultConfirmResultHandler(s)}}async initElement(){const t={mode:"payment"===this.intentType?"payment":"setup"};if(void 0!==this.amount&&(t.amount=this.amount),null!=this.currency&&""!==this.currency&&(t.currency=this.currency),null!=this.buttonHeight&&""!==this.buttonHeight)if("string"==typeof this.buttonHeight){const s=parseInt(this.buttonHeight.replace("px",""),10);isNaN(s)||(t.buttonHeight=s)}else t.buttonHeight=this.buttonHeight;await this.expressCheckoutManager.initialize(this.el,t,{onConfirm:async t=>{this.confirm.emit(t),this.shouldUseDefaultConfirmAction&&null!=this.clientSecret&&""!==this.clientSecret&&await this.defaultConfirmAction(t)},onClick:t=>{this.expressCheckoutClick.emit(t)},onCancel:()=>{this.cancel.emit(),this.progress=""}})}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){this.expressCheckoutManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:s,isReady:i}=this.expressCheckoutManager.getState();return"failure"===t?e("p",null,n.t("Failed to load Stripe")):"loading"===t?e("p",null,n.t("Loading")):e("div",{class:"stripe-express-checkout-wrap"},e("div",{id:"express-checkout-element"}),s&&e("div",{id:"express-checkout-errors",class:"stripe-element-errors"},s),!i&&"success"===t&&e("div",{class:"stripe-express-checkout-loading"},n.t("Loading")))}get el(){return i(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}};c.style=":root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-express-checkout-wrap{width:100%;max-width:500px;margin:0 auto;padding:1rem 0}.stripe-express-checkout-wrap #express-checkout-element{margin-bottom:1rem}.stripe-express-checkout-wrap .stripe-element-errors{color:var(--stripe-error-color, #fa755a);font-size:14px;margin-top:0.5rem;padding:0.5rem;background-color:var(--stripe-error-bg, #fff5f5);border:1px solid var(--stripe-error-border, #fdd);border-radius:6px}.stripe-express-checkout-wrap .stripe-express-checkout-loading{text-align:center;padding:1rem;color:var(--stripe-loading-color, #6772e5);font-size:14px}";export{c as stripe_express_checkout_element}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,a as e,h as i,g as s}from"./p-C6bbmyga.js";import{s as r,c as n,i as o}from"./p-CrjrbGJ3.js";import{S as a}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const c=t=>{const{stripe:e,isCheckoutSession:i,checkout:s,checkoutSessionClientSecret:r,elements:n,intentClientSecret:o}=t,a={stripe:e};return i?null==s?{error:"Checkout not properly initialized"}:(a.checkout=s,a.checkoutSessionClientSecret=r,{props:a}):null==n?{error:"Elements not properly initialized"}:(a.elements=n,a.intentClientSecret=o,{props:a})},l=class{async initStripe(t,e){const i=++this.initGeneration;await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName,clientSecret:this.intentClientSecret}),await this.mountWhenLoaded(i)}async initStripeWithCheckoutSession(t,e,i){const s=++this.initGeneration;await this.stripeService.initializeWithCheckoutSession(t,e,{stripeAccount:null==i?void 0:i.stripeAccount,applicationName:this.applicationName,elementsOptions:null==i?void 0:i.elementsOptions}),await this.mountWhenLoaded(s)}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.paymentElementManager.setError(t),this}updatePublishableKey(t){const e={};e.stripeAccount=this.stripeService.state.stripeAccount;const i=Object.values(e).filter((t=>null!=t&&""!==t)).length>0;this.hasCheckoutSessionClientSecret()?this.initStripeWithCheckoutSession(t,this.checkoutSessionClientSecret,{stripeAccount:e.stripeAccount}):this.initStripe(t,i?e:void 0)}updateStripeAccountId(t){this.hasCheckoutSessionClientSecret()?this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:t}):this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateIntentClientSecret(){if(null!=this.checkoutSessionClientSecret&&""!==this.checkoutSessionClientSecret)return;const{publishableKey:t,stripeAccount:e}=this.stripeService.state;null!=t&&""!==t&&await this.initStripe(t,{stripeAccount:e})}async updateCheckoutSessionClientSecret(t){null!=this.publishableKey&&""!==this.publishableKey&&null!=t&&""!==t&&await this.initStripeWithCheckoutSession(this.publishableKey,t,{stripeAccount:this.stripeAccount})}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.stripeService.getStripe(),e=!0===this.stripeService.state.isCheckoutSession;if(null==t)return void console.error("Stripe not properly initialized");const i=c({stripe:t,isCheckoutSession:e,checkout:this.stripeService.getCheckout(),checkoutSessionClientSecret:this.checkoutSessionClientSecret,elements:this.stripeService.getElements(),intentClientSecret:this.intentClientSecret});"error"in i?console.error(i.error):this.formSubmit.emit(i.props)}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}async checkoutSessionConfirmResultHandler(t){this.checkoutSessionConfirmResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||(null==this.checkoutSessionClientSecret||""===this.checkoutSessionClientSecret?this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}):this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:this.stripeService.state.stripeAccount})))}async defaultFormSubmitAction(t,{stripe:e,elements:i}){t.preventDefault();try{const t=window.location.href,s=await(async(t,e,i,s)=>{const r=await("payment"===i?t.confirmPayment({elements:e,confirmParams:{return_url:s},redirect:"if_required"}):t.confirmSetup({elements:e,confirmParams:{return_url:s},redirect:"if_required"}));if(r.error)throw new a(r.error);return r})(e,i,this.intentType,t);this.defaultFormSubmitResultHandler(s)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}async checkoutSessionFormSubmitAction(t,e){t.preventDefault();try{const t=window.location.href,i=await(async(t,e)=>{var i;const s=await t.loadActions();if("error"===s.type)throw new a({type:"api_error",code:s.error.code||"checkout_session_error",message:s.error.message});const{actions:r}=s,n=await r.confirm({returnUrl:e,redirect:"if_required"});if("error"===n.type){const t={type:"card_error",code:n.error.code||"payment_failed",message:n.error.message,decline_code:"paymentFailed"===n.error.code?null===(i=n.error.paymentFailed)||void 0===i?void 0:i.declineCode:void 0};throw new a(t)}return n})(e,t);this.checkoutSessionConfirmResultHandler(i)}catch(t){throw console.error(t),this.checkoutSessionConfirmResultHandler(t instanceof Error?t:new Error(String(t))),t}}constructor(i){t(this,i),this.stripeLoaded=e(this,"stripeLoaded",7),this.formSubmit=e(this,"formSubmit",7),this.defaultFormSubmitResult=e(this,"defaultFormSubmitResult",7),this.checkoutSessionConfirmResult=e(this,"checkoutSessionConfirmResult",7),this.initGeneration=0,this.intentType="payment",this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=r.createStripeService(),this.paymentElementManager=r.createPaymentElementManager(this.stripeService)}componentWillLoad(){this.startStripe()}async mountWhenLoaded(t){if(t!==this.initGeneration)return;if("success"===this.stripeService.state.loadStripeStatus){if(await this.initElement(),t!==this.initGeneration)return;return void this.stripeLoadedEventHandler()}const e=this.stripeService.onChange("loadStripeStatus",(async i=>{t===this.initGeneration?"success"===i&&(await this.initElement(),t===this.initGeneration?(this.stripeLoadedEventHandler(),e()):e()):e()}))}hasCheckoutSessionClientSecret(){return null!=this.checkoutSessionClientSecret&&""!==this.checkoutSessionClientSecret}startStripe(){null!=this.publishableKey&&""!==this.publishableKey&&(null==this.checkoutSessionClientSecret||""===this.checkoutSessionClientSecret?this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount}):this.initStripeWithCheckoutSession(this.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:this.stripeAccount}))}async initElement(){await this.paymentElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-payment-element");null!=t?(null!=this._submitHandler&&t.removeEventListener("submit",this._submitHandler),this._submitHandler=async t=>{const e=this.stripeService.getStripe(),i=!0===this.stripeService.state.isCheckoutSession;if(null==e)return void console.error("Stripe not properly initialized");const s=c({stripe:e,isCheckoutSession:i,checkout:this.stripeService.getCheckout(),checkoutSessionClientSecret:this.checkoutSessionClientSecret,elements:this.stripeService.getElements(),intentClientSecret:this.intentClientSecret});if("error"in s)return void console.error(s.error);const r=s.props;this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,r):!0===this.shouldUseDefaultFormSubmitAction?i&&null!=r.checkout?await this.checkoutSessionFormSubmitAction(t,r.checkout):null!=this.intentClientSecret&&""!==this.intentClientSecret?await this.defaultFormSubmitAction(t,r):t.preventDefault():t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){const e=t instanceof Error?t.message:String(t);this.paymentElementManager.setError(e),this.progress="failure"}},t.addEventListener("submit",this._submitHandler)):console.error("Form element #stripe-payment-element not found")}componentDidLoad(){this.el.classList.add(n())}disconnectedCallback(){if(this.paymentElementManager.unmount(),null!=this._submitHandler){const t=this.el.querySelector("#stripe-payment-element");null!=t&&t.removeEventListener("submit",this._submitHandler)}}render(){const{loadStripeStatus:t,isCheckoutSession:e}=this.stripeService.state,{errorMessage:s}=this.paymentElementManager.getState();if("failure"===t)return i("p",null,o.t("Failed to load Stripe"));const r=(t=>{const{progress:e,isCheckoutSession:i,loadStripeStatus:s,intentClientSecret:r}=t;return"loading"===e||!(i?"success"===s:null!=r&&""!==r)})({progress:this.progress,isCheckoutSession:!0===e,loadStripeStatus:t,intentClientSecret:this.intentClientSecret});return i("div",{class:"stripe-payment-sheet-wrap"},i("form",{id:"stripe-payment-element"},i("div",{class:"stripe-heading"},o.t(this.sheetTitle)),i("div",null,i("div",{class:"stripe-section-title"},o.t("Payment information"))),i("div",{class:"payment-info visible"},i("div",{id:"payment-element"})),i("div",{id:"payment-errors",class:"stripe-element-errors"},s),i("div",{style:{marginTop:"32px"}},i("button",{type:"submit",disabled:r},o.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return s(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}],checkoutSessionClientSecret:[{updateCheckoutSessionClientSecret:0}]}}};l.style=':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .StripeElement{padding:8px 16px;min-height:64px;border-radius:6px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info{margin-top:8px}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}';export{l as stripe_payment_element}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,a as s,h as e,g as i}from"./p-C6bbmyga.js";import{s as r,c as o,i as a}from"./p-CrjrbGJ3.js";import"./p-CBXaOfXU.js";const n=class{async initStripe(t,s){if(await this.stripeService.initialize(t,{stripeAccount:null==s?void 0:s.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async s=>{"success"===s&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.addressElementManager.setError(t),this}async getValue(){const t=this.addressElementManager.getElement();if(null==t)throw new Error("Address element not initialized");return await t.getValue({format:"localized"})}updatePublishableKey(t){const s={};null!=this.stripeAccount&&""!==this.stripeAccount&&(s.stripeAccount=this.stripeAccount),this.initStripe(t,Object.keys(s).length>0?s:void 0)}updateStripeAccountId(t){const s=this.stripeService.state.publishableKey||this.publishableKey;null!=s&&""!==s&&this.initStripe(s,{stripeAccount:t})}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=await this.getValue();this.formSubmit.emit({address:t})}componentWillRender(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(e){t(this,e),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.mode="billing",this.sheetTitle="Billing address",this.buttonLabel="Save",this.progress="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.stripeService=r.createStripeService(),this.addressElementManager=r.createAddressElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={mode:this.mode};null!=this.defaultCountry&&""!==this.defaultCountry&&(t.defaultValues={address:{country:this.defaultCountry}}),this.allowedCountries&&this.allowedCountries.length>0&&(t.allowedCountries=this.allowedCountries),await this.addressElementManager.initialize(this.el,t);const s=this.el.querySelector("#stripe-address-element-form");null!=s?(null!=this.formSubmitListener&&s.removeEventListener("submit",this.formSubmitListener),this.formSubmitListener=async t=>{if(t.preventDefault(),null!=this.addressElementManager.getElement()){this.progress="loading";try{const s=await this.getValue();null!=this.handleSubmit&&await this.handleSubmit(t,{address:s}),await this.formSubmitEventHandler(),null!=this.handleSubmit&&(this.progress="success")}catch(t){const s=t instanceof Error?t.message:String(t);this.addressElementManager.setError(s),this.progress="failure"}}else console.error("Address element not initialized")},s.addEventListener("submit",this.formSubmitListener)):console.error("Form element #stripe-address-element-form not found")}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){if(null!=this.formSubmitListener){const t=this.el.querySelector("#stripe-address-element-form");null!=t&&t.removeEventListener("submit",this.formSubmitListener),this.formSubmitListener=void 0}this.addressElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:s}=this.addressElementManager.getState();if("failure"===t)return e("p",null,a.t("Failed to load Stripe"));const i="loading"===this.progress;return e("div",{class:"stripe-payment-sheet-wrap"},e("form",{id:"stripe-address-element-form"},e("div",{class:"stripe-heading"},a.t(this.sheetTitle)),e("div",{class:"payment-info address visible"},e("div",{id:"address-element"})),e("div",{id:"address-errors",class:"stripe-element-errors"},s),e("div",{class:"submit-button-wrapper"},e("button",{type:"submit",disabled:i},a.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return i(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}};n.style=':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap #address-element{margin-top:16px}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info.address{margin-bottom:16px}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap .submit-button-wrapper{margin-top:32px}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}';export{n as stripe_address_element}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,a as e,h as i,g as o,d as s}from"./p-C6bbmyga.js";import{s as n,c as a,i as r}from"./p-CrjrbGJ3.js";import{S as l}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const d=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},c=class{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,d(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,d(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:o}){t.preventDefault();try{const t=await((t,e,i,o)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:o}}):t.confirmCardSetup(i,{payment_method:{card:o}}))(e,0,o,i);if(null!=t.error)throw new l(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(i){t(this,i),this.stripeLoaded=e(this,"stripeLoaded",7),this.formSubmit=e(this,"formSubmit",7),this.defaultFormSubmitResult=e(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=n.createStripeService(),this.cardElementManager=n.createCardElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,d(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:o}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const s={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:o,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,s):!0===this.shouldUseDefaultFormSubmitAction&&null!=o&&""!==o?await this.defaultFormSubmitAction(t,s):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(a())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const o=document.createElement("stripe-payment-request-button");i.appendChild(o),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:o,paymentRequestShippingAddressChangeHandler:s}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=o&&t.setPaymentRequestShippingOptionEventHandler(o),null!=s&&t.setPaymentRequestShippingAddressEventHandler(s)})(o,e),o.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return i("p",null,r.t("Failed to load Stripe"));const o="loading"===this.progress;return i("div",{class:"stripe-payment-sheet-wrap"},i("form",{id:"stripe-card-element"},i("div",{class:"stripe-heading"},r.t(this.sheetTitle)),i("div",{id:"stripe-payment-request-button"}),i("div",null,i("div",{class:"stripe-section-title"},r.t("Card information"))),i("div",{class:"payment-info card visible"},i("fieldset",{class:"stripe-input-box"},i("div",null,i("label",null,this.showLabel?i("lenged",null,r.t("Card Number")):null,i("div",{id:"card-number"}))),i("div",{class:"stripe-input-column",style:{display:"flex"}},i("label",{style:{width:"50%"}},this.showLabel?i("lenged",null,r.t("MM / YY")):null,i("div",{id:"card-expiry"})),i("label",{style:{width:"50%"}},this.showLabel?i("lenged",null,r.t("CVC")):null,i("div",{id:"card-cvc"}))))),i("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?i("div",{style:{marginTop:"1.5rem"}},i("div",{class:"stripe-section-title"},r.t("Country or region"))):null,this.zip?i("div",{class:"payment-info card visible"},i("fieldset",{class:"stripe-input-box"},i("div",null,i("label",null,this.showLabel?i("lenged",null,r.t("Postal Code")):null,i("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:r.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,i("div",{style:{marginTop:"32px"}},i("button",{type:"submit",disabled:o},r.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return o(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}};c.style=':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .StripeElement{padding:8px 16px;min-height:64px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}';const p=class{constructor(i){t(this,i),this.close=e(this,"close",7),this.showCloseButton=!0,this.open=!1,this.renderedOpen=!1}onOpenChange(t){t?this.openModalAnimation():(this.renderedOpen=!1,this.close.emit())}async toggleModal(){this.open?await this.closeModal():await this.openModal()}async openModal(){this.open=!0}async closeModal(){this.open=!1}componentDidLoad(){const t=a();t&&this.el.classList.add(t),this.open&&this.openModalAnimation()}openModalAnimation(){if(!this.el.shadowRoot)return void(this.renderedOpen=!0);const t=this.el.shadowRoot.querySelector(".modal-child");t.classList.add("loading"),t.style.willChange="transform",t.addEventListener("transitionend",(()=>{t.style.willChange="auto",t.classList.remove("loading")}),{once:!0}),requestAnimationFrame((()=>{this.renderedOpen=this.open}))}render(){const{renderedOpen:t,showCloseButton:e}=this;return i(s,{key:"38fb86acf7cf5887a426c67b1a1271f7fae7048c"},i("div",{key:"f751d92c327ee2e564edfcd4d18f4dca43c20c37",class:"modal-row"+(t?" open":""),onClick:()=>this.closeModal()},i("div",{key:"11519ccd44a5069df3247c530a2c1e114eab7aef",class:"modal-child",onClick:t=>t.stopPropagation()},e?i("div",{class:"modal-close-button-wrap"},i("ion-icon",{name:"close",size:"large",class:"modal-close-button",onClick:()=>this.closeModal()})):null,i("div",{key:"a41f7f263b488b5bbc2a999cbabf6b9e407bca85",class:"modal-loading"},i("svg",{key:"0b3b25cb2812bc4d837fb4b7e6af4a5f42f0247e",version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 2400 2400"},i("g",{key:"10a9f9ec59699e6d2988b9c65cd02da1754fd760","stroke-width":"200","stroke-linecap":"round",stroke:"currentColor",fill:"none",id:"spinner"},i("line",{key:"ed271fa584b930ceed5397c271b31e0d48c72f72",x1:"1200",y1:"600",x2:"1200",y2:"100"}),i("line",{key:"3cf855a84f3ab58b914b7aeb784fbc5b95d8ae94",opacity:"0.5",x1:"1200",y1:"2300",x2:"1200",y2:"1800"}),i("line",{key:"2cce4b62a276399235509e94f47a63acf9c69a0f",opacity:"0.917",x1:"900",y1:"680.4",x2:"650",y2:"247.4"}),i("line",{key:"64c175ef068591417b043f7630a44d34eae7cb59",opacity:"0.417",x1:"1750",y1:"2152.6",x2:"1500",y2:"1719.6"}),i("line",{key:"0856a654e3aa756dfb1e9fc316b8b379fa9d5a4e",opacity:"0.833",x1:"680.4",y1:"900",x2:"247.4",y2:"650"}),i("line",{key:"c60f1f8495df9b8cdcc8941255d08c01a0e1c02f",opacity:"0.333",x1:"2152.6",y1:"1750",x2:"1719.6",y2:"1500"}),i("line",{key:"204bc2a7765e43b86f91c3fb9b1e72a3a39bb323",opacity:"0.75",x1:"600",y1:"1200",x2:"100",y2:"1200"}),i("line",{key:"7584b272f9efd7f746c1bcc5c8a5576098b02381",opacity:"0.25",x1:"2300",y1:"1200",x2:"1800",y2:"1200"}),i("line",{key:"7a053e9eb5f0da3fbf6fb7c9680bf73073bb126d",opacity:"0.667",x1:"680.4",y1:"1500",x2:"247.4",y2:"1750"}),i("line",{key:"f8b817095143d739589e45c99b03c7afbdfc8293",opacity:"0.167",x1:"2152.6",y1:"650",x2:"1719.6",y2:"900"}),i("line",{key:"aae0e36dbdfff44196f9758c8a5ed2337139ebe0",opacity:"0.583",x1:"900",y1:"1719.6",x2:"650",y2:"2152.6"}),i("line",{key:"3a257b30cb289f29ba386ccca7519bcdc22c3786",opacity:"0.083",x1:"1750",y1:"247.4",x2:"1500",y2:"680.4"}),i("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"})))),i("div",{key:"da5ef8031e5b826d854a065d8172389cdd84fbf0",class:"modal-content"},i("slot",{key:"fbe97a3a4d5489de5ae6f49342c58d537b317842"})))))}get el(){return o(this)}static get watchers(){return{open:[{onOpenChange:0}]}}};p.style=':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{box-sizing:border-box}:host *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}:host button{cursor:pointer}:host{display:block}.modal-row{opacity:0;pointer-events:none;will-change:transform}.modal-row.open{opacity:1;pointer-events:auto;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:1ch;background:rgba(0, 0, 0, 0.3)}.modal-row .modal-child{transform:translateY(100%);transition:transform 420ms ease;position:relative}.modal-row .modal-child .modal-loading{display:none;position:absolute;top:160px;left:50%;transform:translateX(-50%);width:24px;height:24px}.modal-row .modal-child.loading .modal-loading{display:flex;justify-content:center;align-items:center}.modal-row .modal-child.loading .modal-loading svg{width:24px;height:24px}.modal-row .modal-child.loading .modal-content{visibility:hidden}.modal-row.open .modal-child{transform:translateY(0%)}.modal-child{padding:16px 8px 24px;background-color:#fff;width:100%}.modal-close-button-wrap{padding-left:8px}.modal-close-button-wrap .modal-close-button{width:32px;display:block;fill:var(--color-label);cursor:pointer}';export{c as stripe_card_element,p as stripe_modal}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,a as e,h as s,d as i,g as a}from"./p-C6bbmyga.js";import{l as n}from"./p-CBXaOfXU.js";const o=class{constructor(s){t(this,s),this.stripeLoaded=e(this,"stripeLoaded",7),this.loadStripeStatus="",this.applicationName="stripe-pwa-elements"}async isAvailable(t){if(void 0===this.publishableKey)throw new Error("You should set publishableKey before calling this method.");const e=(await n(this.publishableKey,{stripeAccount:this.stripeAccount})).paymentRequest({country:"US",currency:"usd",total:{label:"Demo total",amount:1099},disableWallets:["applePay","googlePay","browserCard"].filter((e=>e!==t))}),s=await e.canMakePayment();if(!s||"applePay"===t&&!s[t]||"googlePay"===t&&!s[t])throw new Error(`This device cannot use ${t}.`)}async setPaymentMethodEventHandler(t){this.paymentMethodEventHandler=t}async setPaymentRequestShippingOptionEventHandler(t){this.shippingOptionEventHandler=t}async setPaymentRequestShippingAddressEventHandler(t){this.shippingAddressEventHandler=t}stripeLoadedEventHandler(){const t={stripe:this.stripe};this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}componentWillLoad(){void 0!==this.publishableKey&&void 0!==this.paymentRequestOption?this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount}):this.loadStripeStatus="failure"}connectedCallback(){console.warn("[stripe-pwa-elements] <stripe-payment-request-button> is deprecated. stripe.paymentRequest() is being removed in Stripe.js 9.x (deprecated 2025-09-30 / removed 2026-03-25). Please migrate to <stripe-express-checkout-element>, which supports Apple Pay, Google Pay, Link, PayPal, and more. Migration guide: https://hideokamoto.github.io/stripe-pwa-elements/guides/migrate-payment-request-button-to-express-checkout/")}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this}async initStripe(t,e){this.loadStripeStatus="loading",n(t,{stripeAccount:null==e?void 0:e.stripeAccount}).then((t=>{this.loadStripeStatus="success",t.registerAppInfo({name:this.applicationName}),this.stripe=t})).catch((t=>{console.log(t),this.loadStripeStatus="failure"})).then((()=>{if(this.stripe)return this.initElement(0==!(null==e?void 0:e.showButton))})).then((()=>{this.stripe&&this.stripeLoadedEventHandler()}))}async initElement(t=!0){const e=this.stripe.paymentRequest(this.paymentRequestOption);if(!await e.canMakePayment())throw new Error("Payment Request is not supported.");if(this.paymentMethodEventHandler&&e.on("paymentmethod",(t=>{this.paymentMethodEventHandler(t,this.stripe)})),this.shippingOptionEventHandler&&e.on("shippingoptionchange",(t=>{this.shippingOptionEventHandler(t,this.stripe)})),this.shippingAddressEventHandler&&e.on("shippingaddresschange",(t=>{this.shippingAddressEventHandler(t,this.stripe)})),t){this.paymentRequestElement&&this.paymentRequestElement.unmount();const t=this.stripe.elements().create("paymentRequestButton",{paymentRequest:e});this.paymentRequestElement=t;const s=this.el.querySelector("#payment-request-button");t.mount(s),this.el.querySelector("#payment-request").classList.add("visible")}else e.show()}disconnectedCallback(){this.paymentRequestElement&&(this.paymentRequestElement.unmount(),this.paymentRequestElement=void 0),this.stripe=void 0}render(){return s(i,{key:"dd3ae348f9e9c798acdeca095ad9c157afd4734f"},s("div",{key:"f2e13b6980318ede1812d4f54223b7aeb9cfc51b",id:"payment-request"},s("div",{key:"ff6c1218924044d1ffc11354909f25c1745ef254",id:"payment-request-button"})),s("slot",{key:"ec2131a0503baa15cdcf3571040e9ce6040da708"}))}get el(){return a(this)}};o.style=":host{display:block}";export{o as stripe_payment_request_button}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,a as s,h as e,g as r}from"./p-C6bbmyga.js";import{s as i,c as o,i as c}from"./p-CrjrbGJ3.js";import"./p-CBXaOfXU.js";const n=class{updatePublishableKey(t){this.initStripe(t,{stripeAccount:this.stripeAccount})}updateStripeAccountId(t){const s=this.stripeService.state.publishableKey||this.publishableKey;s&&this.initStripe(s,{stripeAccount:t})}async initStripe(t,s){if(await this.stripeService.initialize(t,{stripeAccount:null==s?void 0:s.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async s=>{"success"===s&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async setErrorMessage(t){return this.currencySelectorElementManager.setError(t),this}async getSelectedCurrency(){return this.currencySelectorElementManager.getState().selectedCurrency}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async currencyChangeEventHandler(t){const s={currency:t};this.currencyChange.emit(s),this.handleCurrencyChange&&await this.handleCurrencyChange(s)}componentWillRender(){this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(e){t(this,e),this.stripeLoaded=s(this,"stripeLoaded",7),this.currencyChange=s(this,"currencyChange",7),this.applicationName="stripe-pwa-elements",this.stripeService=i.createStripeService(),this.currencySelectorElementManager=i.createCurrencySelectorElementManager(this.stripeService)}componentWillLoad(){this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={};this.clientSecret&&(t.clientSecret=this.clientSecret),(await this.currencySelectorElementManager.initialize(this.el,t)).on("change",(t=>{var s;(null===(s=null==t?void 0:t.value)||void 0===s?void 0:s.currency)&&this.currencyChangeEventHandler(t.value.currency)}))}componentDidLoad(){const t=o();t&&this.el.classList.add(t)}disconnectedCallback(){this.currencySelectorElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:s}=this.currencySelectorElementManager.getState();return"failure"===t?e("p",null,c.t("Failed to load Stripe")):e("div",{class:"stripe-currency-selector-wrap"},e("div",{id:"currency-selector"}),s?e("div",{id:"currency-selector-errors",class:"stripe-element-errors"},s):null)}get el(){return r(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}};n.style=':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{box-sizing:border-box}:host *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}:host button{cursor:pointer}:host{display:block;width:100%}.stripe-currency-selector-wrap{width:100%;padding:0;margin:0}.stripe-currency-selector-wrap #currency-selector{width:100%;min-height:40px}.stripe-currency-selector-wrap #currency-selector-errors{margin-top:8px}';export{n as stripe_currency_selector}
|