stripe-pwa-elements 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/factory-Cm6zUD7R.js +1206 -0
- package/dist/cjs/{factory-Cd2VI_N2.js → i18n-lBbOeQt4.js} +12 -1149
- package/dist/cjs/ion-icon_2.cjs.entry.js +725 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stripe-address-element.cjs.entry.js +5 -4
- package/dist/cjs/stripe-card-element-modal.cjs.entry.js +3 -2
- package/dist/cjs/{stripe-card-element_2.cjs.entry.js → stripe-card-element.cjs.entry.js} +8 -93
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +4 -3
- package/dist/cjs/stripe-elements.cjs.js +1 -1
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +24 -5
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +4 -3
- package/dist/cjs/stripe-payment-element.cjs.entry.js +12 -124
- package/dist/cjs/stripe-payment-element.helpers-CvAhIqLt.js +119 -0
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +2 -2
- package/dist/cjs/stripe-payment-sheet.cjs.entry.js +987 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/stripe-address-element/stripe-address-element.js +2 -2
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +3 -2
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +4 -3
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +18 -0
- package/dist/collection/components/stripe-modal/stripe-modal.css +27 -1
- package/dist/collection/components/stripe-modal/stripe-modal.js +132 -1
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +4 -7
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +4 -4
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +3 -3
- package/dist/collection/components/stripe-payment-sheet/payment-sheet-state.js +193 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +94 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.css +68 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.helpers.js +274 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +763 -0
- package/dist/collection/services/express-checkout-element-manager.js +36 -2
- package/dist/collection/services/link-authentication-element-manager.js +5 -0
- package/dist/collection/services/stripe-service.js +20 -6
- package/dist/collection/utils/focus.js +76 -0
- package/dist/collection/utils/i18n.js +12 -0
- package/dist/components/factory.js +1 -1
- package/dist/components/i18n.js +1 -0
- package/dist/components/stripe-address-element.js +1 -1
- package/dist/components/stripe-card-element-modal.js +1 -1
- package/dist/components/stripe-card-element2.js +1 -1
- package/dist/components/stripe-currency-selector.js +1 -1
- package/dist/components/stripe-express-checkout-element.js +1 -1
- package/dist/components/stripe-link-authentication-element.js +1 -1
- package/dist/components/stripe-modal2.js +1 -1
- package/dist/components/stripe-payment-element.helpers.js +1 -0
- package/dist/components/stripe-payment-element.js +1 -1
- package/dist/components/stripe-payment-request-button2.js +1 -1
- package/dist/components/stripe-payment-sheet.d.ts +11 -0
- package/dist/components/stripe-payment-sheet.js +1 -0
- package/dist/esm/factory-BaGv8K_i.js +1203 -0
- package/dist/esm/{factory-VTa1Gc94.js → i18n-CL5n3bOb.js} +13 -1149
- package/dist/esm/ion-icon_2.entry.js +722 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stripe-address-element.entry.js +2 -1
- package/dist/esm/stripe-card-element-modal.entry.js +3 -2
- package/dist/esm/{stripe-card-element_2.entry.js → stripe-card-element.entry.js} +6 -90
- package/dist/esm/stripe-currency-selector.entry.js +2 -1
- package/dist/esm/stripe-elements.js +1 -1
- package/dist/esm/stripe-express-checkout-element.entry.js +20 -1
- package/dist/esm/stripe-link-authentication-element.entry.js +2 -1
- package/dist/esm/stripe-payment-element.entry.js +4 -116
- package/dist/esm/stripe-payment-element.helpers-Bu9RfxS4.js +114 -0
- package/dist/esm/stripe-payment-request-button.entry.js +2 -2
- package/dist/esm/stripe-payment-sheet.entry.js +985 -0
- package/dist/stripe-elements/p-2e41699e.entry.js +1 -0
- package/dist/stripe-elements/p-3fc4583a.entry.js +1 -0
- package/dist/stripe-elements/{p-ae0c336e.entry.js → p-4891edf0.entry.js} +1 -1
- package/dist/stripe-elements/p-7e826964.entry.js +1 -0
- package/dist/stripe-elements/p-BhKXGROE.js +1 -0
- package/dist/stripe-elements/p-CL5n3bOb.js +1 -0
- package/dist/stripe-elements/p-DlMEZwSe.js +1 -0
- package/dist/stripe-elements/p-a395a5d1.entry.js +1 -0
- package/dist/stripe-elements/p-b62c9dae.entry.js +1 -0
- package/dist/stripe-elements/p-b7c20e8e.entry.js +1 -0
- package/dist/stripe-elements/p-ba791c8f.entry.js +1 -0
- package/dist/stripe-elements/p-bec62526.entry.js +1 -0
- package/dist/stripe-elements/p-f5552c81.entry.js +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -1
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +2 -1
- package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +2 -1
- package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +5 -0
- package/dist/types/components/stripe-modal/stripe-modal.d.ts +43 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +7 -2
- package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +1 -1
- package/dist/types/components/stripe-payment-sheet/payment-sheet-state.d.ts +121 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +39 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +157 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.helpers.d.ts +153 -0
- package/dist/types/components.d.ts +182 -10
- package/dist/types/index.d.ts +2 -0
- package/dist/types/services/interfaces.d.ts +3 -0
- package/dist/types/services/stripe-service.d.ts +7 -2
- package/dist/types/utils/focus.d.ts +15 -0
- package/package.json +7 -3
- package/readme.md +59 -6
- package/dist/cjs/ion-icon.cjs.entry.js +0 -431
- package/dist/components/utils.js +0 -1
- package/dist/esm/ion-icon.entry.js +0 -429
- package/dist/stripe-elements/p-1bd46766.entry.js +0 -1
- package/dist/stripe-elements/p-1c6e0a45.entry.js +0 -1
- package/dist/stripe-elements/p-3f42ca0c.entry.js +0 -1
- package/dist/stripe-elements/p-5cf62945.entry.js +0 -1
- package/dist/stripe-elements/p-74de1556.entry.js +0 -1
- package/dist/stripe-elements/p-76e57d78.entry.js +0 -1
- package/dist/stripe-elements/p-840d499f.entry.js +0 -1
- package/dist/stripe-elements/p-CrjrbGJ3.js +0 -1
- package/dist/stripe-elements/p-cfd8e081.entry.js +0 -1
|
@@ -1,123 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-Dkb0SxZc.js');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var i18n = require('./i18n-lBbOeQt4.js');
|
|
5
|
+
var factory = require('./factory-Cm6zUD7R.js');
|
|
6
|
+
var stripePaymentElement_helpers = require('./stripe-payment-element.helpers-CvAhIqLt.js');
|
|
6
7
|
require('./index-CYbA1N_k.js');
|
|
7
|
-
|
|
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
|
-
};
|
|
8
|
+
require('./error-FFC4kSs5.js');
|
|
121
9
|
|
|
122
10
|
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)}`;
|
|
123
11
|
|
|
@@ -265,7 +153,7 @@ const StripePaymentElement = class {
|
|
|
265
153
|
console.error('Stripe not properly initialized');
|
|
266
154
|
return;
|
|
267
155
|
}
|
|
268
|
-
const result = buildSubmitEventProps({
|
|
156
|
+
const result = stripePaymentElement_helpers.buildSubmitEventProps({
|
|
269
157
|
stripe,
|
|
270
158
|
isCheckoutSession,
|
|
271
159
|
checkout: this.stripeService.getCheckout(),
|
|
@@ -316,7 +204,7 @@ const StripePaymentElement = class {
|
|
|
316
204
|
try {
|
|
317
205
|
// Get current page URL for return_url
|
|
318
206
|
const returnUrl = window.location.href;
|
|
319
|
-
const result = await confirmPaymentOrSetup(stripe, elements, this.intentType, returnUrl);
|
|
207
|
+
const result = await stripePaymentElement_helpers.confirmPaymentOrSetup(stripe, elements, this.intentType, returnUrl);
|
|
320
208
|
this.defaultFormSubmitResultHandler(result);
|
|
321
209
|
}
|
|
322
210
|
catch (e) {
|
|
@@ -336,7 +224,7 @@ const StripePaymentElement = class {
|
|
|
336
224
|
try {
|
|
337
225
|
// Get current page URL for return_url
|
|
338
226
|
const returnUrl = window.location.href;
|
|
339
|
-
const result = await confirmCheckoutSession(checkout, returnUrl);
|
|
227
|
+
const result = await stripePaymentElement_helpers.confirmCheckoutSession(checkout, returnUrl);
|
|
340
228
|
this.checkoutSessionConfirmResultHandler(result);
|
|
341
229
|
}
|
|
342
230
|
catch (e) {
|
|
@@ -485,7 +373,7 @@ const StripePaymentElement = class {
|
|
|
485
373
|
return;
|
|
486
374
|
}
|
|
487
375
|
// Build submit event props based on mode (shared with formSubmitEventHandler)
|
|
488
|
-
const result = buildSubmitEventProps({
|
|
376
|
+
const result = stripePaymentElement_helpers.buildSubmitEventProps({
|
|
489
377
|
stripe,
|
|
490
378
|
isCheckoutSession,
|
|
491
379
|
checkout: this.stripeService.getCheckout(),
|
|
@@ -533,7 +421,7 @@ const StripePaymentElement = class {
|
|
|
533
421
|
formElement.addEventListener('submit', this._submitHandler);
|
|
534
422
|
}
|
|
535
423
|
componentDidLoad() {
|
|
536
|
-
this.el.classList.add(
|
|
424
|
+
this.el.classList.add(i18n.checkPlatform());
|
|
537
425
|
}
|
|
538
426
|
disconnectedCallback() {
|
|
539
427
|
this.paymentElementManager.unmount();
|
|
@@ -549,10 +437,10 @@ const StripePaymentElement = class {
|
|
|
549
437
|
const { loadStripeStatus, isCheckoutSession } = this.stripeService.state;
|
|
550
438
|
const { errorMessage } = this.paymentElementManager.getState();
|
|
551
439
|
if (loadStripeStatus === 'failure') {
|
|
552
|
-
return index.h("p", null,
|
|
440
|
+
return index.h("p", null, i18n.i18n.t('Failed to load Stripe'));
|
|
553
441
|
}
|
|
554
442
|
// Determine if button should be disabled (see isSubmitButtonDisabled helper for mode-specific rules)
|
|
555
|
-
const disabled = isSubmitButtonDisabled({
|
|
443
|
+
const disabled = stripePaymentElement_helpers.isSubmitButtonDisabled({
|
|
556
444
|
progress: this.progress,
|
|
557
445
|
isCheckoutSession: isCheckoutSession === true,
|
|
558
446
|
loadStripeStatus,
|
|
@@ -562,7 +450,7 @@ const StripePaymentElement = class {
|
|
|
562
450
|
// NOTE: `stripe-payment-sheet-wrap` is a legacy CSS class kept for backward compatibility.
|
|
563
451
|
// It is a leftover from a former component name but is part of the public DOM contract,
|
|
564
452
|
// 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" },
|
|
453
|
+
index.h("div", { class: "stripe-payment-sheet-wrap" }, index.h("form", { id: "stripe-payment-element" }, index.h("div", { class: "stripe-heading" }, i18n.i18n.t(this.sheetTitle)), index.h("div", null, index.h("div", { class: "stripe-section-title" }, i18n.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' ? i18n.i18n.t('Loading') : i18n.i18n.t(this.buttonLabel))))));
|
|
566
454
|
}
|
|
567
455
|
get el() { return index.getElement(this); }
|
|
568
456
|
static get watchers() { return {
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var error = require('./error-FFC4kSs5.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Determine whether the submit button should be disabled.
|
|
7
|
+
* For Checkout Session mode: the checkout is ready once Stripe finished loading.
|
|
8
|
+
* For Payment Intent / Setup Intent mode: an intent client secret must be present.
|
|
9
|
+
* @param params progress / loading state and the current mode information
|
|
10
|
+
* @returns true when the submit button should be disabled
|
|
11
|
+
*/
|
|
12
|
+
const isSubmitButtonDisabled = (params) => {
|
|
13
|
+
const { progress, isCheckoutSession, loadStripeStatus, intentClientSecret } = params;
|
|
14
|
+
const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : intentClientSecret != null && intentClientSecret !== '';
|
|
15
|
+
return progress === 'loading' || !hasValidSecret;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
|
|
19
|
+
* Calls `confirmPayment` or `confirmSetup` depending on the intent type.
|
|
20
|
+
* @param stripe the loaded Stripe.js instance
|
|
21
|
+
* @param elements the Stripe Elements instance bound to the payment element
|
|
22
|
+
* @param intentType the configured intent type
|
|
23
|
+
* @param returnUrl the URL Stripe should redirect back to when required
|
|
24
|
+
* @param extraConfirmParams optional params merged into `confirmParams` (for example `payment_method_data.billing_details`)
|
|
25
|
+
* @returns the confirmation result
|
|
26
|
+
* @throws StripeAPIError when Stripe returns an error
|
|
27
|
+
*/
|
|
28
|
+
const confirmPaymentOrSetup = async (stripe, elements, intentType, returnUrl, extraConfirmParams) => {
|
|
29
|
+
const result = await (() => {
|
|
30
|
+
if (intentType === 'payment') {
|
|
31
|
+
return stripe.confirmPayment({
|
|
32
|
+
elements,
|
|
33
|
+
confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
|
|
34
|
+
redirect: 'if_required',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return stripe.confirmSetup({
|
|
38
|
+
elements,
|
|
39
|
+
confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
|
|
40
|
+
redirect: 'if_required',
|
|
41
|
+
});
|
|
42
|
+
})();
|
|
43
|
+
if (result.error) {
|
|
44
|
+
throw new error.StripeAPIError(result.error);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Confirm a Checkout Session payment using the checkout actions.
|
|
50
|
+
* @param checkout the Stripe Checkout instance
|
|
51
|
+
* @param returnUrl the URL Stripe should redirect back to when required
|
|
52
|
+
* @returns the confirmation result
|
|
53
|
+
* @throws StripeAPIError when loading actions or confirming fails
|
|
54
|
+
*/
|
|
55
|
+
const confirmCheckoutSession = async (checkout, returnUrl) => {
|
|
56
|
+
var _a;
|
|
57
|
+
// Load actions from the checkout session
|
|
58
|
+
const loadActionsResult = await checkout.loadActions();
|
|
59
|
+
if (loadActionsResult.type === 'error') {
|
|
60
|
+
// Create a StripeError-compatible object from the Checkout Session error
|
|
61
|
+
const stripeError = {
|
|
62
|
+
type: 'api_error',
|
|
63
|
+
code: loadActionsResult.error.code || 'checkout_session_error',
|
|
64
|
+
message: loadActionsResult.error.message,
|
|
65
|
+
};
|
|
66
|
+
throw new error.StripeAPIError(stripeError);
|
|
67
|
+
}
|
|
68
|
+
const { actions } = loadActionsResult;
|
|
69
|
+
// Confirm the payment using checkout session actions
|
|
70
|
+
const result = await actions.confirm({
|
|
71
|
+
returnUrl,
|
|
72
|
+
redirect: 'if_required',
|
|
73
|
+
});
|
|
74
|
+
if (result.type === 'error') {
|
|
75
|
+
// Create a StripeError-compatible object from the confirm error
|
|
76
|
+
const stripeError = {
|
|
77
|
+
type: 'card_error',
|
|
78
|
+
code: result.error.code || 'payment_failed',
|
|
79
|
+
message: result.error.message,
|
|
80
|
+
decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
|
|
81
|
+
};
|
|
82
|
+
throw new error.StripeAPIError(stripeError);
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Resolve the mode-specific properties for a submit event.
|
|
88
|
+
* Picks the Checkout or Elements payload depending on the active mode and
|
|
89
|
+
* reports a descriptive error string when the required instance is missing.
|
|
90
|
+
* @param params the resolved Stripe instances and client secrets for the current mode
|
|
91
|
+
* @returns the submit event props, or an error message when an instance is missing
|
|
92
|
+
*/
|
|
93
|
+
const buildSubmitEventProps = (params) => {
|
|
94
|
+
const { stripe, isCheckoutSession, checkout, checkoutSessionClientSecret, elements, intentClientSecret } = params;
|
|
95
|
+
const props = {
|
|
96
|
+
stripe,
|
|
97
|
+
};
|
|
98
|
+
if (isCheckoutSession) {
|
|
99
|
+
// Checkout Session mode
|
|
100
|
+
if (checkout == null) {
|
|
101
|
+
return { error: 'Checkout not properly initialized' };
|
|
102
|
+
}
|
|
103
|
+
props.checkout = checkout;
|
|
104
|
+
props.checkoutSessionClientSecret = checkoutSessionClientSecret;
|
|
105
|
+
return { props };
|
|
106
|
+
}
|
|
107
|
+
// Payment Intent / Setup Intent mode
|
|
108
|
+
if (elements == null) {
|
|
109
|
+
return { error: 'Elements not properly initialized' };
|
|
110
|
+
}
|
|
111
|
+
props.elements = elements;
|
|
112
|
+
props.intentClientSecret = intentClientSecret;
|
|
113
|
+
return { props };
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
exports.buildSubmitEventProps = buildSubmitEventProps;
|
|
117
|
+
exports.confirmCheckoutSession = confirmCheckoutSession;
|
|
118
|
+
exports.confirmPaymentOrSetup = confirmPaymentOrSetup;
|
|
119
|
+
exports.isSubmitButtonDisabled = isSubmitButtonDisabled;
|
|
@@ -87,7 +87,7 @@ const StripePaymentRequestButton = class {
|
|
|
87
87
|
console.warn('[stripe-pwa-elements] <stripe-payment-request-button> is deprecated. ' +
|
|
88
88
|
'stripe.paymentRequest() is being removed in Stripe.js 9.x (deprecated 2025-09-30 / removed 2026-03-25). ' +
|
|
89
89
|
'Please migrate to <stripe-express-checkout-element>, which supports Apple Pay, Google Pay, Link, PayPal, and more. ' +
|
|
90
|
-
'Migration guide: https://
|
|
90
|
+
'Migration guide: https://stripe-pwa-elements-docs.wp-kyoto.workers.dev/guides/migrate-payment-request-button-to-express-checkout/');
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* @param option
|
|
@@ -194,7 +194,7 @@ const StripePaymentRequestButton = class {
|
|
|
194
194
|
this.stripe = undefined;
|
|
195
195
|
}
|
|
196
196
|
render() {
|
|
197
|
-
return (index.h(index.Host, { key: '
|
|
197
|
+
return (index.h(index.Host, { key: '644a4b729c72e87b42df5e1b43262d3195e7ebc6' }, index.h("div", { key: 'aff26789868bbec0f1f6abc463fb14d7f3e73c1b', id: "payment-request" }, index.h("div", { key: '074a25f3c5b2575696ddaeacf2715935212964a5', id: "payment-request-button" })), index.h("slot", { key: '5173400bd63ab201f02934cea4edcab4bb7eed9c' })));
|
|
198
198
|
}
|
|
199
199
|
get el() { return index.getElement(this); }
|
|
200
200
|
};
|