parent
7c5b1b3aa8
commit
b4f39d5ccf
|
@ -1,12 +1,14 @@
|
|||
import { HttpStatus } from '@nestjs/common';
|
||||
import { UnprocessableEntityException } from '@nestjs/common';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { TransactionType } from 'src/modules/transaction/transaction/constants';
|
||||
import { CreateTransactionManager } from 'src/modules/transaction/transaction/domain/usecases/managers/create-transaction.manager';
|
||||
import { generateInvoiceCodeHelper } from 'src/modules/transaction/transaction/domain/usecases/managers/helpers/generate-invoice-code.helper';
|
||||
import { mappingRevertTransaction } from 'src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper';
|
||||
|
||||
export class CreateBookingManager extends CreateTransactionManager {
|
||||
async beforeProcess(): Promise<void> {
|
||||
await super.beforeProcess();
|
||||
mappingRevertTransaction(this.data, TransactionType.ONLINE);
|
||||
|
||||
const invoiceCode = await generateInvoiceCodeHelper(
|
||||
this.dataService,
|
||||
|
|
|
@ -20,9 +20,8 @@ export class BookingOrderController {
|
|||
) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: TransactionDto): Promise<TransactionEntity> {
|
||||
async create(@Body() data: TransactionDto) {
|
||||
const payload: Partial<TransactionEntity> = data;
|
||||
payload.type = TransactionType.ONLINE;
|
||||
|
||||
this.createBooking.setData(payload as any);
|
||||
this.createBooking.setService(
|
||||
|
@ -31,6 +30,19 @@ export class BookingOrderController {
|
|||
this.midtransService,
|
||||
);
|
||||
await this.createBooking.execute();
|
||||
return this.createBooking.getResult();
|
||||
const result = await this.createBooking.getResult();
|
||||
const {
|
||||
invoice_code,
|
||||
status,
|
||||
payment_midtrans_token,
|
||||
payment_midtrans_url,
|
||||
} = result;
|
||||
|
||||
return {
|
||||
invoice_code,
|
||||
status,
|
||||
payment_midtrans_token,
|
||||
payment_midtrans_url,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue