add charge dmenu wallet
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-04 15:16:51 +03:30
parent 0bab27871a
commit 30dba5ae37
2 changed files with 46 additions and 2 deletions
@@ -444,6 +444,46 @@ export class RestaurantService {
}
}
async finishChargeRequest(invoiceId: string) {
this.logger.log(`Finishing charge request for invoice ${invoiceId}`);
try {
const url = `${this.config.baseUrl}/super-admin/restaurants/charge-request/finish`;
const { data } = await firstValueFrom(
this.httpService
.post(url, { invoiceId }, {
headers: this.getHeaders(),
})
.pipe(
catchError((err: AxiosError) => {
this.logger.error(
`Failed to finish charge request for invoice ${invoiceId}: ${err.message}`,
err.stack,
);
return throwError(() => err);
}),
),
);
this.logger.log(`Successfully finished charge request for invoice ${invoiceId}`);
return data;
} catch (error: unknown) {
if (error instanceof AxiosError && error.response) {
this.logger.error(
`External API error finishing charge request for invoice ${invoiceId} (status ${error.response.status}):`,
error.response.data,
);
const errorResponse = {
...error.response.data,
message: error.response.data.error?.message || error.message,
};
throw new HttpException(errorResponse, error.response.status);
}
this.logger.error(
`Error finishing charge request for invoice ${invoiceId}: ${error instanceof Error ? error.message : "Unknown error"}`,
);
throw error;
}
}
async directLogin(userSubscriptionId: string, userId: string) {
try {
// 1. Get userSubscription by id
@@ -948,9 +948,13 @@ export class InvoicesService {
await this.addNotifyForWalletDeduction(invoice, user, userWallet, WalletMessage.SUPPORT_PLAN_WALLET_TRANSFER);
//
} else if (invoice.isExternal) {
if (invoice.items[0]?.name == 'purchase_design') {
if (invoice.items[0]?.name == 'dmenu_wallet_charge') {
this.restaurantService.finishChargeRequest(invoice.id);
} else if (invoice.items[0]?.name == 'purchase_plan') {
this.dpageService.finishPurchaseDesign(invoice.externalBusinessId!, invoice.id)
} else if (invoice.items[0]?.name == 'purchase_new_catalogue') {
}
else if (invoice.items[0]?.name == 'purchase_new_catalogue') {
// call dpage api
const businessId = invoice.externalBusinessId
if (!businessId) {