fix email

This commit is contained in:
Emily
2024-09-13 19:02:15 +02:00
parent e7c2dbf237
commit c253846b86
2 changed files with 8 additions and 5 deletions

View File

@@ -94,7 +94,7 @@ async function onPaymentOnetimeSuccess(event: Event.PaymentIntentSucceededEvent)
if (!user) return { ok: false, error: 'USER NOT EXIST FOR PROJECT' + project.id } if (!user) return { ok: false, error: 'USER NOT EXIST FOR PROJECT' + project.id }
setTimeout(() => { setTimeout(() => {
EmailService.sendPurchaseEmail(user.email); EmailService.sendPurchaseEmail(user.email, project.name);
}, 1); }, 1);
return { ok: true }; return { ok: true };
@@ -139,7 +139,8 @@ async function onPaymentSuccess(event: Event.InvoicePaidEvent) {
if (!user) return { ok: false, error: 'USER NOT EXIST FOR PROJECT' + project.id } if (!user) return { ok: false, error: 'USER NOT EXIST FOR PROJECT' + project.id }
setTimeout(() => { setTimeout(() => {
EmailService.sendPurchaseEmail(user.email); if (PLAN.ID == 0) return;
EmailService.sendPurchaseEmail(user.email, project.name);
}, 1); }, 1);
return { ok: true }; return { ok: true };

View File

@@ -82,13 +82,15 @@ class EmailService {
} }
} }
async sendPurchaseEmail(target: string) { async sendPurchaseEmail(target: string, projectName: string) {
try { try {
const sendSmtpEmail = new SendSmtpEmail(); const sendSmtpEmail = new SendSmtpEmail();
sendSmtpEmail.subject = "Thank You for Upgrading Your Litlyx Plan!"; sendSmtpEmail.subject = "Thank You for Upgrading Your Litlyx Plan!";
sendSmtpEmail.sender = { "name": "Litlyx", "email": "help@litlyx.com" }; sendSmtpEmail.sender = { "name": "Litlyx", "email": "help@litlyx.com" };
sendSmtpEmail.to = [{ "email": target }]; sendSmtpEmail.to = [{ "email": target }];
sendSmtpEmail.htmlContent = PURCHASE_EMAIL; sendSmtpEmail.htmlContent = PURCHASE_EMAIL
.replace(/\[Project Name\]/, projectName)
.toString();;
await this.apiInstance.sendTransacEmail(sendSmtpEmail); await this.apiInstance.sendTransacEmail(sendSmtpEmail);
return true; return true;
} catch (ex) { } catch (ex) {