wallet
This commit is contained in:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user