This commit is contained in:
2025-12-13 12:30:38 +03:30
parent 5d872db4ad
commit 9d9de98c03
13 changed files with 142 additions and 91 deletions
@@ -61,17 +61,17 @@ export class PaymentsService {
const { amount, method, restaurantDomain, gateway, merchantId, user } = await this.validateOrder(orderId);
// Handle Wallet payment immediately
if (method === PaymentMethodEnum.Wallet) {
// Check wallet balance
if (user.wallet < amount) {
throw new BadRequestException('Insufficient wallet balance');
}
// if (method === PaymentMethodEnum.Wallet) {
// // Check wallet balance
// if (user.wallet < amount) {
// throw new BadRequestException('Insufficient wallet balance');
// }
// Deduct from wallet and create payment record
const payment = await this.processWalletPayment(orderId, amount, user);
// // Deduct from wallet and create payment record
// const payment = await this.processWalletPayment(orderId, amount, user);
return { paymentUrl: null }; // No redirect needed for wallet
}
// return { paymentUrl: null }; // No redirect needed for wallet
// }
const { authority } = await this.createPayment(restaurantDomain, {
amount,
@@ -149,13 +149,13 @@ export class PaymentsService {
}
// Double-check balance
if (freshUser.wallet < amount) {
throw new BadRequestException('Insufficient wallet balance');
}
// if (freshUser.wallet < amount) {
// throw new BadRequestException('Insufficient wallet balance');
// }
// Deduct from wallet
freshUser.wallet -= amount;
em.persist(freshUser);
// freshUser.wallet -= amount;
// em.persist(freshUser);
// Create payment record
const payment = em.create(Payment, {