@cowris/paymentdb-client 1.0.7 → 2.0.1

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 (37) hide show
  1. package/index.js +10 -0
  2. package/package.json +9 -6
  3. package/prisma/schema/currency.prisma +13 -9
  4. package/prisma/schema/funding.prisma +2 -1
  5. package/prisma/schema/hold.prisma +39 -0
  6. package/prisma/schema/managedWallet.prisma +2 -1
  7. package/prisma/schema/migrations/20251231010424_init/migration.sql +99 -0
  8. package/prisma/schema/migrations/20260105150708_init/migration.sql +395 -0
  9. package/prisma/schema/paymentIntent.prisma +26 -0
  10. package/prisma/schema/reversal.prisma +1 -1
  11. package/prisma/schema/schema.prisma +0 -1
  12. package/prisma/schema/transfer.prisma +2 -2
  13. package/prisma/schema/webhookEvent.prisma +29 -0
  14. package/prisma/schema/withdrawal.prisma +5 -5
  15. package/prisma/generated/paymentdb/client.d.ts +0 -1
  16. package/prisma/generated/paymentdb/client.js +0 -4
  17. package/prisma/generated/paymentdb/default.d.ts +0 -1
  18. package/prisma/generated/paymentdb/default.js +0 -4
  19. package/prisma/generated/paymentdb/edge.d.ts +0 -1
  20. package/prisma/generated/paymentdb/edge.js +0 -351
  21. package/prisma/generated/paymentdb/index-browser.js +0 -338
  22. package/prisma/generated/paymentdb/index.d.ts +0 -22365
  23. package/prisma/generated/paymentdb/index.js +0 -372
  24. package/prisma/generated/paymentdb/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
  25. package/prisma/generated/paymentdb/package.json +0 -146
  26. package/prisma/generated/paymentdb/runtime/edge-esm.js +0 -34
  27. package/prisma/generated/paymentdb/runtime/edge.js +0 -34
  28. package/prisma/generated/paymentdb/runtime/index-browser.d.ts +0 -370
  29. package/prisma/generated/paymentdb/runtime/index-browser.js +0 -16
  30. package/prisma/generated/paymentdb/runtime/library.d.ts +0 -3687
  31. package/prisma/generated/paymentdb/runtime/library.js +0 -146
  32. package/prisma/generated/paymentdb/runtime/react-native.js +0 -83
  33. package/prisma/generated/paymentdb/runtime/wasm-compiler-edge.js +0 -83
  34. package/prisma/generated/paymentdb/runtime/wasm-engine-edge.js +0 -35
  35. package/prisma/generated/paymentdb/schema.prisma +0 -199
  36. package/prisma/generated/paymentdb/wasm.d.ts +0 -1
  37. package/prisma/generated/paymentdb/wasm.js +0 -338
package/index.js CHANGED
@@ -1,6 +1,16 @@
1
1
  const { PrismaClient } = require('./prisma/generated/paymentdb');
2
2
 
3
+ import { PrismaPg } from "@prisma/adapter-pg";
4
+ import pg from "pg";
5
+
6
+ const pool = new pg.Pool({
7
+ connectionString: process.env.DATABASE_URL,
8
+ });
9
+
10
+ const adapter = new PrismaPg(pool);
11
+
3
12
  const prisma = new PrismaClient({
13
+ adapter,
4
14
  log: ['error', 'query', 'info', 'warn'],
5
15
  });
