@cowris/paymentdb-client 1.0.7 → 2.0.0

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.
Files changed (32) hide show
  1. package/package.json +9 -6
  2. package/prisma/schema/currency.prisma +13 -9
  3. package/prisma/schema/funding.prisma +2 -1
  4. package/prisma/schema/hold.prisma +39 -0
  5. package/prisma/schema/managedWallet.prisma +2 -1
  6. package/prisma/schema/migrations/20251231010424_init/migration.sql +99 -0
  7. package/prisma/schema/paymentIntent.prisma +26 -0
  8. package/prisma/schema/schema.prisma +0 -1
  9. package/prisma/schema/webhookEvent.prisma +29 -0
  10. package/prisma/generated/paymentdb/client.d.ts +0 -1
  11. package/prisma/generated/paymentdb/client.js +0 -4
  12. package/prisma/generated/paymentdb/default.d.ts +0 -1
  13. package/prisma/generated/paymentdb/default.js +0 -4
  14. package/prisma/generated/paymentdb/edge.d.ts +0 -1
  15. package/prisma/generated/paymentdb/edge.js +0 -351
  16. package/prisma/generated/paymentdb/index-browser.js +0 -338
  17. package/prisma/generated/paymentdb/index.d.ts +0 -22365
  18. package/prisma/generated/paymentdb/index.js +0 -372
  19. package/prisma/generated/paymentdb/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
  20. package/prisma/generated/paymentdb/package.json +0 -146
  21. package/prisma/generated/paymentdb/runtime/edge-esm.js +0 -34
  22. package/prisma/generated/paymentdb/runtime/edge.js +0 -34
  23. package/prisma/generated/paymentdb/runtime/index-browser.d.ts +0 -370
  24. package/prisma/generated/paymentdb/runtime/index-browser.js +0 -16
  25. package/prisma/generated/paymentdb/runtime/library.d.ts +0 -3687
  26. package/prisma/generated/paymentdb/runtime/library.js +0 -146
  27. package/prisma/generated/paymentdb/runtime/react-native.js +0 -83
  28. package/prisma/generated/paymentdb/runtime/wasm-compiler-edge.js +0 -83
  29. package/prisma/generated/paymentdb/runtime/wasm-engine-edge.js +0 -35
  30. package/prisma/generated/paymentdb/schema.prisma +0 -199
  31. package/prisma/generated/paymentdb/wasm.d.ts +0 -1
  32. package/prisma/generated/paymentdb/wasm.js +0 -338
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowris/paymentdb-client",
3
- "version": "1.0.7",
3
+ "version": "2.0.0",
4
4
  "description": "This is a Prisma Client package for the Cowris PaymentDB. It provides a simple interface to interact with the Payment database, allowing you to perform CRUD operations on payment and transaction data and related tables.",
5
5
  "main": "index.js",
6
6
  "private": false,
@@ -23,16 +23,19 @@
23
23
  },
24
24
  "homepage": "https://github.com/Cowristech/services-paymentdb#readme",
25
25
  "dependencies": {
26
- "@prisma/client": "^6.6.0",
27
- "dotenv": "^16.4.7",
26
+ "@prisma/adapter-pg": "^7.2.0",
27
+ "dotenv": "^16.6.1",
28
+ "pg": "^8.16.3",
28
29
  "uuid": "^11.1.0"
29
30
  },
30
31
  "devDependencies": {
31
- "prisma": "^6.6.0"
32
+ "@types/node": "^25.0.3",
33
+ "@types/pg": "^8.16.0",
34
+ "prisma": "^7.2.0"
32
35
  },
33
36
  "peerDependencies": {
34
- "@prisma/client": "^6.6.0",
35
- "prisma": "^6.6.0"
37
+ "@prisma/client": "^7.2.0",
38
+ "prisma": ""
36
39
  },
