Metadata-Version: 2.4
Name: univapay-client-sdk
Version: 1.1.0
Summary: Use the Univapay Payments Client SDK to create & manage payments
Author-email: Univapay Developers <dev@univapay.com>
Project-URL: Documentation, https://docs.univapay.com
Keywords: Univapay Payments SDK
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: apimatic-core>=0.2.24,~=0.2.0
Requires-Dist: apimatic-core-interfaces>=0.1.8,~=0.1.0
Requires-Dist: apimatic-requests-client-adapter>=0.1.10,~=0.1.0
Requires-Dist: python-dotenv<2.0,>=0.21
Provides-Extra: testutils
Requires-Dist: pytest>=7.2.2; extra == "testutils"
Requires-Dist: pytest-django<5,>=4.5.2; extra == "testutils"
Requires-Dist: Django~=3.2.25; python_version < "3.13" and extra == "testutils"
Requires-Dist: Django~=5.1.3; python_version >= "3.13" and extra == "testutils"
Requires-Dist: Flask~=2.2.5; extra == "testutils"
Requires-Dist: fastapi~=0.95.2; extra == "testutils"
Requires-Dist: httpx~=0.24.1; extra == "testutils"
Requires-Dist: anyio~=3.7.1; extra == "testutils"
Requires-Dist: typing-extensions~=4.7.1; extra == "testutils"
Requires-Dist: Werkzeug<3.0,>=2.2; extra == "testutils"
Dynamic: license-file


# Getting Started with Univapay Public API

## Introduction

OpenAPI specification for the Univapay Online Payment API.

### Authentication (JWT)

This API uses JWT (JSON Web Tokens) for authentication via the HTTP `Authorization` header. To authenticate, you must generate an **Application Token** in the Univapay dashboard.  This generates two components: 1. **Token (`{jwt}`)** 2. **Secret (`{secret}`)**

#### ⚠️ Security Warning

The **Secret** grants extensive privileges (e.g., creating charges, capturing authorized card charges, refunding).
**NEVER expose the `{secret}` in frontend application code** (e.g., consumer browsers) or public repositories. It is strictly for backend server-to-server communication.
*Univapay is not responsible for accidents caused by leaked secrets.*

#### Bearer Auth Formats

Depending on where you are calling the API from, the Bearer format changes:

* **Frontend / Browser (No Secret)**: `Bearer {jwt}`
  *(Used for Widgets or Inline Forms. You must register your allowed domains in the dashboard when creating the token).*
* **Backend / Server (With Secret)**: `Bearer {secret}.{jwt}`
  *(Required for all backend processing).*

We will assume that all requests are going to originate from a backend server thus, all requests will require the secret

#### Token Types

* **Store Token**: Grants full access to requests for that specific store.
* **Merchant Token**: Can't create transaction tokens but can access data from multiple stores.

## Install the Package

The package is compatible with Python versions `3.7+`.
Install the package from PyPi using the following pip command:

```bash
pip install univapay-client-sdk==1.1.0
```

You can also view the package at:
https://pypi.python.org/pypi/univapay-client-sdk/1.1.0

## Test the SDK

You can test the generated SDK and the server with test cases. `unittest` is used as the testing framework and `pytest` is used as the test runner. You can run the tests as follows:

Navigate to the root directory of the SDK and run the following commands


pip install -r test-requirements.txt
pytest


## Initialize the API Client

**_Note:_** Documentation for the client can be found [here.](doc/client.md)

The following parameters are configurable for the API Client:

| Parameter | Type | Description |
|  --- | --- | --- |
| base_url | `str` | Base URL for the API<br>*Default*: `"https://api.univapay.com"` |
| direct_debit_base_url | `str` | Base URL for the Direct Debit API<br>*Default*: `"https://direct-debit.gopay-services.com"` |
| environment | [`Environment`](README.md#environments) | The API environment. <br> **Default: `Environment.PRODUCTION`** |
| http_client_instance | `Union[Session, HttpClientProvider]` | The Http Client passed from the sdk user for making requests |
| override_http_client_configuration | `bool` | The value which determines to override properties of the passed Http Client from the sdk user |
| http_call_back | `HttpCallBack` | The callback value that is invoked before and after an HTTP call is made to an endpoint |
| timeout | `float` | The value to use for connection timeout. <br> **Default: 30** |
| max_retries | `int` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
| backoff_factor | `float` | A backoff factor to apply between attempts after the second try. <br> **Default: 2** |
| retry_statuses | `Array of int` | The http statuses on which retry is to be done. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
| retry_methods | `Array of string` | The http methods on which retry is to be done. <br> **Default: ["GET", "PUT", "GET", "PUT"]** |
| proxy_settings | [`ProxySettings`](doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
| logging_configuration | [`LoggingConfiguration`](doc/logging-configuration.md) | The SDK logging configuration for API calls |
| bearer_auth_credentials | [`BearerAuthCredentials`](doc/auth/oauth-2-bearer-token.md) | The credential object for OAuth 2 Bearer token |

The API client can be initialized as follows:

### Code-Based Client Initialization

```python
import logging

from univapayclientsdk.configuration import Environment
from univapayclientsdk.http.auth.oauth_2 import BearerAuthCredentials
from univapayclientsdk.logging.configuration.api_logging_configuration import LoggingConfiguration
from univapayclientsdk.logging.configuration.api_logging_configuration import RequestLoggingConfiguration
from univapayclientsdk.logging.configuration.api_logging_configuration import ResponseLoggingConfiguration
from univapayclientsdk.univapay_client_sdk_client import UnivapayClientSdkClient

client = UnivapayClientSdkClient(
    bearer_auth_credentials=BearerAuthCredentials(
        access_token='AccessToken'
    ),
    environment=Environment.PRODUCTION,
    base_url='https://api.univapay.com',
    direct_debit_base_url='https://direct-debit.gopay-services.com',
    logging_configuration=LoggingConfiguration(
        log_level=logging.INFO,
        request_logging_config=RequestLoggingConfiguration(
            log_body=True
        ),
        response_logging_config=ResponseLoggingConfiguration(
            log_headers=True
        )
    )
)
```

### Environment-Based Client Initialization

```python
from univapayclientsdk.univapay_client_sdk_client import UnivapayClientSdkClient

# Specify the path to your .env file if it’s located outside the project’s root directory.
client = UnivapayClientSdkClient.from_environment(dotenv_path='/path/to/.env')
```

See the [Environment-Based Client Initialization](doc/environment-based-client-initialization.md) section for details.

## Environments

The SDK can be configured to use a different environment for making API calls. Available environments are:

### Fields

| Name | Description |
|  --- | --- |
| PRODUCTION | **Default** Production Server |

## Authorization

This API uses the following authentication schemes.

* [`JWT_TOKEN (OAuth 2 Bearer token)`](doc/auth/oauth-2-bearer-token.md)

## List of APIs

* [Transaction Tokens](doc/controllers/transaction-tokens.md)
* [Direct Debit](doc/controllers/direct-debit.md)
* [Transaction History](doc/controllers/transaction-history.md)
* [Charges](doc/controllers/charges.md)
* [Refunds](doc/controllers/refunds.md)
* [Subscriptions](doc/controllers/subscriptions.md)
* [Cancels](doc/controllers/cancels.md)
* [Merchants](doc/controllers/merchants.md)
* [Stores](doc/controllers/stores.md)
* [Webhooks](doc/controllers/webhooks.md)
* [Checkout](doc/controllers/checkout.md)

## Webhooks

* [Charge](doc/events/webhooks/charge-handler.md)
* [Token](doc/events/webhooks/token-handler.md)
* [Refund](doc/events/webhooks/refund-handler.md)
* [Cancel](doc/events/webhooks/cancel-handler.md)
* [Subscription](doc/events/webhooks/subscription-handler.md)
* [Bank-Transfer](doc/events/webhooks/bank-transfer-handler.md)
* [Customs](doc/events/webhooks/customs-handler.md)

## SDK Infrastructure

### Configuration

* [ProxySettings](doc/proxy-settings.md)
* [Environment-Based Client Initialization](doc/environment-based-client-initialization.md)
* [AbstractLogger](doc/abstract-logger.md)
* [LoggingConfiguration](doc/logging-configuration.md)
* [RequestLoggingConfiguration](doc/request-logging-configuration.md)
* [ResponseLoggingConfiguration](doc/response-logging-configuration.md)

### HTTP

* [HttpResponse](doc/http-response.md)
* [HttpRequest](doc/http-request.md)
* [Request](doc/request.md)

### Utilities

* [ApiResponse](doc/api-response.md)
* [ApiHelper](doc/api-helper.md)
* [HttpDateTime](doc/http-date-time.md)
* [RFC3339DateTime](doc/rfc3339-date-time.md)
* [UnixDateTime](doc/unix-date-time.md)

