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,9 +1,123 @@
|
|
|
1
|
-
import { r as registerInstance,
|
|
2
|
-
import { s as serviceFactory, c as checkPlatform, i as i18n } from './factory-
|
|
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-VTa1Gc94.js';
|
|
3
3
|
import { S as StripeAPIError } from './error-XRfh5Wrs.js';
|
|
4
|
-
import './index-
|
|
4
|
+
import './index-CBXaOfXU.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Determine whether the submit button should be disabled.
|
|
8
|
+
* For Checkout Session mode: the checkout is ready once Stripe finished loading.
|
|
9
|
+
* For Payment Intent / Setup Intent mode: an intent client secret must be present.
|
|
10
|
+
* @param params progress / loading state and the current mode information
|
|
11
|
+
* @returns true when the submit button should be disabled
|
|
12
|
+
*/
|
|
13
|
+
const isSubmitButtonDisabled = (params) => {
|
|
14
|
+
const { progress, isCheckoutSession, loadStripeStatus, intentClientSecret } = params;
|
|
15
|
+
const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : intentClientSecret != null && intentClientSecret !== '';
|
|
16
|
+
return progress === 'loading' || !hasValidSecret;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
|
|
20
|
+
* Calls `confirmPayment` or `confirmSetup` depending on the intent type.
|
|
21
|
+
* @param stripe the loaded Stripe.js instance
|
|
22
|
+
* @param elements the Stripe Elements instance bound to the payment element
|
|
23
|
+
* @param intentType the configured intent type
|
|
24
|
+
* @param returnUrl the URL Stripe should redirect back to when required
|
|
25
|
+
* @returns the confirmation result
|
|
26
|
+
* @throws StripeAPIError when Stripe returns an error
|
|
27
|
+
*/
|
|
28
|
+
const confirmPaymentOrSetup = async (stripe, elements, intentType, returnUrl) => {
|
|
29
|
+
const result = await (() => {
|
|
30
|
+
if (intentType === 'payment') {
|
|
31
|
+
return stripe.confirmPayment({
|
|
32
|
+
elements,
|
|
33
|
+
confirmParams: {
|
|
34
|
+
return_url: returnUrl,
|
|
35
|
+
},
|
|
36
|
+
redirect: 'if_required',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return stripe.confirmSetup({
|
|
40
|
+
elements,
|
|
41
|
+
confirmParams: {
|
|
42
|
+
return_url: returnUrl,
|
|
43
|
+
},
|
|
44
|
+
redirect: 'if_required',
|
|
45
|
+
});
|
|
46
|
+
})();
|
|
47
|
+
if (result.error) {
|
|
48
|
+
throw new StripeAPIError(result.error);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Confirm a Checkout Session payment using the checkout actions.
|
|
54
|
+
* @param checkout the Stripe Checkout instance
|
|
55
|
+
* @param returnUrl the URL Stripe should redirect back to when required
|
|
56
|
+
* @returns the confirmation result
|
|
57
|
+
* @throws StripeAPIError when loading actions or confirming fails
|
|
58
|
+
*/
|
|
59
|
+
const confirmCheckoutSession = async (checkout, returnUrl) => {
|
|
60
|
+
var _a;
|
|
61
|
+
// Load actions from the checkout session
|
|
62
|
+
const loadActionsResult = await checkout.loadActions();
|
|
63
|
+
if (loadActionsResult.type === 'error') {
|
|
64
|
+
// Create a StripeError-compatible object from the Checkout Session error
|
|
65
|
+
const stripeError = {
|
|
66
|
+
type: 'api_error',
|
|
67
|
+
code: loadActionsResult.error.code || 'checkout_session_error',
|
|
68
|
+
message: loadActionsResult.error.message,
|
|
69
|
+
};
|
|
70
|
+
throw new StripeAPIError(stripeError);
|
|
71
|
+
}
|
|
72
|
+
const { actions } = loadActionsResult;
|
|
73
|
+
// Confirm the payment using checkout session actions
|
|
74
|
+
const result = await actions.confirm({
|
|
75
|
+
returnUrl,
|
|
76
|
+
redirect: 'if_required',
|
|
77
|
+
});
|
|
78
|
+
if (result.type === 'error') {
|
|
79
|
+
// Create a StripeError-compatible object from the confirm error
|
|
80
|
+
const stripeError = {
|
|
81
|
+
type: 'card_error',
|
|
82
|
+
code: result.error.code || 'payment_failed',
|
|
83
|
+
message: result.error.message,
|
|
84
|
+
decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
|
|
85
|
+
};
|
|
86
|
+
throw new StripeAPIError(stripeError);
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Resolve the mode-specific properties for a submit event.
|
|
92
|
+
* Picks the Checkout or Elements payload depending on the active mode and
|
|
93
|
+
* reports a descriptive error string when the required instance is missing.
|
|
94
|
+
* @param params the resolved Stripe instances and client secrets for the current mode
|
|
95
|
+
* @returns the submit event props, or an error message when an instance is missing
|
|
96
|
+
*/
|
|
97
|
+
const buildSubmitEventProps = (params) => {
|
|
98
|
+
const { stripe, isCheckoutSession, checkout, checkoutSessionClientSecret, elements, intentClientSecret } = params;
|
|
99
|
+
const props = {
|
|
100
|
+
stripe,
|
|
101
|
+
};
|
|
102
|
+
if (isCheckoutSession) {
|
|
103
|
+
// Checkout Session mode
|
|
104
|
+
if (checkout == null) {
|
|
105
|
+
return { error: 'Checkout not properly initialized' };
|
|
106
|
+
}
|
|
107
|
+
props.checkout = checkout;
|
|
108
|
+
props.checkoutSessionClientSecret = checkoutSessionClientSecret;
|
|
109
|
+
return { props };
|
|
110
|
+
}
|
|
111
|
+
// Payment Intent / Setup Intent mode
|
|
112
|
+
if (elements == null) {
|
|
113
|
+
return { error: 'Elements not properly initialized' };
|
|
114
|
+
}
|
|
115
|
+
props.elements = elements;
|
|
116
|
+
props.intentClientSecret = intentClientSecret;
|
|
117
|
+
return { props };
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
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)}`;
|
|
7
121
|
|
|
8
122
|
const StripePaymentElement = class {
|
|
9
123
|
/**
|
|
@@ -21,26 +135,14 @@ const StripePaymentElement = class {
|
|
|
21
135
|
* ```
|
|
22
136
|
*/
|
|
23
137
|
async initStripe(publishableKey, options) {
|
|
138
|
+
const generation = ++this.initGeneration;
|
|
24
139
|
await this.stripeService.initialize(publishableKey, {
|
|
25
140
|
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
26
141
|
applicationName: this.applicationName,
|
|
142
|
+
// Payment Element needs the client secret when the Elements group is created
|
|
143
|
+
clientSecret: this.intentClientSecret,
|
|
27
144
|
});
|
|
28
|
-
|
|
29
|
-
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
30
|
-
await this.initElement();
|
|
31
|
-
this.stripeLoadedEventHandler();
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
// Otherwise, wait for successful load
|
|
35
|
-
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
36
|
-
if (newState !== 'success') {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
await this.initElement();
|
|
40
|
-
this.stripeLoadedEventHandler();
|
|
41
|
-
unsubscribe(); // Clean up listener after first success
|
|
42
|
-
});
|
|
43
|
-
}
|
|
145
|
+
await this.mountWhenLoaded(generation);
|
|
44
146
|
}
|
|
45
147
|
/**
|
|
46
148
|
* Get Stripe.js and initialize with Checkout Session mode
|
|
@@ -62,27 +164,13 @@ const StripePaymentElement = class {
|
|
|
62
164
|
* ```
|
|
63
165
|
*/
|
|
64
166
|
async initStripeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, options) {
|
|
167
|
+
const generation = ++this.initGeneration;
|
|
65
168
|
await this.stripeService.initializeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, {
|
|
66
169
|
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
67
170
|
applicationName: this.applicationName,
|
|
68
171
|
elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
|
|
69
172
|
});
|
|
70
|
-
|
|
71
|
-
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
72
|
-
await this.initElement();
|
|
73
|
-
this.stripeLoadedEventHandler();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Otherwise, wait for successful load
|
|
77
|
-
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
78
|
-
if (newState !== 'success') {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
await this.initElement();
|
|
82
|
-
this.stripeLoadedEventHandler();
|
|
83
|
-
unsubscribe(); // Clean up listener after first success
|
|
84
|
-
});
|
|
85
|
-
}
|
|
173
|
+
await this.mountWhenLoaded(generation);
|
|
86
174
|
}
|
|
87
175
|
/**
|
|
88
176
|
* Update the form submit progress
|
|
@@ -123,23 +211,37 @@ const StripePaymentElement = class {
|
|
|
123
211
|
updatePublishableKey(publishableKey) {
|
|
124
212
|
const options = {};
|
|
125
213
|
options.stripeAccount = this.stripeService.state.stripeAccount;
|
|
126
|
-
const hasOptionValue = Object.values(options).filter(
|
|
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
|
+
}
|
|
127
219
|
this.initStripe(publishableKey, hasOptionValue ? options : undefined);
|
|
128
220
|
}
|
|
129
221
|
updateStripeAccountId(stripeAccount) {
|
|
222
|
+
if (this.hasCheckoutSessionClientSecret()) {
|
|
223
|
+
this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, { stripeAccount });
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
130
226
|
this.initStripe(this.stripeService.state.publishableKey, {
|
|
131
227
|
stripeAccount: stripeAccount,
|
|
132
228
|
});
|
|
133
229
|
}
|
|
134
230
|
async updateIntentClientSecret() {
|
|
135
|
-
//
|
|
136
|
-
if (this.
|
|
137
|
-
|
|
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;
|
|
138
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 });
|
|
139
241
|
}
|
|
140
242
|
async updateCheckoutSessionClientSecret(newValue) {
|
|
141
243
|
// Re-initialize with checkout session when client secret changes
|
|
142
|
-
if (this.publishableKey && newValue) {
|
|
244
|
+
if (this.publishableKey != null && this.publishableKey !== '' && newValue != null && newValue !== '') {
|
|
143
245
|
await this.initStripeWithCheckoutSession(this.publishableKey, newValue, {
|
|
144
246
|
stripeAccount: this.stripeAccount,
|
|
145
247
|
});
|
|
@@ -149,42 +251,31 @@ const StripePaymentElement = class {
|
|
|
149
251
|
const event = {
|
|
150
252
|
stripe: this.stripeService.getStripe(),
|
|
151
253
|
};
|
|
152
|
-
if (this.stripeDidLoaded) {
|
|
254
|
+
if (this.stripeDidLoaded != null) {
|
|
153
255
|
this.stripeDidLoaded(event);
|
|
154
256
|
}
|
|
155
257
|
this.stripeLoaded.emit(event);
|
|
156
258
|
}
|
|
157
259
|
async formSubmitEventHandler() {
|
|
158
260
|
const stripe = this.stripeService.getStripe();
|
|
159
|
-
const isCheckoutSession = this.stripeService.state.isCheckoutSession;
|
|
160
|
-
if (
|
|
261
|
+
const isCheckoutSession = this.stripeService.state.isCheckoutSession === true;
|
|
262
|
+
if (stripe == null) {
|
|
161
263
|
console.error('Stripe not properly initialized');
|
|
162
264
|
return;
|
|
163
265
|
}
|
|
164
|
-
const
|
|
266
|
+
const result = buildSubmitEventProps({
|
|
165
267
|
stripe,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
eventData.checkoutSessionClientSecret = this.checkoutSessionClientSecret;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
// Payment Intent / Setup Intent mode
|
|
179
|
-
const elements = this.stripeService.getElements();
|
|
180
|
-
if (!elements) {
|
|
181
|
-
console.error('Elements not properly initialized');
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
eventData.elements = elements;
|
|
185
|
-
eventData.intentClientSecret = this.intentClientSecret;
|
|
268
|
+
isCheckoutSession,
|
|
269
|
+
checkout: this.stripeService.getCheckout(),
|
|
270
|
+
checkoutSessionClientSecret: this.checkoutSessionClientSecret,
|
|
271
|
+
elements: this.stripeService.getElements(),
|
|
272
|
+
intentClientSecret: this.intentClientSecret,
|
|
273
|
+
});
|
|
274
|
+
if ('error' in result) {
|
|
275
|
+
console.error(result.error);
|
|
276
|
+
return;
|
|
186
277
|
}
|
|
187
|
-
this.formSubmit.emit(
|
|
278
|
+
this.formSubmit.emit(result.props);
|
|
188
279
|
}
|
|
189
280
|
async defaultFormSubmitResultHandler(result) {
|
|
190
281
|
this.defaultFormSubmitResult.emit(result);
|
|
@@ -193,12 +284,20 @@ const StripePaymentElement = class {
|
|
|
193
284
|
this.checkoutSessionConfirmResult.emit(result);
|
|
194
285
|
}
|
|
195
286
|
componentWillRender() {
|
|
196
|
-
|
|
287
|
+
const { publishableKey } = this.stripeService.state;
|
|
288
|
+
if (publishableKey == null || publishableKey === '') {
|
|
197
289
|
return;
|
|
198
290
|
}
|
|
199
291
|
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
200
292
|
return;
|
|
201
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
|
+
}
|
|
202
301
|
this.initStripe(this.stripeService.state.publishableKey, {
|
|
203
302
|
stripeAccount: this.stripeService.state.stripeAccount,
|
|
204
303
|
});
|
|
@@ -213,30 +312,9 @@ const StripePaymentElement = class {
|
|
|
213
312
|
async defaultFormSubmitAction(event, { stripe, elements }) {
|
|
214
313
|
event.preventDefault();
|
|
215
314
|
try {
|
|
216
|
-
const { intentType } = this;
|
|
217
315
|
// Get current page URL for return_url
|
|
218
316
|
const returnUrl = window.location.href;
|
|
219
|
-
const result = await (
|
|
220
|
-
if (intentType === 'payment') {
|
|
221
|
-
return stripe.confirmPayment({
|
|
222
|
-
elements,
|
|
223
|
-
confirmParams: {
|
|
224
|
-
return_url: returnUrl,
|
|
225
|
-
},
|
|
226
|
-
redirect: 'if_required',
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
return stripe.confirmSetup({
|
|
230
|
-
elements,
|
|
231
|
-
confirmParams: {
|
|
232
|
-
return_url: returnUrl,
|
|
233
|
-
},
|
|
234
|
-
redirect: 'if_required',
|
|
235
|
-
});
|
|
236
|
-
})();
|
|
237
|
-
if (result.error) {
|
|
238
|
-
throw new StripeAPIError(result.error);
|
|
239
|
-
}
|
|
317
|
+
const result = await confirmPaymentOrSetup(stripe, elements, this.intentType, returnUrl);
|
|
240
318
|
this.defaultFormSubmitResultHandler(result);
|
|
241
319
|
}
|
|
242
320
|
catch (e) {
|
|
@@ -252,38 +330,11 @@ const StripePaymentElement = class {
|
|
|
252
330
|
* @param checkout - The Stripe Checkout instance
|
|
253
331
|
*/
|
|
254
332
|
async checkoutSessionFormSubmitAction(event, checkout) {
|
|
255
|
-
var _a;
|
|
256
333
|
event.preventDefault();
|
|
257
334
|
try {
|
|
258
|
-
// Load actions from the checkout session
|
|
259
|
-
const loadActionsResult = await checkout.loadActions();
|
|
260
|
-
if (loadActionsResult.type === 'error') {
|
|
261
|
-
// Create a StripeError-compatible object from the Checkout Session error
|
|
262
|
-
const stripeError = {
|
|
263
|
-
type: 'api_error',
|
|
264
|
-
code: loadActionsResult.error.code || 'checkout_session_error',
|
|
265
|
-
message: loadActionsResult.error.message,
|
|
266
|
-
};
|
|
267
|
-
throw new StripeAPIError(stripeError);
|
|
268
|
-
}
|
|
269
|
-
const { actions } = loadActionsResult;
|
|
270
335
|
// Get current page URL for return_url
|
|
271
336
|
const returnUrl = window.location.href;
|
|
272
|
-
|
|
273
|
-
const result = await actions.confirm({
|
|
274
|
-
returnUrl,
|
|
275
|
-
redirect: 'if_required',
|
|
276
|
-
});
|
|
277
|
-
if (result.type === 'error') {
|
|
278
|
-
// Create a StripeError-compatible object from the confirm error
|
|
279
|
-
const stripeError = {
|
|
280
|
-
type: 'card_error',
|
|
281
|
-
code: result.error.code || 'payment_failed',
|
|
282
|
-
message: result.error.message,
|
|
283
|
-
decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
|
|
284
|
-
};
|
|
285
|
-
throw new StripeAPIError(stripeError);
|
|
286
|
-
}
|
|
337
|
+
const result = await confirmCheckoutSession(checkout, returnUrl);
|
|
287
338
|
this.checkoutSessionConfirmResultHandler(result);
|
|
288
339
|
}
|
|
289
340
|
catch (e) {
|
|
@@ -294,10 +345,12 @@ const StripePaymentElement = class {
|
|
|
294
345
|
}
|
|
295
346
|
constructor(hostRef) {
|
|
296
347
|
registerInstance(this, hostRef);
|
|
297
|
-
this.stripeLoaded = createEvent(this, "stripeLoaded");
|
|
298
|
-
this.formSubmit = createEvent(this, "formSubmit");
|
|
299
|
-
this.defaultFormSubmitResult = createEvent(this, "defaultFormSubmitResult");
|
|
300
|
-
this.checkoutSessionConfirmResult = createEvent(this, "checkoutSessionConfirmResult");
|
|
348
|
+
this.stripeLoaded = createEvent(this, "stripeLoaded", 7);
|
|
349
|
+
this.formSubmit = createEvent(this, "formSubmit", 7);
|
|
350
|
+
this.defaultFormSubmitResult = createEvent(this, "defaultFormSubmitResult", 7);
|
|
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;
|
|
301
354
|
/**
|
|
302
355
|
* Default submit handle type.
|
|
303
356
|
* If you want to use `setupIntent`, should update this attribute.
|
|
@@ -339,11 +392,71 @@ const StripePaymentElement = class {
|
|
|
339
392
|
// Dependency Injection via factory
|
|
340
393
|
this.stripeService = serviceFactory.createStripeService();
|
|
341
394
|
this.paymentElementManager = serviceFactory.createPaymentElementManager(this.stripeService);
|
|
342
|
-
|
|
343
|
-
|
|
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, {
|
|
344
453
|
stripeAccount: this.stripeAccount,
|
|
345
454
|
});
|
|
455
|
+
return;
|
|
346
456
|
}
|
|
457
|
+
this.initStripe(this.publishableKey, {
|
|
458
|
+
stripeAccount: this.stripeAccount,
|
|
459
|
+
});
|
|
347
460
|
}
|
|
348
461
|
/**
|
|
349
462
|
* Initialize Component using Stripe Element
|
|
@@ -353,57 +466,47 @@ const StripePaymentElement = class {
|
|
|
353
466
|
await this.paymentElementManager.initialize(this.el);
|
|
354
467
|
// Add form submit listener scoped to this component instance
|
|
355
468
|
const formElement = this.el.querySelector('#stripe-payment-element');
|
|
356
|
-
if (
|
|
469
|
+
if (formElement == null) {
|
|
357
470
|
console.error('Form element #stripe-payment-element not found');
|
|
358
471
|
return;
|
|
359
472
|
}
|
|
360
473
|
// Remove existing listener if present to prevent duplicates
|
|
361
|
-
if (this._submitHandler) {
|
|
474
|
+
if (this._submitHandler != null) {
|
|
362
475
|
formElement.removeEventListener('submit', this._submitHandler);
|
|
363
476
|
}
|
|
364
477
|
// Create and store the submit handler
|
|
365
478
|
this._submitHandler = async (e) => {
|
|
366
479
|
const stripe = this.stripeService.getStripe();
|
|
367
|
-
const isCheckoutSession = this.stripeService.state.isCheckoutSession;
|
|
368
|
-
if (
|
|
480
|
+
const isCheckoutSession = this.stripeService.state.isCheckoutSession === true;
|
|
481
|
+
if (stripe == null) {
|
|
369
482
|
console.error('Stripe not properly initialized');
|
|
370
483
|
return;
|
|
371
484
|
}
|
|
372
|
-
// Build submit event props based on mode
|
|
373
|
-
const
|
|
485
|
+
// Build submit event props based on mode (shared with formSubmitEventHandler)
|
|
486
|
+
const result = buildSubmitEventProps({
|
|
374
487
|
stripe,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
submitEventProps.checkoutSessionClientSecret = this.checkoutSessionClientSecret;
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
// Payment Intent / Setup Intent mode
|
|
388
|
-
const elements = this.stripeService.getElements();
|
|
389
|
-
if (!elements) {
|
|
390
|
-
console.error('Elements not properly initialized');
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
submitEventProps.elements = elements;
|
|
394
|
-
submitEventProps.intentClientSecret = this.intentClientSecret;
|
|
488
|
+
isCheckoutSession,
|
|
489
|
+
checkout: this.stripeService.getCheckout(),
|
|
490
|
+
checkoutSessionClientSecret: this.checkoutSessionClientSecret,
|
|
491
|
+
elements: this.stripeService.getElements(),
|
|
492
|
+
intentClientSecret: this.intentClientSecret,
|
|
493
|
+
});
|
|
494
|
+
if ('error' in result) {
|
|
495
|
+
console.error(result.error);
|
|
496
|
+
return;
|
|
395
497
|
}
|
|
498
|
+
const submitEventProps = result.props;
|
|
396
499
|
this.progress = 'loading';
|
|
397
500
|
try {
|
|
398
|
-
if (this.handleSubmit) {
|
|
501
|
+
if (this.handleSubmit != null) {
|
|
399
502
|
await this.handleSubmit(e, submitEventProps);
|
|
400
503
|
}
|
|
401
504
|
else if (this.shouldUseDefaultFormSubmitAction === true) {
|
|
402
|
-
if (isCheckoutSession && submitEventProps.checkout) {
|
|
505
|
+
if (isCheckoutSession && submitEventProps.checkout != null) {
|
|
403
506
|
// Use Checkout Session confirmation
|
|
404
507
|
await this.checkoutSessionFormSubmitAction(e, submitEventProps.checkout);
|
|
405
508
|
}
|
|
406
|
-
else if (this.intentClientSecret) {
|
|
509
|
+
else if (this.intentClientSecret != null && this.intentClientSecret !== '') {
|
|
407
510
|
// Use Payment Intent / Setup Intent confirmation
|
|
408
511
|
await this.defaultFormSubmitAction(e, submitEventProps);
|
|
409
512
|
}
|
|
@@ -415,7 +518,7 @@ const StripePaymentElement = class {
|
|
|
415
518
|
e.preventDefault();
|
|
416
519
|
}
|
|
417
520
|
await this.formSubmitEventHandler();
|
|
418
|
-
if (this.handleSubmit || this.shouldUseDefaultFormSubmitAction === true) {
|
|
521
|
+
if (this.handleSubmit != null || this.shouldUseDefaultFormSubmitAction === true) {
|
|
419
522
|
this.progress = 'success';
|
|
420
523
|
}
|
|
421
524
|
}
|
|
@@ -433,9 +536,9 @@ const StripePaymentElement = class {
|
|
|
433
536
|
disconnectedCallback() {
|
|
434
537
|
this.paymentElementManager.unmount();
|
|
435
538
|
// Remove event listener to prevent memory leaks
|
|
436
|
-
if (this._submitHandler) {
|
|
539
|
+
if (this._submitHandler != null) {
|
|
437
540
|
const formElement = this.el.querySelector('#stripe-payment-element');
|
|
438
|
-
if (formElement) {
|
|
541
|
+
if (formElement != null) {
|
|
439
542
|
formElement.removeEventListener('submit', this._submitHandler);
|
|
440
543
|
}
|
|
441
544
|
}
|
|
@@ -446,22 +549,35 @@ const StripePaymentElement = class {
|
|
|
446
549
|
if (loadStripeStatus === 'failure') {
|
|
447
550
|
return h("p", null, i18n.t('Failed to load Stripe'));
|
|
448
551
|
}
|
|
449
|
-
// Determine if button should be disabled
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
552
|
+
// Determine if button should be disabled (see isSubmitButtonDisabled helper for mode-specific rules)
|
|
553
|
+
const disabled = isSubmitButtonDisabled({
|
|
554
|
+
progress: this.progress,
|
|
555
|
+
isCheckoutSession: isCheckoutSession === true,
|
|
556
|
+
loadStripeStatus,
|
|
557
|
+
intentClientSecret: this.intentClientSecret,
|
|
558
|
+
});
|
|
559
|
+
return (
|
|
560
|
+
// NOTE: `stripe-payment-sheet-wrap` is a legacy CSS class kept for backward compatibility.
|
|
561
|
+
// It is a leftover from a former component name but is part of the public DOM contract,
|
|
562
|
+
// so external stylesheets may target it. Keep it in the rendered output and the .scss.
|
|
563
|
+
h("div", { class: "stripe-payment-sheet-wrap" }, h("form", { id: "stripe-payment-element" }, h("div", { class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", null, h("div", { class: "stripe-section-title" }, i18n.t('Payment information'))), h("div", { class: "payment-info visible" }, h("div", { id: "payment-element" })), h("div", { id: "payment-errors", class: "stripe-element-errors" }, errorMessage), h("div", { style: { marginTop: '32px' } }, h("button", { type: "submit", disabled: disabled }, this.progress === 'loading' ? i18n.t('Loading') : i18n.t(this.buttonLabel))))));
|
|
455
564
|
}
|
|
456
565
|
get el() { return getElement(this); }
|
|
457
566
|
static get watchers() { return {
|
|
458
|
-
"publishableKey": [
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
"
|
|
567
|
+
"publishableKey": [{
|
|
568
|
+
"updatePublishableKey": 0
|
|
569
|
+
}],
|
|
570
|
+
"stripeAccount": [{
|
|
571
|
+
"updateStripeAccountId": 0
|
|
572
|
+
}],
|
|
573
|
+
"intentClientSecret": [{
|
|
574
|
+
"updateIntentClientSecret": 0
|
|
575
|
+
}],
|
|
576
|
+
"checkoutSessionClientSecret": [{
|
|
577
|
+
"updateCheckoutSessionClientSecret": 0
|
|
578
|
+
}]
|
|
462
579
|
}; }
|
|
463
580
|
};
|
|
464
|
-
StripePaymentElement.style = stripePaymentElementCss;
|
|
581
|
+
StripePaymentElement.style = stripePaymentElementCss();
|
|
465
582
|
|
|
466
583
|
export { StripePaymentElement as stripe_payment_element };
|
|
467
|
-
//# sourceMappingURL=stripe-payment-element.entry.js.map
|