mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 02:58:11 +00:00
payments
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from "typeorm";
|
||||
import { PaymentEntity } from "./payment.entity";
|
||||
|
||||
@Entity({ schema: "freight", name: "payment_refunds" })
|
||||
export class PaymentRefundEntity {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id!: string;
|
||||
|
||||
@Column({ type: "uuid", name: "payment_id" })
|
||||
paymentId!: string;
|
||||
|
||||
@Column({ type: "int", name: "amount_minor" })
|
||||
amountMinor!: number;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true })
|
||||
reason?: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, name: "provider_refund_id" })
|
||||
providerRefundId?: string;
|
||||
|
||||
@Column({ type: "varchar", length: 50 })
|
||||
status!: string;
|
||||
|
||||
@CreateDateColumn({ name: "created_at" })
|
||||
createdAt!: Date;
|
||||
|
||||
@ManyToOne(() => PaymentEntity, (payment) => payment.refunds, { onDelete: "RESTRICT" })
|
||||
@JoinColumn({ name: "payment_id" })
|
||||
payment!: PaymentEntity;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
} from "typeorm";
|
||||
|
||||
export type WebhookPaymentMethod = "telebirr" | "cbe-birr" | "ebirr";
|
||||
|
||||
@Entity({ schema: "freight", name: "payment_webhook_events" })
|
||||
@Unique(["provider", "externalEventId"])
|
||||
@Index(["merchantOrderId"])
|
||||
export class PaymentWebhookEventEntity {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id!: string;
|
||||
|
||||
@Column({ type: "enum", enum: ["telebirr", "cbe-birr", "ebirr"] })
|
||||
provider!: WebhookPaymentMethod;
|
||||
|
||||
@Column({ type: "varchar", length: 255, name: "external_event_id" })
|
||||
externalEventId!: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, name: "merchant_order_id" })
|
||||
merchantOrderId?: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, name: "provider_txn_id" })
|
||||
providerTxnId?: string;
|
||||
|
||||
@Column({ type: "boolean", name: "signature_valid" })
|
||||
signatureValid!: boolean;
|
||||
|
||||
@Column({ type: "varchar", length: 100 })
|
||||
status!: string;
|
||||
|
||||
@Column({ type: "jsonb" })
|
||||
payload!: Record<string, unknown>;
|
||||
|
||||
@CreateDateColumn({ name: "received_at" })
|
||||
receivedAt!: Date;
|
||||
|
||||
@Column({ type: "timestamp", nullable: true, name: "processed_at" })
|
||||
processedAt?: Date;
|
||||
|
||||
@Column({ type: "text", nullable: true, name: "processing_error" })
|
||||
processingError?: string;
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { BaseEntity, Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { PaymentRefundEntity } from "./payment-refund.entity";
|
||||
|
||||
|
||||
type PaymentType = "booking"
|
||||
type PaymentMethod = "telebirr" | "cbe-birr" | "ebirr"
|
||||
type PaymentMethod = "telebirr" | "cbe-birr" | "ebirr" | "waafi" | "card" | "dmoney"
|
||||
type Currency = "ETB" | "USD"
|
||||
export type PaymentStatus = "action-required" | "processing" | "success" | "failed" | "canceled" | "refunded"
|
||||
|
||||
@@ -17,7 +18,7 @@ export class PaymentEntity extends BaseEntity {
|
||||
@Column({ type: "enum", enum: ["booking"] })
|
||||
type!: PaymentType;
|
||||
|
||||
@Column({ type: "enum", enum: ["telebirr", "cbe-birr", "ebirr"] })
|
||||
@Column({ type: "enum", enum: ["telebirr", "cbe-birr", "ebirr", "waafi", "card", "dmoney"] })
|
||||
method!: PaymentMethod
|
||||
|
||||
@Column({ type: "enum", enum: ["ETB", "USD"] })
|
||||
@@ -62,4 +63,7 @@ export class PaymentEntity extends BaseEntity {
|
||||
@CreateDateColumn({ name: "created_at" })
|
||||
createdAt!: Date
|
||||
|
||||
@OneToMany(() => PaymentRefundEntity, (refund) => refund.payment)
|
||||
refunds!: PaymentRefundEntity[];
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user