No project description provided
Project description
Payme Software Development Kit
Welcome to payme-pkg, the Payme SDK for Python.
You can use it for test and production mode. Join our community and ask everything you need.
Installation
pip install payme-pkg
Table of Contents
- Installation
- Django Integration
- Payme Client SDK
Django Integration
Add 'payme' in to your settings.py
INSTALLED_APPS = [
...
'payme',
...
]
License API Key Configuration
Set your license API key using one of the following methods (get your key at https://docs.pay-tech.uz/console or contact @muhammadali_me on Telegram):
Option 1: Django Settings (Recommended)
Add the key directly in your settings.py:
PAYTECH_LICENSE_API_KEY = "your-license-api-key-here"
Option 2: Environment Variable
Set the key as an environment variable or in your .env file:
export PAYTECH_LICENSE_API_KEY="your-license-api-key-here"
Or add it to your .env file:
PAYTECH_LICENSE_API_KEY=your-license-api-key-here
Note: The SDK searches for the API key in the following order:
- Django settings (
settings.PAYTECH_LICENSE_API_KEY)- Environment variable /
.envfile (PAYTECH_LICENSE_API_KEY)If the key is not found in either location, an error will be raised with instructions on how to configure it.
One Time Payment Configuration
One time payment (Однаразовый платеж) configuration settings.py
Example project: https://github.com/PayTechUz/shop-backend
PAYME_ID = "your-payme-id"
PAYME_KEY = "your-payme-key"
PAYME_ACCOUNT_FIELD = "order_id"
PAYME_AMOUNT_FIELD = "total_amount"
PAYME_ACCOUNT_MODEL = "orders.models.Orders"
PAYME_ONE_TIME_PAYMENT = True
PAYME_DISABLE_ADMIN = False # (optionally configuration if you want to disable change to True)
Create a new View that about handling call backs
from payme.views import PaymeWebHookAPIView
class PaymeCallBackAPIView(PaymeWebHookAPIView):
def handle_successfully_payment(self, params, result, *args, **kwargs):
"""
Handle the successful payment. You can override this method
"""
print(f"Transaction successfully performed for this params: {params} and performed_result: {result}")
def handle_cancelled_payment(self, params, result, *args, **kwargs):
"""
Handle the cancelled payment. You can override this method
"""
print(f"Transaction cancelled for this params: {params} and cancelled_result: {result}")
Add a payme path to core of urlpatterns:
from django.urls import path
from django.urls import include
from your_app.views import PaymeCallBackAPIView
urlpatterns = [
...
path("payment/update/", PaymeCallBackAPIView.as_view()),
...
]
Run migrations
python manage.py migrate
🎉 Congratulations you have been integrated merchant api methods with django, keep reading docs. After successfull migrations check your admin panel and see results what happened.
Payme Client SDK
The Payme SDK provides a unified client interface for working with all Payme services.
Initialization
Initialize the Payme client with your credentials:
from payme import Payme
# Basic initialization (for Cards API and Payment Links)
payme = Payme(
payme_id="your-payme-id",
is_test_mode=True, # Optional: defaults to False
)
# Full initialization (for all features including Receipts API)
payme = Payme(
payme_id="your-payme-id",
payme_key="your-payme-key", # Required for Receipts API
is_test_mode=True,
)
Cards API
Manage card tokenization and verification.
Create Card
Create a new card token.
response = payme.cards_create(
number="8600495473316478",
expire="0399", # MMYY format
save=True, # Optional: save card for future use
timeout=10 # Optional: request timeout in seconds
)
print(response.result.card.token) # Card token
print(response.result.card.number) # Masked card number
Get Verify Code
Request a verification code for a card.
response = payme.cards_get_verify_code(
token="card-token",
timeout=10
)
print(response.result.sent) # True if code was sent
print(response.result.phone) # Phone number where code was sent
Verify Card
Verify a card with the code received via SMS.
response = payme.cards_verify(
token="card-token",
code="666666", # Code from SMS
timeout=10
)
print(response.result.card.verify) # True if verified
Check Card
Check the status of a card.
response = payme.cards_check(
token="card-token",
timeout=10
)
print(response.result.card.verify) # Verification status
Remove Card
Remove a card token.
response = payme.cards_remove(
token="card-token",
timeout=10
)
print(response.result.success) # True if removed
Test Cards
Run comprehensive tests for card operations.
payme.cards_test()
Receipts API
Manage payment receipts (requires payme_key).
Create Receipt
Create a new payment receipt.
response = payme.receipts_create(
account={"order_id": 12345},
amount=50000, # Amount in tiyins (50000 tiyins = 500 UZS)
description="Payment for order #12345", # Optional
detail={ # Optional
"items": [
{"name": "Product 1", "price": 25000, "quantity": 1},
{"name": "Product 2", "price": 25000, "quantity": 1}
]
},
timeout=10
)
print(response.result.receipt._id) # Receipt ID
Pay Receipt
Pay a receipt using a card token.
response = payme.receipts_pay(
receipts_id="receipt-id",
token="card-token",
timeout=10
)
print(response.result.receipt.state) # Payment state (4 = paid)
Send Receipt
Send receipt details to a phone number.
response = payme.receipts_send(
receipts_id="receipt-id",
phone="998901234567",
timeout=10
)
print(response.result.success) # True if sent
Cancel Receipt
Cancel a receipt.
response = payme.receipts_cancel(
receipts_id="receipt-id",
timeout=10
)
print(response.result.receipt.state) # State (50 = cancelled)
Check Receipt
Check the status of a receipt.
response = payme.receipts_check(
receipts_id="receipt-id",
timeout=10
)
print(response.result.state) # Current state
Get Receipt
Get detailed information about a specific receipt.
response = payme.receipts_get(
receipts_id="receipt-id",
timeout=10
)
print(response.result.receipt) # Receipt details
Get All Receipts
Get all receipts within a time range.
response = payme.receipts_get_all(
count=10, # Number of receipts to retrieve
from_=1609459200000, # Start timestamp (milliseconds)
to=1640995200000, # End timestamp (milliseconds)
offset=0, # Pagination offset
timeout=10
)
for receipt in response.result:
print(receipt._id, receipt.amount)
Set Fiscal Data
Set fiscal data for a receipt.
response = payme.receipts_set_fiscal_data(
receipt_id="receipt-id",
qr_code_url="https://ofd.uz/check?t=123&s=456&r=789&c=2024",
timeout=10
)
print(response.result.success) # True if set
Test Receipts
Run comprehensive tests for receipt operations.
payme.receipts_test()
Payment Initialization
Generate payment links for customers.
Generate Pay Link
Generate a payment link for checkout.
pay_link = payme.generate_pay_link(
id=12345, # Account ID
amount=5000, # Amount in UZS (will be converted to tiyins)
return_url="https://example.com/success"
)
print(pay_link)
# Output: https://checkout.paycom.uz/bT1...
Generate Fallback Link
Generate a fallback payment link with custom form fields.
fallback_link = payme.generate_fallback_link(
form_fields={ # Optional
"driver_id": 12345,
"amount": 1000
}
)
print(fallback_link)
# Output: https://payme.uz/fallback/merchant/?id=...&driver_id=12345&amount=1000
Note: The fallback ID is different from the merchant ID. Contact the Payme team to get your fallback ID.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file payme_pkg-3.3.2.tar.gz.
File metadata
- Download URL: payme_pkg-3.3.2.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7d9aaa941a649f85841b2eae5aa11a260c581fbdf120323ed8af6cea10a1741
|
|
| MD5 |
bd450f5eac10f08f40e8325b597543a3
|
|
| BLAKE2b-256 |
3bf0cd17e2298412136fe9aa6deabbfbe12db5afe9f3b89986da305cd33098a3
|
File details
Details for the file payme_pkg-3.3.2-cp312-cp312-macosx_10_13_universal2.whl.
File metadata
- Download URL: payme_pkg-3.3.2-cp312-cp312-macosx_10_13_universal2.whl
- Upload date:
- Size: 809.1 kB
- Tags: CPython 3.12, macOS 10.13+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1de500a54d3ab2c1d299d7fe46d7d75ec8fd8d995c36155ce058177857892219
|
|
| MD5 |
1d67ef6d6e51cb2d04a00f76c52f9a3c
|
|
| BLAKE2b-256 |
347f467231f9b5fa0a3ee04b5b2c9baa6ec65a74c72b2ab570037dd19f84b879
|