feat: automated order confirmation emails after checkout#379
Open
swetalin-10 wants to merge 4 commits into
Open
feat: automated order confirmation emails after checkout#379swetalin-10 wants to merge 4 commits into
swetalin-10 wants to merge 4 commits into
Conversation
- BACKEND/services/email.service.js: shared nodemailer transport; sendOrderConfirmationEmail builds a branded HTML receipt (item table, order ID, estimated delivery +5 days, total charged) and sends it; also exports sendPasswordResetEmail for the password-reset flow; graceful no-op with console.log when SMTP env vars are not set - BACKEND/controllers/checkout.controller.js: after Order.create in the Stripe webhook, fires sendOrderConfirmationEmail using session.customer_details.email (preferred, always present in Stripe Checkout) with fallback to looking up the User document by userId stored in session metadata; email is non-blocking — failures are caught and logged, never breaking order fulfillment - nodemailer added to BACKEND dependencies
|
@swetalin-10 is attempting to deploy a commit to the niharika-mente's projects Team on Vercel. A member of the Team first needs to authorize it. |
Resolved add/add conflict in BACKEND/services/email.service.js: - kept sendOrderConfirmationEmail (this PR) - kept sendPasswordResetEmail from upstream (niharika-mente#360) - unified on single createTransporter() factory
Resolved 2 conflicts in checkout.controller.js: - imports: kept sendOrderConfirmationEmail (this PR) + processReferralOnPurchase (upstream) - webhook body: kept both post-Order.create blocks — confirmation email and referral reward
Aamod-Dev
requested changes
Jun 21, 2026
Aamod-Dev
left a comment
Collaborator
There was a problem hiding this comment.
Needs changes: There are merge conflicts. Please resolve them.
Contributor
Author
|
Now their is no merge conflicts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #133
What changed
After a successful Stripe checkout, the customer now receives an HTML email receipt automatically.
BACKEND/services/email.service.js(new)Shared nodemailer transport initialized once at startup from
EMAIL_HOST / EMAIL_PORT / EMAIL_USER / EMAIL_PASSenv vars. Two exports:sendOrderConfirmationEmail(email, order)— branded receipt with item table, order ID, estimated delivery (+5 days), and total chargedsendPasswordResetEmail(email, resetUrl)— ready for the password-reset flowNo SMTP config? The service logs a warning and skips silently — no crashes, no required setup for local dev.
BACKEND/controllers/checkout.controller.js(modified)After
Order.createin the Stripe webhook handler:session.customer_details.email(always present in Stripe Checkout) — preferred sourcesession.metadata.userIdif no Stripe emailThe call is non-blocking:
.catch()logs the error server-side but never interrupts fulfillment or the200 { received: true }response Stripe expects.Email preview
Environment variables required
Add to
BACKEND/.env:For Gmail, generate an App Password (2FA must be on). Works with any SMTP provider (SendGrid, Mailgun, etc.) by swapping the host/port.
Testing
stripe listen --forward-to localhost:5000/api/checkout/webhook)4242 4242 4242 4242EMAIL_HOST— server logs[Email] Would send "Order Confirmation…" to …and continues normally