paymentus-auth


Namepaymentus-auth JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryPaymentus Python Auth SDK
upload_time2025-08-12 12:30:28
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords paymentus auth authentication authorization jwt api sdk access token
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Paymentus Auth

Authentication client for Paymentus API services. This package handles JWT token management and authentication for Paymentus API endpoints.

## Installation

```bash
pip install paymentus-auth
```

## Usage

### Basic Usage

```python
import asyncio
from paymentus_auth import Auth, AuthConfig

async def main():
    # Initialize the auth client
    auth_config = AuthConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        scope=['xotp'],  # Base scopes
        tla='ABC'
    )

    auth_client = Auth(auth_config)

    # Fetch a token
    token = await auth_client.fetch_token()
    print(f"Token: {token}")
    
    # Check if token is expired
    is_token_expired = auth_client.is_token_expired()
    print(f"Token Expired: {is_token_expired}")
    
    # Get current token
    current_token = auth_client.get_current_token()
    print(f"Current Token: {current_token}")

asyncio.run(main())
```

## Configuration Options

The `Auth` constructor accepts the following configuration:

| Option | Type | Required | Description |
|--------|------|----------|-------------|
| `base_url` | string | Yes | Base URL for the Paymentus API, it varies based on the environment biller is in |
| `pre_shared_key` | string | Yes | Pre-shared key for JWT signing |
| `scope` | string[] | Yes | Array of API scopes (e.g., ['xotp', 'xotp:profile']) |
| `tla` | string | Yes | Three-letter acronym for your application |
| `aud` | string | No | Audience claim for the JWT (optional) |
| `timeout` | number | No | Request timeout in milliseconds (default: 5000) |
| `user_login` | string | No | User login identifier |
| `pm_token` | string[] | No | Payment method tokens |
| `payments_data` | list | No | Payment data for the transaction |

## Available Scopes

The SDK supports the following scopes:

- `xotp` - Basic XOTP functionality
- `xotp:profile` - Profile management
- `xotp:profile:read` - Read profile data
- `xotp:profile:create` - Create profiles
- `xotp:profile:update` - Update profiles
- `xotp:profile:delete` - Delete profiles
- `xotp:listProfiles` - List profiles
- `xotp:payment` - Payment processing
- `xotp:autopay` - Autopay functionality
- `xotp:autopay:delete` - Delete autopay settings
- `xotp:accounts` - Account management
- `xotp:accounts:listAccounts` - List accounts

## Error Handling

The package throws specific error types for different scenarios:

```python
from paymentus_auth.errors import ConfigurationError, TokenError, NetworkError

try:
    token = await auth_client.fetch_token()
except ConfigurationError as e:
    print(f"Configuration Error: {e}")
except TokenError as e:
    print(f"Token Error: {e}")
except NetworkError as e:
    print(f"Network Error: {e}")
```

## Advanced Usage

### Using Multiple Scopes

```python
import asyncio
from paymentus_auth import Auth, AuthConfig

async def main():
    auth_config = AuthConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        scope=['xotp:profile', 'xotp:payment'],  # Multiple scopes
        tla='ABC',
        aud='WEB_SDK'
    )
    
    auth_client = Auth(auth_config)
    token = await auth_client.fetch_token()
    print(f"Token: {token}")

asyncio.run(main())
```

### Using Optional Fields

```python
import asyncio
from paymentus_auth import Auth, AuthConfig

async def main():
    auth_config = AuthConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        scope=['xotp'],
        tla='ABC',
        aud='WEB_SDK',
        user_login='user@example.com',
        pm_token=['token1', 'token2'],
        payments_data=[{
            'account_number': '123456',
            'conv_fee_state': 'NY',
            'conv_fee_country': 'US'
        }]
    )
    
    auth_client = Auth(auth_config)
    token = await auth_client.fetch_token()
    print(f"Token: {token}")

asyncio.run(main())
```

## API Reference

### Auth Class

#### Constructor

```python
Auth(config: AuthConfig)
```

Creates a new Auth client instance with the provided configuration.

#### Methods

##### fetch_token()

```python
async fetch_token() -> str
```

Fetches a new JWT token from the Paymentus API. Returns a Promise that resolves to the token string.

##### get_current_token()

```python
get_current_token() -> str or None
```

Returns the current token if available, or None if no token has been fetched.

##### is_token_expired()

