stripe-pwa-elements 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -3
- package/dist/cjs/error-FFC4kSs5.js +0 -3
- package/dist/cjs/{factory-Hsw0e7-d.js → factory-da3xAKkz.js} +194 -73
- package/dist/cjs/{index-Ba1pBePA.js → index-CYbA1N_k.js} +24 -6
- package/dist/cjs/index-Dkb0SxZc.js +4694 -0
- package/dist/cjs/index.cjs.js +0 -1
- package/dist/cjs/ion-icon.cjs.entry.js +22 -13
- package/dist/cjs/loader.cjs.js +2 -3
- package/dist/cjs/stripe-address-element.cjs.entry.js +34 -26
- package/dist/cjs/stripe-card-element-modal.cjs.entry.js +6 -7
- package/dist/cjs/stripe-card-element_2.cjs.entry.js +135 -73
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +13 -10
- package/dist/cjs/stripe-elements.cjs.js +31 -5
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +25 -22
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +13 -10
- package/dist/cjs/stripe-payment-element.cjs.entry.js +190 -131
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +12 -7
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/stripe-address-element/stripe-address-element.js +29 -21
- package/dist/collection/components/stripe-card-element/stripe-card-element.helpers.js +57 -0
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +55 -68
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.css +2 -2
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +16 -12
- package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +10 -6
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +28 -20
- package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +12 -7
- package/dist/collection/components/stripe-modal/stripe-modal.css +36 -2
- package/dist/collection/components/stripe-modal/stripe-modal.js +34 -7
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +114 -0
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +69 -126
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +34 -12
- package/dist/collection/index.js +0 -1
- package/dist/collection/interfaces.js +0 -1
- package/dist/collection/services/address-element-manager.js +3 -4
- package/dist/collection/services/card-element-manager.js +3 -4
- package/dist/collection/services/currency-selector-element-manager.js +3 -4
- package/dist/collection/services/express-checkout-element-manager.js +9 -10
- package/dist/collection/services/factory.js +0 -1
- package/dist/collection/services/interfaces.js +0 -1
- package/dist/collection/services/link-authentication-element-manager.js +3 -4
- package/dist/collection/services/payment-element-manager.js +4 -5
- package/dist/collection/services/stripe-service.js +5 -6
- package/dist/collection/utils/element-finder.js +2 -3
- package/dist/collection/utils/error.js +0 -1
- package/dist/collection/utils/i18n.js +0 -1
- package/dist/collection/utils/platform.js +0 -1
- package/dist/collection/utils/test-setup.js +5 -0
- package/dist/collection/utils/utils.js +2 -3
- package/dist/components/error.js +1 -16
- package/dist/components/factory.js +1 -3736
- package/dist/components/icon.js +1 -459
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -4
- package/dist/components/index2.js +1 -192
- package/dist/components/ion-icon.js +1 -9
- package/dist/components/stripe-address-element.js +1 -327
- package/dist/components/stripe-card-element-modal.js +1 -174
- package/dist/components/stripe-card-element.js +1 -9
- package/dist/components/stripe-card-element2.js +1 -440
- package/dist/components/stripe-currency-selector.js +1 -218
- package/dist/components/stripe-express-checkout-element.js +1 -332
- package/dist/components/stripe-link-authentication-element.js +1 -256
- package/dist/components/stripe-modal.js +1 -9
- package/dist/components/stripe-modal2.js +1 -88
- package/dist/components/stripe-payment-element.js +1 -510
- package/dist/components/stripe-payment-request-button.js +1 -9
- package/dist/components/stripe-payment-request-button2.js +1 -224
- package/dist/components/utils.js +1 -89
- package/dist/esm/app-globals-DQuL1Twl.js +0 -3
- package/dist/esm/error-XRfh5Wrs.js +0 -3
- package/dist/esm/{factory-Li_TGt9P.js → factory-DeqoYLf_.js} +194 -73
- package/dist/esm/index-C6bbmyga.js +4677 -0
- package/dist/esm/{index-BHDCxQOb.js → index-CBXaOfXU.js} +24 -6
- package/dist/esm/index.js +0 -1
- package/dist/esm/ion-icon.entry.js +22 -13
- package/dist/esm/loader.js +3 -4
- package/dist/esm/stripe-address-element.entry.js +34 -26
- package/dist/esm/stripe-card-element-modal.entry.js +6 -7
- package/dist/esm/stripe-card-element_2.entry.js +135 -73
- package/dist/esm/stripe-currency-selector.entry.js +13 -10
- package/dist/esm/stripe-elements.js +32 -6
- package/dist/esm/stripe-express-checkout-element.entry.js +25 -22
- package/dist/esm/stripe-link-authentication-element.entry.js +13 -10
- package/dist/esm/stripe-payment-element.entry.js +190 -131
- package/dist/esm/stripe-payment-request-button.entry.js +12 -7
- package/dist/stripe-elements/index.esm.js +0 -2
- package/dist/stripe-elements/p--sA2m1ad.js +1 -0
- package/dist/stripe-elements/p-38e7b187.entry.js +1 -0
- package/dist/stripe-elements/p-44495284.entry.js +1 -0
- package/dist/stripe-elements/p-4ba675fa.entry.js +1 -0
- package/dist/stripe-elements/p-5cf62945.entry.js +1 -0
- package/dist/stripe-elements/p-C6bbmyga.js +2 -0
- package/dist/stripe-elements/p-CBXaOfXU.js +1 -0
- package/dist/stripe-elements/p-DQuL1Twl.js +1 -2
- package/dist/stripe-elements/p-XRfh5Wrs.js +1 -2
- package/dist/stripe-elements/p-c24ae181.entry.js +1 -0
- package/dist/stripe-elements/p-d9e86451.entry.js +1 -0
- package/dist/stripe-elements/p-f09c86a0.entry.js +1 -0
- package/dist/stripe-elements/p-f64f394d.entry.js +1 -0
- package/dist/stripe-elements/p-f6d2425e.entry.js +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -2
- package/dist/stripe-elements/svg/.gitignore +4 -0
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +5 -1
- package/dist/types/components/stripe-card-element/stripe-card-element.helpers.d.ts +29 -0
- package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +4 -4
- package/dist/types/components/stripe-modal/stripe-modal.d.ts +6 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +2 -2
- package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +54 -0
- package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +8 -0
- package/dist/types/components.d.ts +139 -29
- package/dist/types/index.d.ts +1 -0
- package/dist/types/services/interfaces.d.ts +3 -3
- package/dist/types/services/stripe-service.d.ts +2 -2
- package/dist/types/stencil-public-runtime.d.ts +110 -5
- package/dist/types/utils/test-setup.d.ts +1 -0
- package/package.json +50 -30
- package/readme.md +386 -133
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
- package/dist/cjs/error-FFC4kSs5.js.map +0 -1
- package/dist/cjs/factory-Hsw0e7-d.js.map +0 -1
- package/dist/cjs/index-Ba1pBePA.js.map +0 -1
- package/dist/cjs/index-C1haN5iF.js +0 -1907
- package/dist/cjs/index-C1haN5iF.js.map +0 -1
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/ion-icon.entry.cjs.js.map +0 -1
- package/dist/cjs/loader.cjs.js.map +0 -1
- package/dist/cjs/stripe-address-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-card-element-modal.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-card-element.stripe-modal.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-currency-selector.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-elements.cjs.js.map +0 -1
- package/dist/cjs/stripe-express-checkout-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-link-authentication-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-payment-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-payment-request-button.entry.cjs.js.map +0 -1
- package/dist/collection/components/stripe-address-element/stripe-address-element.js.map +0 -1
- package/dist/collection/components/stripe-card-element/stripe-card-element.js.map +0 -1
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js.map +0 -1
- package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js.map +0 -1
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js.map +0 -1
- package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js.map +0 -1
- package/dist/collection/components/stripe-modal/stripe-modal.js.map +0 -1
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js.map +0 -1
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js.map +0 -1
- package/dist/collection/index.js.map +0 -1
- package/dist/collection/interfaces.js.map +0 -1
- package/dist/collection/services/address-element-manager.js.map +0 -1
- package/dist/collection/services/card-element-manager.js.map +0 -1
- package/dist/collection/services/currency-selector-element-manager.js.map +0 -1
- package/dist/collection/services/express-checkout-element-manager.js.map +0 -1
- package/dist/collection/services/factory.js.map +0 -1
- package/dist/collection/services/interfaces.js.map +0 -1
- package/dist/collection/services/link-authentication-element-manager.js.map +0 -1
- package/dist/collection/services/payment-element-manager.js.map +0 -1
- package/dist/collection/services/stripe-service.js.map +0 -1
- package/dist/collection/utils/element-finder.js.map +0 -1
- package/dist/collection/utils/error.js.map +0 -1
- package/dist/collection/utils/i18n.js.map +0 -1
- package/dist/collection/utils/platform.js.map +0 -1
- package/dist/collection/utils/utils.js.map +0 -1
- package/dist/components/error.js.map +0 -1
- package/dist/components/factory.js.map +0 -1
- package/dist/components/icon.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/index2.js.map +0 -1
- package/dist/components/ion-icon.js.map +0 -1
- package/dist/components/stripe-address-element.js.map +0 -1
- package/dist/components/stripe-card-element-modal.js.map +0 -1
- package/dist/components/stripe-card-element.js.map +0 -1
- package/dist/components/stripe-card-element2.js.map +0 -1
- package/dist/components/stripe-currency-selector.js.map +0 -1
- package/dist/components/stripe-express-checkout-element.js.map +0 -1
- package/dist/components/stripe-link-authentication-element.js.map +0 -1
- package/dist/components/stripe-modal.js.map +0 -1
- package/dist/components/stripe-modal2.js.map +0 -1
- package/dist/components/stripe-payment-element.js.map +0 -1
- package/dist/components/stripe-payment-request-button.js.map +0 -1
- package/dist/components/stripe-payment-request-button2.js.map +0 -1
- package/dist/components/utils.js.map +0 -1
- package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
- package/dist/esm/error-XRfh5Wrs.js.map +0 -1
- package/dist/esm/factory-Li_TGt9P.js.map +0 -1
- package/dist/esm/index-BHDCxQOb.js.map +0 -1
- package/dist/esm/index-Dkis4t79.js +0 -1895
- package/dist/esm/index-Dkis4t79.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ion-icon.entry.js.map +0 -1
- package/dist/esm/loader.js.map +0 -1
- package/dist/esm/stripe-address-element.entry.js.map +0 -1
- package/dist/esm/stripe-card-element-modal.entry.js.map +0 -1
- package/dist/esm/stripe-card-element.stripe-modal.entry.js.map +0 -1
- package/dist/esm/stripe-currency-selector.entry.js.map +0 -1
- package/dist/esm/stripe-elements.js.map +0 -1
- package/dist/esm/stripe-express-checkout-element.entry.js.map +0 -1
- package/dist/esm/stripe-link-authentication-element.entry.js.map +0 -1
- package/dist/esm/stripe-payment-element.entry.js.map +0 -1
- package/dist/esm/stripe-payment-request-button.entry.js.map +0 -1
- package/dist/stripe-elements/index.esm.js.map +0 -1
- package/dist/stripe-elements/ion-icon.entry.esm.js.map +0 -1
- package/dist/stripe-elements/loader.esm.js.map +0 -1
- package/dist/stripe-elements/p-01d63033.entry.js +0 -2
- package/dist/stripe-elements/p-01d63033.entry.js.map +0 -1
- package/dist/stripe-elements/p-1b8f9c7f.entry.js +0 -2
- package/dist/stripe-elements/p-1b8f9c7f.entry.js.map +0 -1
- package/dist/stripe-elements/p-37008853.entry.js +0 -2
- package/dist/stripe-elements/p-37008853.entry.js.map +0 -1
- package/dist/stripe-elements/p-5d152193.entry.js +0 -2
- package/dist/stripe-elements/p-5d152193.entry.js.map +0 -1
- package/dist/stripe-elements/p-623f13e6.entry.js +0 -2
- package/dist/stripe-elements/p-623f13e6.entry.js.map +0 -1
- package/dist/stripe-elements/p-809c9f2f.entry.js +0 -2
- package/dist/stripe-elements/p-809c9f2f.entry.js.map +0 -1
- package/dist/stripe-elements/p-BHDCxQOb.js +0 -2
- package/dist/stripe-elements/p-BHDCxQOb.js.map +0 -1
- package/dist/stripe-elements/p-DQuL1Twl.js.map +0 -1
- package/dist/stripe-elements/p-Dkis4t79.js +0 -3
- package/dist/stripe-elements/p-Dkis4t79.js.map +0 -1
- package/dist/stripe-elements/p-WnA32N4v.js +0 -2
- package/dist/stripe-elements/p-WnA32N4v.js.map +0 -1
- package/dist/stripe-elements/p-XRfh5Wrs.js.map +0 -1
- package/dist/stripe-elements/p-ba41e196.entry.js +0 -2
- package/dist/stripe-elements/p-ba41e196.entry.js.map +0 -1
- package/dist/stripe-elements/p-bb1bc49a.entry.js +0 -2
- package/dist/stripe-elements/p-bb1bc49a.entry.js.map +0 -1
- package/dist/stripe-elements/p-f21ea941.entry.js +0 -2
- package/dist/stripe-elements/p-f21ea941.entry.js.map +0 -1
- package/dist/stripe-elements/stripe-address-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-card-element-modal.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-card-element.stripe-modal.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-currency-selector.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-elements.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-express-checkout-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-link-authentication-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-payment-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-payment-request-button.entry.esm.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var factory = require('./factory-
|
|
3
|
+
var index = require('./index-Dkb0SxZc.js');
|
|
4
|
+
var factory = require('./factory-da3xAKkz.js');
|
|
5
5
|
var error = require('./error-FFC4kSs5.js');
|
|
6
|
-
require('./index-
|
|
6
|
+
require('./index-CYbA1N_k.js');
|
|
7
7
|
|
|
8
|
-
const stripeExpressCheckoutElementCss =
|
|
8
|
+
const stripeExpressCheckoutElementCss = () => `: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}`;
|
|
9
9
|
|
|
10
10
|
const StripeExpressCheckoutElement = class {
|
|
11
11
|
updatePublishableKey(publishableKey) {
|
|
@@ -113,7 +113,7 @@ const StripeExpressCheckoutElement = class {
|
|
|
113
113
|
const event = {
|
|
114
114
|
stripe: this.stripeService.getStripe(),
|
|
115
115
|
};
|
|
116
|
-
if (this.stripeDidLoaded) {
|
|
116
|
+
if (this.stripeDidLoaded != null) {
|
|
117
117
|
this.stripeDidLoaded(event);
|
|
118
118
|
}
|
|
119
119
|
this.stripeLoaded.emit(event);
|
|
@@ -123,11 +123,11 @@ const StripeExpressCheckoutElement = class {
|
|
|
123
123
|
}
|
|
124
124
|
constructor(hostRef) {
|
|
125
125
|
index.registerInstance(this, hostRef);
|
|
126
|
-
this.stripeLoaded = index.createEvent(this, "stripeLoaded");
|
|
127
|
-
this.confirm = index.createEvent(this, "confirm");
|
|
128
|
-
this.expressCheckoutClick = index.createEvent(this, "expressCheckoutClick");
|
|
129
|
-
this.cancel = index.createEvent(this, "cancel");
|
|
130
|
-
this.defaultConfirmResult = index.createEvent(this, "defaultConfirmResult");
|
|
126
|
+
this.stripeLoaded = index.createEvent(this, "stripeLoaded", 7);
|
|
127
|
+
this.confirm = index.createEvent(this, "confirm", 7);
|
|
128
|
+
this.expressCheckoutClick = index.createEvent(this, "expressCheckoutClick", 7);
|
|
129
|
+
this.cancel = index.createEvent(this, "cancel", 7);
|
|
130
|
+
this.defaultConfirmResult = index.createEvent(this, "defaultConfirmResult", 7);
|
|
131
131
|
/**
|
|
132
132
|
* Default submit handle type.
|
|
133
133
|
* If you want to use `setupIntent`, should update this attribute.
|
|
@@ -151,14 +151,14 @@ const StripeExpressCheckoutElement = class {
|
|
|
151
151
|
// Dependency Injection via factory
|
|
152
152
|
this.stripeService = factory.serviceFactory.createStripeService();
|
|
153
153
|
this.expressCheckoutManager = factory.serviceFactory.createExpressCheckoutElementManager(this.stripeService);
|
|
154
|
-
if (this.publishableKey) {
|
|
154
|
+
if (this.publishableKey != null && this.publishableKey !== '') {
|
|
155
155
|
this.initStripe(this.publishableKey, {
|
|
156
156
|
stripeAccount: this.stripeAccount,
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
componentWillUpdate() {
|
|
161
|
-
if (
|
|
161
|
+
if (this.stripeService.state.publishableKey == null || this.stripeService.state.publishableKey === '') {
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
@@ -178,10 +178,10 @@ const StripeExpressCheckoutElement = class {
|
|
|
178
178
|
this.progress = 'loading';
|
|
179
179
|
const stripe = this.stripeService.getStripe();
|
|
180
180
|
const { intentType, clientSecret } = this;
|
|
181
|
-
if (
|
|
181
|
+
if (stripe == null) {
|
|
182
182
|
throw new Error('Stripe not initialized');
|
|
183
183
|
}
|
|
184
|
-
if (
|
|
184
|
+
if (clientSecret == null || clientSecret === '') {
|
|
185
185
|
throw new Error('Client secret is required');
|
|
186
186
|
}
|
|
187
187
|
const result = await (() => {
|
|
@@ -204,7 +204,7 @@ const StripeExpressCheckoutElement = class {
|
|
|
204
204
|
redirect: 'if_required',
|
|
205
205
|
});
|
|
206
206
|
})();
|
|
207
|
-
if (result.error) {
|
|
207
|
+
if (result.error != null) {
|
|
208
208
|
throw new error.StripeAPIError(result.error);
|
|
209
209
|
}
|
|
210
210
|
// Complete the payment in the Express Checkout Element
|
|
@@ -233,10 +233,10 @@ const StripeExpressCheckoutElement = class {
|
|
|
233
233
|
if (this.amount !== undefined) {
|
|
234
234
|
elementOptions.amount = this.amount;
|
|
235
235
|
}
|
|
236
|
-
if (this.currency) {
|
|
236
|
+
if (this.currency != null && this.currency !== '') {
|
|
237
237
|
elementOptions.currency = this.currency;
|
|
238
238
|
}
|
|
239
|
-
if (this.buttonHeight) {
|
|
239
|
+
if (this.buttonHeight != null && this.buttonHeight !== '') {
|
|
240
240
|
// Convert string like "48px" to number for Stripe API
|
|
241
241
|
if (typeof this.buttonHeight === 'string') {
|
|
242
242
|
const height = parseInt(this.buttonHeight.replace('px', ''), 10);
|
|
@@ -252,7 +252,7 @@ const StripeExpressCheckoutElement = class {
|
|
|
252
252
|
await this.expressCheckoutManager.initialize(this.el, elementOptions, {
|
|
253
253
|
onConfirm: async (event) => {
|
|
254
254
|
this.confirm.emit(event);
|
|
255
|
-
if (this.shouldUseDefaultConfirmAction && this.clientSecret) {
|
|
255
|
+
if (this.shouldUseDefaultConfirmAction && this.clientSecret != null && this.clientSecret !== '') {
|
|
256
256
|
await this.defaultConfirmAction(event);
|
|
257
257
|
}
|
|
258
258
|
},
|
|
@@ -284,11 +284,14 @@ const StripeExpressCheckoutElement = class {
|
|
|
284
284
|
}
|
|
285
285
|
get el() { return index.getElement(this); }
|
|
286
286
|
static get watchers() { return {
|
|
287
|
-
"publishableKey": [
|
|
288
|
-
|
|
287
|
+
"publishableKey": [{
|
|
288
|
+
"updatePublishableKey": 0
|
|
289
|
+
}],
|
|
290
|
+
"stripeAccount": [{
|
|
291
|
+
"updateStripeAccountId": 0
|
|
292
|
+
}]
|
|
289
293
|
}; }
|
|
290
294
|
};
|
|
291
|
-
StripeExpressCheckoutElement.style = stripeExpressCheckoutElementCss;
|
|
295
|
+
StripeExpressCheckoutElement.style = stripeExpressCheckoutElementCss();
|
|
292
296
|
|
|
293
297
|
exports.stripe_express_checkout_element = StripeExpressCheckoutElement;
|
|
294
|
-
//# sourceMappingURL=stripe-express-checkout-element.entry.cjs.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var factory = require('./factory-
|
|
5
|
-
require('./index-
|
|
3
|
+
var index = require('./index-Dkb0SxZc.js');
|
|
4
|
+
var factory = require('./factory-da3xAKkz.js');
|
|
5
|
+
require('./index-CYbA1N_k.js');
|
|
6
6
|
|
|
7
|
-
const stripeLinkAuthenticationElementCss =
|
|
7
|
+
const stripeLinkAuthenticationElementCss = () => `: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-link-authentication-wrap{box-sizing:border-box}.stripe-link-authentication-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-link-authentication-wrap button{cursor:pointer}.stripe-link-authentication-wrap{display:block;width:100%;background:#fff;padding:16px}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement{padding:8px 16px;min-height:64px;border-radius:6px;display:flex;justify-content:center;align-items:center}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement>.__PrivateStripeElement{width:100%}.stripe-link-authentication-wrap .stripe-link-authentication-container .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}`;
|
|
8
8
|
|
|
9
9
|
const StripeLinkAuthenticationElement = class {
|
|
10
10
|
updatePublishableKey(publishableKey) {
|
|
@@ -156,8 +156,8 @@ const StripeLinkAuthenticationElement = class {
|
|
|
156
156
|
}
|
|
157
157
|
constructor(hostRef) {
|
|
158
158
|
index.registerInstance(this, hostRef);
|
|
159
|
-
this.stripeLoaded = index.createEvent(this, "stripeLoaded");
|
|
160
|
-
this.linkAuthenticationChange = index.createEvent(this, "linkAuthenticationChange");
|
|
159
|
+
this.stripeLoaded = index.createEvent(this, "stripeLoaded", 7);
|
|
160
|
+
this.linkAuthenticationChange = index.createEvent(this, "linkAuthenticationChange", 7);
|
|
161
161
|
/**
|
|
162
162
|
* Overwrite the application name that registered
|
|
163
163
|
* For wrapper library (like Capacitor)
|
|
@@ -212,11 +212,14 @@ const StripeLinkAuthenticationElement = class {
|
|
|
212
212
|
}
|
|
213
213
|
get el() { return index.getElement(this); }
|
|
214
214
|
static get watchers() { return {
|
|
215
|
-
"publishableKey": [
|
|
216
|
-
|
|
215
|
+
"publishableKey": [{
|
|
216
|
+
"updatePublishableKey": 0
|
|
217
|
+
}],
|
|
218
|
+
"stripeAccount": [{
|
|
219
|
+
"updateStripeAccountId": 0
|
|
220
|
+
}]
|
|
217
221
|
}; }
|
|
218
222
|
};
|
|
219
|
-
StripeLinkAuthenticationElement.style = stripeLinkAuthenticationElementCss;
|
|
223
|
+
StripeLinkAuthenticationElement.style = stripeLinkAuthenticationElementCss();
|
|
220
224
|
|
|
221
225
|
exports.stripe_link_authentication_element = StripeLinkAuthenticationElement;
|
|
222
|
-
//# sourceMappingURL=stripe-link-authentication-element.entry.cjs.js.map
|
|
@@ -1,11 +1,125 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var factory = require('./factory-
|
|
3
|
+
var index = require('./index-Dkb0SxZc.js');
|
|
4
|
+
var factory = require('./factory-da3xAKkz.js');
|
|
5
5
|
var error = require('./error-FFC4kSs5.js');
|
|
6
|
-
require('./index-
|
|
6
|
+
require('./index-CYbA1N_k.js');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Determine whether the submit button should be disabled.
|
|
10
|
+
* For Checkout Session mode: the checkout is ready once Stripe finished loading.
|
|
11
|
+
* For Payment Intent / Setup Intent mode: an intent client secret must be present.
|
|
12
|
+
* @param params progress / loading state and the current mode information
|
|
13
|
+
* @returns true when the submit button should be disabled
|
|
14
|
+
*/
|
|
15
|
+
const isSubmitButtonDisabled = (params) => {
|
|
16
|
+
const { progress, isCheckoutSession, loadStripeStatus, intentClientSecret } = params;
|
|
17
|
+
const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : intentClientSecret != null && intentClientSecret !== '';
|
|
18
|
+
return progress === 'loading' || !hasValidSecret;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
|
|
22
|
+
* Calls `confirmPayment` or `confirmSetup` depending on the intent type.
|
|
23
|
+
* @param stripe the loaded Stripe.js instance
|
|
24
|
+
* @param elements the Stripe Elements instance bound to the payment element
|
|
25
|
+
* @param intentType the configured intent type
|
|
26
|
+
* @param returnUrl the URL Stripe should redirect back to when required
|
|
27
|
+
* @returns the confirmation result
|
|
28
|
+
* @throws StripeAPIError when Stripe returns an error
|
|
29
|
+
*/
|
|
30
|
+
const confirmPaymentOrSetup = async (stripe, elements, intentType, returnUrl) => {
|
|
31
|
+
const result = await (() => {
|
|
32
|
+
if (intentType === 'payment') {
|
|
33
|
+
return stripe.confirmPayment({
|
|
34
|
+
elements,
|
|
35
|
+
confirmParams: {
|
|
36
|
+
return_url: returnUrl,
|
|
37
|
+
},
|
|
38
|
+
redirect: 'if_required',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return stripe.confirmSetup({
|
|
42
|
+
elements,
|
|
43
|
+
confirmParams: {
|
|
44
|
+
return_url: returnUrl,
|
|
45
|
+
},
|
|
46
|
+
redirect: 'if_required',
|
|
47
|
+
});
|
|
48
|
+
})();
|
|
49
|
+
if (result.error) {
|
|
50
|
+
throw new error.StripeAPIError(result.error);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Confirm a Checkout Session payment using the checkout actions.
|
|
56
|
+
* @param checkout the Stripe Checkout instance
|
|
57
|
+
* @param returnUrl the URL Stripe should redirect back to when required
|
|
58
|
+
* @returns the confirmation result
|
|
59
|
+
* @throws StripeAPIError when loading actions or confirming fails
|
|
60
|
+
*/
|
|
61
|
+
const confirmCheckoutSession = async (checkout, returnUrl) => {
|
|
62
|
+
var _a;
|
|
63
|
+
// Load actions from the checkout session
|
|
64
|
+
const loadActionsResult = await checkout.loadActions();
|
|
65
|
+
if (loadActionsResult.type === 'error') {
|
|
66
|
+
// Create a StripeError-compatible object from the Checkout Session error
|
|
67
|
+
const stripeError = {
|
|
68
|
+
type: 'api_error',
|
|
69
|
+
code: loadActionsResult.error.code || 'checkout_session_error',
|
|
70
|
+
message: loadActionsResult.error.message,
|
|
71
|
+
};
|
|
72
|
+
throw new error.StripeAPIError(stripeError);
|
|
73
|
+
}
|
|
74
|
+
const { actions } = loadActionsResult;
|
|
75
|
+
// Confirm the payment using checkout session actions
|
|
76
|
+
const result = await actions.confirm({
|
|
77
|
+
returnUrl,
|
|
78
|
+
redirect: 'if_required',
|
|
79
|
+
});
|
|
80
|
+
if (result.type === 'error') {
|
|
81
|
+
// Create a StripeError-compatible object from the confirm error
|
|
82
|
+
const stripeError = {
|
|
83
|
+
type: 'card_error',
|
|
84
|
+
code: result.error.code || 'payment_failed',
|
|
85
|
+
message: result.error.message,
|
|
86
|
+
decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
|
|
87
|
+
};
|
|
88
|
+
throw new error.StripeAPIError(stripeError);
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Resolve the mode-specific properties for a submit event.
|
|
94
|
+
* Picks the Checkout or Elements payload depending on the active mode and
|
|
95
|
+
* reports a descriptive error string when the required instance is missing.
|
|
96
|
+
* @param params the resolved Stripe instances and client secrets for the current mode
|
|
97
|
+
* @returns the submit event props, or an error message when an instance is missing
|
|
98
|
+
*/
|
|
99
|
+
const buildSubmitEventProps = (params) => {
|
|
100
|
+
const { stripe, isCheckoutSession, checkout, checkoutSessionClientSecret, elements, intentClientSecret } = params;
|
|
101
|
+
const props = {
|
|
102
|
+
stripe,
|
|
103
|
+
};
|
|
104
|
+
if (isCheckoutSession) {
|
|
105
|
+
// Checkout Session mode
|
|
106
|
+
if (checkout == null) {
|
|
107
|
+
return { error: 'Checkout not properly initialized' };
|
|
108
|
+
}
|
|
109
|
+
props.checkout = checkout;
|
|
110
|
+
props.checkoutSessionClientSecret = checkoutSessionClientSecret;
|
|
111
|
+
return { props };
|
|
112
|
+
}
|
|
113
|
+
// Payment Intent / Setup Intent mode
|
|
114
|
+
if (elements == null) {
|
|
115
|
+
return { error: 'Elements not properly initialized' };
|
|
116
|
+
}
|
|
117
|
+
props.elements = elements;
|
|
118
|
+
props.intentClientSecret = intentClientSecret;
|
|
119
|
+
return { props };
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const stripePaymentElementCss = () => `: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)}`;
|
|
9
123
|
|
|
10
124
|
const StripePaymentElement = class {
|
|
11
125
|
/**
|
|
@@ -125,7 +239,7 @@ const StripePaymentElement = class {
|
|
|
125
239
|
updatePublishableKey(publishableKey) {
|
|
126
240
|
const options = {};
|
|
127
241
|
options.stripeAccount = this.stripeService.state.stripeAccount;
|
|
128
|
-
const hasOptionValue = Object.values(options).filter(
|
|
242
|
+
const hasOptionValue = Object.values(options).filter(value => value != null && value !== '').length > 0;
|
|
129
243
|
this.initStripe(publishableKey, hasOptionValue ? options : undefined);
|
|
130
244
|
}
|
|
131
245
|
updateStripeAccountId(stripeAccount) {
|
|
@@ -141,7 +255,7 @@ const StripePaymentElement = class {
|
|
|
141
255
|
}
|
|
142
256
|
async updateCheckoutSessionClientSecret(newValue) {
|
|
143
257
|
// Re-initialize with checkout session when client secret changes
|
|
144
|
-
if (this.publishableKey && newValue) {
|
|
258
|
+
if (this.publishableKey != null && this.publishableKey !== '' && newValue != null && newValue !== '') {
|
|
145
259
|
await this.initStripeWithCheckoutSession(this.publishableKey, newValue, {
|
|
146
260
|
stripeAccount: this.stripeAccount,
|
|
147
261
|
});
|
|
@@ -151,42 +265,31 @@ const StripePaymentElement = class {
|
|
|
151
265
|
const event = {
|
|
152
266
|
stripe: this.stripeService.getStripe(),
|
|
153
267
|
};
|
|
154
|
-
if (this.stripeDidLoaded) {
|
|
268
|
+
if (this.stripeDidLoaded != null) {
|
|
155
269
|
this.stripeDidLoaded(event);
|
|
156
270
|
}
|
|
157
271
|
this.stripeLoaded.emit(event);
|
|
158
272
|
}
|
|
159
273
|
async formSubmitEventHandler() {
|
|
160
274
|
const stripe = this.stripeService.getStripe();
|
|
161
|
-
const isCheckoutSession = this.stripeService.state.isCheckoutSession;
|
|
162
|
-
if (
|
|
275
|
+
const isCheckoutSession = this.stripeService.state.isCheckoutSession === true;
|
|
276
|
+
if (stripe == null) {
|
|
163
277
|
console.error('Stripe not properly initialized');
|
|
164
278
|
return;
|
|
165
279
|
}
|
|
166
|
-
const
|
|
280
|
+
const result = buildSubmitEventProps({
|
|
167
281
|
stripe,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
eventData.checkoutSessionClientSecret = this.checkoutSessionClientSecret;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
// Payment Intent / Setup Intent mode
|
|
181
|
-
const elements = this.stripeService.getElements();
|
|
182
|
-
if (!elements) {
|
|
183
|
-
console.error('Elements not properly initialized');
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
eventData.elements = elements;
|
|
187
|
-
eventData.intentClientSecret = this.intentClientSecret;
|
|
282
|
+
isCheckoutSession,
|
|
283
|
+
checkout: this.stripeService.getCheckout(),
|
|
284
|
+
checkoutSessionClientSecret: this.checkoutSessionClientSecret,
|
|
285
|
+
elements: this.stripeService.getElements(),
|
|
286
|
+
intentClientSecret: this.intentClientSecret,
|
|
287
|
+
});
|
|
288
|
+
if ('error' in result) {
|
|
289
|
+
console.error(result.error);
|
|
290
|
+
return;
|
|
188
291
|
}
|
|
189
|
-
this.formSubmit.emit(
|
|
292
|
+
this.formSubmit.emit(result.props);
|
|
190
293
|
}
|
|
191
294
|
async defaultFormSubmitResultHandler(result) {
|
|
192
295
|
this.defaultFormSubmitResult.emit(result);
|
|
@@ -195,7 +298,8 @@ const StripePaymentElement = class {
|
|
|
195
298
|
this.checkoutSessionConfirmResult.emit(result);
|
|
196
299
|
}
|
|
197
300
|
componentWillRender() {
|
|
198
|
-
|
|
301
|
+
const { publishableKey } = this.stripeService.state;
|
|
302
|
+
if (publishableKey == null || publishableKey === '') {
|
|
199
303
|
return;
|
|
200
304
|
}
|
|
201
305
|
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
@@ -215,30 +319,9 @@ const StripePaymentElement = class {
|
|
|
215
319
|
async defaultFormSubmitAction(event, { stripe, elements }) {
|
|
216
320
|
event.preventDefault();
|
|
217
321
|
try {
|
|
218
|
-
const { intentType } = this;
|
|
219
322
|
// Get current page URL for return_url
|
|
220
323
|
const returnUrl = window.location.href;
|
|
221
|
-
const result = await (
|
|
222
|
-
if (intentType === 'payment') {
|
|
223
|
-
return stripe.confirmPayment({
|
|
224
|
-
elements,
|
|
225
|
-
confirmParams: {
|
|
226
|
-
return_url: returnUrl,
|
|
227
|
-
},
|
|
228
|
-
redirect: 'if_required',
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
return stripe.confirmSetup({
|
|
232
|
-
elements,
|
|
233
|
-
confirmParams: {
|
|
234
|
-
return_url: returnUrl,
|
|
235
|
-
},
|
|
236
|
-
redirect: 'if_required',
|
|
237
|
-
});
|
|
238
|
-
})();
|
|
239
|
-
if (result.error) {
|
|
240
|
-
throw new error.StripeAPIError(result.error);
|
|
241
|
-
}
|
|
324
|
+
const result = await confirmPaymentOrSetup(stripe, elements, this.intentType, returnUrl);
|
|
242
325
|
this.defaultFormSubmitResultHandler(result);
|
|
243
326
|
}
|
|
244
327
|
catch (e) {
|
|
@@ -254,38 +337,11 @@ const StripePaymentElement = class {
|
|
|
254
337
|
* @param checkout - The Stripe Checkout instance
|
|
255
338
|
*/
|
|
256
339
|
async checkoutSessionFormSubmitAction(event, checkout) {
|
|
257
|
-
var _a;
|
|
258
340
|
event.preventDefault();
|
|
259
341
|
try {
|
|
260
|
-
// Load actions from the checkout session
|
|
261
|
-
const loadActionsResult = await checkout.loadActions();
|
|
262
|
-
if (loadActionsResult.type === 'error') {
|
|
263
|
-
// Create a StripeError-compatible object from the Checkout Session error
|
|
264
|
-
const stripeError = {
|
|
265
|
-
type: 'api_error',
|
|
266
|
-
code: loadActionsResult.error.code || 'checkout_session_error',
|
|
267
|
-
message: loadActionsResult.error.message,
|
|
268
|
-
};
|
|
269
|
-
throw new error.StripeAPIError(stripeError);
|
|
270
|
-
}
|
|
271
|
-
const { actions } = loadActionsResult;
|
|
272
342
|
// Get current page URL for return_url
|
|
273
343
|
const returnUrl = window.location.href;
|
|
274
|
-
|
|
275
|
-
const result = await actions.confirm({
|
|
276
|
-
returnUrl,
|
|
277
|
-
redirect: 'if_required',
|
|
278
|
-
});
|
|
279
|
-
if (result.type === 'error') {
|
|
280
|
-
// Create a StripeError-compatible object from the confirm error
|
|
281
|
-
const stripeError = {
|
|
282
|
-
type: 'card_error',
|
|
283
|
-
code: result.error.code || 'payment_failed',
|
|
284
|
-
message: result.error.message,
|
|
285
|
-
decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
|
|
286
|
-
};
|
|
287
|
-
throw new error.StripeAPIError(stripeError);
|
|
288
|
-
}
|
|
344
|
+
const result = await confirmCheckoutSession(checkout, returnUrl);
|
|
289
345
|
this.checkoutSessionConfirmResultHandler(result);
|
|
290
346
|
}
|
|
291
347
|
catch (e) {
|
|
@@ -296,10 +352,10 @@ const StripePaymentElement = class {
|
|
|
296
352
|
}
|
|
297
353
|
constructor(hostRef) {
|
|
298
354
|
index.registerInstance(this, hostRef);
|
|
299
|
-
this.stripeLoaded = index.createEvent(this, "stripeLoaded");
|
|
300
|
-
this.formSubmit = index.createEvent(this, "formSubmit");
|
|
301
|
-
this.defaultFormSubmitResult = index.createEvent(this, "defaultFormSubmitResult");
|
|
302
|
-
this.checkoutSessionConfirmResult = index.createEvent(this, "checkoutSessionConfirmResult");
|
|
355
|
+
this.stripeLoaded = index.createEvent(this, "stripeLoaded", 7);
|
|
356
|
+
this.formSubmit = index.createEvent(this, "formSubmit", 7);
|
|
357
|
+
this.defaultFormSubmitResult = index.createEvent(this, "defaultFormSubmitResult", 7);
|
|
358
|
+
this.checkoutSessionConfirmResult = index.createEvent(this, "checkoutSessionConfirmResult", 7);
|
|
303
359
|
/**
|
|
304
360
|
* Default submit handle type.
|
|
305
361
|
* If you want to use `setupIntent`, should update this attribute.
|
|
@@ -341,7 +397,7 @@ const StripePaymentElement = class {
|
|
|
341
397
|
// Dependency Injection via factory
|
|
342
398
|
this.stripeService = factory.serviceFactory.createStripeService();
|
|
343
399
|
this.paymentElementManager = factory.serviceFactory.createPaymentElementManager(this.stripeService);
|
|
344
|
-
if (this.publishableKey) {
|
|
400
|
+
if (this.publishableKey != null && this.publishableKey !== '') {
|
|
345
401
|
this.initStripe(this.publishableKey, {
|
|
346
402
|
stripeAccount: this.stripeAccount,
|
|
347
403
|
});
|
|
@@ -355,57 +411,47 @@ const StripePaymentElement = class {
|
|
|
355
411
|
await this.paymentElementManager.initialize(this.el);
|
|
356
412
|
// Add form submit listener scoped to this component instance
|
|
357
413
|
const formElement = this.el.querySelector('#stripe-payment-element');
|
|
358
|
-
if (
|
|
414
|
+
if (formElement == null) {
|
|
359
415
|
console.error('Form element #stripe-payment-element not found');
|
|
360
416
|
return;
|
|
361
417
|
}
|
|
362
418
|
// Remove existing listener if present to prevent duplicates
|
|
363
|
-
if (this._submitHandler) {
|
|
419
|
+
if (this._submitHandler != null) {
|
|
364
420
|
formElement.removeEventListener('submit', this._submitHandler);
|
|
365
421
|
}
|
|
366
422
|
// Create and store the submit handler
|
|
367
423
|
this._submitHandler = async (e) => {
|
|
368
424
|
const stripe = this.stripeService.getStripe();
|
|
369
|
-
const isCheckoutSession = this.stripeService.state.isCheckoutSession;
|
|
370
|
-
if (
|
|
425
|
+
const isCheckoutSession = this.stripeService.state.isCheckoutSession === true;
|
|
426
|
+
if (stripe == null) {
|
|
371
427
|
console.error('Stripe not properly initialized');
|
|
372
428
|
return;
|
|
373
429
|
}
|
|
374
|
-
// Build submit event props based on mode
|
|
375
|
-
const
|
|
430
|
+
// Build submit event props based on mode (shared with formSubmitEventHandler)
|
|
431
|
+
const result = buildSubmitEventProps({
|
|
376
432
|
stripe,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
submitEventProps.checkoutSessionClientSecret = this.checkoutSessionClientSecret;
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
// Payment Intent / Setup Intent mode
|
|
390
|
-
const elements = this.stripeService.getElements();
|
|
391
|
-
if (!elements) {
|
|
392
|
-
console.error('Elements not properly initialized');
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
submitEventProps.elements = elements;
|
|
396
|
-
submitEventProps.intentClientSecret = this.intentClientSecret;
|
|
433
|
+
isCheckoutSession,
|
|
434
|
+
checkout: this.stripeService.getCheckout(),
|
|
435
|
+
checkoutSessionClientSecret: this.checkoutSessionClientSecret,
|
|
436
|
+
elements: this.stripeService.getElements(),
|
|
437
|
+
intentClientSecret: this.intentClientSecret,
|
|
438
|
+
});
|
|
439
|
+
if ('error' in result) {
|
|
440
|
+
console.error(result.error);
|
|
441
|
+
return;
|
|
397
442
|
}
|
|
443
|
+
const submitEventProps = result.props;
|
|
398
444
|
this.progress = 'loading';
|
|
399
445
|
try {
|
|
400
|
-
if (this.handleSubmit) {
|
|
446
|
+
if (this.handleSubmit != null) {
|
|
401
447
|
await this.handleSubmit(e, submitEventProps);
|
|
402
448
|
}
|
|
403
449
|
else if (this.shouldUseDefaultFormSubmitAction === true) {
|
|
404
|
-
if (isCheckoutSession && submitEventProps.checkout) {
|
|
450
|
+
if (isCheckoutSession && submitEventProps.checkout != null) {
|
|
405
451
|
// Use Checkout Session confirmation
|
|
406
452
|
await this.checkoutSessionFormSubmitAction(e, submitEventProps.checkout);
|
|
407
453
|
}
|
|
408
|
-
else if (this.intentClientSecret) {
|
|
454
|
+
else if (this.intentClientSecret != null && this.intentClientSecret !== '') {
|
|
409
455
|
// Use Payment Intent / Setup Intent confirmation
|
|
410
456
|
await this.defaultFormSubmitAction(e, submitEventProps);
|
|
411
457
|
}
|
|
@@ -417,7 +463,7 @@ const StripePaymentElement = class {
|
|
|
417
463
|
e.preventDefault();
|
|
418
464
|
}
|
|
419
465
|
await this.formSubmitEventHandler();
|
|
420
|
-
if (this.handleSubmit || this.shouldUseDefaultFormSubmitAction === true) {
|
|
466
|
+
if (this.handleSubmit != null || this.shouldUseDefaultFormSubmitAction === true) {
|
|
421
467
|
this.progress = 'success';
|
|
422
468
|
}
|
|
423
469
|
}
|
|
@@ -435,9 +481,9 @@ const StripePaymentElement = class {
|
|
|
435
481
|
disconnectedCallback() {
|
|
436
482
|
this.paymentElementManager.unmount();
|
|
437
483
|
// Remove event listener to prevent memory leaks
|
|
438
|
-
if (this._submitHandler) {
|
|
484
|
+
if (this._submitHandler != null) {
|
|
439
485
|
const formElement = this.el.querySelector('#stripe-payment-element');
|
|
440
|
-
if (formElement) {
|
|
486
|
+
if (formElement != null) {
|
|
441
487
|
formElement.removeEventListener('submit', this._submitHandler);
|
|
442
488
|
}
|
|
443
489
|
}
|
|
@@ -448,22 +494,35 @@ const StripePaymentElement = class {
|
|
|
448
494
|
if (loadStripeStatus === 'failure') {
|
|
449
495
|
return index.h("p", null, factory.i18n.t('Failed to load Stripe'));
|
|
450
496
|
}
|
|
451
|
-
// Determine if button should be disabled
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
497
|
+
// Determine if button should be disabled (see isSubmitButtonDisabled helper for mode-specific rules)
|
|
498
|
+
const disabled = isSubmitButtonDisabled({
|
|
499
|
+
progress: this.progress,
|
|
500
|
+
isCheckoutSession: isCheckoutSession === true,
|
|
501
|
+
loadStripeStatus,
|
|
502
|
+
intentClientSecret: this.intentClientSecret,
|
|
503
|
+
});
|
|
504
|
+
return (
|
|
505
|
+
// NOTE: `stripe-payment-sheet-wrap` is a legacy CSS class kept for backward compatibility.
|
|
506
|
+
// It is a leftover from a former component name but is part of the public DOM contract,
|
|
507
|
+
// so external stylesheets may target it. Keep it in the rendered output and the .scss.
|
|
508
|
+
index.h("div", { class: "stripe-payment-sheet-wrap" }, index.h("form", { id: "stripe-payment-element" }, index.h("div", { class: "stripe-heading" }, factory.i18n.t(this.sheetTitle)), index.h("div", null, index.h("div", { class: "stripe-section-title" }, factory.i18n.t('Payment information'))), index.h("div", { class: "payment-info visible" }, index.h("div", { id: "payment-element" })), index.h("div", { id: "payment-errors", class: "stripe-element-errors" }, errorMessage), index.h("div", { style: { marginTop: '32px' } }, index.h("button", { type: "submit", disabled: disabled }, this.progress === 'loading' ? factory.i18n.t('Loading') : factory.i18n.t(this.buttonLabel))))));
|
|
457
509
|
}
|
|
458
510
|
get el() { return index.getElement(this); }
|
|
459
511
|
static get watchers() { return {
|
|
460
|
-
"publishableKey": [
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
"
|
|
512
|
+
"publishableKey": [{
|
|
513
|
+
"updatePublishableKey": 0
|
|
514
|
+
}],
|
|
515
|
+
"stripeAccount": [{
|
|
516
|
+
"updateStripeAccountId": 0
|
|
517
|
+
}],
|
|
518
|
+
"intentClientSecret": [{
|
|
519
|
+
"updateIntentClientSecret": 0
|
|
520
|
+
}],
|
|
521
|
+
"checkoutSessionClientSecret": [{
|
|
522
|
+
"updateCheckoutSessionClientSecret": 0
|
|
523
|
+
}]
|
|
464
524
|
}; }
|
|
465
525
|
};
|
|
466
|
-
StripePaymentElement.style = stripePaymentElementCss;
|
|
526
|
+
StripePaymentElement.style = stripePaymentElementCss();
|
|
467
527
|
|
|
468
528
|
exports.stripe_payment_element = StripePaymentElement;
|
|
469
|
-
//# sourceMappingURL=stripe-payment-element.entry.cjs.js.map
|