> ## Documentation Index
> Fetch the complete documentation index at: https://developers.uqpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authorization decision

> Handle PGP-encrypted card authorization decisions with the Python SDK.

Authorization decision lets your integration approve or decline card transactions in real time. The SDK decrypts the request from UQPAY, invokes your decision function, and encrypts your response.

Before implementing the handler, review the [authorization decision workflow, prerequisites, response codes, and timeout requirements](/card-issuance/v1.6/guide/authorization-decisions).

```python theme={null}
from uqpay.crypto import generate_auth_decision_key_pair

# Generate a key pair once and store securely
keys = generate_auth_decision_key_pair(name="MyApp", email="ops@example.com")

# Configure at startup
client.issuing.auth_decision.configure(
    private_key=keys["private_key"],
    uqpay_public_key="<UQPAY public key from dashboard>",
)

# Define your decision function
def decide(transaction: dict) -> dict:
    if transaction.get("amount", 0) > 10000:
        return {"response_code": "05"}  # Decline
    return {"response_code": "00", "partner_reference_id": "ref-001"}

# In your HTTP handler:
encrypted_response = client.issuing.auth_decision.handle(
    body=request.get_data(),
    headers=dict(request.headers),
    decide=decide,
)
```

Store private keys and passphrases in a secret manager or environment variable. Never commit them to source control.