37
40
  "files": [
38
41
  "index.js",
@@ -1,12 +1,16 @@
1
1
  model Currency {
2
- id String @id @default(uuid())
3
- name String @unique
4
- symbol String
5
- code String?
6
- country String
7
- created_at DateTime @default(now())
8
- updated_at DateTime @updatedAt
2
+ id String @id @default(uuid())
3
+ name String
4
+ code String @unique // NGN, USD, EUR
5
+ symbol String // ₦, $, €
6
+ country String
9
7
 
10
- payment_providers GlobalPaymentProvider[]
11
- accounts PaymentAccount[]
8
+ minor_unit String // kobo, cent, e.t.c
9
+ minor_unit_factor Int
10
+
11
+ created_at DateTime @default(now())
12
+ updated_at DateTime @updatedAt
13
+
14
+ payment_providers GlobalPaymentProvider[]
15
+ accounts PaymentAccount[]
12
16
  }
@@ -13,8 +13,9 @@ model Funding {
13
13
  id String @id @default(uuid())
14
14
  transaction_id String @unique
15
15
  account_id String
16
+ managed_wallet_id String?
16
17
  status String
17
- amount String
18
+ amount Int
18
19
  source_currency_id String?
19
20
  destination_currency_id String
20
21
  sender_account_information_id String? @unique
@@ -0,0 +1,39 @@
1
+ model Hold {
2
+ id String @id @default(uuid())
3
+
4
+ account_id String
5
+ managed_wallet_id String?
6
+ amount Int // kobo
7
+ currency_id String
8
+
9
+ reference String @unique
10
+ reason HoldReason
11
+
12
+ status HoldStatus
13
+ expires_at DateTime
14
+
15
+ // linkage
16
+ transfer_id String? // internal transfer
17
+ payment_intent_id String?
18
+ webhookEventId String?
19
+
20
+ created_at DateTime @default(now())
21
+ updated_at DateTime @updatedAt
22
+
23
+ @@index([account_id])
24
+ @@index([status])
25
+ @@index([expires_at])
26
+ }
27
+
28
+ enum HoldStatus {
29
+ ACTIVE
30
+ CONSUMED
31
+ RELEASED
32
+ EXPIRED
33
+ }
34
+
35
+ enum HoldReason {
36
+ TRANSFER
37
+ WITHDRAWAL
38
+ REVERSAL
39
+ }
@@ -7,7 +7,8 @@ model ManagedWallet {
7
7
  wallet_customer_phone String?
8
8
  account_number String?
9
9
  email String?
10
- balance String @default("0.00")
10
+ total_balance Int @default(0) // based on currency's smallest unit
11
+ available_balance Int @default(0) // based on currency's smallest unit
11
12
  currency_id String
12
13
  global_payment_provider_id String
13
14
  type String
@@ -0,0 +1,99 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `Currency` table. If the table is not empty, all the data it contains will be lost.
5
+ - You are about to drop the `Funding` table. If the table is not empty, all the data it contains will be lost.
6
+ - You are about to drop the `GlobalPaymentProvider` table. If the table is not empty, all the data it contains will be lost.
7
+ - You are about to drop the `ManagedWallet` table. If the table is not empty, all the data it contains will be lost.
8
+ - You are about to drop the `Otp` table. If the table is not empty, all the data it contains will be lost.
9
+ - You are about to drop the `PaymentAccount` table. If the table is not empty, all the data it contains will be lost.
10
+ - You are about to drop the `Reversal` table. If the table is not empty, all the data it contains will be lost.
11
+ - You are about to drop the `SenderAccountInformation` table. If the table is not empty, all the data it contains will be lost.
12
+ - You are about to drop the `Transaction` table. If the table is not empty, all the data it contains will be lost.
13
+ - You are about to drop the `Transfer` table. If the table is not empty, all the data it contains will be lost.
14
+ - You are about to drop the `TransferDestinationAccountDetails` table. If the table is not empty, all the data it contains will be lost.
15
+ - You are about to drop the `Withdrawal` table. If the table is not empty, all the data it contains will be lost.
16
+ - You are about to drop the `WithdrawalDestinationAccountDetails` table. If the table is not empty, all the data it contains will be lost.
17
+ - You are about to drop the `_CurrencyToGlobalPaymentProvider` table. If the table is not empty, all the data it contains will be lost.
18
+
19
+ */
20
+ -- DropForeignKey
21
+ ALTER TABLE "Funding" DROP CONSTRAINT "Funding_sender_account_information_id_fkey";
22
+
23
+ -- DropForeignKey
24
+ ALTER TABLE "ManagedWallet" DROP CONSTRAINT "ManagedWallet_account_id_fkey";
25
+
26
+ -- DropForeignKey
27
+ ALTER TABLE "PaymentAccount" DROP CONSTRAINT "PaymentAccount_currency_id_fkey";
28
+
29
+ -- DropForeignKey
30
+ ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_account_id_fkey";
31
+
32
+ -- DropForeignKey
33
+ ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_funding_id_fkey";
34
+
35
+ -- DropForeignKey
36
+ ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_provider_id_fkey";
37
+
38
+ -- DropForeignKey
39
+ ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_reversal_id_fkey";
40
+
41
+ -- DropForeignKey
42
+ ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_transfer_id_fkey";
43
+
44
+ -- DropForeignKey
45
+ ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_withdrawal_id_fkey";
46
+
47
+ -- DropForeignKey
48
+ ALTER TABLE "Transfer" DROP CONSTRAINT "Transfer_destination_account_details_id_fkey";
49
+
50
+ -- DropForeignKey
51
+ ALTER TABLE "Withdrawal" DROP CONSTRAINT "Withdrawal_destination_account_details_id_fkey";
52
+
53
+ -- DropForeignKey
54
+ ALTER TABLE "_CurrencyToGlobalPaymentProvider" DROP CONSTRAINT "_CurrencyToGlobalPaymentProvider_A_fkey";
55
+
56
+ -- DropForeignKey
57
+ ALTER TABLE "_CurrencyToGlobalPaymentProvider" DROP CONSTRAINT "_CurrencyToGlobalPaymentProvider_B_fkey";
58
+
59
+ -- DropTable
60
+ DROP TABLE "Currency";
61
+
62
+ -- DropTable
63
+ DROP TABLE "Funding";
64
+
65
+ -- DropTable
66
+ DROP TABLE "GlobalPaymentProvider";
67
+
68
+ -- DropTable
69
+ DROP TABLE "ManagedWallet";
70
+
71
+ -- DropTable
72
+ DROP TABLE "Otp";
73
+
74
+ -- DropTable
75
+ DROP TABLE "PaymentAccount";
76
+
77
+ -- DropTable
78
+ DROP TABLE "Reversal";
79
+
80
+ -- DropTable
81
+ DROP TABLE "SenderAccountInformation";
82
+
83
+ -- DropTable
84
+ DROP TABLE "Transaction";
85
+
86
+ -- DropTable
87
+ DROP TABLE "Transfer";
88
+
89
+ -- DropTable
90
+ DROP TABLE "TransferDestinationAccountDetails";
91
+
92
+ -- DropTable
93
+ DROP TABLE "Withdrawal";
94
+
95
+ -- DropTable
96
+ DROP TABLE "WithdrawalDestinationAccountDetails";
97
+
98
+ -- DropTable
99
+ DROP TABLE "_CurrencyToGlobalPaymentProvider";
@@ -0,0 +1,26 @@
1
+ model PaymentIntent {
2
+ id String @id @default(uuid())
3
+ reference String @unique
4
+ account_id String
5
+ managed_wallet_id String?
6
+ amount Int // amount in kobo
7
+ currency_id String // NGN, USD, etc
8
+ global_payment_provider_id String
9
+ provider_intent_id String?
10
+ status PaymentIntentStatus
11
+ metadata Json?
12
+ created_at DateTime @default(now())
13
+ updated_at DateTime @updatedAt
14
+
15
+ webhook_events WebhookEvent[]
16
+
17
+ @@index([account_id])
18
+ @@index([reference])
19
+ }
20
+
21
+ enum PaymentIntentStatus {
22
+ PENDING
23
+ SUCCEEDED
24
+ FAILED
25
+ CANCELLED
26
+ }
@@ -5,5 +5,4 @@ generator client {
5
5
 
6
6
  datasource db {
7
7
  provider = "postgresql"
8
- url = env("PAYMENT_DATABASE_URL")
9
8
  }
@@ -0,0 +1,29 @@
1
+ model WebhookEvent {
2
+ id String @id @default(uuid())
3
+ provider_id String
4
+ event_type EventType
5
+ reference String @unique
6
+ provider_event_id String? // Paystack transaction ID
7
+ payload Json
8
+ verified Boolean @default(false)
9
+ processed Boolean @default(false)
10
+ received_at DateTime @default(now())
11
+ processed_at DateTime?
12
+
13
+ payment_intent_id String?
14
+ paymentIntent PaymentIntent? @relation(fields: [payment_intent_id], references: [id])
15
+
16
+ @@index([reference])
17
+ @@index([processed])
18
+ }
19
+
20
+ enum EventType {
21
+ FUNDING_SUCCESS
22
+ FUNDING_FAILED
23
+ WITHDRAWAL_SUCCESS
24
+ WITHDRAWAL_FAILED
25
+ REVERSAL_SUCCESS
26
+ REVERSAL_FAILED
27
+ TRANSFER_SUCCESS
28
+ TRANSFER_FAILED
29
+ }
@@ -1 +0,0 @@
1
- export * from "./index"
@@ -1,4 +0,0 @@
1
-
2
- /* !!! This is code generated by Prisma. Do not edit directly. !!!
3
- /* eslint-disable */
4
- module.exports = { ...require('.') }
@@ -1 +0,0 @@
1
- export * from "./index"
@@ -1,4 +0,0 @@
1
-
2
- /* !!! This is code generated by Prisma. Do not edit directly. !!!
3
- /* eslint-disable */
4
- module.exports = { ...require('.') }
@@ -1 +0,0 @@
1
- export * from "./default"