Fix admin email to display correct payment amount
All checks were successful
Build and Push Docker Images / docker (push) Successful in 2m18s
All checks were successful
Build and Push Docker Images / docker (push) Successful in 2m18s
- Admin notification was showing 6 instead of 600 - Root cause: double cents-to-dollars conversion - webhooks.js already converts to dollars before calling sendAdminNotification - Updated sendAdminNotification to handle pre-converted dollar amounts - Simplified formatting logic for clarity server/utils/emailService.js:155-162
This commit is contained in:
parent
e11d04e1bc
commit
039ddc0fa8
@ -151,7 +151,14 @@ export async function sendContactEmail(contactData) {
|
|||||||
|
|
||||||
// Send admin notification for new order
|
// Send admin notification for new order
|
||||||
export async function sendAdminNotification(orderDetails, customerEmail) {
|
export async function sendAdminNotification(orderDetails, customerEmail) {
|
||||||
const subject = `New Order: ${orderDetails.tons} tons CO₂ - $${(orderDetails.totalAmount / 100).toFixed(2)}`;
|
// totalAmount is already in dollars (converted before calling this function)
|
||||||
|
const totalAmount = typeof orderDetails.totalAmount === 'string'
|
||||||
|
? orderDetails.totalAmount
|
||||||
|
: (orderDetails.totalAmount / 100).toFixed(2);
|
||||||
|
|
||||||
|
// Format amount with commas for subject line
|
||||||
|
const formattedAmount = parseFloat(totalAmount).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
|
const subject = `New Order: ${orderDetails.tons} tons CO₂ - $${formattedAmount}`;
|
||||||
const adminEmail = process.env.ADMIN_EMAIL || 'matt@puffinoffset.com';
|
const adminEmail = process.env.ADMIN_EMAIL || 'matt@puffinoffset.com';
|
||||||
|
|
||||||
// Check if admin notifications are enabled
|
// Check if admin notifications are enabled
|
||||||
@ -167,7 +174,7 @@ export async function sendAdminNotification(orderDetails, customerEmail) {
|
|||||||
{
|
{
|
||||||
tons: orderDetails.tons,
|
tons: orderDetails.tons,
|
||||||
portfolioId: orderDetails.portfolioId,
|
portfolioId: orderDetails.portfolioId,
|
||||||
totalAmount: (orderDetails.totalAmount / 100).toFixed(2),
|
totalAmount: totalAmount,
|
||||||
orderId: orderDetails.orderId,
|
orderId: orderDetails.orderId,
|
||||||
customerEmail,
|
customerEmail,
|
||||||
timestamp: new Date().toLocaleString('en-US', {
|
timestamp: new Date().toLocaleString('en-US', {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user