feat: update README
This commit is contained in:
parent
e9327b6ba5
commit
3678d0457c
98
README.md
98
README.md
|
@ -1,56 +1,86 @@
|
|||
# Bitcoin Payment Checker
|
||||
|
||||
Bitcoin Payment Checker is a Go application that allows clients to pay for orders using Bitcoin. The application calculates the Bitcoin equivalent of the order amount, provides a wallet address for payment, and tracks the payment status.
|
||||
Bitcoin Payment Checker is a modern Go application designed to facilitate Bitcoin payments for orders. It provides a seamless interface for clients to pay the Bitcoin equivalent of an order amount, offering a wallet address for payment and tracking the payment status in real-time.
|
||||
|
||||
## Demo
|
||||
## Features
|
||||
|
||||
You can try it here on bitcoin testnet: https://btcpaychecker.urkob.com/
|
||||
- **Real-time Bitcoin Conversion**: Automatically calculates the Bitcoin equivalent of the order amount using current market rates.
|
||||
- **Order Tracking**: Monitors the payment status from initiation to completion, ensuring transparency and reliability.
|
||||
- **Notification System**: Alerts via email when payments are processed or if there are any issues.
|
||||
- **Secure and Scalable**: Designed with security and scalability in mind, making it suitable for businesses of all sizes.
|
||||
- **Grafana Monitoring**: Supports integration with Grafana for advanced monitoring and analytics of payment transactions.
|
||||
|
||||
## Application Structure
|
||||
## Getting Started
|
||||
|
||||
The application is structured into several packages:
|
||||
### Prerequisites
|
||||
|
||||
- `handler`: Contains the HTTP handlers for the application. The `OrderHandler` is responsible for processing new orders and calculating the Bitcoin price.
|
||||
- `services`: Contains various services used by the application, such as the `Order` service for managing orders and the `PriceConversor` service for converting USD to Bitcoin.
|
||||
- `main`: The entry point of the application. It sets up the database connection, initializes the services, and starts the HTTP server.
|
||||
- Go (1.15 or later)
|
||||
- Docker and Docker Compose (for containerization and services)
|
||||
- MongoDB (for database)
|
||||
- An SMTP server (for email notifications)
|
||||
- Grafana (for monitoring, optional)
|
||||
|
||||
## Key Files
|
||||
|
||||
- `handler/order.go`: Contains the `OrderHandler` which processes new orders. It calculates the Bitcoin price of the order, stores the order in the database, and renders an HTML page with the order details.
|
||||
- `main.go`: The entry point of the application. It sets up the database connection, initializes the services, and starts the HTTP server.
|
||||
### Installation
|
||||
|
||||
## Running the Application
|
||||
|
||||
To run the application, you need to have Go installed. Then, you can run the application using the `go run` command:
|
||||
1- **Clone the Repository**
|
||||
|
||||
```bash
|
||||
go run main.go
|
||||
git clone https://github.com/yourusername/btcpaychecker.git
|
||||
cd btcpaychecker
|
||||
```
|
||||
|
||||
This will start the application and listen for HTTP requests on the configured port.
|
||||
2- **Environment Configuration**
|
||||
|
||||
Configure your application by setting the necessary environment variables. You can find a template in .env.example. Rename this to .env and fill in the details accordingly.
|
||||
|
||||
3- **Build and Run**
|
||||
|
||||
- Without Docker: If you prefer to run the application directly on your machine:
|
||||
|
||||
```bash
|
||||
go run cmd/btcpaychecker/main.go
|
||||
```
|
||||
|
||||
- With Docker: To containerize your application, use the following commands:
|
||||
|
||||
```bash
|
||||
docker build -t btcpaychecker .
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
The application uses the following environment variables:
|
||||
The application can be configured using the following environment variables:
|
||||
|
||||
```env
|
||||
PAY_CHECKER_ENV: The environment the application is running in. If set to "dev", the application will load configuration from a .env file.
|
||||
DB_ADDRESS: The address of the MongoDB database.
|
||||
DB_NAME: The name of the MongoDB database.
|
||||
ORDERS_COLLECTION: The name of the MongoDB collection for orders.
|
||||
CONVERSOR_API: The API used for converting USD to Bitcoin.
|
||||
RPC_HOST, RPC_AUTH, RPC_ZMQ, WALLET_ADDRESS: Configuration for the Bitcoin service.
|
||||
MAIL_USER, MAIL_PASSWORD, MAIL_HOST, MAIL_PORT, MAIL_FROM: Configuration for the mail service.
|
||||
```
|
||||
|
||||
### Webhook configuration
|
||||
|
||||
If you want some http endpoint to be called by **POST** you have to set up `WEBHOOK_URL` as environment variable with absolute URL of your endpoint. After payment is completed by client, order will be send through http `POST`.
|
||||
- **DB_ADDRESS**: MongoDB address.
|
||||
- **DB_NAME**: Database name.
|
||||
- **ORDERS_COLLECTION**: Collection for orders.
|
||||
- **CONVERSOR_API**: API for currency conversion.
|
||||
- **RPC_HOST, RPC_AUTH, RPC_ZMQ, WALLET_ADDRESS**: Bitcoin service configuration.
|
||||
- **MAIL_USER, MAIL_PASSWORD, MAIL_HOST, MAIL_PORT, MAIL_FROM**: SMTP configuration for email notifications.
|
||||
- **WEBHOOK_URL**: (Optional) For POST callbacks upon payment completion.
|
||||
|
||||
## Dependencies
|
||||
|
||||
The application uses several external packages:
|
||||
List of Go modules and external packages used:
|
||||
|
||||
gofiber/fiber/v2: For building the HTTP server and handling requests.
|
||||
go.mongodb.org/mongo-driver/mongo: For connecting to and interacting with MongoDB.
|
||||
net/smtp: For sending emails.
|
||||
- gofiber/fiber/v2: For HTTP server and routing.
|
||||
- go.mongodb.org/mongo-driver/mongo: MongoDB driver.
|
||||
- net/smtp: For sending emails.
|
||||
|
||||
## Dockerization
|
||||
|
||||
A Dockerfile is provided for easy application containerization, allowing for straightforward deployment and scalability. Refer to the Dockerfile for more details.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines on how to contribute to this project.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the LICENSE file for details.
|
||||
|
||||
## Demo
|
||||
|
||||
You can try it **[here on bitcoin testnet](https://btcpaychecker.com)**
|
||||
|
|
Loading…
Reference in New Issue