mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
import { BaseEntity, Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
|
import { PaymentRefundEntity } from "./payment-refund.entity";
|
|
|
|
|
|
/** Invoice source that owns the intent ('booking', 'demurrage', …) — caller-supplied. */
|
|
type PaymentType = string
|
|
type PaymentMethod = "telebirr" | "cbe-birr" | "ebirr" | "waafi" | "card" | "dmoney" | "cac-bank" | "cbe-bill"
|
|
type Currency = "ETB" | "USD"
|
|
export type PaymentStatus = "action-required" | "processing" | "success" | "failed" | "canceled" | "refunded"
|
|
|
|
@Entity({ schema: 'freight', name: 'payments' })
|
|
export class PaymentEntity extends BaseEntity {
|
|
@PrimaryGeneratedColumn("uuid")
|
|
id!: string
|
|
|
|
@Column({ type: 'varchar', length: 255, name: "ref_id" })
|
|
refId!: string
|
|
|
|
@Column({ type: "varchar", length: 50 })
|
|
type!: PaymentType;
|
|
|
|
@Column({ type: "varchar", length: 40, nullable: true, name: "reference_type" })
|
|
referenceType?: string;
|
|
|
|
@Column({ type: "enum", enum: ["telebirr", "cbe-birr", "ebirr", "waafi", "card", "dmoney", "cac-bank", "cbe-bill"] })
|
|
method!: PaymentMethod
|
|
|
|
@Column({ type: "enum", enum: ["ETB", "USD"] })
|
|
currency!: Currency
|
|
|
|
@Column({ type: "numeric" })
|
|
amount!: number
|
|
|
|
@Column({ type: "varchar", length: 255, name: "reason", })
|
|
reason?: string;
|
|
|
|
@Column({ type: "jsonb", default: {}, name: "raw_initiation" })
|
|
rawInitiation?: Record<string, unknown>
|
|
|
|
@Column({ type: "jsonb", nullable: true, name: "client_action" })
|
|
clientAction?: Record<string, unknown>;
|
|
|
|
@Column({ type: "varchar", length: 255, unique: true, name: "merchant_order_id", })
|
|
merchantOrderId!: string
|
|
|
|
@Column({ type: "varchar", length: 255, unique: true, nullable: true, name: "transaction_id", })
|
|
transactionId?: string
|
|
|
|
@Column({ type: "enum", enum: ["action-required", "processing", "success", "failed", "canceled", "refunded"], default: "action-required" })
|
|
status!: PaymentStatus
|
|
|
|
@Column({ type: "date", nullable: true, name: "paid_at" })
|
|
paidAt?: Date
|
|
|
|
@Column({ type: "timestamp", nullable: true, name: "refunded_at" })
|
|
refundedAt?: Date
|
|
|
|
@Column({ type: "timestamp", nullable: true, name: "expires_at" })
|
|
expiresAt?: Date
|
|
|
|
@Column({ type: "varchar", length: 30, nullable: true, name: "failer_code" })
|
|
failerCode?: string
|
|
|
|
@Column({ type: "varchar", length: 255, nullable: true, name: "failer_message" })
|
|
failureMessage?: string
|
|
|
|
@CreateDateColumn({ name: "created_at" })
|
|
createdAt!: Date
|
|
|
|
@OneToMany(() => PaymentRefundEntity, (refund) => refund.payment)
|
|
refunds!: PaymentRefundEntity[];
|
|
|
|
} |