Pepecoin Payment Gateway is a Python-based backend server built using FastAPI to handle transactions, monitor payments, and automate order management for applications and merchants accepting Pepecoin cryptocurrency payments.
- 🚀 FastAPI: High-performance API implementation with OpenAPI documentation.
- 💳 Payment Processing: Automatically generate payment addresses, monitor transactions, and confirm payments.
- 🔄 Order Management: Create, list, cancel, and track orders with real-time updates.
- 🔧 Customizable: Add metadata and descriptions to orders for better tracking.
- 🔒 Secure: API key authentication and secure database storage.
- 🔍 Transaction Monitoring: Automatic transaction validation with Pepecoin blockchain.
- Python 3.7+
- A running Pepecoin full node with RPC enabled, or access to a Pepecoin blockchain API.
- PostgreSQL or another supported database.
Install the package via pip:
pip install pepecoin
Create a .env
file in the project root:
DATABASE_URL=postgresql://user:password@localhost/pepecoin_db
PEPECOIN_RPC_URL=http://localhost:12345/
PEPECOIN_RPC_USER=your_rpc_username
PEPECOIN_RPC_PASSWORD=your_rpc_password
API_KEY=your_api_key_here
Run database migrations to set up tables:
alembic upgrade head
Run the FastAPI server:
uvicorn app.main:app --host 0.0.0.0 --port 8000
The server will start on http://localhost:8000
.
- POST
/v1/orders
- Request:
{
"amount": 10.5,
"currency": "PEPE",
"description": "Purchase of digital artwork",
"customer_email": "customer@example.com",
"metadata": {
"order_number": "12345"
}
}
- Response:
{
"order_id": "ord_123456789",
"payment_address": "PpK1q2w3e4r5t6y7u8i9o0pLkJhGfDsA",
"amount_due": 10.5,
"amount_paid": 0.0,
"status": "Pending",
"created_at": "2023-10-15T12:34:56Z",
"expires_at": "2023-10-15T13:34:56Z",
"transactions": [],
"metadata": {
"order_number": "12345"
}
}
- GET
/v1/orders/{order_id}
- Response:
{
"order_id": "ord_123456789",
"payment_address": "PpK1q2w3e4r5t6y7u8i9o0pLkJhGfDsA",
"amount_due": 10.5,
"amount_paid": 10.5,
"status": "Paid",
"created_at": "2023-10-15T12:34:56Z",
"expires_at": "2023-10-15T13:34:56Z",
"transactions": [
{
"txid": "b6f6991d3c...e8e8e8e8e8",
"amount": 10.5,
"confirmations": 3,
"timestamp": "2023-10-15T12:35:00Z"
}
],
"metadata": {
"order_number": "12345"
}
}
- GET
/v1/orders
- Query Parameters:
status
(Optional): Filter by order status (e.g.,Pending
,Paid
).limit
(Optional): Number of results to return (default: 20).offset
(Optional): Pagination offset (default: 0).
- DELETE
/v1/orders/{order_id}
- Response:
{
"order_id": "ord_123456789",
"status": "Cancelled"
}
pepecoin_payment_gateway/
├── app/
│ ├── main.py # Entry point of the application
│ ├── api/ # API routes and dependencies
│ ├── models/ # Database models
│ ├── schemas/ # Pydantic schemas for requests/responses
│ ├── services/ # Business logic and Pepecoin node interactions
│ ├── db.py # Database initialization
│ ├── config.py # Configuration and environment variables
│ └── utils.py # Helper utilities
├── alembic/ # Database migrations
├── tests/ # Unit and integration tests
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── .env # Environment variables (do not commit this!)
└── .gitignore # Git ignore file
- Install testing dependencies:
pip install pytest pytest-cov
- Run tests:
pytest --cov=app tests/
Use Docker to containerize the application for easier deployment.
- Build the Docker image:
docker build -t pepecoin-payment-gateway .
- Run the container:
docker run -p 8000:8000 --env-file .env pepecoin-payment-gateway
- Use Gunicorn with Uvicorn workers for production.
- Deploy behind a reverse proxy (e.g., Nginx) for SSL termination.
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create a new feature branch:
git checkout -b feature/my-feature
. - Commit your changes:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature/my-feature
. - Open a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.
- Thanks to the Pepecoin community for blockchain insights.
- Built with ❤️ using FastAPI.