stripe-pwa-elements 3.2.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -3
- package/dist/cjs/error-FFC4kSs5.js +0 -3
- package/dist/cjs/{factory-CbbbSvkg.js → factory-Cd2VI_N2.js} +216 -77
- 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 +41 -26
- package/dist/cjs/stripe-card-element-modal.cjs.entry.js +6 -7
- package/dist/cjs/stripe-card-element_2.cjs.entry.js +129 -72
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +20 -10
- package/dist/cjs/stripe-elements.cjs.js +31 -5
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +32 -22
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +20 -10
- package/dist/cjs/stripe-payment-element.cjs.entry.js +283 -167
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +30 -18
- package/dist/collection/collection-manifest.json +6 -5
- package/dist/collection/components/stripe-address-element/stripe-address-element.js +36 -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 +62 -68
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +15 -11
- package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +17 -6
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +35 -20
- package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +19 -7
- package/dist/collection/components/stripe-modal/stripe-modal.js +18 -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 +162 -162
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +48 -19
- 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 +27 -10
- 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 +0 -1
- 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 -112
- 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-Drde6-y7.js → factory-VTa1Gc94.js} +216 -77
- 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 +41 -26
- package/dist/esm/stripe-card-element-modal.entry.js +6 -7
- package/dist/esm/stripe-card-element_2.entry.js +129 -72
- package/dist/esm/stripe-currency-selector.entry.js +20 -10
- package/dist/esm/stripe-elements.js +32 -6
- package/dist/esm/stripe-express-checkout-element.entry.js +32 -22
- package/dist/esm/stripe-link-authentication-element.entry.js +20 -10
- package/dist/esm/stripe-payment-element.entry.js +283 -167
- package/dist/esm/stripe-payment-request-button.entry.js +27 -15
- package/dist/stripe-elements/index.esm.js +0 -2
- 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-5cf62945.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-C6bbmyga.js +2 -0
- package/dist/stripe-elements/p-CBXaOfXU.js +1 -0
- package/dist/stripe-elements/p-CrjrbGJ3.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-ae0c336e.entry.js +1 -0
- package/dist/stripe-elements/p-cfd8e081.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-address-element/stripe-address-element.d.ts +6 -0
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +11 -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-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 +20 -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 +14 -1
- package/dist/types/components.d.ts +139 -29
- package/dist/types/index.d.ts +1 -0
- package/dist/types/services/interfaces.d.ts +4 -3
- package/dist/types/services/stripe-service.d.ts +8 -4
- package/dist/types/stencil-public-runtime.d.ts +110 -5
- 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-CbbbSvkg.js.map +0 -1
- package/dist/cjs/index-BXVW_rzh.js +0 -1932
- package/dist/cjs/index-BXVW_rzh.js.map +0 -1
- package/dist/cjs/index-Ba1pBePA.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/test-setup.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-Drde6-y7.js.map +0 -1
- package/dist/esm/index-BHDCxQOb.js.map +0 -1
- package/dist/esm/index-DJwTOfxZ.js +0 -1920
- package/dist/esm/index-DJwTOfxZ.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-02f6e421.entry.js +0 -2
- package/dist/stripe-elements/p-02f6e421.entry.js.map +0 -1
- package/dist/stripe-elements/p-19888fa6.entry.js +0 -2
- package/dist/stripe-elements/p-19888fa6.entry.js.map +0 -1
- package/dist/stripe-elements/p-4d505729.entry.js +0 -2
- package/dist/stripe-elements/p-4d505729.entry.js.map +0 -1
- package/dist/stripe-elements/p-7e7ad92a.entry.js +0 -2
- package/dist/stripe-elements/p-7e7ad92a.entry.js.map +0 -1
- package/dist/stripe-elements/p-8bb4212c.entry.js +0 -2
- package/dist/stripe-elements/p-8bb4212c.entry.js.map +0 -1
- package/dist/stripe-elements/p-9aee2b6b.entry.js +0 -2
- package/dist/stripe-elements/p-9aee2b6b.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-DI2vmGaI.js +0 -2
- package/dist/stripe-elements/p-DI2vmGaI.js.map +0 -1
- package/dist/stripe-elements/p-DJwTOfxZ.js +0 -3
- package/dist/stripe-elements/p-DJwTOfxZ.js.map +0 -1
- package/dist/stripe-elements/p-DQuL1Twl.js.map +0 -1
- package/dist/stripe-elements/p-XRfh5Wrs.js.map +0 -1
- package/dist/stripe-elements/p-ba251393.entry.js +0 -2
- package/dist/stripe-elements/p-ba251393.entry.js.map +0 -1
- package/dist/stripe-elements/p-c649edfc.entry.js +0 -2
- package/dist/stripe-elements/p-c649edfc.entry.js.map +0 -1
- package/dist/stripe-elements/p-e8bb43ae.entry.js +0 -2
- package/dist/stripe-elements/p-e8bb43ae.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,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index
|
|
4
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Dkb0SxZc.js');
|
|
4
|
+
var index$1 = require('./index-CYbA1N_k.js');
|
|
5
5
|
|
|
6
|
-
const stripePaymentRequestButtonCss =
|
|
6
|
+
const stripePaymentRequestButtonCss = () => `:host{display:block}`;
|
|
7
7
|
|
|
8
8
|
const StripePaymentRequestButton = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
index.registerInstance(this, hostRef);
|
|
11
|
+
this.stripeLoaded = index.createEvent(this, "stripeLoaded", 7);
|
|
12
|
+
this.loadStripeStatus = '';
|
|
13
|
+
/**
|
|
14
|
+
* Overwrite the application name that registered
|
|
15
|
+
* For wrapper library (like Capacitor)
|
|
16
|
+
*/
|
|
17
|
+
this.applicationName = 'stripe-pwa-elements';
|
|
18
|
+
}
|
|
9
19
|
/**
|
|
10
20
|
* Check isAvailable ApplePay or GooglePay.
|
|
11
21
|
* If you run this method, you should run before initStripe.
|
|
@@ -14,7 +24,7 @@ const StripePaymentRequestButton = class {
|
|
|
14
24
|
if (this.publishableKey === undefined) {
|
|
15
25
|
throw new Error('You should set publishableKey before calling this method.');
|
|
16
26
|
}
|
|
17
|
-
const stripe = await index.loadStripe(this.publishableKey, {
|
|
27
|
+
const stripe = await index$1.loadStripe(this.publishableKey, {
|
|
18
28
|
stripeAccount: this.stripeAccount,
|
|
19
29
|
});
|
|
20
30
|
const paymentRequest = stripe.paymentRequest({
|
|
@@ -58,15 +68,12 @@ const StripePaymentRequestButton = class {
|
|
|
58
68
|
}
|
|
59
69
|
this.stripeLoaded.emit(event);
|
|
60
70
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* For wrapper library (like Capacitor)
|
|
68
|
-
*/
|
|
69
|
-
this.applicationName = 'stripe-pwa-elements';
|
|
71
|
+
/**
|
|
72
|
+
* Props are not yet populated inside the constructor when the component is registered via
|
|
73
|
+
* the custom-elements build (`dist/components/*`), so initialization that depends on them
|
|
74
|
+
* must run in `componentWillLoad`, where both the lazy and custom-elements builds have them set.
|
|
75
|
+
*/
|
|
76
|
+
componentWillLoad() {
|
|
70
77
|
if (this.publishableKey !== undefined && this.paymentRequestOption !== undefined) {
|
|
71
78
|
this.initStripe(this.publishableKey, {
|
|
72
79
|
stripeAccount: this.stripeAccount,
|
|
@@ -76,6 +83,12 @@ const StripePaymentRequestButton = class {
|
|
|
76
83
|
this.loadStripeStatus = 'failure';
|
|
77
84
|
}
|
|
78
85
|
}
|
|
86
|
+
connectedCallback() {
|
|
87
|
+
console.warn('[stripe-pwa-elements] <stripe-payment-request-button> is deprecated. ' +
|
|
88
|
+
'stripe.paymentRequest() is being removed in Stripe.js 9.x (deprecated 2025-09-30 / removed 2026-03-25). ' +
|
|
89
|
+
'Please migrate to <stripe-express-checkout-element>, which supports Apple Pay, Google Pay, Link, PayPal, and more. ' +
|
|
90
|
+
'Migration guide: https://hideokamoto.github.io/stripe-pwa-elements/guides/migrate-payment-request-button-to-express-checkout/');
|
|
91
|
+
}
|
|
79
92
|
/**
|
|
80
93
|
* @param option
|
|
81
94
|
* @private
|
|
@@ -91,7 +104,7 @@ const StripePaymentRequestButton = class {
|
|
|
91
104
|
*/
|
|
92
105
|
async initStripe(publishableKey, options = undefined) {
|
|
93
106
|
this.loadStripeStatus = 'loading';
|
|
94
|
-
index.loadStripe(publishableKey, {
|
|
107
|
+
index$1.loadStripe(publishableKey, {
|
|
95
108
|
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
96
109
|
})
|
|
97
110
|
.then(stripe => {
|
|
@@ -181,11 +194,10 @@ const StripePaymentRequestButton = class {
|
|
|
181
194
|
this.stripe = undefined;
|
|
182
195
|
}
|
|
183
196
|
render() {
|
|
184
|
-
return (index
|
|
197
|
+
return (index.h(index.Host, { key: 'dd3ae348f9e9c798acdeca095ad9c157afd4734f' }, index.h("div", { key: 'f2e13b6980318ede1812d4f54223b7aeb9cfc51b', id: "payment-request" }, index.h("div", { key: 'ff6c1218924044d1ffc11354909f25c1745ef254', id: "payment-request-button" })), index.h("slot", { key: 'ec2131a0503baa15cdcf3571040e9ce6040da708' })));
|
|
185
198
|
}
|
|
186
|
-
get el() { return index
|
|
199
|
+
get el() { return index.getElement(this); }
|
|
187
200
|
};
|
|
188
|
-
StripePaymentRequestButton.style = stripePaymentRequestButtonCss;
|
|
201
|
+
StripePaymentRequestButton.style = stripePaymentRequestButtonCss();
|
|
189
202
|
|
|
190
203
|
exports.stripe_payment_request_button = StripePaymentRequestButton;
|
|
191
|
-
//# sourceMappingURL=stripe-payment-request-button.entry.cjs.js.map
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
"components/stripe-address-element/stripe-address-element.js",
|
|
4
4
|
"components/stripe-payment-element/stripe-payment-element.js",
|
|
5
5
|
"components/stripe-card-element/stripe-card-element.js",
|
|
6
|
-
"components/stripe-card-element-modal/stripe-card-element-modal.js",
|
|
7
6
|
"components/stripe-currency-selector/stripe-currency-selector.js",
|
|
8
7
|
"components/stripe-express-checkout-element/stripe-express-checkout-element.js",
|
|
9
8
|
"components/stripe-link-authentication-element/stripe-link-authentication-element.js",
|
|
10
|
-
"components/stripe-
|
|
11
|
-
"components/stripe-
|
|
9
|
+
"components/stripe-payment-request-button/stripe-payment-request-button.js",
|
|
10
|
+
"components/stripe-card-element-modal/stripe-card-element-modal.js",
|
|
11
|
+
"components/stripe-modal/stripe-modal.js"
|
|
12
12
|
],
|
|
13
|
+
"mixins": [],
|
|
13
14
|
"compiler": {
|
|
14
15
|
"name": "@stencil/core",
|
|
15
|
-
"version": "4.
|
|
16
|
-
"typescriptVersion": "5.
|
|
16
|
+
"version": "4.43.5",
|
|
17
|
+
"typescriptVersion": "5.8.3"
|
|
17
18
|
},
|
|
18
19
|
"collections": [
|
|
19
20
|
{
|
|
@@ -98,22 +98,23 @@ export class StripeAddressElement {
|
|
|
98
98
|
*/
|
|
99
99
|
async getValue() {
|
|
100
100
|
const addressElement = this.addressElementManager.getElement();
|
|
101
|
-
if (
|
|
101
|
+
if (addressElement == null) {
|
|
102
102
|
throw new Error('Address element not initialized');
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
// Dahlia defaults to Latin; preserve the component's browser-localized values.
|
|
105
|
+
const result = await addressElement.getValue({ format: 'localized' });
|
|
105
106
|
return result;
|
|
106
107
|
}
|
|
107
108
|
updatePublishableKey(publishableKey) {
|
|
108
109
|
const options = {};
|
|
109
|
-
if (this.stripeAccount) {
|
|
110
|
+
if (this.stripeAccount != null && this.stripeAccount !== '') {
|
|
110
111
|
options.stripeAccount = this.stripeAccount;
|
|
111
112
|
}
|
|
112
|
-
this.initStripe(publishableKey, Object.keys(options).length ? options : undefined);
|
|
113
|
+
this.initStripe(publishableKey, Object.keys(options).length > 0 ? options : undefined);
|
|
113
114
|
}
|
|
114
115
|
updateStripeAccountId(stripeAccount) {
|
|
115
116
|
const publishableKey = this.stripeService.state.publishableKey || this.publishableKey;
|
|
116
|
-
if (
|
|
117
|
+
if (publishableKey == null || publishableKey === '') {
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
this.initStripe(publishableKey, {
|
|
@@ -124,7 +125,7 @@ export class StripeAddressElement {
|
|
|
124
125
|
const event = {
|
|
125
126
|
stripe: this.stripeService.getStripe(),
|
|
126
127
|
};
|
|
127
|
-
if (this.stripeDidLoaded) {
|
|
128
|
+
if (this.stripeDidLoaded != null) {
|
|
128
129
|
this.stripeDidLoaded(event);
|
|
129
130
|
}
|
|
130
131
|
this.stripeLoaded.emit(event);
|
|
@@ -136,7 +137,7 @@ export class StripeAddressElement {
|
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
componentWillRender() {
|
|
139
|
-
if (
|
|
140
|
+
if (this.stripeService.state.publishableKey == null || this.stripeService.state.publishableKey === '') {
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
142
143
|
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
@@ -183,7 +184,14 @@ export class StripeAddressElement {
|
|
|
183
184
|
// Dependency Injection via factory
|
|
184
185
|
this.stripeService = serviceFactory.createStripeService();
|
|
185
186
|
this.addressElementManager = serviceFactory.createAddressElementManager(this.stripeService);
|
|
186
|
-
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Props are not yet populated inside the constructor when the component is registered via
|
|
190
|
+
* the custom-elements build (`dist/components/*`), so initialization that depends on them
|
|
191
|
+
* must run in `componentWillLoad`, where both the lazy and custom-elements builds have them set.
|
|
192
|
+
*/
|
|
193
|
+
componentWillLoad() {
|
|
194
|
+
if (this.publishableKey != null && this.publishableKey !== '') {
|
|
187
195
|
this.initStripe(this.publishableKey, {
|
|
188
196
|
stripeAccount: this.stripeAccount,
|
|
189
197
|
});
|
|
@@ -197,7 +205,7 @@ export class StripeAddressElement {
|
|
|
197
205
|
const addressOptions = {
|
|
198
206
|
mode: this.mode,
|
|
199
207
|
};
|
|
200
|
-
if (this.defaultCountry) {
|
|
208
|
+
if (this.defaultCountry != null && this.defaultCountry !== '') {
|
|
201
209
|
addressOptions.defaultValues = {
|
|
202
210
|
address: {
|
|
203
211
|
country: this.defaultCountry,
|
|
@@ -211,30 +219,30 @@ export class StripeAddressElement {
|
|
|
211
219
|
await this.addressElementManager.initialize(this.el, addressOptions);
|
|
212
220
|
// Add form submit listener scoped to this component instance
|
|
213
221
|
const formElement = this.el.querySelector('#stripe-address-element-form');
|
|
214
|
-
if (
|
|
222
|
+
if (formElement == null) {
|
|
215
223
|
console.error('Form element #stripe-address-element-form not found');
|
|
216
224
|
return;
|
|
217
225
|
}
|
|
218
226
|
// Remove previous listener if it exists to prevent duplicate submissions
|
|
219
|
-
if (this.formSubmitListener) {
|
|
227
|
+
if (this.formSubmitListener != null) {
|
|
220
228
|
formElement.removeEventListener('submit', this.formSubmitListener);
|
|
221
229
|
}
|
|
222
230
|
// Create and store the listener
|
|
223
231
|
this.formSubmitListener = async (e) => {
|
|
224
232
|
e.preventDefault();
|
|
225
233
|
const addressElement = this.addressElementManager.getElement();
|
|
226
|
-
if (
|
|
234
|
+
if (addressElement == null) {
|
|
227
235
|
console.error('Address element not initialized');
|
|
228
236
|
return;
|
|
229
237
|
}
|
|
230
238
|
this.progress = 'loading';
|
|
231
239
|
try {
|
|
232
240
|
const addressValue = await this.getValue();
|
|
233
|
-
if (this.handleSubmit) {
|
|
241
|
+
if (this.handleSubmit != null) {
|
|
234
242
|
await this.handleSubmit(e, { address: addressValue });
|
|
235
243
|
}
|
|
236
244
|
await this.formSubmitEventHandler();
|
|
237
|
-
if (this.handleSubmit) {
|
|
245
|
+
if (this.handleSubmit != null) {
|
|
238
246
|
this.progress = 'success';
|
|
239
247
|
}
|
|
240
248
|
}
|
|
@@ -251,9 +259,9 @@ export class StripeAddressElement {
|
|
|
251
259
|
}
|
|
252
260
|
disconnectedCallback() {
|
|
253
261
|
// Remove form submit listener
|
|
254
|
-
if (this.formSubmitListener) {
|
|
262
|
+
if (this.formSubmitListener != null) {
|
|
255
263
|
const formElement = this.el.querySelector('#stripe-address-element-form');
|
|
256
|
-
if (formElement) {
|
|
264
|
+
if (formElement != null) {
|
|
257
265
|
formElement.removeEventListener('submit', this.formSubmitListener);
|
|
258
266
|
}
|
|
259
267
|
this.formSubmitListener = undefined;
|
|
@@ -267,6 +275,10 @@ export class StripeAddressElement {
|
|
|
267
275
|
return h("p", null, i18n.t('Failed to load Stripe'));
|
|
268
276
|
}
|
|
269
277
|
const disabled = this.progress === 'loading';
|
|
278
|
+
// NOTE: `stripe-payment-sheet-wrap` below is a legacy CSS class kept for backward
|
|
279
|
+
// compatibility (leftover from a former component name). It is part of the public
|
|
280
|
+
// DOM contract — consumers may target it in their own stylesheets — so it must
|
|
281
|
+
// remain in the rendered output. Do not remove it.
|
|
270
282
|
return (h("div", { class: "stripe-payment-sheet-wrap" }, h("form", { id: "stripe-address-element-form" }, h("div", { class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { class: "payment-info address visible" }, h("div", { id: "address-element" })), h("div", { id: "address-errors", class: "stripe-element-errors" }, errorMessage), h("div", { class: "submit-button-wrapper" }, h("button", { type: "submit", disabled: disabled }, this.progress === 'loading' ? i18n.t('Loading') : i18n.t(this.buttonLabel))))));
|
|
271
283
|
}
|
|
272
284
|
static get is() { return "stripe-address-element"; }
|
|
@@ -495,7 +507,8 @@ export class StripeAddressElement {
|
|
|
495
507
|
"StripeDidLoadedHandler": {
|
|
496
508
|
"location": "import",
|
|
497
509
|
"path": "../../interfaces",
|
|
498
|
-
"id": "src/interfaces.ts::StripeDidLoadedHandler"
|
|
510
|
+
"id": "src/interfaces.ts::StripeDidLoadedHandler",
|
|
511
|
+
"referenceLocation": "StripeDidLoadedHandler"
|
|
499
512
|
}
|
|
500
513
|
}
|
|
501
514
|
},
|
|
@@ -536,7 +549,8 @@ export class StripeAddressElement {
|
|
|
536
549
|
"StripeLoadedEvent": {
|
|
537
550
|
"location": "import",
|
|
538
551
|
"path": "../../interfaces",
|
|
539
|
-
"id": "src/interfaces.ts::StripeLoadedEvent"
|
|
552
|
+
"id": "src/interfaces.ts::StripeLoadedEvent",
|
|
553
|
+
"referenceLocation": "StripeLoadedEvent"
|
|
540
554
|
}
|
|
541
555
|
}
|
|
542
556
|
}
|
|
@@ -588,7 +602,8 @@ export class StripeAddressElement {
|
|
|
588
602
|
"InitStripeOptions": {
|
|
589
603
|
"location": "import",
|
|
590
604
|
"path": "../../interfaces",
|
|
591
|
-
"id": "src/interfaces.ts::InitStripeOptions"
|
|
605
|
+
"id": "src/interfaces.ts::InitStripeOptions",
|
|
606
|
+
"referenceLocation": "InitStripeOptions"
|
|
592
607
|
}
|
|
593
608
|
},
|
|
594
609
|
"return": "Promise<void>"
|
|
@@ -623,7 +638,8 @@ export class StripeAddressElement {
|
|
|
623
638
|
"ProgressStatus": {
|
|
624
639
|
"location": "import",
|
|
625
640
|
"path": "../../interfaces",
|
|
626
|
-
"id": "src/interfaces.ts::ProgressStatus"
|
|
641
|
+
"id": "src/interfaces.ts::ProgressStatus",
|
|
642
|
+
"referenceLocation": "ProgressStatus"
|
|
627
643
|
}
|
|
628
644
|
},
|
|
629
645
|
"return": "Promise<this>"
|
|
@@ -708,4 +724,3 @@ export class StripeAddressElement {
|
|
|
708
724
|
}];
|
|
709
725
|
}
|
|
710
726
|
}
|
|
711
|
-
//# sourceMappingURL=stripe-address-element.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the `InitStripeOptions` object from an optional connected-account id.
|
|
3
|
+
* Returns `undefined` when no account is provided, mirroring the behavior
|
|
4
|
+
* expected by `initStripe` (so the second argument can be omitted entirely).
|
|
5
|
+
* @param stripeAccount Optional connected-account id
|
|
6
|
+
* @returns InitStripeOptions when an account id exists, otherwise undefined
|
|
7
|
+
*/
|
|
8
|
+
export const buildInitStripeOptionsFromAccount = (stripeAccount) => {
|
|
9
|
+
if (stripeAccount != null && stripeAccount !== '') {
|
|
10
|
+
return { stripeAccount };
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Confirm a Stripe card intent, dispatching to `confirmCardPayment` or
|
|
16
|
+
* `confirmCardSetup` based on the configured intent type.
|
|
17
|
+
* @param stripe The loaded Stripe.js instance
|
|
18
|
+
* @param intentType Whether this is a payment or setup intent
|
|
19
|
+
* @param intentClientSecret The client secret of the intent to confirm
|
|
20
|
+
* @param cardNumberElement The Stripe card number element to confirm with
|
|
21
|
+
* @returns The PaymentIntent or SetupIntent confirmation result
|
|
22
|
+
*/
|
|
23
|
+
export const confirmCardIntent = (stripe, intentType, intentClientSecret, cardNumberElement) => {
|
|
24
|
+
if (intentType === 'payment') {
|
|
25
|
+
return stripe.confirmCardPayment(intentClientSecret, {
|
|
26
|
+
payment_method: {
|
|
27
|
+
card: cardNumberElement,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return stripe.confirmCardSetup(intentClientSecret, {
|
|
32
|
+
payment_method: {
|
|
33
|
+
card: cardNumberElement,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Wire up the optional payment-request handlers onto a freshly created
|
|
39
|
+
* `<stripe-payment-request-button>` element. Only handlers that are provided
|
|
40
|
+
* on the option object are attached, preserving the original behavior.
|
|
41
|
+
* @param element The payment-request-button custom element instance
|
|
42
|
+
* @param option The payment request button option (handlers + config)
|
|
43
|
+
* @returns void
|
|
44
|
+
*/
|
|
45
|
+
export const attachPaymentRequestHandlers = (element, option) => {
|
|
46
|
+
const { paymentRequestPaymentMethodHandler, paymentRequestShippingOptionChangeHandler, paymentRequestShippingAddressChangeHandler } = option;
|
|
47
|
+
element.setPaymentRequestOption(option);
|
|
48
|
+
if (paymentRequestPaymentMethodHandler != null) {
|
|
49
|
+
element.setPaymentMethodEventHandler(paymentRequestPaymentMethodHandler);
|
|
50
|
+
}
|
|
51
|
+
if (paymentRequestShippingOptionChangeHandler != null) {
|
|
52
|
+
element.setPaymentRequestShippingOptionEventHandler(paymentRequestShippingOptionChangeHandler);
|
|
53
|
+
}
|
|
54
|
+
if (paymentRequestShippingAddressChangeHandler != null) {
|
|
55
|
+
element.setPaymentRequestShippingAddressEventHandler(paymentRequestShippingAddressChangeHandler);
|
|
56
|
+
}
|
|
57
|
+
};
|