@funnelsgrove/payments 0.1.14 → 0.1.16

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.
@@ -166,12 +166,7 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
166
166
  }, 0);
167
167
  return () => window.clearTimeout(resizeTimer);
168
168
  }, [effectiveSelectedMethod]);
169
- const ensureCustomerEmail = async () => {
170
- const normalizedEmail = resolvedCustomerEmail.trim();
171
- if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
172
- setSharedError(customerEmailInvalidMessage);
173
- return null;
174
- }
169
+ const commitCustomerEmail = async (normalizedEmail) => {
175
170
  if (!customerEmailEditable || !onCustomerEmailCommit) {
176
171
  return normalizedEmail;
177
172
  }
@@ -183,6 +178,26 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
183
178
  onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(nextEmail);
184
179
  return nextEmail;
185
180
  };
181
+ const commitEmailDraftIfValid = (value) => {
182
+ const normalizedEmail = value.trim();
183
+ if (!customerEmailEditable || !onCustomerEmailCommit) {
184
+ return;
185
+ }
186
+ if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
187
+ return;
188
+ }
189
+ void commitCustomerEmail(normalizedEmail).catch((commitError) => {
190
+ setSharedError(getFriendlyCardErrorMessage(commitError));
191
+ });
192
+ };
193
+ const ensureCustomerEmail = async () => {
194
+ const normalizedEmail = resolvedCustomerEmail.trim();
195
+ if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
196
+ setSharedError(customerEmailInvalidMessage);
197
+ return null;
198
+ }
199
+ return commitCustomerEmail(normalizedEmail);
200
+ };
186
201
  const handleSubmit = async (event) => {
187
202
  event.preventDefault();
188
203
  if (submitting) {
@@ -205,7 +220,6 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
205
220
  const result = await checkoutState.checkout.confirm({
206
221
  email: syncedEmail || undefined,
207
222
  redirect: 'if_required',
208
- returnUrl,
209
223
  });
210
224
  if (result.type === 'error') {
211
225
  const message = result.error.message || 'Payment failed.';
@@ -251,7 +265,7 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
251
265
  effectiveSelectedMethod === 'card' ? 'is-visible' : '',
252
266
  ]
253
267
  .filter(Boolean)
254
- .join(' '), children: [_jsxs("div", { className: 'shared-checkout-v2-card-box', children: [_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { className: 'shared-checkout-v2-email-label', children: customerEmailLabel }), _jsx("span", { className: 'shared-checkout-v2-email-control', children: _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable, inputMode: 'email', readOnly: !customerEmailEditable, value: customerEmailEditable ? emailDraft : initialCustomerEmail, placeholder: customerEmailPlaceholder, onChange: (event) => {
268
+ .join(' '), children: [_jsxs("div", { className: 'shared-checkout-v2-card-box', children: [_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { className: 'shared-checkout-v2-email-label', children: customerEmailLabel }), _jsx("span", { className: 'shared-checkout-v2-email-control', children: _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable, inputMode: 'email', readOnly: !customerEmailEditable, value: customerEmailEditable ? emailDraft : initialCustomerEmail, placeholder: customerEmailPlaceholder, onBlur: (event) => commitEmailDraftIfValid(event.currentTarget.value), onChange: (event) => {
255
269
  if (!customerEmailEditable) {
256
270
  return;
257
271
  }
@@ -70,7 +70,6 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl,
70
70
  email: preparedCustomerEmail || (customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || undefined,
71
71
  expressCheckoutConfirmEvent: event,
72
72
  redirect: 'if_required',
73
- returnUrl,
74
73
  });
75
74
  if (result.type === 'error') {
76
75
  const message = result.error.message || 'Wallet checkout failed.';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",