Skip to main content

Payme Software Development Kit

Support Group on Telegram

PyPI - Downloads

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.

Watch the YouTube Demo

Installation

pip install payme-pkg

No license key. Since 3.4.0 payme-pkg is fully open source under the MIT license — there is no PAYTECH_LICENSE_API_KEY and no license_api_key argument any more. Upgrading from 3.3.x? Delete both; every public import stays the same. See the changelog.

Table of Contents

Django Integration

Add 'payme' in to your settings.py

INSTALLED_APPS = [
    ...
    'payme',
    ...
]

Add 'payme' credentials inside to settings.py

One time payment (Однаразовый платеж) configuration settings.py

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 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 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.

Metadata

Release files for payme-pkg 3.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for payme-pkg 3.4.0
File Size Uploaded
payme_pkg-3.4.0.tar.gz 27.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for payme-pkg 3.4.0
File Interpreter ABI Platform
payme_pkg-3.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.5 kB

Release files / payme_pkg-3.4.0.tar.gz

Download URL payme_pkg-3.4.0.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e98288ec7313362b4597f734008cb0ab8eee2422945827553540890b57029b51
BLAKE2b-256 checksum
How to use checksums
5ff5f1d4aa0b996dd9025dfc9520b1bb99950a74d957b20f86c924459ce8624d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / payme_pkg-3.4.0-py3-none-any.whl

Download URL payme_pkg-3.4.0-py3-none-any.whl
Size 31.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44dd37b622dfe50226360b6b22f027e862dce364f38f81bb4e709f300557bca5
BLAKE2b-256 checksum
How to use checksums
f702a635c00b1237b67d884705091c17e9429a06c54eae199703b4bc0ca937a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page