---
title: Auto Payment (card tokenization & recurring)
description: Card tokenization and recurring payments with the PayTechUZ Python SDK — save a card once, then charge it automatically on Payme and Click.
source: https://pay-tech.uz/en/docs/python-sdk
---

# Auto Payment

The PayTechUZ SDK provides a unified Framework integration for handling Auto Payments (Card tokenization and recurrent payments).

## Payme

### Cards

You can manage saved cards using the `cards` property of the `PaymeGateway` instance.

```python
from paytechuz.gateways.payme import PaymeGateway


# Initialize Payme gateway
payme = PaymeGateway(
    payme_id="your_payme_id",
    payme_key="your_payme_key",
    is_test_mode=True
)

# 1. Create a new card
# This will return a token that needs to be verified
create_response = payme.cards.create(
    card_number="8600000000000000",
    expire_date="12/25",
    save=True  # Set to True to save the card for future use
)
print(create_response)

# 2. Get verification code (if not received automatically)
payme.cards.get_verify_code(token="card_token")

# 3. Verify the card with the code sent to the user via SMS
verify_response = payme.cards.verify(
    token="card_token",
    code="123456"
)
print(verify_response)

# 4. Check card status
check_response = payme.cards.check(token="card_token")
print(check_response)

# 5. Remove a saved card
payme.cards.remove(token="card_token")
```

### Receipts

You can manage receipts using the `receipts` property of the `PaymeGateway` instance.

```python
from paytechuz.gateways.payme import PaymeGateway

# Initialize Payme gateway
payme = PaymeGateway(
    payme_id="your_payme_id",
    payme_key="your_payme_key",
    is_test_mode=True
)

# 1. Create a receipt
create_response = payme.receipts.create(
    amount=100000, # 1000 sum (in tiyin)
    account={"order_id": "12345"},
    description="Payment for order #12345"
)
print(create_response)

# 2. Pay a receipt with a saved card
pay_response = payme.receipts.pay(
    receipt_id="receipt_id",
    token="card_token_here"
)
print(pay_response)

# 3. Check receipt status
check_response = payme.receipts.check(receipt_id="receipt_id")
print(check_response)

# 4. Send receipt to phone number (SMS)
send_response = payme.receipts.send(
    receipt_id="receipt_id",
    phone="998901234567"
)
print(send_response)

# 5. Cancel a receipt
cancel_response = payme.receipts.cancel(
    receipt_id="receipt_id",
    reason="Refund requested"
)
print(cancel_response)
```

## Click

### Cards

Click supports card tokenization via the standardized `cards` property.

```python
from paytechuz.gateways.click import ClickGateway

# Initialize Click gateway
click = ClickGateway(
    service_id="your_service_id",
    merchant_id="your_merchant_id",
    merchant_user_id="your_merchant_user_id",
    secret_key="your_secret_key",
    is_test_mode=True
)

# 1. Request a card token
# This returns a temporary token and sends SMS to the user
token_response = click.cards.create(
    card_number="8600000000000000",
    expire_date="0330",  # MMYY format
    save=True  # Same as Payme! (maps to temporary=0)
)
print(token_response)

# 2. Verify the card token
verify_response = click.cards.verify(
    card_token="card_token",
    sms_code="12345"
)
print(verify_response)

# 3. Make a payment with the verified token
payment_response = click.cards.pay(
    card_token=card_token,
    amount=50000,
    transaction_parameter="order_123"
)
print(payment_response)
```

### Invoices

You can manage invoices using the `invoices` property (or `receipts` alias) of the `ClickGateway` instance.

```python
# 1. Create an invoice
invoice_response = click.invoices.create(
    id="order_123",
    amount=150000,
    phone="998901234567",
    description="Payment for order #123"
)
print(invoice_response)

# 2. Check invoice status
status_response = click.invoices.check(invoice_id="invoice_id")
print(status_response)

# 3. Cancel an invoice
cancel_response = click.invoices.cancel(
    invoice_id="invoice_id",
    reason="Order cancelled"
)
print(cancel_response)
```
