@funnelsgrove/payments 0.78.0 → 0.80.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.
- package/README.md +4 -2
- package/dist/generated/package-version.d.ts +1 -1
- package/dist/generated/package-version.js +1 -1
- package/dist/providers/stripe/components/ManualWalletExpressCheckoutElement.d.ts +10 -1
- package/dist/providers/stripe/components/ManualWalletExpressCheckoutElement.js +7 -2
- package/dist/providers/stripe/components/StripeCheckoutExpressCheckoutButton.d.ts +7 -0
- package/dist/providers/stripe/components/StripeCheckoutExpressCheckoutButton.js +26 -4
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -299,6 +299,8 @@ When a live funnel still uses one of these, migrate the funnel deliberately with
|
|
|
299
299
|
|
|
300
300
|
Funnels should call `resolvePublishedBillingRuntime` once at their runtime-provider boundary. Screens consume its resolved view and should not parse offer sets or pricing-experiment variants themselves. Pass the resolved `stripePublishableKey` into shared Stripe checkout hooks so Stripe.js can load while the Checkout Session request is still in flight; the key returned by that request remains the compatibility fallback.
|
|
301
301
|
|
|
302
|
+
The resolved `provider` is `'stripe' | 'solidgate' | 'paypal' | 'paddle'`; `'paddle'` was added in payments 0.75.0 with runtime 0.47.0. Type funnel props that receive it as `ResolvedPublishedBillingRuntime['provider']` instead of a literal union, so a new provider does not break the funnel build.
|
|
303
|
+
|
|
302
304
|
## Client implementation structure
|
|
303
305
|
|
|
304
306
|
Provider-neutral plan types, selection and recurrence live in
|
|
@@ -359,8 +361,8 @@ The build normalizes generated relative ESM imports to explicit `.js` files for
|
|
|
359
361
|
[Checkout email recovery](../../docs/product-specs/billing.md#checkout-email-recovery)
|
|
360
362
|
owns the behavior. Pass `onCustomerEmailCommit` to wallet surfaces and the card
|
|
361
363
|
checkout dialog. It must save the access email, adopt the returned Funnel User, and
|
|
362
|
-
update the `customerEmail` and `userId` inputs used by checkout.
|
|
363
|
-
|
|
364
|
+
update the `customerEmail` and `userId` inputs used by checkout. Missing or invalid
|
|
365
|
+
email hides the wallet surface; the funnel's primary CTA collects it. Provider rejection can open the surface's repair dialog.
|
|
364
366
|
`onResolveCustomerEmail` can resolve a known identity before asking for input;
|
|
365
367
|
its caller must also adopt the resolved identity. `emailDialogContent` customizes
|
|
366
368
|
prompt copy. Keep `beforeConfirm` for immediate preparation only, without awaiting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PAYMENTS_PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PAYMENTS_PACKAGE_VERSION = "0.80.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.80.0";
|
|
@@ -23,8 +23,17 @@ type Props = ComponentProps<typeof ExpressCheckoutElement> & {
|
|
|
23
23
|
};
|
|
24
24
|
/** The sheet shows the Checkout Session's amount and currency. Renders nothing until the session has loaded. */
|
|
25
25
|
export declare function ManualWalletExpressCheckoutElement({ checkout, stripePromise, walletRef, ...element }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
26
|
+
/**
|
|
27
|
+
* Confirming a Checkout Session with a PaymentMethod requires the email on the PaymentMethod.
|
|
28
|
+
* The Stripe wallet contract test confirms real test-mode sessions with these params.
|
|
29
|
+
*/
|
|
30
|
+
export declare const manualWalletPaymentMethodParams: (email: string) => {
|
|
31
|
+
billing_details: {
|
|
32
|
+
email: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
26
35
|
/** Creates the PaymentMethod from the confirmed wallet sheet, which closes the sheet. */
|
|
27
|
-
export declare function createManualWalletPaymentMethod({ elements, stripe }: ManualWallet): Promise<{
|
|
36
|
+
export declare function createManualWalletPaymentMethod({ elements, stripe }: ManualWallet, email: string): Promise<{
|
|
28
37
|
paymentMethodId: string;
|
|
29
38
|
} | {
|
|
30
39
|
error: StripeError | undefined;
|
|
@@ -40,13 +40,18 @@ export function ManualWalletExpressCheckoutElement(_a) {
|
|
|
40
40
|
return null;
|
|
41
41
|
return (_jsxs(Elements, { stripe: stripePromise, options: options, children: [_jsx(ManualWalletBridge, { walletRef: walletRef }), _jsx(ExpressCheckoutElement, Object.assign({}, element))] }));
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Confirming a Checkout Session with a PaymentMethod requires the email on the PaymentMethod.
|
|
45
|
+
* The Stripe wallet contract test confirms real test-mode sessions with these params.
|
|
46
|
+
*/
|
|
47
|
+
export const manualWalletPaymentMethodParams = (email) => ({ billing_details: { email } });
|
|
43
48
|
/** Creates the PaymentMethod from the confirmed wallet sheet, which closes the sheet. */
|
|
44
|
-
export async function createManualWalletPaymentMethod({ elements, stripe }) {
|
|
49
|
+
export async function createManualWalletPaymentMethod({ elements, stripe }, email) {
|
|
45
50
|
if (!elements || !stripe)
|
|
46
51
|
return { error: undefined };
|
|
47
52
|
const submitted = await elements.submit();
|
|
48
53
|
if (submitted.error)
|
|
49
54
|
return { error: submitted.error };
|
|
50
|
-
const created = await stripe.createPaymentMethod({ elements });
|
|
55
|
+
const created = await stripe.createPaymentMethod({ elements, params: manualWalletPaymentMethodParams(email) });
|
|
51
56
|
return created.paymentMethod ? { paymentMethodId: created.paymentMethod.id } : { error: created.error };
|
|
52
57
|
}
|
|
@@ -4,6 +4,13 @@ import { type StripeCheckoutErrorDetails } from '../services/stripeCheckoutError
|
|
|
4
4
|
export type StripeWalletCheckoutSuccess = {
|
|
5
5
|
checkoutSessionId: string | null;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* The `email` for checkout.confirm(). A Checkout Session created with `customer_email`, or with a
|
|
9
|
+
* `customer` that has an email, already carries it, and stripe.js throws when confirm() sets it again.
|
|
10
|
+
*/
|
|
11
|
+
export declare const walletConfirmEmailParams: (sessionEmail: string | null | undefined, customerEmail: string | null | undefined) => {
|
|
12
|
+
email?: string;
|
|
13
|
+
};
|
|
7
14
|
export type StripeCheckoutExpressCheckoutButtonProps = {
|
|
8
15
|
amountCents: number;
|
|
9
16
|
beforeConfirm?: () => Promise<string | null>;
|
|
@@ -10,6 +10,14 @@ import { getUnsupportedCheckoutCountryMessage, normalizeSupportedCheckoutCountri
|
|
|
10
10
|
import { trackCheckoutCanceled, trackCheckoutFailureShown, } from '../../../services/checkoutObservability.service.js';
|
|
11
11
|
import { createManualWalletPaymentMethod, ManualWalletExpressCheckoutElement } from './ManualWalletExpressCheckoutElement.js';
|
|
12
12
|
import { isStripeCheckoutAlreadyPaidError, normalizeStripeCheckoutError } from '../services/stripeCheckoutError.js';
|
|
13
|
+
/**
|
|
14
|
+
* The `email` for checkout.confirm(). A Checkout Session created with `customer_email`, or with a
|
|
15
|
+
* `customer` that has an email, already carries it, and stripe.js throws when confirm() sets it again.
|
|
16
|
+
*/
|
|
17
|
+
export const walletConfirmEmailParams = (sessionEmail, customerEmail) => {
|
|
18
|
+
const email = customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim();
|
|
19
|
+
return (sessionEmail === null || sessionEmail === void 0 ? void 0 : sessionEmail.trim()) || !email ? {} : { email };
|
|
20
|
+
};
|
|
13
21
|
const ExpressCheckoutElementWithCancel = ExpressCheckoutElement;
|
|
14
22
|
const WALLET_DECLINE_SHEET_MESSAGE = 'Your bank declined this card. Choose another card or approve the payment in your bank app.';
|
|
15
23
|
const buildDefaultOptions = () => ({
|
|
@@ -271,7 +279,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
271
279
|
await (onPaymentInfoSubmitted === null || onPaymentInfoSubmitted === void 0 ? void 0 : onPaymentInfoSubmitted());
|
|
272
280
|
let paymentMethodId = null;
|
|
273
281
|
if (stripePromise) {
|
|
274
|
-
const created = await createManualWalletPaymentMethod(manualWalletRef.current);
|
|
282
|
+
const created = await createManualWalletPaymentMethod(manualWalletRef.current, preparedCustomerEmail.trim());
|
|
275
283
|
if ('error' in created) {
|
|
276
284
|
const message = ((_d = created.error) === null || _d === void 0 ? void 0 : _d.message) || 'Wallet checkout is not ready yet.';
|
|
277
285
|
reportFailure(message, 'wallet_payment_method', event.expressPaymentType, created.error);
|
|
@@ -281,9 +289,23 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
281
289
|
// Creating the PaymentMethod closed the wallet sheet; the charge result shows on the page.
|
|
282
290
|
paymentMethodId = created.paymentMethodId;
|
|
283
291
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
292
|
+
let result;
|
|
293
|
+
try {
|
|
294
|
+
result = await checkoutState.checkout.confirm(Object.assign(Object.assign(Object.assign({}, (confirmEmail
|
|
295
|
+
? walletConfirmEmailParams(checkoutState.checkout.email, preparedCustomerEmail || customerEmail)
|
|
296
|
+
: {})), (paymentMethodId ? { paymentMethod: paymentMethodId } : { expressCheckoutConfirmEvent: event })), { redirect: 'if_required' }));
|
|
297
|
+
}
|
|
298
|
+
catch (confirmError) {
|
|
299
|
+
// stripe.js throws on invalid confirm() input instead of returning an error result;
|
|
300
|
+
// without this the wallet sheet closes and the customer sees nothing.
|
|
301
|
+
const message = confirmError instanceof Error && confirmError.message
|
|
302
|
+
? confirmError.message
|
|
303
|
+
: 'Wallet checkout failed.';
|
|
304
|
+
reportFailure(message, 'wallet_confirmation', event.expressPaymentType, confirmError);
|
|
305
|
+
if (!paymentMethodId)
|
|
306
|
+
event.paymentFailed({ reason: 'fail', message });
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
287
309
|
if (result.type === 'error' && !isStripeCheckoutAlreadyPaidError(result.error)) {
|
|
288
310
|
const message = result.error.message || 'Wallet checkout failed.';
|
|
289
311
|
const details = reportFailure(message, 'wallet_confirmation', event.expressPaymentType, result.error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/payments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"lint": "eslint .",
|
|
30
30
|
"prepublishOnly": "npm run build",
|
|
31
31
|
"smoke:wallet": "npm run build && node scripts/wallet-checkout-smoke.mjs",
|
|
32
|
-
"test:run": "vitest run --passWithNoTests"
|
|
32
|
+
"test:run": "vitest run --passWithNoTests",
|
|
33
|
+
"test:stripe-contract": "vitest run --config vitest.contract.config.ts"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@solidgate/react-sdk": "1.34.0",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"@types/react": "^19",
|
|
45
46
|
"@types/react-dom": "^19",
|
|
46
47
|
"jsdom": "20.0.3",
|
|
48
|
+
"playwright": "1.58.2",
|
|
47
49
|
"typescript": "^5",
|
|
48
50
|
"vitest": "^3.2.4",
|
|
49
51
|
"@funnelsgrove/runtime": "0.49.0",
|