```python
is_token_expired() -> bool
```

Returns true if the current token is expired or no token is available.

## Development

### Building

```bash
python -m pip install -e .
```

### Testing

```bash
python -m pytest
```


## Disclaimer

These SDKs are intended for use with the URLs and keys that are provided to you for your company by Paymentus. If you do not have this information, please reach out to your implementation or account manager. If you are interested in learning more about the solutions that Paymentus provides, you can visit our website at paymentus.com. You can request access to our complete documentation at developer.paymentus.io. If you are currently not a customer or partner and would like to learn more about the solution and how you can get started with Paymentus, please contact us at https://www.paymentus.com/lets-talk/.

## Contact us

If you have any questions or need assistance, please contact us at sdksupport@paymentus.com.

## License

MIT

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "paymentus-auth",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Paymentus SDK Support <sdksupport@paymentus.com>",
    "keywords": "paymentus, auth, authentication, authorization, jwt, api, sdk, access token",
    "author": null,
    "author_email": "Paymentus SDK Support <sdksupport@paymentus.com>",
    "download_url": "https://files.pythonhosted.org/packages/48/de/343fae4831496ee054fd60f77166101527f7ddc33bdd14e57da69ae6d46f/paymentus_auth-1.0.0.tar.gz",
    "platform": null,
    "description": "# Paymentus Auth\n\nAuthentication client for Paymentus API services. This package handles JWT token management and authentication for Paymentus API endpoints.\n\n## Installation\n\n```bash\npip install paymentus-auth\n```\n\n## Usage\n\n### Basic Usage\n\n```python\nimport asyncio\nfrom paymentus_auth import Auth, AuthConfig\n\nasync def main():\n    # Initialize the auth client\n    auth_config = AuthConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        scope=['xotp'],  # Base scopes\n        tla='ABC'\n    )\n\n    auth_client = Auth(auth_config)\n\n    # Fetch a token\n    token = await auth_client.fetch_token()\n    print(f\"Token: {token}\")\n    \n    # Check if token is expired\n    is_token_expired = auth_client.is_token_expired()\n    print(f\"Token Expired: {is_token_expired}\")\n    \n    # Get current token\n    current_token = auth_client.get_current_token()\n    print(f\"Current Token: {current_token}\")\n\nasyncio.run(main())\n```\n\n## Configuration Options\n\nThe `Auth` constructor accepts the following configuration:\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `base_url` | string | Yes | Base URL for the Paymentus API, it varies based on the environment biller is in |\n| `pre_shared_key` | string | Yes | Pre-shared key for JWT signing |\n| `scope` | string[] | Yes | Array of API scopes (e.g., ['xotp', 'xotp:profile']) |\n| `tla` | string | Yes | Three-letter acronym for your application |\n| `aud` | string | No | Audience claim for the JWT (optional) |\n| `timeout` | number | No | Request timeout in milliseconds (default: 5000) |\n| `user_login` | string | No | User login identifier |\n| `pm_token` | string[] | No | Payment method tokens |\n| `payments_data` | list | No | Payment data for the transaction |\n\n## Available Scopes\n\nThe SDK supports the following scopes:\n\n- `xotp` - Basic XOTP functionality\n- `xotp:profile` - Profile management\n- `xotp:profile:read` - Read profile data\n- `xotp:profile:create` - Create profiles\n- `xotp:profile:update` - Update profiles\n- `xotp:profile:delete` - Delete profiles\n- `xotp:listProfiles` - List profiles\n- `xotp:payment` - Payment processing\n- `xotp:autopay` - Autopay functionality\n- `xotp:autopay:delete` - Delete autopay settings\n- `xotp:accounts` - Account management\n- `xotp:accounts:listAccounts` - List accounts\n\n## Error Handling\n\nThe package throws specific error types for different scenarios:\n\n```python\nfrom paymentus_auth.errors import ConfigurationError, TokenError, NetworkError\n\ntry:\n    token = await auth_client.fetch_token()\nexcept ConfigurationError as e:\n    print(f\"Configuration Error: {e}\")\nexcept TokenError as e:\n    print(f\"Token Error: {e}\")\nexcept NetworkError as e:\n    print(f\"Network Error: {e}\")\n```\n\n## Advanced Usage\n\n### Using Multiple Scopes\n\n```python\nimport asyncio\nfrom paymentus_auth import Auth, AuthConfig\n\nasync def main():\n    auth_config = AuthConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        scope=['xotp:profile', 'xotp:payment'],  # Multiple scopes\n        tla='ABC',\n        aud='WEB_SDK'\n    )\n    \n    auth_client = Auth(auth_config)\n    token = await auth_client.fetch_token()\n    print(f\"Token: {token}\")\n\nasyncio.run(main())\n```\n\n### Using Optional Fields\n\n```python\nimport asyncio\nfrom paymentus_auth import Auth, AuthConfig\n\nasync def main():\n    auth_config = AuthConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        scope=['xotp'],\n        tla='ABC',\n        aud='WEB_SDK',\n        user_login='user@example.com',\n        pm_token=['token1', 'token2'],\n        payments_data=[{\n            'account_number': '123456',\n            'conv_fee_state': 'NY',\n            'conv_fee_country': 'US'\n        }]\n    )\n    \n    auth_client = Auth(auth_config)\n    token = await auth_client.fetch_token()\n    print(f\"Token: {token}\")\n\nasyncio.run(main())\n```\n\n## API Reference\n\n### Auth Class\n\n#### Constructor\n\n```python\nAuth(config: AuthConfig)\n```\n\nCreates a new Auth client instance with the provided configuration.\n\n#### Methods\n\n##### fetch_token()\n\n```python\nasync fetch_token() -> str\n```\n\nFetches a new JWT token from the Paymentus API. Returns a Promise that resolves to the token string.\n\n##### get_current_token()\n\n```python\nget_current_token() -> str or None\n```\n\nReturns the current token if available, or None if no token has been fetched.\n\n##### is_token_expired()\n\n```python\nis_token_expired() -> bool\n```\n\nReturns true if the current token is expired or no token is available.\n\n## Development\n\n### Building\n\n```bash\npython -m pip install -e .\n```\n\n### Testing\n\n```bash\npython -m pytest\n```\n\n\n## Disclaimer\n\nThese SDKs are intended for use with the URLs and keys that are provided to you for your company by Paymentus. If you do not have this information, please reach out to your implementation or account manager. If you are interested in learning more about the solutions that Paymentus provides, you can visit our website at paymentus.com. You can request access to our complete documentation at developer.paymentus.io. If you are currently not a customer or partner and would like to learn more about the solution and how you can get started with Paymentus, please contact us at https://www.paymentus.com/lets-talk/.\n\n## Contact us\n\nIf you have any questions or need assistance, please contact us at sdksupport@paymentus.com.\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Paymentus Python Auth SDK",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://www.paymentus.com/",
        "Source": "https://developer.paymentus.io/"
    },
    "split_keywords": [
        "paymentus",
        " auth",
        " authentication",
        " authorization",
        " jwt",
        " api",
        " sdk",
        " access token"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "19b03327b75eda05849a194763e56f36d8767e89d7f6d0fb3819270d1deb800c",
                "md5": "a1062eb6ceffb2898679b6205082ab4b",
                "sha256": "6befe212cc937671765c8b06ce79616a41549fc36064600c74e390ac485018dd"
            },
            "downloads": -1,
            "filename": "paymentus_auth-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a1062eb6ceffb2898679b6205082ab4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 7075,
            "upload_time": "2025-08-12T12:30:27",
            "upload_time_iso_8601": "2025-08-12T12:30:27.724168Z",
            "url": "https://files.pythonhosted.org/packages/19/b0/3327b75eda05849a194763e56f36d8767e89d7f6d0fb3819270d1deb800c/paymentus_auth-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "48de343fae4831496ee054fd60f77166101527f7ddc33bdd14e57da69ae6d46f",
                "md5": "85ae018f8f7f2854ba9d62edfd6596d2",
                "sha256": "b9ce3fdfb4afeb7b9706ba252e77f4ed68fa53859e324affcc49762b03d8eed2"
            },
            "downloads": -1,
            "filename": "paymentus_auth-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "85ae018f8f7f2854ba9d62edfd6596d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 10161,
            "upload_time": "2025-08-12T12:30:28",
            "upload_time_iso_8601": "2025-08-12T12:30:28.945698Z",
            "url": "https://files.pythonhosted.org/packages/48/de/343fae4831496ee054fd60f77166101527f7ddc33bdd14e57da69ae6d46f/paymentus_auth-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-12 12:30:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "paymentus-auth"
}
        
Elapsed time: 0.54177s