6
16
 
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.1",
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 BigInt
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 BigInt // 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 BigInt @default(0) // based on currency's smallest unit
11
+ available_balance BigInt @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,395 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "HoldStatus" AS ENUM ('ACTIVE', 'CONSUMED', 'RELEASED', 'EXPIRED');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "HoldReason" AS ENUM ('TRANSFER', 'WITHDRAWAL', 'REVERSAL');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "PaymentIntentStatus" AS ENUM ('PENDING', 'SUCCEEDED', 'FAILED', 'CANCELLED');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "EventType" AS ENUM ('FUNDING_SUCCESS', 'FUNDING_FAILED', 'WITHDRAWAL_SUCCESS', 'WITHDRAWAL_FAILED', 'REVERSAL_SUCCESS', 'REVERSAL_FAILED', 'TRANSFER_SUCCESS', 'TRANSFER_FAILED');
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "PaymentAccount" (
15
+ "id" TEXT NOT NULL,
16
+ "account_number" TEXT,
17
+ "email" TEXT,
18
+ "currency_id" TEXT NOT NULL,
19
+ "wallet_id" TEXT NOT NULL,
20
+ "wallet_queue_url" TEXT,
21
+ "wallet_webhook_url" TEXT,
22
+
23
+ CONSTRAINT "PaymentAccount_pkey" PRIMARY KEY ("id")
24
+ );
25
+
26
+ -- CreateTable
27
+ CREATE TABLE "Currency" (
28
+ "id" TEXT NOT NULL,
29
+ "name" TEXT NOT NULL,
30
+ "code" TEXT NOT NULL,
31
+ "symbol" TEXT NOT NULL,
32
+ "country" TEXT NOT NULL,
33
+ "minor_unit" TEXT NOT NULL,
34
+ "minor_unit_factor" INTEGER NOT NULL,
35
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
36
+ "updated_at" TIMESTAMP(3) NOT NULL,
37
+
38
+ CONSTRAINT "Currency_pkey" PRIMARY KEY ("id")
39
+ );
40
+
41
+ -- CreateTable
42
+ CREATE TABLE "SenderAccountInformation" (
43
+ "id" TEXT NOT NULL,
44
+ "account_firstname" TEXT DEFAULT '',
45
+ "account_lastname" TEXT DEFAULT '',
46
+ "account_number" TEXT,
47
+ "account_email" TEXT,
48
+ "account_bank_name" TEXT,
49
+
50
+ CONSTRAINT "SenderAccountInformation_pkey" PRIMARY KEY ("id")
51
+ );
52
+
53
+ -- CreateTable
54
+ CREATE TABLE "Funding" (
55
+ "id" TEXT NOT NULL,
56
+ "transaction_id" TEXT NOT NULL,
57
+ "account_id" TEXT NOT NULL,
58
+ "managed_wallet_id" TEXT,
59
+ "status" TEXT NOT NULL,
60
+ "amount" BIGINT NOT NULL,
61
+ "source_currency_id" TEXT,
62
+ "destination_currency_id" TEXT NOT NULL,
63
+ "sender_account_information_id" TEXT,
64
+
65
+ CONSTRAINT "Funding_pkey" PRIMARY KEY ("id")
66
+ );
67
+
68
+ -- CreateTable
69
+ CREATE TABLE "GlobalPaymentProvider" (
70
+ "id" TEXT NOT NULL,
71
+ "name" TEXT NOT NULL,
72
+ "idx" SERIAL NOT NULL,
73
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
74
+ "updated_at" TIMESTAMP(3) NOT NULL,
75
+
76
+ CONSTRAINT "GlobalPaymentProvider_pkey" PRIMARY KEY ("id")
77
+ );
78
+
79
+ -- CreateTable
80
+ CREATE TABLE "Hold" (
81
+ "id" TEXT NOT NULL,
82
+ "account_id" TEXT NOT NULL,
83
+ "managed_wallet_id" TEXT,
84
+ "amount" BIGINT NOT NULL,
85
+ "currency_id" TEXT NOT NULL,
86
+ "reference" TEXT NOT NULL,
87
+ "reason" "HoldReason" NOT NULL,
88
+ "status" "HoldStatus" NOT NULL,
89
+ "expires_at" TIMESTAMP(3) NOT NULL,
90
+ "transfer_id" TEXT,
91
+ "payment_intent_id" TEXT,
92
+ "webhookEventId" TEXT,
93
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
94
+ "updated_at" TIMESTAMP(3) NOT NULL,
95
+
96
+ CONSTRAINT "Hold_pkey" PRIMARY KEY ("id")
97
+ );
98
+
99
+ -- CreateTable
100
+ CREATE TABLE "ManagedWallet" (
101
+ "id" TEXT NOT NULL,
102
+ "account_id" TEXT NOT NULL,
103
+ "customer_name" TEXT,
104
+ "wallet_identifier" TEXT,
105
+ "wallet_customer_email" TEXT,
106
+ "wallet_customer_phone" TEXT,
107
+ "account_number" TEXT,
108
+ "email" TEXT,
109
+ "total_balance" BIGINT NOT NULL DEFAULT 0,
110
+ "available_balance" BIGINT NOT NULL DEFAULT 0,
111
+ "currency_id" TEXT NOT NULL,
112
+ "global_payment_provider_id" TEXT NOT NULL,
113
+ "type" TEXT NOT NULL,
114
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
115
+ "updated_at" TIMESTAMP(3) NOT NULL,
116
+
117
+ CONSTRAINT "ManagedWallet_pkey" PRIMARY KEY ("id")
118
+ );
119
+
120
+ -- CreateTable
121
+ CREATE TABLE "Otp" (
122
+ "id" TEXT NOT NULL,
123
+ "email" TEXT NOT NULL,
124
+ "otp" TEXT NOT NULL,
125
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
126
+ "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
127
+ "expires_at" TIMESTAMP(3) NOT NULL,
128
+
129
+ CONSTRAINT "Otp_pkey" PRIMARY KEY ("id")
130
+ );
131
+
132
+ -- CreateTable
133
+ CREATE TABLE "PaymentIntent" (
134
+ "id" TEXT NOT NULL,
135
+ "reference" TEXT NOT NULL,
136
+ "account_id" TEXT NOT NULL,
137
+ "managed_wallet_id" TEXT,
138
+ "amount" BIGINT NOT NULL,
139
+ "currency_id" TEXT NOT NULL,
140
+ "global_payment_provider_id" TEXT NOT NULL,
141
+ "provider_intent_id" TEXT,
142
+ "status" "PaymentIntentStatus" NOT NULL,
143
+ "metadata" JSONB,
144
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
145
+ "updated_at" TIMESTAMP(3) NOT NULL,
146
+
147
+ CONSTRAINT "PaymentIntent_pkey" PRIMARY KEY ("id")
148
+ );
149
+
150
+ -- CreateTable
151
+ CREATE TABLE "Reversal" (
152
+ "id" TEXT NOT NULL,
153
+ "transaction_id" TEXT NOT NULL,
154
+ "account_id" TEXT NOT NULL,
155
+ "source_currency_id" TEXT,
156
+ "destination_currency_id" TEXT NOT NULL,
157
+ "amount" BIGINT NOT NULL,
158
+ "status" TEXT NOT NULL,
159
+
160
+ CONSTRAINT "Reversal_pkey" PRIMARY KEY ("id")
161
+ );
162
+
163
+ -- CreateTable
164
+ CREATE TABLE "Transaction" (
165
+ "id" TEXT NOT NULL,
166
+ "account_id" TEXT NOT NULL,
167
+ "funding_id" TEXT,
168
+ "withdrawal_id" TEXT,
169
+ "reversal_id" TEXT,
170
+ "transfer_id" TEXT,
171
+ "type" TEXT NOT NULL,
172
+ "status" TEXT NOT NULL,
173
+ "metadata" JSONB,
174
+ "provider_id" TEXT,
175
+ "reference_id" TEXT NOT NULL,
176
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
177
+ "upadated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
178
+
179
+ CONSTRAINT "Transaction_pkey" PRIMARY KEY ("id")
180
+ );
181
+
182
+ -- CreateTable
183
+ CREATE TABLE "TransferDestinationAccountDetails" (
184
+ "id" TEXT NOT NULL,
185
+ "account_firstname" TEXT NOT NULL DEFAULT '',
186
+ "account_lastname" TEXT NOT NULL DEFAULT '',
187
+ "account_number" TEXT,
188
+ "account_email" TEXT,
189
+ "account_bank_name" TEXT,
190
+
191
+ CONSTRAINT "TransferDestinationAccountDetails_pkey" PRIMARY KEY ("id")
192
+ );
193
+
194
+ -- CreateTable
195
+ CREATE TABLE "Transfer" (
196
+ "id" TEXT NOT NULL,
197
+ "transaction_id" TEXT NOT NULL,
198
+ "from_account_id" TEXT NOT NULL,
199
+ "to_account_id" TEXT,
200
+ "destination_account_details_id" TEXT,
201
+ "source_currency_id" TEXT NOT NULL,
202
+ "destination_currency_id" TEXT NOT NULL,
203
+ "amount_in_source_currency" BIGINT NOT NULL,
204
+ "amount_in_destination_currency" BIGINT NOT NULL,
205
+ "status" TEXT NOT NULL,
206
+
207
+ CONSTRAINT "Transfer_pkey" PRIMARY KEY ("id")
208
+ );
209
+
210
+ -- CreateTable
211
+ CREATE TABLE "WebhookEvent" (
212
+ "id" TEXT NOT NULL,
213
+ "provider_id" TEXT NOT NULL,
214
+ "event_type" "EventType" NOT NULL,
215
+ "reference" TEXT NOT NULL,
216
+ "provider_event_id" TEXT,
217
+ "payload" JSONB NOT NULL,
218
+ "verified" BOOLEAN NOT NULL DEFAULT false,
219
+ "processed" BOOLEAN NOT NULL DEFAULT false,
220
+ "received_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
221
+ "processed_at" TIMESTAMP(3),
222
+ "payment_intent_id" TEXT,
223
+
224
+ CONSTRAINT "WebhookEvent_pkey" PRIMARY KEY ("id")
225
+ );
226
+
227
+ -- CreateTable
228
+ CREATE TABLE "WithdrawalDestinationAccountDetails" (
229
+ "id" TEXT NOT NULL,
230
+ "account_firstname" TEXT NOT NULL DEFAULT '',
231
+ "account_lastname" TEXT NOT NULL DEFAULT '',
232
+ "account_number" TEXT,
233
+ "account_email" TEXT,
234
+ "account_bank_name" TEXT,
235
+
236
+ CONSTRAINT "WithdrawalDestinationAccountDetails_pkey" PRIMARY KEY ("id")
237
+ );
238
+
239
+ -- CreateTable
240
+ CREATE TABLE "Withdrawal" (
241
+ "id" TEXT NOT NULL,
242
+ "transaction_id" TEXT NOT NULL,
243
+ "from_account_id" TEXT NOT NULL,
244
+ "amount_in_source_currency" BIGINT NOT NULL,
245
+ "status" TEXT NOT NULL,
246
+ "destination_account_details_id" TEXT,
247
+ "source_currency_id" TEXT NOT NULL,
248
+ "destination_currency_id" TEXT NOT NULL,
249
+ "amount_in_destination_currency" BIGINT NOT NULL,
250
+
251
+ CONSTRAINT "Withdrawal_pkey" PRIMARY KEY ("id")
252
+ );
253
+
254
+ -- CreateTable
255
+ CREATE TABLE "_CurrencyToGlobalPaymentProvider" (
256
+ "A" TEXT NOT NULL,
257
+ "B" TEXT NOT NULL,
258
+
259
+ CONSTRAINT "_CurrencyToGlobalPaymentProvider_AB_pkey" PRIMARY KEY ("A","B")
260
+ );
261
+
262
+ -- CreateIndex
263
+ CREATE UNIQUE INDEX "PaymentAccount_account_number_key" ON "PaymentAccount"("account_number");
264
+
265
+ -- CreateIndex
266
+ CREATE UNIQUE INDEX "PaymentAccount_wallet_id_key" ON "PaymentAccount"("wallet_id");
267
+
268
+ -- CreateIndex
269
+ CREATE INDEX "wallet_id_index" ON "PaymentAccount"("wallet_id");
270
+
271
+ -- CreateIndex
272
+ CREATE INDEX "wallet_account_number" ON "PaymentAccount"("account_number");
273
+
274
+ -- CreateIndex
275
+ CREATE UNIQUE INDEX "Currency_code_key" ON "Currency"("code");
276
+
277
+ -- CreateIndex
278
+ CREATE UNIQUE INDEX "Funding_transaction_id_key" ON "Funding"("transaction_id");
279
+
280
+ -- CreateIndex
281
+ CREATE UNIQUE INDEX "Funding_sender_account_information_id_key" ON "Funding"("sender_account_information_id");
282
+
283
+ -- CreateIndex
284
+ CREATE UNIQUE INDEX "Hold_reference_key" ON "Hold"("reference");
285
+
286
+ -- CreateIndex
287
+ CREATE INDEX "Hold_account_id_idx" ON "Hold"("account_id");
288
+
289
+ -- CreateIndex
290
+ CREATE INDEX "Hold_status_idx" ON "Hold"("status");
291
+
292
+ -- CreateIndex
293
+ CREATE INDEX "Hold_expires_at_idx" ON "Hold"("expires_at");
294
+
295
+ -- CreateIndex
296
+ CREATE INDEX "otp_email_index" ON "Otp"("email");
297
+
298
+ -- CreateIndex
299
+ CREATE INDEX "otp_str_index" ON "Otp"("otp");
300
+
301
+ -- CreateIndex
302
+ CREATE UNIQUE INDEX "PaymentIntent_reference_key" ON "PaymentIntent"("reference");
303
+
304
+ -- CreateIndex
305
+ CREATE INDEX "PaymentIntent_account_id_idx" ON "PaymentIntent"("account_id");
306
+
307
+ -- CreateIndex
308
+ CREATE INDEX "PaymentIntent_reference_idx" ON "PaymentIntent"("reference");
309
+
310
+ -- CreateIndex
311
+ CREATE UNIQUE INDEX "Reversal_transaction_id_key" ON "Reversal"("transaction_id");
312
+
313
+ -- CreateIndex
314
+ CREATE UNIQUE INDEX "Transaction_id_key" ON "Transaction"("id");
315
+
316
+ -- CreateIndex
317
+ CREATE UNIQUE INDEX "Transaction_funding_id_key" ON "Transaction"("funding_id");
318
+
319
+ -- CreateIndex
320
+ CREATE UNIQUE INDEX "Transaction_withdrawal_id_key" ON "Transaction"("withdrawal_id");
321
+
322
+ -- CreateIndex
323
+ CREATE UNIQUE INDEX "Transaction_reversal_id_key" ON "Transaction"("reversal_id");
324
+
325
+ -- CreateIndex
326
+ CREATE UNIQUE INDEX "Transaction_transfer_id_key" ON "Transaction"("transfer_id");
327
+
328
+ -- CreateIndex
329
+ CREATE UNIQUE INDEX "Transaction_reference_id_key" ON "Transaction"("reference_id");
330
+
331
+ -- CreateIndex
332
+ CREATE UNIQUE INDEX "Transfer_transaction_id_key" ON "Transfer"("transaction_id");
333
+
334
+ -- CreateIndex
335
+ CREATE UNIQUE INDEX "Transfer_destination_account_details_id_key" ON "Transfer"("destination_account_details_id");
336
+
337
+ -- CreateIndex
338
+ CREATE UNIQUE INDEX "WebhookEvent_reference_key" ON "WebhookEvent"("reference");
339
+
340
+ -- CreateIndex
341
+ CREATE INDEX "WebhookEvent_reference_idx" ON "WebhookEvent"("reference");
342
+
343
+ -- CreateIndex
344
+ CREATE INDEX "WebhookEvent_processed_idx" ON "WebhookEvent"("processed");
345
+
346
+ -- CreateIndex
347
+ CREATE UNIQUE INDEX "Withdrawal_transaction_id_key" ON "Withdrawal"("transaction_id");
348
+
349
+ -- CreateIndex
350
+ CREATE UNIQUE INDEX "Withdrawal_destination_account_details_id_key" ON "Withdrawal"("destination_account_details_id");
351
+
352
+ -- CreateIndex
353
+ CREATE INDEX "_CurrencyToGlobalPaymentProvider_B_index" ON "_CurrencyToGlobalPaymentProvider"("B");
354
+
355
+ -- AddForeignKey
356
+ ALTER TABLE "PaymentAccount" ADD CONSTRAINT "PaymentAccount_currency_id_fkey" FOREIGN KEY ("currency_id") REFERENCES "Currency"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
357
+
358
+ -- AddForeignKey
359
+ ALTER TABLE "Funding" ADD CONSTRAINT "Funding_sender_account_information_id_fkey" FOREIGN KEY ("sender_account_information_id") REFERENCES "SenderAccountInformation"("id") ON DELETE SET NULL ON UPDATE CASCADE;
360
+
361
+ -- AddForeignKey
362
+ ALTER TABLE "ManagedWallet" ADD CONSTRAINT "ManagedWallet_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "PaymentAccount"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
363
+
364
+ -- AddForeignKey
365
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_provider_id_fkey" FOREIGN KEY ("provider_id") REFERENCES "GlobalPaymentProvider"("id") ON DELETE SET NULL ON UPDATE CASCADE;
366
+
367
+ -- AddForeignKey
368
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "PaymentAccount"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
369
+
370
+ -- AddForeignKey
371
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_transfer_id_fkey" FOREIGN KEY ("transfer_id") REFERENCES "Transfer"("id") ON DELETE SET NULL ON UPDATE CASCADE;
372
+
373
+ -- AddForeignKey
374
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_funding_id_fkey" FOREIGN KEY ("funding_id") REFERENCES "Funding"("id") ON DELETE SET NULL ON UPDATE CASCADE;
375
+
376
+ -- AddForeignKey
377
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_withdrawal_id_fkey" FOREIGN KEY ("withdrawal_id") REFERENCES "Withdrawal"("id") ON DELETE SET NULL ON UPDATE CASCADE;
378
+
379
+ -- AddForeignKey
380
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_reversal_id_fkey" FOREIGN KEY ("reversal_id") REFERENCES "Reversal"("id") ON DELETE SET NULL ON UPDATE CASCADE;
381
+
382
+ -- AddForeignKey
383
+ ALTER TABLE "Transfer" ADD CONSTRAINT "Transfer_destination_account_details_id_fkey" FOREIGN KEY ("destination_account_details_id") REFERENCES "TransferDestinationAccountDetails"("id") ON DELETE SET NULL ON UPDATE CASCADE;
384
+
385
+ -- AddForeignKey
386
+ ALTER TABLE "WebhookEvent" ADD CONSTRAINT "WebhookEvent_payment_intent_id_fkey" FOREIGN KEY ("payment_intent_id") REFERENCES "PaymentIntent"("id") ON DELETE SET NULL ON UPDATE CASCADE;
387
+
388
+ -- AddForeignKey
389
+ ALTER TABLE "Withdrawal" ADD CONSTRAINT "Withdrawal_destination_account_details_id_fkey" FOREIGN KEY ("destination_account_details_id") REFERENCES "WithdrawalDestinationAccountDetails"("id") ON DELETE SET NULL ON UPDATE CASCADE;
390
+
391
+ -- AddForeignKey
392
+ ALTER TABLE "_CurrencyToGlobalPaymentProvider" ADD CONSTRAINT "_CurrencyToGlobalPaymentProvider_A_fkey" FOREIGN KEY ("A") REFERENCES "Currency"("id") ON DELETE CASCADE ON UPDATE CASCADE;
393
+
394
+ -- AddForeignKey
395
+ ALTER TABLE "_CurrencyToGlobalPaymentProvider" ADD CONSTRAINT "_CurrencyToGlobalPaymentProvider_B_fkey" FOREIGN KEY ("B") REFERENCES "GlobalPaymentProvider"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -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 BigInt // 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,7 +5,7 @@ model Reversal {
5
5
  source_currency_id String?
6
6
  destination_currency_id String
7
7
 
8
- amount String
8
+ amount BigInt
9
9
  status String
10
10
 
11
11
  transaction Transaction?
@@ -5,5 +5,4 @@ generator client {
5
5
 
6
6
  datasource db {
7
7
  provider = "postgresql"
8
- url = env("PAYMENT_DATABASE_URL")
9
8
  }