mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
122 lines
3.2 KiB
TypeScript
122 lines
3.2 KiB
TypeScript
import { ProviderPaymentStatus } from "@edr/types";
|
|
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
import { IsEnum, IsIn, IsOptional, IsString } from "class-validator";
|
|
|
|
export type PaymentPlatformDto = "web" | "mobile";
|
|
|
|
export enum PaymentMethodTypeEnum {
|
|
TELEBIRR = "TELEBIRR",
|
|
CBE_BIRR = "CBE_BIRR",
|
|
EBIRR = "EBIRR",
|
|
WAAFI = "WAAFI",
|
|
CARD = "CARD",
|
|
DMONEY = "DMONEY",
|
|
CAC_BANK = "CAC_BANK",
|
|
}
|
|
|
|
export class InitiatePaymentDto {
|
|
@ApiProperty({ example: "invoice-uuid" })
|
|
@IsString()
|
|
invoiceId!: string;
|
|
|
|
@ApiProperty({
|
|
enum: PaymentMethodTypeEnum,
|
|
description: "Payment method: TELEBIRR/CBE_BIRR/EBIRR (Ethiopia), WAAFI (Djibouti), CARD (International), DMONEY",
|
|
example: "TELEBIRR",
|
|
})
|
|
@IsEnum(PaymentMethodTypeEnum)
|
|
method!: PaymentMethodTypeEnum;
|
|
|
|
@ApiPropertyOptional({ enum: ["web", "mobile"], default: "web" })
|
|
@IsOptional()
|
|
@IsIn(["web", "mobile"])
|
|
platform?: PaymentPlatformDto;
|
|
|
|
@ApiPropertyOptional({ description: "Payer account / mobile number (e.g. for Waafi MWALLET)" })
|
|
@IsOptional()
|
|
@IsString()
|
|
payerAccount?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Browser return URL after successful payment" })
|
|
@IsOptional()
|
|
@IsString()
|
|
returnUrl?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Browser return URL after failed/cancelled payment" })
|
|
@IsOptional()
|
|
@IsString()
|
|
failureUrl?: string;
|
|
}
|
|
|
|
export class RefundDto {
|
|
@ApiProperty({ example: "booking-uuid" })
|
|
@IsString()
|
|
bookingId!: string;
|
|
|
|
@ApiPropertyOptional({ description: "Optional reason for refund" })
|
|
@IsOptional()
|
|
@IsString()
|
|
reason?: string;
|
|
}
|
|
|
|
export class ClientActionDto {
|
|
@ApiProperty({
|
|
enum: ["REDIRECT", "LAUNCH_APP", "COLLECT_OTP", "SHOW_BILL_REFERENCE"],
|
|
})
|
|
type!: "REDIRECT" | "LAUNCH_APP" | "COLLECT_OTP" | "SHOW_BILL_REFERENCE";
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=REDIRECT (web flow)" })
|
|
url?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=LAUNCH_APP (mobile flow)" })
|
|
appId?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=LAUNCH_APP (mobile flow)" })
|
|
receiveCode?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=LAUNCH_APP (mobile flow)" })
|
|
shortCode?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=COLLECT_OTP (e.g. CAC Bank)" })
|
|
providerOrderId?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=COLLECT_OTP" })
|
|
message?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Set when type=SHOW_BILL_REFERENCE (CBE bill payment)",
|
|
})
|
|
billReference?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=SHOW_BILL_REFERENCE" })
|
|
instructions?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Set when type=SHOW_BILL_REFERENCE" })
|
|
expiresAt?: string;
|
|
}
|
|
|
|
export class InitiateResponseDto {
|
|
@ApiProperty()
|
|
intentId!: string;
|
|
|
|
@ApiProperty({ enum: ProviderPaymentStatus })
|
|
status!: ProviderPaymentStatus;
|
|
|
|
@ApiPropertyOptional({ type: ClientActionDto })
|
|
clientAction?: ClientActionDto;
|
|
|
|
@ApiPropertyOptional()
|
|
merchantOrderId?: string;
|
|
}
|
|
|
|
export class IntentStatusDto extends InitiateResponseDto {
|
|
@ApiPropertyOptional()
|
|
paidAt?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
failureCode?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
failureMessage?: string;
|
|
}
|