Yangi to'lov yaratish
GET
/api?method=create
Parametrlar
| Parametr | Turi | Majburiy | Tavsif |
|---|---|---|---|
shop_id |
string | Ha | Kassangiz ID si |
shop_key |
string | Ha | Kassangiz maxfiy kaliti |
amount |
number | Ha | To'lov summasi (min: 1000, max: 10,000,000) |
order |
string | Ha | Sizning order ID ingiz (unique) |
So'rov namunasi
curl "https://api.payfer.uz/api?method=create&shop_id=shop_abc123&shop_key=xyz789&amount=50000&order=ORDER123"
Muvaffaqiyatli javob
{
"status": "success",
"message": "Payment created successfully",
"payment_id": 12345,
"unique_amount": 50001.50,
"expire_at": "2024-01-20T15:30:00",
"order_code": "ORDER123"
}
unique_amount - mijozga to'lash uchun ko'rsatiladigan summa (P2P konfliktni oldini olish uchun)
Xatolik javobi
{
"status": "error",
"message": "Invalid shop credentials"
}
To'lov holatini tekshirish
GET
/api?method=check
Parametrlar
| Parametr | Turi | Majburiy | Tavsif |
|---|---|---|---|
shop_id |
string | Ha | Kassangiz ID si |
shop_key |
string | Ha | Kassangiz maxfiy kaliti |
order |
string | Ha | Yaratilgan order ID |
So'rov namunasi
curl "https://api.payfer.uz/api?method=check&shop_id=shop_abc123&shop_key=xyz789&order=ORDER123"
Muvaffaqiyatli javob
{
"status": "success",
"payment_status": "paid",
"amount": 50000,
"paid_amount": 50001.50,
"paid_at": "2024-01-20T15:25:30",
"order_code": "ORDER123"
}
payment_status qiymatlari: pending, paid, expired, cancelled
Kassa ma'lumotlari
GET
/api?method=shop
Parametrlar
| Parametr | Turi | Majburiy | Tavsif |
|---|---|---|---|
shop_id |
string | Ha | Kassangiz ID si |
shop_key |
string | Ha | Kassangiz maxfiy kaliti |
So'rov namunasi
curl "https://api.payfer.uz/api?method=shop&shop_id=shop_abc123&shop_key=xyz789"
Muvaffaqiyatli javob
{
"status": "success",
"shop_name": "Mening do'konim",
"balance": 150000,
"total_transactions": 45,
"total_amount": 2250000,
"created_at": "2024-01-01T10:00:00"
}
Xatolik kodlari
| Kod | Xabar | Tavsif |
|---|---|---|
| 400 | Missing required parameters | Majburiy parametrlar to'liq emas |
| 403 | Invalid shop credentials | Shop ID yoki Shop Key noto'g'ri |
| 403 | Shop is not active | Kassa faol emas yoki bloklangan |
| 400 | Amount must be between... | Summa chegaradan tashqarida |
| 400 | Order code already exists | Bu order code avval ishlatilgan |
| 404 | Transaction not found | To'lov topilmadi |
| 503 | Maintenance mode | Tizim texnik ishlar olib bormoqda |
Dasturlash tillarida misollar
import requests
import hashlib
import time
class PayferAPI:
def __init__(self, shop_id, shop_key):
self.shop_id = shop_id
self.shop_key = shop_key
self.base_url = "https://api.payfer.uz"
def create_payment(self, amount, order_code):
"""Yangi to'lov yaratish"""
params = {
"method": "create",
"shop_id": self.shop_id,
"shop_key": self.shop_key,
"amount": amount,
"order": order_code
}
response = requests.get(f"{self.base_url}/api", params=params)
return response.json()
def check_payment(self, order_code):
"""To'lov holatini tekshirish"""
params = {
"method": "check",
"shop_id": self.shop_id,
"shop_key": self.shop_key,
"order": order_code
}
response = requests.get(f"{self.base_url}/api", params=params)
return response.json()
# Foydalanish
payfer = PayferAPI("shop_abc123", "xyz789")
result = payfer.create_payment(50000, "ORDER123")
print(result)
<?php
class PayferAPI {
private $shop_id;
private $shop_key;
private $base_url = "https://api.payfer.uz";
public function __construct($shop_id, $shop_key) {
$this->shop_id = $shop_id;
$this->shop_key = $shop_key;
}
public function createPayment($amount, $order_code) {
$params = [
"method" => "create",
"shop_id" => $this->shop_id,
"shop_key" => $this->shop_key,
"amount" => $amount,
"order" => $order_code
];
$url = $this->base_url . "/api?" . http_build_query($params);
$response = file_get_contents($url);
return json_decode($response, true);
}
public function checkPayment($order_code) {
$params = [
"method" => "check",
"shop_id" => $this->shop_id,
"shop_key" => $this->shop_key,
"order" => $order_code
];
$url = $this->base_url . "/api?" . http_build_query($params);
$response = file_get_contents($url);
return json_decode($response, true);
}
}
// Foydalanish
$payfer = new PayferAPI("shop_abc123", "xyz789");
$result = $payfer->createPayment(50000, "ORDER123");
print_r($result);
?>
class PayferAPI {
constructor(shop_id, shop_key) {
this.shop_id = shop_id;
this.shop_key = shop_key;
this.base_url = "https://api.payfer.uz";
}
async createPayment(amount, order_code) {
const params = new URLSearchParams({
method: "create",
shop_id: this.shop_id,
shop_key: this.shop_key,
amount: amount,
order: order_code
});
const response = await fetch(`${this.base_url}/api?${params}`);
return await response.json();
}
async checkPayment(order_code) {
const params = new URLSearchParams({
method: "check",
shop_id: this.shop_id,
shop_key: this.shop_key,
order: order_code
});
const response = await fetch(`${this.base_url}/api?${params}`);
return await response.json();
}
}
// Foydalanish
const payfer = new PayferAPI("shop_abc123", "xyz789");
payfer.createPayment(50000, "ORDER123")
.then(result => console.log(result));
const axios = require('axios');
class PayferAPI {
constructor(shop_id, shop_key) {
this.shop_id = shop_id;
this.shop_key = shop_key;
this.base_url = "https://api.payfer.uz";
}
async createPayment(amount, order_code) {
const params = {
method: "create",
shop_id: this.shop_id,
shop_key: this.shop_key,
amount: amount,
order: order_code
};
try {
const response = await axios.get(`${this.base_url}/api`, { params });
return response.data;
} catch (error) {
throw error.response?.data || error.message;
}
}
async checkPayment(order_code) {
const params = {
method: "check",
shop_id: this.shop_id,
shop_key: this.shop_key,
order: order_code
};
try {
const response = await axios.get(`${this.base_url}/api`, { params });
return response.data;
} catch (error) {
throw error.response?.data || error.message;
}
}
}
// Foydalanish
const payfer = new PayferAPI("shop_abc123", "xyz789");
payfer.createPayment(50000, "ORDER123")
.then(console.log)
.catch(console.error);
Webhook
To'lov amalga oshganda sizning serveringizga POST so'rov yuboriladi
Headers
Content-Type: application/json
User-Agent: Payfer-Webhook/1.0
Body
{
"status": "paid",
"order_code": "ORDER123",
"amount": 50000,
"paid_amount": 50001.50,
"paid_at": "2024-01-20T15:25:30Z"
}
Muhim!
Webhook'ingiz 200 OK qaytarishi kerak. Agar xatolik yuz bersa, Payfer 3 marta qayta urinadi.