Skip to content

cTrip - Documentation

cTrip Crypto Payment Gateway Documentation

Overview

This is a simple Flask web application for processing payments using the Ethereum blockchain.
Users can generate unique payment addresses, monitor payment statuses,
and send payment information to an admin address.

Setup

git clone https://github.com/rakibmia7254/ctrip

cd ctrip

pip install -r requirements.txt

Active Virtual Environment And Start Flask Server however You want.

Configuration

Open .env Change Veriables What You Want And Save

ADMIN_ADDRESS=0x8f13688c9B53E93dE5A1D0c86b9816e7cc578017
W3_PROVIDER=https://data-seed-prebsc-1-s3.binance.org:8545/
SECRET_KEY=your_secret_key
gasLimit=200000
gasPrice=5

I Used BNB Testnet. Adjust gas prices, gas limits, and other parameters based on your Blockchain network and requirements.

Usage:

Generate Payment Address:

Use the /generate_payment_address endpoint to generate a new payment address.

Make a POST request with a JSON payload containing the desired payment amount.

Example using curl:

curl -X POST -H "X-Api-Key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{"amount": 100}' http://localhost:8080/generate_payment_address

The response will contain the new payment address and its validity period.

Check Payment Status:

Use the /check_payment/{payment_address} endpoint to check the status of a payment.

Replace {payment_address} with the actual Ethereum payment address.

Example using curl:

curl http://localhost:8080/check_payment/YOUR_PAYMENT_ADDRESS

The response will indicate the payment status and, if received, the current balance.

Send Payment Information to Admin:

The application automatically sends payment information to the admin address when a valid payment is received. Adjust the admin address (ADMIN_ADDRESS) and gas parameters as needed.

Endpoints

1. Generate Payment Address

URL: /generate_payment_address

Methods: POST

Description: Generates a unique Ethereum payment address for a specified payment amount. Requires a valid API key in the headers.

Check Payment:

Check Payment:

URL: /check_payment/{payment_address}

Methods: GET

Description: Checks if a payment has been received for the given payment address

Requirements:

1. Python 3.x 2. Flask 3. Web3 4. APScheduler


Author: Rakib Hossain

Contact us: rakib4ggp@gmail.com