A simple payment gateway for the most common cryptocurrencies (BTC, ETH, LTC) using NestJS and Prisma.
$ pnpm install
$ pnpm run setup
The API_KEY needs to be generated using pnpm run setup
. Because is hashed with sha512, so, if you lost it, you will need generate a new one.
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
# unit tests
$ pnpm run test
# e2e tests
$ pnpm run test:e2e
# test coverage
$ pnpm run test:cov
The server is available at http://localhost:3000
(Or in the port that you set in the .env
file).
BTC
: BitcoinETH
: EthereumLTC
: Litecoin
PENDING
: The payment is pending.PROCESSING
: The money was received but waiting for confirmations.PARTIAL_RECEIVED
: The money was received but it's not the full amount. The user can still pay the remaining amount.COMPLETED
: The payment was successful.EXPIRED
: The payment is expired.FAILED
: The payment is failed.
All endpoints require X-API-KEY
header. You can generate it using pnpm run setup
Get a list of all the orders.
Parameters:
page
: The page number to retrieve. Defaults to 1.limit
: The number of orders to retrieve per page. Defaults to 10.status
: Optional. The status to filter by.currency
: Optional. The currency to filter by.walletAddress
: Optional. The wallet address to filter by.
[
{
"order": {
"id": "random-uuid",
"status": "PENDING",
"currency": "BTC",
"amount": 1000,
"confirmations": 2,
"description": "Buy some coffee",
"address": "wallet address to send the payment to",
"expiresAt": 1234567890,
"externalId": "order-12345"
},
"payment": {
"confirmations": 1,
"received": 0,
"transactions": [
{
"txid": "txid",
"confirmations": 1,
"amount": 1000,
"from": "wallet address",
}
]
}
}
]
Create a new order.
{
"currency": "BTC",
"amount": 1000,
"confirmations": 2,
"description": "Buy some coffee",
"expiresAt": 1234567890,
"externalId": "order-12345"
}
{
"id": "random-uuid",
"status": "PENDING",
"currency": "BTC",
"amount": 1000,
"confirmations": 2,
"description": "Buy some coffee",
"address": "wallet address to send the payment to",
"expiresAt": 1234567890,
"externalId": "order-12345"
}
Get an order by its ID.
{
"id": "random-uuid",
"status": "PENDING",
"currency": "BTC",
"amount": 1000,
"confirmations": 2,
"description": "Buy some coffee",
"address": "wallet address to send the payment to",
"expiresAt": 1234567890,
"externalId": "order-12345",
"payment": {
"confirmations": 1,
"received": 0,
"transactions": [
{
"txid": "txid",
"confirmations": 1,
"amount": 1000,
"from": "wallet address",
}
]
}
}
Update the status of an order.
Parameters:
id
: The ID of the order to update.status
: The new status of the order.
If the order is already in the new status, the request will be ignored.
Cancel an order by its ID.
Parameters:
id
: The ID of the order to cancel.
The order will be marked as CANCELED
and the payment will be cancelled.
This project is open-sourced software licensed under the MIT license.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.