feat: integrate email event queue for payment confirmation with attachments
This commit is contained in:
parent
81337c852f
commit
b500c7133f
1 changed files with 106 additions and 69 deletions
|
|
@ -13,6 +13,7 @@ import {
|
||||||
genPdfCondizioniBase64,
|
genPdfCondizioniBase64,
|
||||||
genPdfRicevutaCortesiaBase64,
|
genPdfRicevutaCortesiaBase64,
|
||||||
} from "../services/puppeteer.service";
|
} from "../services/puppeteer.service";
|
||||||
|
import { addEventToQueue } from "./event_queue.controller";
|
||||||
|
|
||||||
export const stripeHealthCheck = async () => {
|
export const stripeHealthCheck = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -167,8 +168,11 @@ export const whIntentSucceededHandler = async ({
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
//SERVIZIO ATTIVATO
|
//TODO inserire gli allegati solo se si ha il pdf generato
|
||||||
await NewMail({
|
await addEventToQueue({
|
||||||
|
data: {
|
||||||
|
tipo: "email",
|
||||||
|
data: {
|
||||||
template: {
|
template: {
|
||||||
mailType: "servizioAttivato",
|
mailType: "servizioAttivato",
|
||||||
},
|
},
|
||||||
|
|
@ -187,14 +191,21 @@ export const whIntentSucceededHandler = async ({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
||||||
content: await genPdfRicevutaCortesiaBase64(ordine.ordine_id),
|
content: await genPdfRicevutaCortesiaBase64(
|
||||||
|
ordine.ordine_id,
|
||||||
|
),
|
||||||
encoding: "base64",
|
encoding: "base64",
|
||||||
contentType: "application/pdf",
|
contentType: "application/pdf",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
userId: utente.id,
|
userId: utente.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lock_expires: new Date(Date.now() + 60 * 1000), // Lock for 1 minute
|
||||||
});
|
});
|
||||||
|
//SERVIZIO ATTIVATO
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OrderTypeEnum.Saldo:
|
case OrderTypeEnum.Saldo:
|
||||||
|
|
@ -207,7 +218,10 @@ export const whIntentSucceededHandler = async ({
|
||||||
isOkSaldo: true,
|
isOkSaldo: true,
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
await NewMail({
|
await addEventToQueue({
|
||||||
|
data: {
|
||||||
|
tipo: "email",
|
||||||
|
data: {
|
||||||
template: {
|
template: {
|
||||||
mailType: "pagamentoConferma",
|
mailType: "pagamentoConferma",
|
||||||
},
|
},
|
||||||
|
|
@ -217,14 +231,20 @@ export const whIntentSucceededHandler = async ({
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
||||||
content: await genPdfRicevutaCortesiaBase64(ordine.ordine_id),
|
content: await genPdfRicevutaCortesiaBase64(
|
||||||
|
ordine.ordine_id,
|
||||||
|
),
|
||||||
encoding: "base64",
|
encoding: "base64",
|
||||||
contentType: "application/pdf",
|
contentType: "application/pdf",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
userId: utente.id,
|
userId: utente.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lock_expires: new Date(Date.now() + 60 * 1000), // Lock for 1 minute
|
||||||
});
|
});
|
||||||
|
//PAGAMENTO SALDO CONFERMATO
|
||||||
break;
|
break;
|
||||||
case OrderTypeEnum.Consulenza:
|
case OrderTypeEnum.Consulenza:
|
||||||
await trx
|
await trx
|
||||||
|
|
@ -234,7 +254,10 @@ export const whIntentSucceededHandler = async ({
|
||||||
isOkConsulenza: true,
|
isOkConsulenza: true,
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
await NewMail({
|
await addEventToQueue({
|
||||||
|
data: {
|
||||||
|
tipo: "email",
|
||||||
|
data: {
|
||||||
template: {
|
template: {
|
||||||
mailType: "pagamentoConferma",
|
mailType: "pagamentoConferma",
|
||||||
},
|
},
|
||||||
|
|
@ -244,18 +267,27 @@ export const whIntentSucceededHandler = async ({
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
||||||
content: await genPdfRicevutaCortesiaBase64(ordine.ordine_id),
|
content: await genPdfRicevutaCortesiaBase64(
|
||||||
|
ordine.ordine_id,
|
||||||
|
),
|
||||||
encoding: "base64",
|
encoding: "base64",
|
||||||
contentType: "application/pdf",
|
contentType: "application/pdf",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
userId: utente.id,
|
userId: utente.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lock_expires: new Date(Date.now() + 60 * 1000), // Lock for 1 minute
|
||||||
});
|
});
|
||||||
|
//CONSULENZA ATTIVATA
|
||||||
break;
|
break;
|
||||||
case OrderTypeEnum.Altro:
|
case OrderTypeEnum.Altro:
|
||||||
// TODO: Handle other types
|
// TODO: Handle other types
|
||||||
await NewMail({
|
await addEventToQueue({
|
||||||
|
data: {
|
||||||
|
tipo: "email",
|
||||||
|
data: {
|
||||||
template: {
|
template: {
|
||||||
mailType: "pagamentoConferma",
|
mailType: "pagamentoConferma",
|
||||||
},
|
},
|
||||||
|
|
@ -265,13 +297,18 @@ export const whIntentSucceededHandler = async ({
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
filename: `ricevuta_cortesia_${ordine.ordine_id}.pdf`,
|
||||||
content: await genPdfRicevutaCortesiaBase64(ordine.ordine_id),
|
content: await genPdfRicevutaCortesiaBase64(
|
||||||
|
ordine.ordine_id,
|
||||||
|
),
|
||||||
encoding: "base64",
|
encoding: "base64",
|
||||||
contentType: "application/pdf",
|
contentType: "application/pdf",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
userId: utente.id,
|
userId: utente.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lock_expires: new Date(Date.now() + 60 * 1000), // Lock for 1 minute
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue