> For the complete documentation index, see [llms.txt](https://docs.hyperswitch.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperswitch.io/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python.md).

# Python SDK Overview

## 🎯 What is Prism?

Today, integrating multiple payment processors either makes developers running in circles with AI agents to recreate integrations from specs, or developers spending months of engineering effort.

Because every payment processor has diverse APIs, error codes, authentication methods, pdf documents to read, and above all - different behaviour in the actual environment when compared to documented specs. All this rests as tribal or undocumented knowledge making it harder AI agents which are very good at implementing clearly documented specification.

**Prism is a stateless, unified connector library for AI agents and Developers to connect with any payment processor**

**Prism offers hardened transformation through testing on payment processor environment & iterative bug fixing**

**Prism can be embedded in you server application with its wide range of multi-language SDKs, or run as a rRPC microservice**

| ❌ Without Prism                                        | ✅ With Prism                        |
| ------------------------------------------------------ | ----------------------------------- |
| 🗂️ 100+ different API schemas                         | 📋 Single unified schema            |
| ⏳ Never ending agent loops/ months of integration work | ⚡ Hours to integrate, Agent driven  |
| 🔗 Brittle, provider-specific code                     | 🔓 Portable, provider-agnostic code |
| 🚫 Hard to switch providers                            | 🔄 Change providers in 1 line       |

## Installation

```bash
pip install hyperswitch_prism
```

## Quick Start

```python
from hyperswitch_prism import PaymentClient

payment_client = PaymentClient(
    connector='stripe',
    api_key='YOUR_API_KEY',
    environment='SANDBOX'
)

# Authorize a payment
response = await payment_client.authorize({
    "merchant_transaction_id": "txn_order_001",
    "amount": {
        "minor_amount": 1000,
        "currency": "USD"
    },
    "payment_method": {
        "card": {
            "card_number": {"value": "4242424242424242"},
            "card_exp_month": {"value": "12"},
            "card_exp_year": {"value": "2027"},
            "card_cvc": {"value": "123"},
            "card_holder_name": {"value": "John Doe"}
        }
    },
    "auth_type": "NO_THREE_DS"
})

print(response["status"])  # AUTHORIZED
```

## Services

| Service                                                                                                                                       | Description                                       |
| --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| [Payment Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/payment-service.md)                                             | Process payments from authorization to settlement |
| [Recurring Payment Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/recurring-payment-service.md)                         | Manage subscriptions and recurring billing        |
| [Refund Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/refund-service.md)                                               | Retrieve and track refund statuses                |
| [Dispute Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/dispute-service.md)                                             | Handle chargebacks and disputes                   |
| [Event Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/event-service.md)                                                 | Process webhook notifications                     |
| [Payment Method Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/payment-method-service.md)                               | Store and manage payment methods                  |
| [Customer Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/customer-service.md)                                           | Manage customer profiles                          |
| [Merchant Authentication Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/merchant-authentication-service.md)             | Generate access tokens                            |
| [Payment Method Authentication Service](/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python/payment-method-authentication-service.md) | 3D Secure authentication                          |
| [Payout Service](https://github.com/juspay/hyperswitch-docs/blob/main/integration-space/prism/sdks/python/payout-service/README.md)           | Send funds to recipients                          |

## Configuration

| Option        | Type | Required | Description                                  |
| ------------- | ---- | -------- | -------------------------------------------- |
| `connector`   | str  | Yes      | Payment connector name (stripe, adyen, etc.) |
| `api_key`     | str  | Yes      | Your API key                                 |
| `environment` | str  | Yes      | SANDBOX or PRODUCTION                        |
| `timeout`     | int  | No       | Request timeout in seconds (default: 30)     |

## Error Handling

```python
from hyperswitch_prism.exceptions import PaymentDeclined, ValidationError

try:
    response = await payment_client.authorize(request)
except PaymentDeclined as e:
    # Handle declined payment
    print(f"Payment declined: {e.message}")
except ValidationError as e:
    # Handle validation error
    print(f"Validation error: {e.errors}")
except HyperswitchError as e:
    # Handle other errors
    print(f"Error: {e.message}")
```

## Support

For support and documentation, visit <https://docs.hyperswitch.io>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hyperswitch.io/integrations/~/revisions/ZvEM9fIqChWsb1sRGPnD/prism/python.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
