fix bug in online payment success notif

This commit is contained in:
2026-01-01 23:28:37 +03:30
parent 30e9d199cd
commit 25d121f272
@@ -6,13 +6,13 @@ import { Permission } from 'src/common/enums/permission.enum';
import { NotifTitleEnum } from 'src/modules/notifications/interfaces/notification.interface';
import { NotificationService } from 'src/modules/notifications/services/notification.service';
import { ConfigService } from '@nestjs/config';
import { PaymentMethodEnum } from '../interface/payment';
import { OrdersService } from 'src/modules/orders/providers/orders.service';
@Injectable()
export class PaymentListeners {
private readonly logger = new Logger(PaymentListeners.name);
private orderCreatedSmsTemplateId: string;
private paymentSucceedSmsTemplateId: string;
constructor(
private readonly adminService: AdminRepository,
private readonly notificationService: NotificationService,
@@ -20,6 +20,7 @@ export class PaymentListeners {
private readonly orderService: OrdersService,
) {
this.orderCreatedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_CREATED') ?? '123';
this.paymentSucceedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ONLINE_PAYMENT_SUCCEED') ?? '123';
}
private getPaymentMethodFarsi(method: string): string {
@@ -90,7 +91,7 @@ export class PaymentListeners {
adminId: admin.id,
}));
// admin notifs
await this.notificationService.sendNotification({
restaurantId: event.restaurantId,
message: {
@@ -131,16 +132,17 @@ export class PaymentListeners {
userId: order.user.id,
},
];
// user notif
await this.notificationService.sendNotification({
restaurantId: event.restaurantId,
message: {
title: NotifTitleEnum.PAYMENT_SUCCESS,
content: `پرداخت سفارش شماره ${order.orderNumber} با روش ${this.getPaymentMethodFarsi(order.paymentMethod.method)} و مبلغ ${order.total} تومان با موفقیت انجام شد`,
sms: {
templateId: this.orderCreatedSmsTemplateId,
templateId: this.paymentSucceedSmsTemplateId,
parameters: {
orderNumber: String(order.orderNumber),
total: order.total.toString(),
orderNumber: event.orderNumber,
total: event.total.toString(),
},
},
pushNotif: {