feat(sms): add WALLET_CHARGED sms trigger for online topup, manual admin credit, refund, and cashback
Deploy Canina / deploy (push) Successful in 43s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 0s

This commit is contained in:
parsa aghaei committed 2026-09-05 14:06:23 +03:30
1 parent 7093978e27
commit e15c25dae1
5 files changed
+168 -3

No files matched your search

+63
View File
@@ -608,6 +608,38 @@ export class PaymentService {
});
}
// Send SMS notification if wallet top-up
if (transaction.type === 'WALLET_TOPUP' && transaction.userId) {
try {
const user = await this.prisma.user.findUnique({
where: { id: transaction.userId },
});
if (user?.mobile) {
const customerFullName = (
user.firstName
? `${user.firstName} ${user.lastName || ''}`
: 'کاربر گرامی'
).trim();
const topupData = {
customerName: customerFullName,
customerPhone: user.mobile,
amount: Number(transaction.amount || 0).toLocaleString('fa-IR'),
balance: Number(user.walletBalance || 0).toLocaleString('fa-IR'),
reason: 'شارژ آنلاین از طریق درگاه بانکی',
date: new Date().toLocaleDateString('fa-IR'),
};
this.smsService
.triggerEvent('WALLET_CHARGED', topupData)
.catch((err) => {
this.logger.warn(`Could not trigger SMS event WALLET_CHARGED: ${err}`);
});
}
} catch (err) {
this.logger.warn(`Error dispatching WALLET_CHARGED SMS: ${err}`);
}
}
return {
success: true,
status: 'VERIFIED',
@@ -1075,6 +1107,37 @@ export class PaymentService {
}
});
if (transaction.type === 'WALLET_TOPUP' && transaction.userId) {
try {
const user = await this.prisma.user.findUnique({
where: { id: transaction.userId },
});
if (user?.mobile) {
const customerFullName = (
user.firstName
? `${user.firstName} ${user.lastName || ''}`
: 'کاربر گرامی'
).trim();
const topupData = {
customerName: customerFullName,
customerPhone: user.mobile,
amount: Number(transaction.amount || 0).toLocaleString('fa-IR'),
balance: Number(user.walletBalance || 0).toLocaleString('fa-IR'),
reason: adminNote || 'افزایش موجودی (کارت به کارت / فیش بانکی)',
date: new Date().toLocaleDateString('fa-IR'),
};
this.smsService
.triggerEvent('WALLET_CHARGED', topupData)
.catch((err) => {
this.logger.warn(`Could not trigger SMS event WALLET_CHARGED: ${err}`);
});
}
} catch (err) {
this.logger.warn(`Error dispatching WALLET_CHARGED SMS: ${err}`);
}
}
return {
success: true,
message: 'تراکنش با موفقیت به صورت دستی تایید و اعمال شد',