Trakteer Payment Gateway API
A Node.js-based payment gateway integration for Trakteer.id, supporting multiple payment methods including QRIS, e-wallets, virtual accounts, and credit cards.
π Features
-
Multiple payment method support:
- QRIS
- GoPay
- OVO
- DANA
- LinkAja
- ShopeePay
- Virtual Accounts (BNI, BRI, Mandiri, Permata, BCA, Others)
- Credit/Debit Cards
-
Easy integration with Trakteer.id
-
Secure payment processing
-
Configurable through environment variables
-
Docker support with HAProxy load balancer
π Prerequisites
- Node.js (Latest Version)
- npm
- Docker (optional, for containerization)
π Installation
-
Clone the repository:
git clone https://github.com/sazumivicky/trakteer-payment-api.git cd trakteer-payment-api -
Install dependencies:
npm install -
Create a
.envfile in the root directory with the following variables:PORT=3000 TRAKTEER_API_URL=your_api_url TRAKTEER_QRIS_URL=your_qris_url TRAKTEER_GOPAY_URL=your_gopay_url TRAKTEER_OVO_URL=your_ovo_url TRAKTEER_DANA_URL=your_dana_url TRAKTEER_LINKAJA_URL=your_linkaja_url TRAKTEER_SHOPEEPAY_URL=your_shopeepay_url TRAKTEER_VA_OTHERS_URL=your_va_others_url TRAKTEER_VA_BNI_URL=your_va_bni_url TRAKTEER_VA_BRI_URL=your_va_bri_url TRAKTEER_VA_MANDIRI_URL=your_va_mandiri_url TRAKTEER_VA_PERMATA_URL=your_va_permata_url TRAKTEER_VA_BCA_URL=your_va_bca_url TRAKTEER_CARDS_URL=your_cards_url TRAKTEER_SESSION=your_session_token CSRF_TOKEN=your_csrf_token CREATOR_ID=your_creator_id UNIT_ID=your_unit_id SUPPORTER_ID=your_supporter_id MIDTRANS_CHARGE_URL=your_midtrans_url
πββοΈ Running the Application
Standard Mode
npm start
Using Docker
docker build -t trakteer-payment-api .
docker run -p 3000:3000 trakteer-payment-api
π API Usage
Payment Endpoint
GET /payment
Query Parameters:
method(required): Payment method (qris, gopay, ovo, dana, linkaja, shopeepay, va-others, va-bni, va-bri, va-mandiri, va-permata, va-bca, cards)pizzas(required): Quantity of pizzas (each pizza costs 50,000)display_name(optional): Supporter's display namesupport_message(optional): Support messageovo_number(required for OVO): Phone number for OVO paymentlinkaja_number(required for LinkAja): Phone number for LinkAja payment
Example Requests:
-
QRIS Payment:
http://localhost:3000/payment?method=qris&pizzas=2&display_name=John%20Doe&support_message=Keep%20it%20up! -
OVO Payment:
http://localhost:3000/payment?method=ovo&pizzas=1&display_name=John%20Doe&support_message=Great%20work!&ovo_number=085236226786 -
Virtual Account BCA:
http://localhost:3000/payment?method=va-bca&pizzas=3&display_name=John%20Doe&support_message=Amazing! -
GoPay:
http://localhost:3000/payment?method=gopay&pizzas=2&display_name=John%20Doe&support_message=Keep%20creating!
π Security Features
- Environment variables for sensitive data
- CSRF token protection
- Request validation and sanitization
- Secure header configurations
- Rate limiting support
- Error handling and logging
π³ Docker Configuration
The project includes Docker support with HAProxy as a load balancer:
Docker Files
Dockerfile: Contains the container configurationhaproxy.cfg: HAProxy load balancer configuration
Running with Docker Compose
docker-compose up -d
π§ Configuration
Environment Variables
| Variable | Description | Required |
|---|---|---|
| PORT | Server port | Yes |
| TRAKTEER_API_URL | Main API URL | Yes |
| TRAKTEER_SESSION | Session token | Yes |
| CSRF_TOKEN | CSRF protection token | Yes |
| CREATOR_ID | Your Trakteer creator ID | Yes |
| UNIT_ID | Trakteer unit ID | Yes |
π Error Handling
The API includes comprehensive error handling:
- Input validation errors (400)
- Authentication errors (401)
- Server errors (500)
- Payment gateway errors
π Response Format
Success Response
{
"success": true,
"data": {
"payment_url": "https://payment-url.example",
"order_id": "ORDER123"
}
}
Error Response
{
"success": false,
"error": "Error message description"
}
π License
This project is licensed under the MIT License - see the LICENSE file for details.
βοΈ Author
Sazumi Viki
π€ Contributing
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
π Support
If you find this project helpful, please give it a βοΈ!
π Contact
- GitHub: @sazumivicky
- Website: sazumi.moe
- Email: [email protected]
π Changelog
[1.0.0] - 10-30-2024
- Initial release
- Basic payment gateway integration
- Multiple payment method support
- Docker support with HAProxy