-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add client payment table #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3b55991
feat: add clientPayment table
lissavxo 04ffce3
feat: add generatePaymentId endpoint
lissavxo 735d9dd
fix: parse address paymentId
lissavxo 33ccad2
refactor: clean up
lissavxo b8308eb
refactor: clean up
lissavxo 7a03089
feat: add amount to client payment
lissavxo abd8fc9
fix: update clientpayment method
lissavxo 8078a46
feat: add generatePaymentId endpoint
lissavxo ad196aa
feat: update paymentId
lissavxo 7a95368
feat: update client payment comfirmed
lissavxo 8d3f911
fix: generatePaymentId duplicated
lissavxo 74e1ce3
fix: typo confirmed
lissavxo 8713202
refactor: clean up
lissavxo 442a319
fix: check amount to update clientPayment
lissavxo 157cf0d
fix: post params paymentId
lissavxo 47ec902
chore: remove id from client payment
lissavxo f0e2622
chore: paymentId id
lissavxo 15736e1
chore: rename clientPayments obj
lissavxo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Decimal } from '@prisma/client/runtime/library' | ||
| import { generatePaymentId } from 'services/transactionService' | ||
| import { parseAddress, parseCreatePaymentIdPOSTRequest } from 'utils/validators' | ||
| import { RESPONSE_MESSAGES } from 'constants/index' | ||
|
|
||
| export default async (req: any, res: any): Promise<void> => { | ||
| if (req.method === 'POST') { | ||
| try { | ||
| const values = parseCreatePaymentIdPOSTRequest(req.body) | ||
| const address = parseAddress(values.address) | ||
| const amount = values.amount as Decimal | undefined | ||
|
|
||
| const paymentId = await generatePaymentId(address, amount) | ||
|
|
||
| res.status(200).json({ paymentId }) | ||
| } catch (error: any) { | ||
| switch (error.message) { | ||
| case RESPONSE_MESSAGES.ADDRESS_NOT_PROVIDED_400.message: | ||
| res.status(RESPONSE_MESSAGES.ADDRESS_NOT_PROVIDED_400.statusCode).json(RESPONSE_MESSAGES.ADDRESS_NOT_PROVIDED_400) | ||
| break | ||
| default: | ||
| res.status(500).json({ statusCode: 500, message: error.message }) | ||
| } | ||
| } | ||
lissavxo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } else { | ||
| res.status(RESPONSE_MESSAGES.METHOD_NOT_ALLOWED.statusCode) | ||
| .json(RESPONSE_MESSAGES.METHOD_NOT_ALLOWED) | ||
| } | ||
lissavxo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
14 changes: 14 additions & 0 deletions
14
prisma-local/migrations/20250912183436_client_payment/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| -- CreateTable | ||
| CREATE TABLE `ClientPayment` ( | ||
| `paymentId` VARCHAR(191) NOT NULL, | ||
| `status` ENUM('PENDING', 'ADDED_TO_MEMPOOL', 'CONFIRMED') NOT NULL, | ||
| `addressString` VARCHAR(191) NOT NULL, | ||
| `amount` DECIMAL(65, 30) NULL, | ||
| `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), | ||
| `updatedAt` DATETIME(3) NOT NULL, | ||
|
|
||
| PRIMARY KEY (`paymentId`) | ||
| ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE `ClientPayment` ADD CONSTRAINT `ClientPayment_addressString_fkey` FOREIGN KEY (`addressString`) REFERENCES `Address`(`address`) ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.