@adaptware/eagles-db 0.5.51 → 0.5.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptware/eagles-db",
3
- "version": "0.5.51",
3
+ "version": "0.5.53",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -7,6 +7,7 @@ enum IntegrationProvider {
7
7
  MICROSOFT
8
8
  ZOOM
9
9
  CALENDLY
10
+ RAZORPAY
10
11
 
11
12
  @@schema("public")
12
13
  }
@@ -85,6 +85,8 @@ model Organisation {
85
85
  licensing_ledger_entries LicensingLedgerEntry[]
86
86
  license_package_organisations LicensePackageOrganisation[]
87
87
  ai_cost_ledger_entries AiCostLedgerEntry[]
88
+ billing_transactions BillingTransaction[]
89
+ payment_webhook_events PaymentWebhookEvent[]
88
90
 
89
91
  @@index([name])
90
92
  @@schema("public")
@@ -0,0 +1,83 @@
1
+ // PAYMENT SERVICE boundary — portable payment microservice owns these enums/columns.
2
+
3
+ enum BillingTransactionStatus {
4
+ INITIATED
5
+ ORDER_CREATED
6
+ PAYMENT_PENDING
7
+ SUCCESS
8
+ FAILED
9
+ CANCELLED
10
+ REFUND_PENDING
11
+ REFUND_FAILED
12
+ REFUNDED
13
+
14
+ @@schema("public")
15
+ }
16
+
17
+ enum BillingTransactionType {
18
+ PURCHASE
19
+ TOP_UP
20
+ REFUND
21
+
22
+ @@schema("public")
23
+ }
24
+
25
+ enum BillingTransactionFailureCategory {
26
+ RAZORPAY_ORDER
27
+ RAZORPAY_PAYMENT
28
+ REFUND
29
+ INTERNAL
30
+
31
+ @@schema("public")
32
+ }
33
+
34
+ /// Payment reconciliation state when Treadspace status is FAILED but Razorpay captured payment.
35
+ enum BillingPaymentMismatchStatus {
36
+ DETECTED
37
+ UNFULFILLED
38
+
39
+ @@schema("public")
40
+ }
41
+
42
+ /// Financial transaction lifecycle for organisation billing purchases.
43
+ model BillingTransaction {
44
+ id String @id @default(uuid())
45
+ organisation_id String
46
+ /// Opaque plan/product identity supplied at checkout. Not a catalog FK.
47
+ purchase_reference String
48
+ /// Human-readable snapshot captured at checkout for invoices and receipts.
49
+ purchase_display_name String?
50
+ transaction_type BillingTransactionType
51
+ status BillingTransactionStatus @default(INITIATED)
52
+ failure_category BillingTransactionFailureCategory?
53
+ /// Human-readable or provider detail (e.g. Razorpay error_description).
54
+ failure_reason String?
55
+ amount Int
56
+ currency String @default("INR")
57
+ razorpay_order_id String?
58
+ razorpay_payment_id String? @unique
59
+ /// Razorpay payment method at capture (card, netbanking, upi, wallet, etc.).
60
+ payment_method String?
61
+ razorpay_subscription_id String?
62
+ razorpay_refund_id String?
63
+ refund_reason String?
64
+ refund_amount Int?
65
+ idempotency_key String @unique
66
+ invoice_number String? @unique
67
+ /// Email of the org Admin who initiated checkout (bill-to).
68
+ purchaser_email String?
69
+ /// Set when FAILED but Razorpay order/payment is captured (reconciliation path).
70
+ payment_mismatch_status BillingPaymentMismatchStatus?
71
+ /// Strict same-intent SUCCESS transaction that fulfilled the purchase (UNFULFILLED only).
72
+ payment_mismatch_fulfilled_by_id String?
73
+ created_at DateTime @default(now())
74
+ updated_at DateTime @updatedAt
75
+
76
+ organisation Organisation @relation(fields: [organisation_id], references: [id])
77
+
78
+ @@index([organisation_id, status])
79
+ @@index([purchase_reference])
80
+ @@index([razorpay_order_id])
81
+ @@map("billing_transactions")
82
+ @@schema("public")
83
+ }
@@ -0,0 +1,28 @@
1
+ enum PaymentWebhookEventStatus {
2
+ RECEIVED
3
+ PROCESSED
4
+ FAILED
5
+
6
+ @@schema("public")
7
+ }
8
+
9
+ /// Idempotent record of payment provider webhook deliveries.
10
+ model PaymentWebhookEvent {
11
+ id String @id @default(uuid())
12
+ organisation_id String?
13
+ provider String
14
+ provider_event_id String
15
+ event_type String
16
+ status PaymentWebhookEventStatus @default(RECEIVED)
17
+ billing_transaction_id String?
18
+ error_message String?
19
+ processed_at DateTime?
20
+ created_at DateTime @default(now())
21
+
22
+ organisation Organisation? @relation(fields: [organisation_id], references: [id])
23
+
24
+ @@unique([provider, provider_event_id])
25
+ @@index([status, created_at])
26
+ @@map("payment_webhook_events")
27
+ @@schema("public")
28
+ }