Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Payment Integration Example

Modern FastAPI REST API for payment processing with Payme and Click, built on PayTechUZ.

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Configure Environment

Copy .env.example to .env and update with your credentials:

cp .env.example .env

3. Run Application

./run.sh
# or
uvicorn main:app --reload --host 0.0.0.0 --port 8000

API Endpoints

Orders

Create Order with Payment

POST /api/v1/orders
Content-Type: application/json

{
    "product_name": "Test Product",
    "amount": 100.00,
    "payment_method": "payme"
}

Response:

{
    "id": 1,
    "amount": 100.00,
    "payment_method": "payme",
    "payment_link": "https://test.paycom.uz/..."
}

Fields:

  • id - Order ID
  • amount - Payment amount
  • payment_method - Gateway name (payme, click)
  • payment_link - Payment URL to redirect user

Webhooks

  • POST /api/v1/webhooks/payme - Payme webhook
  • POST /api/v1/webhooks/click - Click webhook

cURL Examples

Payme Payment:

curl -X POST http://127.0.0.1:8000/api/v1/orders \
  -H "Content-Type: application/json" \
  -d '{
    "product_name": "Premium Subscription",
    "amount": 50000.00,
    "payment_method": "payme"
  }'

Response:

{
    "id": 1,
    "amount": 50000.00,
    "payment_method": "payme",
    "payment_link": "https://test.paycom.uz/..."
}

Click Payment:

curl -X POST http://127.0.0.1:8000/api/v1/orders \
  -H "Content-Type: application/json" \
  -d '{
    "product_name": "Monthly Plan",
    "amount": 25000.00,
    "payment_method": "click"
  }'

Response:

{
    "id": 2,
    "amount": 25000.00,
    "payment_method": "click",
    "payment_link": "https://my.click.uz/services/pay?..."
}

Testing Webhooks Locally

Use jprq or ngrok to expose your local server:

# Using jprq
jprq http 8000

# Using ngrok
ngrok http 8000

Configure webhook URLs in payment gateway admin panels:

  • Payme: https://your-domain.com/api/v1/webhooks/payme
  • Click: https://your-domain.com/api/v1/webhooks/click

Resources

About

🟢 FastAPI uchun Payme, Click va Uzum integratsiyasi — namunaviy loyiha | FastAPI payment example

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages