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,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-Cd2VI_N2.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
|
/**
|
|
@@ -23,26 +137,14 @@ const StripePaymentElement = class {
|
|
|
23
137
|
* ```
|
|
24
138
|
*/
|
|
25
139
|
async initStripe(publishableKey, options) {
|
|
140
|
+
const generation = ++this.initGeneration;
|
|
26
141
|
await this.stripeService.initialize(publishableKey, {
|
|
27
142
|
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
28
143
|
applicationName: this.applicationName,
|
|
144
|
+
// Payment Element needs the client secret when the Elements group is created
|
|
145
|
+
clientSecret: this.intentClientSecret,
|
|
29
146
|
});
|
|
30
|
-
|
|
31
|
-
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
32
|
-
await this.initElement();
|
|
33
|
-
this.stripeLoadedEventHandler();
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// Otherwise, wait for successful load
|
|
37
|
-
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
38
|
-
if (newState !== 'success') {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
await this.initElement();
|
|
42
|
-
this.stripeLoadedEventHandler();
|
|
43
|
-
unsubscribe(); // Clean up listener after first success
|
|
44
|
-
});
|
|
45
|
-
}
|
|
147
|
+
await this.mountWhenLoaded(generation);
|
|
46
148
|
}
|
|
47
149
|
/**
|
|
48
150
|
* Get Stripe.js and initialize with Checkout Session mode
|
|
@@ -64,27 +166,13 @@ const StripePaymentElement = class {
|
|
|
64
166
|
* ```
|
|
65
167
|
*/
|
|
66
168
|
async initStripeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, options) {
|
|
169
|
+
const generation = ++this.initGeneration;
|
|
67
170
|
await this.stripeService.initializeWithCheckoutSession(publishableKey, checkoutSessionClientSecret, {
|
|
68
171
|
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
69
172
|
applicationName: this.applicationName,
|
|
70
173
|
elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
|
|
71
174
|
});
|
|
72
|
-
|
|
73
|
-
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
74
|
-
await this.initElement();
|
|
75
|
-
this.stripeLoadedEventHandler();
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// Otherwise, wait for successful load
|
|
79
|
-
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
80
|
-
if (newState !== 'success') {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
await this.initElement();
|
|
84
|
-
this.stripeLoadedEventHandler();
|
|
85
|
-
unsubscribe(); // Clean up listener after first success
|
|
86
|
-
});
|
|
87
|
-
}
|
|
175
|
+
await this.mountWhenLoaded(generation);
|
|
88
176
|
}
|
|
89
177
|
/**
|
|
90
178
|
* Update the form submit progress
|
|
@@ -125,23 +213,37 @@ const StripePaymentElement = class {
|
|
|
125
213
|
updatePublishableKey(publishableKey) {
|
|
126
214
|
const options = {};
|
|
127
215
|
options.stripeAccount = this.stripeService.state.stripeAccount;
|
|
128
|
-
const hasOptionValue = Object.values(options).filter(
|
|
216
|
+
const hasOptionValue = Object.values(options).filter(value => value != null && value !== '').length > 0;
|
|
217
|
+
if (this.hasCheckoutSessionClientSecret()) {
|
|
218
|
+
this.initStripeWithCheckoutSession(publishableKey, this.checkoutSessionClientSecret, { stripeAccount: options.stripeAccount });
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
129
221
|
this.initStripe(publishableKey, hasOptionValue ? options : undefined);
|
|
130
222
|
}
|
|
131
223
|
updateStripeAccountId(stripeAccount) {
|
|
224
|
+
if (this.hasCheckoutSessionClientSecret()) {
|
|
225
|
+
this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, { stripeAccount });
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
132
228
|
this.initStripe(this.stripeService.state.publishableKey, {
|
|
133
229
|
stripeAccount: stripeAccount,
|
|
134
230
|
});
|
|
135
231
|
}
|
|
136
232
|
async updateIntentClientSecret() {
|
|
137
|
-
//
|
|
138
|
-
if (this.
|
|
139
|
-
|
|
233
|
+
// Checkout Session mode takes precedence (same rule as startStripe); an intent secret must not switch the mode
|
|
234
|
+
if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
|
|
235
|
+
return;
|
|
140
236
|
}
|
|
237
|
+
// The Elements group is bound to its client secret, so it has to be recreated when the secret changes
|
|
238
|
+
const { publishableKey, stripeAccount } = this.stripeService.state;
|
|
239
|
+
if (publishableKey == null || publishableKey === '') {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
await this.initStripe(publishableKey, { stripeAccount });
|
|
141
243
|
}
|
|
142
244
|
async updateCheckoutSessionClientSecret(newValue) {
|
|
143
245
|
// Re-initialize with checkout session when client secret changes
|
|
144
|
-
if (this.publishableKey && newValue) {
|
|
246
|
+
if (this.publishableKey != null && this.publishableKey !== '' && newValue != null && newValue !== '') {
|
|
145
247
|
await this.initStripeWithCheckoutSession(this.publishableKey, newValue, {
|
|
146
248
|
stripeAccount: this.stripeAccount,
|
|
147
249
|
});
|
|
@@ -151,42 +253,31 @@ const StripePaymentElement = class {
|
|
|
151
253
|
const event = {
|
|
152
254
|
stripe: this.stripeService.getStripe(),
|
|
153
255
|
};
|
|
154
|
-
if (this.stripeDidLoaded) {
|
|
256
|
+
if (this.stripeDidLoaded != null) {
|
|
155
257
|
this.stripeDidLoaded(event);
|
|
156
258
|
}
|
|
157
259
|
this.stripeLoaded.emit(event);
|
|
158
260
|
}
|
|
159
261
|
async formSubmitEventHandler() {
|
|
160
262
|
const stripe = this.stripeService.getStripe();
|
|
161
|
-
const isCheckoutSession = this.stripeService.state.isCheckoutSession;
|
|
162
|
-
if (
|
|
263
|
+
const isCheckoutSession = this.stripeService.state.isCheckoutSession === true;
|
|
264
|
+
if (stripe == null) {
|
|
163
265
|
console.error('Stripe not properly initialized');
|
|
164
266
|
return;
|
|
165
267
|
}
|
|
166
|
-
const
|
|
268
|
+
const result = buildSubmitEventProps({
|
|
167
269
|
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;
|
|
270
|
+
isCheckoutSession,
|
|
271
|
+
checkout: this.stripeService.getCheckout(),
|
|
272
|
+
checkoutSessionClientSecret: this.checkoutSessionClientSecret,
|
|
273
|
+
elements: this.stripeService.getElements(),
|
|
274
|
+
intentClientSecret: this.intentClientSecret,
|
|
275
|
+
});
|
|
276
|
+
if ('error' in result) {
|
|
277
|
+
console.error(result.error);
|
|
278
|
+
return;
|
|
188
279
|
}
|
|
189
|
-
this.formSubmit.emit(
|
|
280
|
+
this.formSubmit.emit(result.props);
|
|
190
281
|
}
|
|
191
282
|
async defaultFormSubmitResultHandler(result) {
|
|
192
283
|
this.defaultFormSubmitResult.emit(result);
|
|
@@ -195,12 +286,20 @@ const StripePaymentElement = class {
|
|
|
195
286
|
this.checkoutSessionConfirmResult.emit(result);
|
|
196
287
|
}
|
|
197
288
|
componentWillRender() {
|
|
198
|
-
|
|
289
|
+
const { publishableKey } = this.stripeService.state;
|
|
290
|
+
if (publishableKey == null || publishableKey === '') {
|
|
199
291
|
return;
|
|
200
292
|
}
|
|
201
293
|
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
202
294
|
return;
|
|
203
295
|
}
|
|
296
|
+
// Retry in the same mode as the initial start
|
|
297
|
+
if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
|
|
298
|
+
this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, {
|
|
299
|
+
stripeAccount: this.stripeService.state.stripeAccount,
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
204
303
|
this.initStripe(this.stripeService.state.publishableKey, {
|
|
205
304
|
stripeAccount: this.stripeService.state.stripeAccount,
|
|
206
305
|
});
|
|
@@ -215,30 +314,9 @@ const StripePaymentElement = class {
|
|
|
215
314
|
async defaultFormSubmitAction(event, { stripe, elements }) {
|
|
216
315
|
event.preventDefault();
|
|
217
316
|
try {
|
|
218
|
-
const { intentType } = this;
|
|
219
317
|
// Get current page URL for return_url
|
|
220
318
|
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
|
-
}
|
|
319
|
+
const result = await confirmPaymentOrSetup(stripe, elements, this.intentType, returnUrl);
|
|
242
320
|
this.defaultFormSubmitResultHandler(result);
|
|
243
321
|
}
|
|
244
322
|
catch (e) {
|
|
@@ -254,38 +332,11 @@ const StripePaymentElement = class {
|
|
|
254
332
|
* @param checkout - The Stripe Checkout instance
|
|
255
333
|
*/
|
|
256
334
|
async checkoutSessionFormSubmitAction(event, checkout) {
|
|
257
|
-
var _a;
|
|
258
335
|
event.preventDefault();
|
|
259
336
|
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
337
|
// Get current page URL for return_url
|
|
273
338
|
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
|
-
}
|
|
339
|
+
const result = await confirmCheckoutSession(checkout, returnUrl);
|
|
289
340
|
this.checkoutSessionConfirmResultHandler(result);
|
|
290
341
|
}
|
|
291
342
|
catch (e) {
|
|
@@ -296,10 +347,12 @@ const StripePaymentElement = class {
|
|
|
296
347
|
}
|
|
297
348
|
constructor(hostRef) {
|
|
298
349
|
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");
|
|
350
|
+
this.stripeLoaded = index.createEvent(this, "stripeLoaded", 7);
|
|
351
|
+
this.formSubmit = index.createEvent(this, "formSubmit", 7);
|
|
352
|
+
this.defaultFormSubmitResult = index.createEvent(this, "defaultFormSubmitResult", 7);
|
|
353
|
+
this.checkoutSessionConfirmResult = index.createEvent(this, "checkoutSessionConfirmResult", 7);
|
|
354
|
+
// Incremented on every initStripe call so that a superseded call stops after its awaits
|
|
355
|
+
this.initGeneration = 0;
|
|
303
356
|
/**
|
|
304
357
|
* Default submit handle type.
|
|
305
358
|
* If you want to use `setupIntent`, should update this attribute.
|
|
@@ -341,11 +394,71 @@ const StripePaymentElement = class {
|
|
|
341
394
|
// Dependency Injection via factory
|
|
342
395
|
this.stripeService = factory.serviceFactory.createStripeService();
|
|
343
396
|
this.paymentElementManager = factory.serviceFactory.createPaymentElementManager(this.stripeService);
|
|
344
|
-
|
|
345
|
-
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Props are not yet populated inside the constructor when the component is registered via
|
|
400
|
+
* the custom-elements build (`dist/components/*`), so initialization that depends on them
|
|
401
|
+
* must run in `componentWillLoad`, where both the lazy and custom-elements builds have them set.
|
|
402
|
+
*/
|
|
403
|
+
componentWillLoad() {
|
|
404
|
+
this.startStripe();
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Mount the element once Stripe.js has loaded, unless a newer init call (of either mode) has superseded this one.
|
|
408
|
+
* @param generation - The value of `initGeneration` taken when the init call started
|
|
409
|
+
*/
|
|
410
|
+
async mountWhenLoaded(generation) {
|
|
411
|
+
// A newer init call supersedes this one
|
|
412
|
+
if (generation !== this.initGeneration) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
// If already successfully loaded, initialize elements immediately
|
|
416
|
+
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
417
|
+
await this.initElement();
|
|
418
|
+
if (generation !== this.initGeneration) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
this.stripeLoadedEventHandler();
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
// Otherwise, wait for successful load
|
|
425
|
+
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
426
|
+
if (generation !== this.initGeneration) {
|
|
427
|
+
unsubscribe();
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (newState !== 'success') {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
await this.initElement();
|
|
434
|
+
if (generation !== this.initGeneration) {
|
|
435
|
+
unsubscribe();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
this.stripeLoadedEventHandler();
|
|
439
|
+
unsubscribe(); // Clean up listener after first success
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
hasCheckoutSessionClientSecret() {
|
|
443
|
+
return this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '';
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Start Stripe.js in the mode that matches the given props.
|
|
447
|
+
* Checkout Session mode when `checkoutSessionClientSecret` is set, PaymentIntent / SetupIntent mode otherwise.
|
|
448
|
+
*/
|
|
449
|
+
startStripe() {
|
|
450
|
+
if (this.publishableKey == null || this.publishableKey === '') {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
|
|
454
|
+
this.initStripeWithCheckoutSession(this.publishableKey, this.checkoutSessionClientSecret, {
|
|
346
455
|
stripeAccount: this.stripeAccount,
|
|
347
456
|
});
|
|
457
|
+
return;
|
|
348
458
|
}
|
|
459
|
+
this.initStripe(this.publishableKey, {
|
|
460
|
+
stripeAccount: this.stripeAccount,
|
|
461
|
+
});
|
|
349
462
|
}
|
|
350
463
|
/**
|
|
351
464
|
* Initialize Component using Stripe Element
|
|
@@ -355,57 +468,47 @@ const StripePaymentElement = class {
|
|
|
355
468
|
await this.paymentElementManager.initialize(this.el);
|
|
356
469
|
// Add form submit listener scoped to this component instance
|
|
357
470
|
const formElement = this.el.querySelector('#stripe-payment-element');
|
|
358
|
-
if (
|
|
471
|
+
if (formElement == null) {
|
|
359
472
|
console.error('Form element #stripe-payment-element not found');
|
|
360
473
|
return;
|
|
361
474
|
}
|
|
362
475
|
// Remove existing listener if present to prevent duplicates
|
|
363
|
-
if (this._submitHandler) {
|
|
476
|
+
if (this._submitHandler != null) {
|
|
364
477
|
formElement.removeEventListener('submit', this._submitHandler);
|
|
365
478
|
}
|
|
366
479
|
// Create and store the submit handler
|
|
367
480
|
this._submitHandler = async (e) => {
|
|
368
481
|
const stripe = this.stripeService.getStripe();
|
|
369
|
-
const isCheckoutSession = this.stripeService.state.isCheckoutSession;
|
|
370
|
-
if (
|
|
482
|
+
const isCheckoutSession = this.stripeService.state.isCheckoutSession === true;
|
|
483
|
+
if (stripe == null) {
|
|
371
484
|
console.error('Stripe not properly initialized');
|
|
372
485
|
return;
|
|
373
486
|
}
|
|
374
|
-
// Build submit event props based on mode
|
|
375
|
-
const
|
|
487
|
+
// Build submit event props based on mode (shared with formSubmitEventHandler)
|
|
488
|
+
const result = buildSubmitEventProps({
|
|
376
489
|
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;
|
|
490
|
+
isCheckoutSession,
|
|
491
|
+
checkout: this.stripeService.getCheckout(),
|
|
492
|
+
checkoutSessionClientSecret: this.checkoutSessionClientSecret,
|
|
493
|
+
elements: this.stripeService.getElements(),
|
|
494
|
+
intentClientSecret: this.intentClientSecret,
|
|
495
|
+
});
|
|
496
|
+
if ('error' in result) {
|
|
497
|
+
console.error(result.error);
|
|
498
|
+
return;
|
|
397
499
|
}
|
|
500
|
+
const submitEventProps = result.props;
|
|
398
501
|
this.progress = 'loading';
|
|
399
502
|
try {
|
|
400
|
-
if (this.handleSubmit) {
|
|
503
|
+
if (this.handleSubmit != null) {
|
|
401
504
|
await this.handleSubmit(e, submitEventProps);
|
|
402
505
|
}
|
|
403
506
|
else if (this.shouldUseDefaultFormSubmitAction === true) {
|
|
404
|
-
if (isCheckoutSession && submitEventProps.checkout) {
|
|
507
|
+
if (isCheckoutSession && submitEventProps.checkout != null) {
|
|
405
508
|
// Use Checkout Session confirmation
|
|
406
509
|
await this.checkoutSessionFormSubmitAction(e, submitEventProps.checkout);
|
|
407
510
|
}
|
|
408
|
-
else if (this.intentClientSecret) {
|
|
511
|
+
else if (this.intentClientSecret != null && this.intentClientSecret !== '') {
|
|
409
512
|
// Use Payment Intent / Setup Intent confirmation
|
|
410
513
|
await this.defaultFormSubmitAction(e, submitEventProps);
|
|
411
514
|
}
|
|
@@ -417,7 +520,7 @@ const StripePaymentElement = class {
|
|
|
417
520
|
e.preventDefault();
|
|
418
521
|
}
|
|
419
522
|
await this.formSubmitEventHandler();
|
|
420
|
-
if (this.handleSubmit || this.shouldUseDefaultFormSubmitAction === true) {
|
|
523
|
+
if (this.handleSubmit != null || this.shouldUseDefaultFormSubmitAction === true) {
|
|
421
524
|
this.progress = 'success';
|
|
422
525
|
}
|
|
423
526
|
}
|
|
@@ -435,9 +538,9 @@ const StripePaymentElement = class {
|
|
|
435
538
|
disconnectedCallback() {
|
|
436
539
|
this.paymentElementManager.unmount();
|
|
437
540
|
// Remove event listener to prevent memory leaks
|
|
438
|
-
if (this._submitHandler) {
|
|
541
|
+
if (this._submitHandler != null) {
|
|
439
542
|
const formElement = this.el.querySelector('#stripe-payment-element');
|
|
440
|
-
if (formElement) {
|
|
543
|
+
if (formElement != null) {
|
|
441
544
|
formElement.removeEventListener('submit', this._submitHandler);
|
|
442
545
|
}
|
|
443
546
|
}
|
|
@@ -448,22 +551,35 @@ const StripePaymentElement = class {
|
|
|
448
551
|
if (loadStripeStatus === 'failure') {
|
|
449
552
|
return index.h("p", null, factory.i18n.t('Failed to load Stripe'));
|
|
450
553
|
}
|
|
451
|
-
// Determine if button should be disabled
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
554
|
+
// Determine if button should be disabled (see isSubmitButtonDisabled helper for mode-specific rules)
|
|
555
|
+
const disabled = isSubmitButtonDisabled({
|
|
556
|
+
progress: this.progress,
|
|
557
|
+
isCheckoutSession: isCheckoutSession === true,
|
|
558
|
+
loadStripeStatus,
|
|
559
|
+
intentClientSecret: this.intentClientSecret,
|
|
560
|
+
});
|
|
561
|
+
return (
|
|
562
|
+
// NOTE: `stripe-payment-sheet-wrap` is a legacy CSS class kept for backward compatibility.
|
|
563
|
+
// It is a leftover from a former component name but is part of the public DOM contract,
|
|
564
|
+
// so external stylesheets may target it. Keep it in the rendered output and the .scss.
|
|
565
|
+
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
566
|
}
|
|
458
567
|
get el() { return index.getElement(this); }
|
|
459
568
|
static get watchers() { return {
|
|
460
|
-
"publishableKey": [
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
"
|
|
569
|
+
"publishableKey": [{
|
|
570
|
+
"updatePublishableKey": 0
|
|
571
|
+
}],
|
|
572
|
+
"stripeAccount": [{
|
|
573
|
+
"updateStripeAccountId": 0
|
|
574
|
+
}],
|
|
575
|
+
"intentClientSecret": [{
|
|
576
|
+
"updateIntentClientSecret": 0
|
|
577
|
+
}],
|
|
578
|
+
"checkoutSessionClientSecret": [{
|
|
579
|
+
"updateCheckoutSessionClientSecret": 0
|
|
580
|
+
}]
|
|
464
581
|
}; }
|
|
465
582
|
};
|
|
466
|
-
StripePaymentElement.style = stripePaymentElementCss;
|
|
583
|
+
StripePaymentElement.style = stripePaymentElementCss();
|
|
467
584
|
|
|
468
585
|
exports.stripe_payment_element = StripePaymentElement;
|
|
469
|
-
//# sourceMappingURL=stripe-payment-element.entry.cjs.js.map
|