@funnelsgrove/payments 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PAYMENTS_PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PAYMENTS_PACKAGE_VERSION = "0.47.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/generate-package-version.mjs.
|
|
2
|
-
export const PAYMENTS_PACKAGE_VERSION = "0.
|
|
2
|
+
export const PAYMENTS_PACKAGE_VERSION = "0.47.0";
|
|
@@ -29,7 +29,11 @@ export type StripeWalletFirstCheckoutProps = {
|
|
|
29
29
|
/** The visitor closed the Apple Pay or Google Pay sheet without paying, e.g. to offer a discount. */
|
|
30
30
|
onCancel?: () => void;
|
|
31
31
|
onError?: (message: string | null) => void;
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Called after a paid checkout. Return `true` when the caller has already moved the visitor on
|
|
34
|
+
* (e.g. client-side navigation to the next step); a card payment then skips the `returnUrl` reload.
|
|
35
|
+
*/
|
|
36
|
+
onSuccess?: () => void | boolean | Promise<void | boolean>;
|
|
33
37
|
returnUrl: string;
|
|
34
38
|
stripePromise: Promise<Stripe | null> | null;
|
|
35
39
|
summaryLabel: string;
|
|
@@ -113,18 +113,21 @@ function StripeWalletFirstCheckoutForm({ amountCents, checkoutAnalytics, checkou
|
|
|
113
113
|
setError(message);
|
|
114
114
|
onError === null || onError === void 0 ? void 0 : onError(message);
|
|
115
115
|
};
|
|
116
|
+
/** Resolves true when the caller's onSuccess handled the navigation itself. */
|
|
116
117
|
const trackSuccess = async (embedded = false) => {
|
|
117
118
|
if (checkoutAnalytics)
|
|
118
119
|
await trackPaidStripeSubscriptionCheckoutCompleted(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId }));
|
|
119
|
-
if (
|
|
120
|
-
|
|
120
|
+
if (embedded)
|
|
121
|
+
return false;
|
|
122
|
+
return (await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess())) === true;
|
|
121
123
|
};
|
|
122
124
|
const finishPaidCheckout = async () => {
|
|
123
125
|
if (await completePaywallCheckout('stripe', checkoutSessionId || '', {
|
|
124
126
|
beforeNotify: async () => { setCompleted(true); await trackSuccess(true); },
|
|
125
127
|
}))
|
|
126
128
|
return;
|
|
127
|
-
await trackSuccess()
|
|
129
|
+
if (await trackSuccess())
|
|
130
|
+
return;
|
|
128
131
|
window.location.assign(returnUrl);
|
|
129
132
|
};
|
|
130
133
|
const submitCard = async (event) => {
|
|
@@ -178,7 +181,7 @@ function StripeWalletFirstCheckoutForm({ amountCents, checkoutAnalytics, checkou
|
|
|
178
181
|
// where the customer paid, until the success screen takes over.
|
|
179
182
|
const paymentStatus = completed ? copy.paymentConfirmed : providerConfirmed ? copy.verifyingPayment : null;
|
|
180
183
|
const locked = Boolean(paymentStatus) && !error;
|
|
181
|
-
return (_jsx(CheckoutLayout, { copy: copy, wallet: wallet, selected: selected, onSelect: onSelect, disabled: submitting || walletConfirming || locked, style: style, walletNote: selected === 'wallet' ? paymentStatus : null, walletSlot: _jsxs(_Fragment, { children: [_jsx("div", { className: 'wfc-wallet-button', "data-ready": walletAvailable === true, children: _jsx(StripeCheckoutExpressCheckoutButton, { amountCents: amountCents, availabilityPaymentMethods: [wallet], beforeConfirm: async () => { setWalletConfirming(true); return customerEmail || null; }, checkoutAnalytics: checkoutAnalytics, checkoutSessionId: checkoutSessionId, confirmEmail: false, customerEmail: customerEmail, customerName: customerName, onAvailabilityChange: setWalletAvailable, onCancel: () => { setWalletConfirming(false); onCancel === null || onCancel === void 0 ? void 0 : onCancel(); }, onEmbeddedComplete: () => setCompleted(true), onError: message => { setWalletConfirming(false); showError(message, undefined, true); }, onPaymentRejected: () => { setWalletConfirming(false); onSelect('card'); }, onSuccess: () => trackSuccess(), onVerificationPending: () => setProviderConfirmed(true), options: expressOptions, returnUrl: returnUrl, summaryLabel: summaryLabel }) }), walletAvailable === null ? _jsx("span", { className: 'wfc-progress wfc-progress--overlay', role: 'status', "aria-label": copy.processingLabel }) : null, walletAvailable === false ? _jsx("p", { className: 'wfc-wallet-unavailable', role: 'status', children: copy.walletUnavailableNote.replace('{wallet}', copy.walletLabels[wallet]) }) : null] }), cardBody: _jsxs("form", { className: 'wfc-card-form', onSubmit: event => void submitCard(event), children: [_jsx(PaymentElement, { options: paymentElementOptions, onChange: event => { setPaymentElementComplete(event.complete); if (!event.empty)
|
|
184
|
+
return (_jsx(CheckoutLayout, { copy: copy, wallet: wallet, selected: selected, onSelect: onSelect, disabled: submitting || walletConfirming || locked, style: style, walletNote: selected === 'wallet' ? paymentStatus : null, walletSlot: _jsxs(_Fragment, { children: [_jsx("div", { className: 'wfc-wallet-button', "data-ready": walletAvailable === true, children: _jsx(StripeCheckoutExpressCheckoutButton, { amountCents: amountCents, availabilityPaymentMethods: [wallet], beforeConfirm: async () => { setWalletConfirming(true); return customerEmail || null; }, checkoutAnalytics: checkoutAnalytics, checkoutSessionId: checkoutSessionId, confirmEmail: false, customerEmail: customerEmail, customerName: customerName, onAvailabilityChange: setWalletAvailable, onCancel: () => { setWalletConfirming(false); onCancel === null || onCancel === void 0 ? void 0 : onCancel(); }, onEmbeddedComplete: () => setCompleted(true), onError: message => { setWalletConfirming(false); showError(message, undefined, true); }, onPaymentRejected: () => { setWalletConfirming(false); onSelect('card'); }, onSuccess: async () => { await trackSuccess(); }, onVerificationPending: () => setProviderConfirmed(true), options: expressOptions, returnUrl: returnUrl, summaryLabel: summaryLabel }) }), walletAvailable === null ? _jsx("span", { className: 'wfc-progress wfc-progress--overlay', role: 'status', "aria-label": copy.processingLabel }) : null, walletAvailable === false ? _jsx("p", { className: 'wfc-wallet-unavailable', role: 'status', children: copy.walletUnavailableNote.replace('{wallet}', copy.walletLabels[wallet]) }) : null] }), cardBody: _jsxs("form", { className: 'wfc-card-form', onSubmit: event => void submitCard(event), children: [_jsx(PaymentElement, { options: paymentElementOptions, onChange: event => { setPaymentElementComplete(event.complete); if (!event.empty)
|
|
182
185
|
onCardEngaged(); }, onReady: () => setPaymentElementReady(true) }), _jsx("button", { type: 'submit', className: 'wfc-submit', disabled: locked || submitting || !paymentElementReady, "aria-live": 'polite', children: locked && paymentStatus ? paymentStatus : submitting ? copy.processingLabel : copy.cardSubmitLabel }), _jsx("p", { className: 'wfc-secure', children: copy.secureNote })] }), footer: error ? _jsx("p", { className: 'wfc-error', role: 'alert', children: error }) : null }));
|
|
183
186
|
}
|
|
184
187
|
/** Shared by the loading and live states so switching between them moves nothing. */
|