57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
Patch,
|
|
Param,
|
|
Delete,
|
|
HttpStatus,
|
|
Logger,
|
|
Req,
|
|
} from '@nestjs/common';
|
|
import { TransactionService } from './transaction.service';
|
|
import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
|
import { FastifyRequest } from 'fastify';
|
|
import { Public } from '../auth/public.decorator';
|
|
|
|
@Controller({
|
|
path: 'ppob_callback',
|
|
version: '1',
|
|
})
|
|
export class PpobCallbackController {
|
|
private readonly logger = new Logger(PpobCallbackController.name);
|
|
|
|
constructor(private readonly transactionService: TransactionService) {}
|
|
|
|
@Public()
|
|
@Get()
|
|
async get(@Req() request: FastifyRequest) {
|
|
const response = request.query;
|
|
|
|
if (response['statuscode'] == 2) {
|
|
//TODO: UPDATE GAGAL
|
|
const updateTransaction =
|
|
await this.transactionService.callbackOrderFailed(
|
|
response['clientid'],
|
|
response,
|
|
);
|
|
} else {
|
|
//TODO: UPDATE BERHASIL
|
|
const updateTransaction =
|
|
await this.transactionService.callbackOrderSuccess(
|
|
response['clientid'],
|
|
response,
|
|
);
|
|
}
|
|
this.logger.log({
|
|
requestQuery: request.query,
|
|
});
|
|
|
|
return {
|
|
statusCode: HttpStatus.OK,
|
|
message: 'success',
|
|
};
|
|
}
|
|
}
|