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