const emailManager = new CheckoutEmailManager();
const result = emailManager.updateEmail(newValue); if (!result.success) setError(result.error); else setError(null); setEmail(newValue); onValidEmailChange?.(newValue);
// checkoutMiddleware.js (Express example) app.post('/api/checkout/update-email', (req, res) => session.stage === 'payment_ready') return res.status(403).json( error: code: 'EMAIL_UPDATE_NOT_ALLOWED', message: 'You are not allowed to update email at this stage.', stage: session.stage, suggestion: 'Use original email or create new checkout.'
;
// Reset for new checkout session reset() this.emailLocked = false; this.originalEmail = ''; this.lockReason = null;
const handleEmailChange = (newValue) => if (isLocked) setError( message: 'You are not allowed to update email during active checkout.', fix: 'Please refresh or restart checkout to change email.' ); return;
return action: 'BLOCK_UPDATE', userMessage: 'Email cannot be changed after entering checkout queue.', suggestedFix: () => userActions.useOriginalEmail(this.originalEmail) ;
export function CheckoutEmailField( initialEmail, isCheckoutLocked, onValidEmailChange ) const [email, setEmail] = useState(initialEmail); const [error, setError] = useState(null); const [isLocked, setIsLocked] = useState(false);