mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
feat: finish working on account transaction webhook
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { TransactionService } from '~/card/services/transaction.service';
|
||||
import { CardTransactionWebhookRequest } from '../dtos/requests';
|
||||
import { AccountTransactionWebhookRequest, CardTransactionWebhookRequest } from '../dtos/requests';
|
||||
|
||||
@Controller('neoleap-webhooks')
|
||||
@ApiTags('Neoleap Webhooks')
|
||||
@ -12,4 +12,9 @@ export class NeoLeapWebhooksController {
|
||||
async handleCardTransactionWebhook(@Body() body: CardTransactionWebhookRequest) {
|
||||
return this.transactionService.createCardTransaction(body);
|
||||
}
|
||||
|
||||
@Post('account-transaction')
|
||||
async handleAccountTransactionWebhook(@Body() body: AccountTransactionWebhookRequest) {
|
||||
return this.transactionService.createAccountTransaction(body);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { IsNumber, IsPositive, IsString } from 'class-validator';
|
||||
|
||||
export class AccountTransactionWebhookRequest {
|
||||
@Expose({ name: 'InstId' })
|
||||
@IsString()
|
||||
@ApiProperty({ name: 'InstId', example: '9000' })
|
||||
instId!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ example: '143761' })
|
||||
transactionId!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ example: '0037' })
|
||||
transactionType!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ example: '26' })
|
||||
transactionCode!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ example: '6823000000000018' })
|
||||
accountNumber!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ example: '6823000000000018' })
|
||||
accountId!: string;
|
||||
|
||||
@Expose()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@ApiProperty({ example: '7080.15' })
|
||||
otb!: number;
|
||||
|
||||
@Expose()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@IsPositive()
|
||||
@ApiProperty({ example: '3050.95' })
|
||||
amount!: number;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ example: 'C' })
|
||||
sign!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ example: '682' })
|
||||
currency!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ name: 'Date', example: '20241112' })
|
||||
date!: string;
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ name: 'Time', example: '125340' })
|
||||
time!: string;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { IsNumber, IsString, ValidateNested } from 'class-validator';
|
||||
import { IsNumber, IsString, Min, ValidateNested } from 'class-validator';
|
||||
|
||||
export class CardAcceptorLocationDto {
|
||||
@Expose()
|
||||
@ -99,6 +99,7 @@ export class CardTransactionWebhookRequest {
|
||||
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(0, { message: 'amount must be zero or a positive number' })
|
||||
@ApiProperty({ example: '100.5' })
|
||||
transactionAmount!: number;
|
||||
|
||||
@ -108,6 +109,7 @@ export class CardTransactionWebhookRequest {
|
||||
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(0, { message: 'amount must be zero or a positive number' })
|
||||
@ApiProperty({ example: '100.5' })
|
||||
billingAmount!: number;
|
||||
|
||||
@ -117,6 +119,7 @@ export class CardTransactionWebhookRequest {
|
||||
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(0, { message: 'amount must be zero or a positive number' })
|
||||
@ApiProperty({ example: '100.5' })
|
||||
settlementAmount!: number;
|
||||
|
||||
@ -127,12 +130,14 @@ export class CardTransactionWebhookRequest {
|
||||
@Expose()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(0, { message: 'amount must be zero or a positive number' })
|
||||
@ApiProperty({ example: '20' })
|
||||
fees!: number;
|
||||
|
||||
@Expose()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(0, { message: 'amount must be zero or a positive number' })
|
||||
@ApiProperty({ example: '4.5' })
|
||||
vatOnFees!: number;
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
export * from './account-transaction-webhook.request.dto';
|
||||
export * from './card-transaction-webhook.request.dto';
|
||||
|
Reference in New Issue
Block a user