paymentus-core


Namepaymentus-core JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryPaymentus Python Core SDK
upload_time2025-08-12 12:30:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords paymentus core client sdk api http rest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Paymentus Server Python SDK

## What is the Paymentus Server SDK?
The Paymentus Server SDK is a comprehensive Python-based toolkit that simplifies integration with the Paymentus Server-side APIs. Designed for backend services, it enables secure, streamlined access to Paymentus' powerful XOTP platform—including payments, user management, autopay, account inquiries, and more. The SDK abstracts authentication flows, allowing developers to focus on building functionality without managing token lifecycles manually.

## Features

- **Modular Architecture**: Use individual packages or the unified SDK
- **Type Safety**: Full type hints and validation using Pydantic
- **Automatic Token Management**: Seamless JWT token handling (via paymentus-sdk-auth)
- **Error Handling**: Comprehensive error types and messages
- **Configuration Validation**: Runtime validation of configuration options
- **Granular Scope Support**: Targeted API access via granular access scopes
- **XOTP Integration**: Full support for payment API functionality

## Installation

```bash
pip install paymentus-core
```

## Basic Usage

### Using the Core SDK

```python
import asyncio
from paymentus_core import SDK, CoreConfig, AuthOptions

async def main():
    # Create AuthConfig first
    auth_options = AuthOptions(
        scope=['xotp']
    )

    # Create SDK configuration with authConfig
    config = CoreConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        tla='ABC',
        auth=auth_options
    )

    # Initialize SDK
    sdk = SDK(config)

    # Fetch token
    token = await sdk.auth.fetch_token()
    print(f"Token: {token}")
    is_token_expired = sdk.auth.is_token_expired()
    print(f"Token Expired: {is_token_expired}")
    current_token = sdk.auth.get_current_token()
    print(f"Current Token: {current_token}")

asyncio.run(main())
```

### Payment Examples

```python
# Example 1: Make Payment
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions, LoggingOptions
from paymentus_xotp.models import (
    Address, Customer, MakePayment, MakePaymentItem,
    PaymentHeader, PaymentMethod, PaymentMethodTypeEnum,
    CreditCardExpiryDate
)
from paymentus_xotp.logging import LogLevel, Logger, MaskingLevel

async def main():
    # Configure the SDK
    config = CoreConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        tla='ABC',
        auth=AuthOptions(
            scope=['xotp:payment']  # scope needed for payment
        ),
        logging=LoggingOptions(
            logger=Logger, # default logger
            level=LogLevel.VERBOSE, # maximum logging
            masking=MaskingLevel.ALL_PII # mask all sensistive data
        )
    )

    # Initialize SDK
    sdk = SDK(config)

    header1 = PaymentHeader(
        account_number='6759373',
        payment_amount=13.21,
        payment_type_code='UTILITY'
    )

    header2 = PaymentHeader(
        account_number='6759375',
        payment_amount=13.21,
        payment_type_code='WATER'
    )

    payment_method = PaymentMethod(
        type=PaymentMethodTypeEnum.VISA,
        account_number='4111111111111111',
        card_holder_name='John Doe',
        credit_card_expiry_date=CreditCardExpiryDate(
            month=12,
            year=2035
        )
    )

    address = Address(
        line1='10 Fifth Ave.',
        state='NY',
        zip_code='12345',
        city='New York',
        country='US'
    )

    customer = Customer(
        first_name='John',
        last_name='Doe',
        email='john@paymentus.com',
        day_phone_nr='9051112233',
        address=address
    )

    payment_item = MakePaymentItem(
        header=[header1, header2],
        payment_method=payment_method,
        customer=customer
    )

    payment_payload = MakePayment(
        payment=payment_item
    )

    try:
        result = await sdk.xotp.make_payment(payment_payload)
        print(result)

        # ----- Sample Output ------
        #payment_response=PaymentResponseList(response=[PaymentResponseItem(account_number='6759373', convenience_fee=1.5, convenience_fee_country='US', convenience_fee_state='OH', convenience_fee_category_code=None, convenience_fee_percent=None, errors=None, payment_amount=13.21, payment_component=None, payment_date='07192025002237', payment_status=<PaymentStatusTypeEnum.ACCEPTED: 'ACCEPTED'>, payment_status_description='Approved', payment_schedule_status=None, reference_number='734944', status=None, staged_id=None, total_amount=14.71, additional_properties={}), PaymentResponseItem(account_number='6759375', convenience_fee=1.5, convenience_fee_country='US', convenience_fee_state='VA', convenience_fee_category_code=None, convenience_fee_percent=None, errors=None, payment_amount=13.21, payment_component=None, payment_date='07192025002241', payment_status=<PaymentStatusTypeEnum.ACCEPTED: 'ACCEPTED'>, payment_status_description='Approved', payment_schedule_status=None, reference_number='734947', status=None, staged_id=None, total_amount=14.71, additional_properties={})], additional_properties={}) additional_properties={}

    
    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```

```python
# Example 2: Refund Payment
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    Address, Customer, Payment, PaymentHeader,
    PaymentMethod, PaymentMethodTypeEnum,
    CreditCardExpiryDate, PaymentRequest
)

async def main():
    try:
        # Configure the SDK
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            ),
            logging=LoggingOptions(
                level=LogLevel.MINIMAL # minimal logging
            )
        )

        sdk = SDK(config)

        header = PaymentHeader(
            account_number='6759370',
            payment_amount=11.22,
            payment_type_code='UTILITY'
        )

        payment_method = PaymentMethod(
            type=PaymentMethodTypeEnum.VISA_IREFUND,
            account_number='4111111111111111',
            card_holder_name='John Doe',
            credit_card_expiry_date=CreditCardExpiryDate(
                month=12,
                year=2035
            )
        )

        address = Address(
            line1='10 Fifth Ave.',
            state='NY',
            zip_code='12345',
            city='New York',
            country='US'
        )

        customer = Customer(
            first_name='John',
            last_name='Doe',
            email='john@paymentus.com',
            day_phone_nr='9051112233',
            address=address
        )

        payment = Payment(
            header=header,
            payment_method=payment_method,
            customer=customer
        )

        refund_payload = PaymentRequest(payment=payment)
        
        result = await sdk.xotp.refund_payment(refund_payload)
        print(result)
    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```

```python
# Example 3: Payment History
import asyncio
import json

from paymentus_core import SDK, CoreConfig, AuthOptions, LoggingOptions
from paymentus_xotp.models import PaymentSearchRequest
from paymentus_xotp.logging import LogLevel


async def main():
    config = CoreConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        tla='ABC',
        auth=AuthOptions(
            scope=['xotp:payment']
        ),
        logging=LoggingOptions(
            level=LogLevel.SILENT # no logging
        )
    )

    sdk = SDK(config)

    search_payload = PaymentSearchRequest(
        account_number='6759371',  # required
        date_from = "06182025",
        date_to = "06192025"
    )
    try:
        result = await sdk.xotp.get_payment_history(search_payload)
        print(result)

    except Exception as error:
        print(f"Error occurred: {error}")
        print(json.dumps(str(error), indent=2))

asyncio.run(main())
```
```python
# Example 4: Fetch Last Payment
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import PaymentSearchRequest

async def main():
    config = CoreConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        tla='ABC',
        auth=AuthOptions(
            scope=['xotp']
        )
    )

    sdk = SDK(config)

    payment_search_request = PaymentSearchRequest(
        account_number="6759370"
    )
    
    try:
        result = await sdk.xotp.fetch_last_payment(payment_search_request=payment_search_request)
        print(result)
    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```
```python
# Example 5: Conv Fee Calculation
import asyncio

from paymentus_core import SDK, AuthOptions, CoreConfig, LoggingOptions
from paymentus_xotp.exceptions import ApiException
from paymentus_xotp.models import (
    ConvenienceFeeCountryEnum,
    Payment,
    PaymentHeader,
    PaymentMethod,
    PaymentMethodCategoryEnum,
    PaymentMethodTypeEnum,
    PaymentRequest,
    PaymentFailedResponse
)
from paymentus_xotp.logging import LogLevel

async def main():
    core_config = CoreConfig(
        base_url='https://<environment>.paymentus.com',
        pre_shared_key='shared-256-bit-secret',
        tla='ABC',
        auth=AuthOptions(
            scope=['xotp:payment']
        ),
        logging=LoggingOptions(
            level=LogLevel.SILENT # no logging
        )
    )

    sdk = SDK(core_config)

    # Create payment header
    header = PaymentHeader(
        payment_amount=22.00,
        convenience_fee_state="NY",
        convenience_fee_country=ConvenienceFeeCountryEnum.US
    )

    # Create payment method
    method = PaymentMethod(
        type=PaymentMethodTypeEnum.MC
    )

    # Create payment
    payment = Payment(
        header=header,
        payment_method=method,
        payment_method_category=PaymentMethodCategoryEnum.CC
    )

    # Create payment request
    fee_payload = PaymentRequest(
        payment=payment
    )

    try:
        # Call the API
        result = await sdk.xotp.cnv_calculation(fee_payload)
        print(result)
    except ApiException as e:
        # 400 bad request
        if e.status == 400:
            error_response = PaymentFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```

```python
# Example 6: Stage Payment
import asyncio
import json

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    Customer, Payment, PaymentRequest,
    PaymentHeader
)

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        header = PaymentHeader(
            account_number='6759370',
            payment_amount=13.21,
            payment_type_code='UTILITY',
            auth_token1='12345'
        )

        customer = Customer(
            first_name='John',
            last_name='Doe',
            email='john@paymentus.com',
            day_phone_nr='9051112233'
        )

        payment = Payment(
            header=header,
            customer=customer
        )

        stage_payment_payload = PaymentRequest(
            payment=payment
        )

        result = await sdk.xotp.stage_payment(stage_payment_payload)
        print(result)

    except Exception as error:
        print(f"Error occurred: {error}")
        print(json.dumps(str(error), indent=2))

asyncio.run(main())
```

### Autopay Examples

```python
# Example 1: Create Autopay
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    AutopayRequest, Payment, PaymentHeader,
    PaymentMethod, Customer, ScheduleTypeCodeEnum, 
    AutopayFailedResponse
)
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:autopay']
            )
        )

        sdk = SDK(config)

        header = PaymentHeader(
            account_number='6759375',
            payment_type_code='UTILITY',
            schedule_type_code=ScheduleTypeCodeEnum.MONTHLY,
            schedule_day=26,
            payment_amount=21.21
        )

        payment_method = PaymentMethod(
            token='some-token'
        )

        customer = Customer(
            first_name='John',
            last_name='Doe',
            email='john@paymentus.com',
            day_phone_nr='9051112233'
        )

        payment_schedule = Payment(
            header=header,
            payment_method=payment_method,
            customer=customer
        )

        autopay_payload = AutopayRequest(
            payment_schedule=payment_schedule
        )

        result = await sdk.xotp.create_autopay(autopay_payload)
        print(result)

    except ApiException as e:
        # 400 bad request
        if e.status == 400:
            error_response = AutopayFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 2: Update Autopay
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    AutopayRequest, Payment, PaymentHeader,
    ScheduleTypeCodeEnum, AutopayFailedResponse
)
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:autopay']
            )
        )

        sdk = SDK(config)

        header = PaymentHeader(
            schedule_type_code=ScheduleTypeCodeEnum.MONTHLY,
            schedule_day=13,
            payment_amount=11.09
        )

        payment_schedule = Payment(
            header=header
        )

        autopay_payload = AutopayRequest(
            payment_schedule=payment_schedule
        )

        reference_number = '3420'

        result = await sdk.xotp.update_autopay(reference_number, autopay_payload)
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found
        if e.status == 400 or e.status == 404:
            error_response = AutopayFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 3: Get Autopay By Reference Number
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.exceptions import ApiException
from paymentus_xotp.models import AutopayFailedResponse

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:autopay']
            )
        )

        sdk = SDK(config)

        reference_number = '3420'

        result = await sdk.xotp.get_autopay(reference_number)
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found
        if e.status == 400 or e.status == 404:
            error_response = AutopayFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 4: List Autopay
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import AutopaySearchRequest

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:autopay']
            )
        )

        sdk = SDK(config)

        list_payload = AutopaySearchRequest(
            login_id='user@example.com',
            account_number='6759370'
        )

        result = await sdk.xotp.list_auto_pay(list_payload)
        print(result)

    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```
```python
# Example 5: Stage Autopay
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    Customer, Payment, PaymentRequest,
    PaymentHeader, ScheduleTypeCodeEnum
)

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        header = PaymentHeader(
            account_number='6759372',
            payment_amount=13.21,
            payment_type_code='UTILITY',
            schedule_type_code=ScheduleTypeCodeEnum.MONTHLY,
            schedule_start_date="20250909",
            schedule_day=11,
            auth_token1='12345'
        )

        customer = Customer(
            first_name='John',
            last_name='Doe',
            email='john@paymentus.com',
            day_phone_nr='9051112233'
        )

        payment = Payment(
            header=header,
            customer=customer
        )

        stage_autopay_payload = PaymentRequest(
            payment=payment
        )

        result = await sdk.xotp.stage_autopay(stage_autopay_payload)
        print(result)

    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```
```python
# Example 6: Delete Autopay
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.exceptions import ApiException
from paymentus_xotp.models import AutopayFailedResponse

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        reference_number = '3420'

        result = await sdk.xotp.delete_autopay(reference_number)
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found
        if e.status == 400 or e.status == 404:
            error_response = AutopayFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```



### Account Examples
```python
# Example 1: Account Inquiry
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions, LoggingOptions
from paymentus_xotp.models import AccountInquiryRequest
from paymentus_xotp.logging import LogLevel, MaskingLevel

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            ),
            logging=LoggingOptions(
                level=LogLevel.VERBOSE, # maximum logging
                masking=MaskingLevel.NONE # no masking
            ),
        )

        sdk = SDK(config)

        payload = AccountInquiryRequest(
            account_number='6759370',
            payment_type_code='UTILITY',
            auth_token1='12345',
            include_schedules=True,
            include_last_used_pm=True,
            detailed_info=True
        )

        result = await sdk.xotp.account_inquiry(payload)
        print(result)
    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```
```python
# Example 2: Account Info by Account Number
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        account_number = '6759370'

        result = await sdk.xotp.get_account_info_by_account_number(account_number)
        print(result)

    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```
```python
# Example 3: Account Info by Email
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        email = 'user@example.com'

        result = await sdk.xotp.get_account_info_by_email(email)
        print(result)

    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```

### User Examples
```python
# Example 1: Create User
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    UserRequest,
    UserProfileInfo,
    UserInfo,
    ClientAccountItem,
    UserRequestItem,
    UserFailedResponse
)
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        profile = UserProfileInfo(
            first_name = "Python",
            last_name = "User",
            email = "python-user@example.com" 
        )

        user_info = UserInfo(
            login_id = "python-user@example.com",
            password = "SecretPassword123",
            force_password_change = True,
            profile = profile
        )

        client_account = ClientAccountItem(
            account_number = "6759370",
            payment_type_code = "UTILITY",
            auth_token1 = "12345"
        )

        user_profile = UserRequestItem(
            user_info = user_info,
            client_account = [client_account]
        )

        user_request = UserRequest(
            user_profile = user_profile,
        )

        result = await sdk.xotp.create_user(user_request)
        print(result)
    except ApiException as e:
        # 400 bad request
        if e.status == 400:
            error_response = UserFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 2: Update User
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    UserUpdateRequest,
    UserUpdateRequestItem,
    UserInfo,
    UserProfileInfo,
    UserLoginId,
    UserFailedResponse
)
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        profile = UserProfileInfo(
            day_phone_nr="5559098888",
            zip_code="28202"
        )

        user_info = UserInfo(
            login_id="python-user@example.com",
            profile=profile
        )

        user_with_permission = UserLoginId(
            login_id="admin@example.com"
        )

        user_profile = UserUpdateRequestItem(
            user_info=user_info,
            user=user_with_permission
        )

        update_request = UserUpdateRequest(
            user_profile=user_profile
        )

        result = await sdk.xotp.update_user(update_request)
        print(result)
    except ApiException as e:
        # 400 bad request
        if e.status == 400:
            error_response = UserFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 3: Get User
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import UserFailedResponse
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        login_id = "python-user@example.com"
        
        include_contact_info = True

        result = await sdk.xotp.get_user(login_id, include_contact_info)        
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found error
        if e.status == 400 or e.status == 404:
            error_response = UserFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 4: Delete User
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    UserDeleteRequest,
    UserDeleteRequestItem,
    UserLoginId, 
    UserFailedResponse
)
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        user_to_delete = UserLoginId(
            login_id="python-user@example.com"
        )

        user_with_permission = UserLoginId(
            login_id="admin@example.com"
        )

        user = UserDeleteRequestItem(
            user_info=user_to_delete,
            user=user_with_permission
        )

        delete_request = UserDeleteRequest(
            user_profile=user
        )

        result = await sdk.xotp.delete_user(delete_request)        
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found error
        if e.status == 400 or e.status == 404:
            error_response = UserFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```

### Profile Examples

```python
# Example 1: Create Profile
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    ProfileRequest,
    ProfileRequestItem,
    ProfileUserInfo,
    ProfileCustomer,
    PaymentMethod,
    CreditCardExpiryDate,
    ProfileFailedResponse
)
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:profile']
            )
        )

        sdk = SDK(config)

        payment_method = PaymentMethod(
            type="VISA",
            account_number="4444444444444448",
            credit_card_expiry_date=CreditCardExpiryDate(
                month=12,
                year=2035
            ),
            card_holder_name="Python User"
        )

        user_info = ProfileUserInfo(
            login_id="user@example.com"
        )

        customer = ProfileCustomer(
            first_name="Python",
            last_name="User"
        )

        profile_item = ProfileRequestItem(
            payment_method=payment_method,
            customer=customer,
            user_info=user_info
        )

        profile_request = ProfileRequest(
            profile=profile_item
        )

        result = await sdk.xotp.create_profile(profile_request)
        print(result)

    except ApiException as e:
        # 400 bad request
        if e.status == 400 or e.status == 404:
            error_response = ProfileFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 2: Update Profile
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import ProfileUpdateRequest, ProfileUpdateItem, ProfileFailedResponse
from paymentus_xotp.exceptions import ApiException

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:profile']
            )
        )
        
        sdk = SDK(config)

        profile_item = ProfileUpdateItem(
            profile_description="Main Payment Profile",
            default_flag=True
        )

        update_request = ProfileUpdateRequest(
            profile=profile_item
        )

        profile_token = "some-token"

        result = await sdk.xotp.update_profile(profile_token, update_request)
        print(result)
    except ApiException as e:
        # 400 bad request or 404 not found error
        if e.status == 400 or e.status == 404:
            error_response = ProfileFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 3: Get Profile
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.exceptions import ApiException
from paymentus_xotp.models import ProfileFailedResponse

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:profile']
            )
        )

        sdk = SDK(config)

        profile_token = "some-token"

        result = await sdk.xotp.get_profile(profile_token)
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found error
        if e.status == 400 or e.status == 404:
            error_response = ProfileFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 4: List Profile
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.exceptions import ApiException
from paymentus_xotp.models import ProfileFailedResponse

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)

        login_id = "user@example.com"

        result = await sdk.xotp.get_profiles(login_id)
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found error
        if e.status == 400 or e.status == 404:
            if e.body != '':
                error_response = ProfileFailedResponse.from_json(e.body)
                print(f"Error: {error_response}")
            else:
                print(f"Error: No profiles found for login ID: {login_id}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 5: Delete Profile
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.exceptions import ApiException
from paymentus_xotp.models import ProfileFailedResponse

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp:profile', 'xotp:profile:delete']
            )
        )

        sdk = SDK(config)

        profile_token = "some-token"

        result = await sdk.xotp.delete_profile(profile_token)
        print(result)

    except ApiException as e:
        # 400 bad request or 404 not found error
        if e.status == 400 or e.status == 404:
            error_response = ProfileFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```

### Other Examples
```python
# Example 1: Get Bank Info
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.exceptions import ApiException
from paymentus_xotp.models import BankInfoFailedResponse

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)
        
        routing_number = "021000128"
        
        result = await sdk.xotp.get_bank_info(routing_number)
        print(result)
    except ApiException as e:
        # 404 invalid routing number
        if e.status == 404:
            error_response = BankInfoFailedResponse.from_json(e.body)
            print(f"Error: {error_response}")
        else:
            # Handle other API exceptions
            print(f"API Exception: {e.status} - {e.reason}")
            print(f"Response Body: {e.body}")
    except Exception as e:
        print(f"Exception: {str(e)}")

asyncio.run(main())
```
```python
# Example 2: Resend Email Confirmation
import asyncio

from paymentus_core import SDK, CoreConfig, AuthOptions
from paymentus_xotp.models import (
    ResendEmailRequest, 
    ResendEmailRequestItem, 
    ResendEmailRequestHeader
)

async def main():
    try:
        config = CoreConfig(
            base_url='https://<environment>.paymentus.com',
            pre_shared_key='shared-256-bit-secret',
            tla='ABC',
            auth=AuthOptions(
                scope=['xotp']
            )
        )

        sdk = SDK(config)
        
        header = ResendEmailRequestHeader(
            account_number="6759370",
            reference_number="731358"
        )
        
        payment = ResendEmailRequestItem(
            header=header
        )
        
        resend_request = ResendEmailRequest(
            payment=payment
        )

        result = await sdk.xotp.resend_email_confirmation(resend_request)
        print(result)
    except Exception as error:
        print(f"Error occurred: {error}")

asyncio.run(main())
```

## Custom Logging

You can implement custom logging middleware by creating a class that implements the Logger interface:

```python
from paymentus_core import CoreConfig, AuthOptions, LoggingOptions, SDK
from paymentus_xotp.logging import Logger
from paymentus_xotp.middlewares.logging_middleware import LogLevel, MaskingLevel

class MyCustomLogger(Logger):
    """Custom logger implementation that formats log messages with custom prefixes."""

    def info(self, message, *args):
        formatted_message = message % args if args else message
        print(f"[[INFO]] -- {formatted_message}")

    def error(self, message, *args):
        formatted_message = message % args if args else message
        print(f"[[ERROR]] -- {formatted_message}")

    def warn(self, message, *args):
        formatted_message = message % args if args else message
        print(f"[[WARN]] -- {formatted_message}")

    def debug(self, message, *args):
        formatted_message = message % args if args else message
        print(f"[[DEBUG]] -- {formatted_message}")

config = CoreConfig(
    base_url='https://<environment>.paymentus.com',
    pre_shared_key='shared-256-bit-secret',
    tla='ABC',
    auth=AuthOptions(
           scope=['xotp']
        ),
    logging=LoggingOptions(
        logger=MyCustomLogger # Provide custom logger
    )
)
```

### Available Log Levels

The SDK supports the following log levels to control the verbosity of logging output:

#### SILENT
Suppresses all logging output. Use this in production environments where you want to minimize overhead and don't need operational visibility.
```python
config = CoreConfig(
    # ... other config options
    logging=LoggingOptions(
        level=LogLevel.SILENT  # For No logging
    )
)
```

#### MINIMAL
Logs only essential information such as request initiation and completion status with response codes. Use this for basic operational monitoring with minimal verbosity.
```python
config = CoreConfig(
    # ... other config options
    logging=LoggingOptions(
        level=LogLevel.MINIMAL  # For Minimal logging
    )
)
```

#### NORMAL
The default log level. Logs request/response information including basic request bodies and error details. Suitable for most development and staging environments.
```python
config = CoreConfig(
    # ... other config options
    logging=LoggingOptions(
        level=LogLevel.NORMAL  # Default logging mode
    )
)
```

#### VERBOSE
Maximum logging level that includes all request/response details, headers, and timing information. Ideal for debugging integration issues in development environments.
```python
config = CoreConfig(
    # ... other config options
    logging=LoggingOptions(
        level=LogLevel.VERBOSE  # For Maximum logging
    )
)
```

### Available Masking Levels

The SDK also supports data masking to protect sensitive information in logs:

- **NONE**: No data masking is applied. Only use in secure environments where logs are properly protected.
```python
config = CoreConfig(
    # ... other config options
    logging=LoggingOptions(
        masking=MaskingLevel.NONE  # No masking in logs
    )
)
```

- **PCI_ONLY**: Masks payment card information (account numbers, CVV) while preserving other data for debugging.
```python
config = CoreConfig(
    # ... other config options
    logging=LoggingOptions(
        masking=MaskingLevel.PCI_ONLY  # Default Mode
    )
)
```

- **ALL_PII**: Maximum protection that masks all personally identifiable information including names, addresses, and payment data.
```python
config = CoreConfig(
    # ... other config options
    logging=LoggingOptions(
        masking=MaskingLevel.ALL_PII  # Maximum masking while logging
    )
)
```

## Error Handling

The SDK provides comprehensive error handling:

```python
from paymentus_core.exceptions import (
    ServerError, 
    NetworkError
)

try:
    result = await sdk.xotp.make_payment(payment_payload)
except NetworkError as e:
    print(f"Network Error: {e}")
    # Handle network issues
except ServerError as e:
    print(f"Server Error: {e}")
    # Handle server issues
```

## 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

## API Reference

### SDK Class

#### Constructor

```python
SDK(config: CoreConfig)
```

Creates a new SDK instance with the provided configuration.

## 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-core",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Paymentus SDK Support <sdksupport@paymentus.com>",
    "keywords": "paymentus, core, client, sdk, api, http, rest",
    "author": null,
    "author_email": "Paymentus SDK Support <sdksupport@paymentus.com>",
    "download_url": "https://files.pythonhosted.org/packages/41/94/1b0b9cdef4781c95414ff3cdc3308cb2855dba0767fb1ba150b3f621db6e/paymentus_core-1.0.0.tar.gz",
    "platform": null,
    "description": "# Paymentus Server Python SDK\n\n## What is the Paymentus Server SDK?\nThe Paymentus Server SDK is a comprehensive Python-based toolkit that simplifies integration with the Paymentus Server-side APIs. Designed for backend services, it enables secure, streamlined access to Paymentus' powerful XOTP platform\u2014including payments, user management, autopay, account inquiries, and more. The SDK abstracts authentication flows, allowing developers to focus on building functionality without managing token lifecycles manually.\n\n## Features\n\n- **Modular Architecture**: Use individual packages or the unified SDK\n- **Type Safety**: Full type hints and validation using Pydantic\n- **Automatic Token Management**: Seamless JWT token handling (via paymentus-sdk-auth)\n- **Error Handling**: Comprehensive error types and messages\n- **Configuration Validation**: Runtime validation of configuration options\n- **Granular Scope Support**: Targeted API access via granular access scopes\n- **XOTP Integration**: Full support for payment API functionality\n\n## Installation\n\n```bash\npip install paymentus-core\n```\n\n## Basic Usage\n\n### Using the Core SDK\n\n```python\nimport asyncio\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\n\nasync def main():\n    # Create AuthConfig first\n    auth_options = AuthOptions(\n        scope=['xotp']\n    )\n\n    # Create SDK configuration with authConfig\n    config = CoreConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        tla='ABC',\n        auth=auth_options\n    )\n\n    # Initialize SDK\n    sdk = SDK(config)\n\n    # Fetch token\n    token = await sdk.auth.fetch_token()\n    print(f\"Token: {token}\")\n    is_token_expired = sdk.auth.is_token_expired()\n    print(f\"Token Expired: {is_token_expired}\")\n    current_token = sdk.auth.get_current_token()\n    print(f\"Current Token: {current_token}\")\n\nasyncio.run(main())\n```\n\n### Payment Examples\n\n```python\n# Example 1: Make Payment\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions, LoggingOptions\nfrom paymentus_xotp.models import (\n    Address, Customer, MakePayment, MakePaymentItem,\n    PaymentHeader, PaymentMethod, PaymentMethodTypeEnum,\n    CreditCardExpiryDate\n)\nfrom paymentus_xotp.logging import LogLevel, Logger, MaskingLevel\n\nasync def main():\n    # Configure the SDK\n    config = CoreConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        tla='ABC',\n        auth=AuthOptions(\n            scope=['xotp:payment']  # scope needed for payment\n        ),\n        logging=LoggingOptions(\n            logger=Logger, # default logger\n            level=LogLevel.VERBOSE, # maximum logging\n            masking=MaskingLevel.ALL_PII # mask all sensistive data\n        )\n    )\n\n    # Initialize SDK\n    sdk = SDK(config)\n\n    header1 = PaymentHeader(\n        account_number='6759373',\n        payment_amount=13.21,\n        payment_type_code='UTILITY'\n    )\n\n    header2 = PaymentHeader(\n        account_number='6759375',\n        payment_amount=13.21,\n        payment_type_code='WATER'\n    )\n\n    payment_method = PaymentMethod(\n        type=PaymentMethodTypeEnum.VISA,\n        account_number='4111111111111111',\n        card_holder_name='John Doe',\n        credit_card_expiry_date=CreditCardExpiryDate(\n            month=12,\n            year=2035\n        )\n    )\n\n    address = Address(\n        line1='10 Fifth Ave.',\n        state='NY',\n        zip_code='12345',\n        city='New York',\n        country='US'\n    )\n\n    customer = Customer(\n        first_name='John',\n        last_name='Doe',\n        email='john@paymentus.com',\n        day_phone_nr='9051112233',\n        address=address\n    )\n\n    payment_item = MakePaymentItem(\n        header=[header1, header2],\n        payment_method=payment_method,\n        customer=customer\n    )\n\n    payment_payload = MakePayment(\n        payment=payment_item\n    )\n\n    try:\n        result = await sdk.xotp.make_payment(payment_payload)\n        print(result)\n\n        # ----- Sample Output ------\n        #payment_response=PaymentResponseList(response=[PaymentResponseItem(account_number='6759373', convenience_fee=1.5, convenience_fee_country='US', convenience_fee_state='OH', convenience_fee_category_code=None, convenience_fee_percent=None, errors=None, payment_amount=13.21, payment_component=None, payment_date='07192025002237', payment_status=<PaymentStatusTypeEnum.ACCEPTED: 'ACCEPTED'>, payment_status_description='Approved', payment_schedule_status=None, reference_number='734944', status=None, staged_id=None, total_amount=14.71, additional_properties={}), PaymentResponseItem(account_number='6759375', convenience_fee=1.5, convenience_fee_country='US', convenience_fee_state='VA', convenience_fee_category_code=None, convenience_fee_percent=None, errors=None, payment_amount=13.21, payment_component=None, payment_date='07192025002241', payment_status=<PaymentStatusTypeEnum.ACCEPTED: 'ACCEPTED'>, payment_status_description='Approved', payment_schedule_status=None, reference_number='734947', status=None, staged_id=None, total_amount=14.71, additional_properties={})], additional_properties={}) additional_properties={}\n\n    \n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n\n```python\n# Example 2: Refund Payment\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    Address, Customer, Payment, PaymentHeader,\n    PaymentMethod, PaymentMethodTypeEnum,\n    CreditCardExpiryDate, PaymentRequest\n)\n\nasync def main():\n    try:\n        # Configure the SDK\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            ),\n            logging=LoggingOptions(\n                level=LogLevel.MINIMAL # minimal logging\n            )\n        )\n\n        sdk = SDK(config)\n\n        header = PaymentHeader(\n            account_number='6759370',\n            payment_amount=11.22,\n            payment_type_code='UTILITY'\n        )\n\n        payment_method = PaymentMethod(\n            type=PaymentMethodTypeEnum.VISA_IREFUND,\n            account_number='4111111111111111',\n            card_holder_name='John Doe',\n            credit_card_expiry_date=CreditCardExpiryDate(\n                month=12,\n                year=2035\n            )\n        )\n\n        address = Address(\n            line1='10 Fifth Ave.',\n            state='NY',\n            zip_code='12345',\n            city='New York',\n            country='US'\n        )\n\n        customer = Customer(\n            first_name='John',\n            last_name='Doe',\n            email='john@paymentus.com',\n            day_phone_nr='9051112233',\n            address=address\n        )\n\n        payment = Payment(\n            header=header,\n            payment_method=payment_method,\n            customer=customer\n        )\n\n        refund_payload = PaymentRequest(payment=payment)\n        \n        result = await sdk.xotp.refund_payment(refund_payload)\n        print(result)\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n\n```python\n# Example 3: Payment History\nimport asyncio\nimport json\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions, LoggingOptions\nfrom paymentus_xotp.models import PaymentSearchRequest\nfrom paymentus_xotp.logging import LogLevel\n\n\nasync def main():\n    config = CoreConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        tla='ABC',\n        auth=AuthOptions(\n            scope=['xotp:payment']\n        ),\n        logging=LoggingOptions(\n            level=LogLevel.SILENT # no logging\n        )\n    )\n\n    sdk = SDK(config)\n\n    search_payload = PaymentSearchRequest(\n        account_number='6759371',  # required\n        date_from = \"06182025\",\n        date_to = \"06192025\"\n    )\n    try:\n        result = await sdk.xotp.get_payment_history(search_payload)\n        print(result)\n\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n        print(json.dumps(str(error), indent=2))\n\nasyncio.run(main())\n```\n```python\n# Example 4: Fetch Last Payment\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import PaymentSearchRequest\n\nasync def main():\n    config = CoreConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        tla='ABC',\n        auth=AuthOptions(\n            scope=['xotp']\n        )\n    )\n\n    sdk = SDK(config)\n\n    payment_search_request = PaymentSearchRequest(\n        account_number=\"6759370\"\n    )\n    \n    try:\n        result = await sdk.xotp.fetch_last_payment(payment_search_request=payment_search_request)\n        print(result)\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n```python\n# Example 5: Conv Fee Calculation\nimport asyncio\n\nfrom paymentus_core import SDK, AuthOptions, CoreConfig, LoggingOptions\nfrom paymentus_xotp.exceptions import ApiException\nfrom paymentus_xotp.models import (\n    ConvenienceFeeCountryEnum,\n    Payment,\n    PaymentHeader,\n    PaymentMethod,\n    PaymentMethodCategoryEnum,\n    PaymentMethodTypeEnum,\n    PaymentRequest,\n    PaymentFailedResponse\n)\nfrom paymentus_xotp.logging import LogLevel\n\nasync def main():\n    core_config = CoreConfig(\n        base_url='https://<environment>.paymentus.com',\n        pre_shared_key='shared-256-bit-secret',\n        tla='ABC',\n        auth=AuthOptions(\n            scope=['xotp:payment']\n        ),\n        logging=LoggingOptions(\n            level=LogLevel.SILENT # no logging\n        )\n    )\n\n    sdk = SDK(core_config)\n\n    # Create payment header\n    header = PaymentHeader(\n        payment_amount=22.00,\n        convenience_fee_state=\"NY\",\n        convenience_fee_country=ConvenienceFeeCountryEnum.US\n    )\n\n    # Create payment method\n    method = PaymentMethod(\n        type=PaymentMethodTypeEnum.MC\n    )\n\n    # Create payment\n    payment = Payment(\n        header=header,\n        payment_method=method,\n        payment_method_category=PaymentMethodCategoryEnum.CC\n    )\n\n    # Create payment request\n    fee_payload = PaymentRequest(\n        payment=payment\n    )\n\n    try:\n        # Call the API\n        result = await sdk.xotp.cnv_calculation(fee_payload)\n        print(result)\n    except ApiException as e:\n        # 400 bad request\n        if e.status == 400:\n            error_response = PaymentFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n\n```python\n# Example 6: Stage Payment\nimport asyncio\nimport json\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    Customer, Payment, PaymentRequest,\n    PaymentHeader\n)\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        header = PaymentHeader(\n            account_number='6759370',\n            payment_amount=13.21,\n            payment_type_code='UTILITY',\n            auth_token1='12345'\n        )\n\n        customer = Customer(\n            first_name='John',\n            last_name='Doe',\n            email='john@paymentus.com',\n            day_phone_nr='9051112233'\n        )\n\n        payment = Payment(\n            header=header,\n            customer=customer\n        )\n\n        stage_payment_payload = PaymentRequest(\n            payment=payment\n        )\n\n        result = await sdk.xotp.stage_payment(stage_payment_payload)\n        print(result)\n\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n        print(json.dumps(str(error), indent=2))\n\nasyncio.run(main())\n```\n\n### Autopay Examples\n\n```python\n# Example 1: Create Autopay\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    AutopayRequest, Payment, PaymentHeader,\n    PaymentMethod, Customer, ScheduleTypeCodeEnum, \n    AutopayFailedResponse\n)\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:autopay']\n            )\n        )\n\n        sdk = SDK(config)\n\n        header = PaymentHeader(\n            account_number='6759375',\n            payment_type_code='UTILITY',\n            schedule_type_code=ScheduleTypeCodeEnum.MONTHLY,\n            schedule_day=26,\n            payment_amount=21.21\n        )\n\n        payment_method = PaymentMethod(\n            token='some-token'\n        )\n\n        customer = Customer(\n            first_name='John',\n            last_name='Doe',\n            email='john@paymentus.com',\n            day_phone_nr='9051112233'\n        )\n\n        payment_schedule = Payment(\n            header=header,\n            payment_method=payment_method,\n            customer=customer\n        )\n\n        autopay_payload = AutopayRequest(\n            payment_schedule=payment_schedule\n        )\n\n        result = await sdk.xotp.create_autopay(autopay_payload)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request\n        if e.status == 400:\n            error_response = AutopayFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 2: Update Autopay\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    AutopayRequest, Payment, PaymentHeader,\n    ScheduleTypeCodeEnum, AutopayFailedResponse\n)\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:autopay']\n            )\n        )\n\n        sdk = SDK(config)\n\n        header = PaymentHeader(\n            schedule_type_code=ScheduleTypeCodeEnum.MONTHLY,\n            schedule_day=13,\n            payment_amount=11.09\n        )\n\n        payment_schedule = Payment(\n            header=header\n        )\n\n        autopay_payload = AutopayRequest(\n            payment_schedule=payment_schedule\n        )\n\n        reference_number = '3420'\n\n        result = await sdk.xotp.update_autopay(reference_number, autopay_payload)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found\n        if e.status == 400 or e.status == 404:\n            error_response = AutopayFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 3: Get Autopay By Reference Number\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.exceptions import ApiException\nfrom paymentus_xotp.models import AutopayFailedResponse\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:autopay']\n            )\n        )\n\n        sdk = SDK(config)\n\n        reference_number = '3420'\n\n        result = await sdk.xotp.get_autopay(reference_number)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found\n        if e.status == 400 or e.status == 404:\n            error_response = AutopayFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 4: List Autopay\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import AutopaySearchRequest\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:autopay']\n            )\n        )\n\n        sdk = SDK(config)\n\n        list_payload = AutopaySearchRequest(\n            login_id='user@example.com',\n            account_number='6759370'\n        )\n\n        result = await sdk.xotp.list_auto_pay(list_payload)\n        print(result)\n\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n```python\n# Example 5: Stage Autopay\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    Customer, Payment, PaymentRequest,\n    PaymentHeader, ScheduleTypeCodeEnum\n)\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        header = PaymentHeader(\n            account_number='6759372',\n            payment_amount=13.21,\n            payment_type_code='UTILITY',\n            schedule_type_code=ScheduleTypeCodeEnum.MONTHLY,\n            schedule_start_date=\"20250909\",\n            schedule_day=11,\n            auth_token1='12345'\n        )\n\n        customer = Customer(\n            first_name='John',\n            last_name='Doe',\n            email='john@paymentus.com',\n            day_phone_nr='9051112233'\n        )\n\n        payment = Payment(\n            header=header,\n            customer=customer\n        )\n\n        stage_autopay_payload = PaymentRequest(\n            payment=payment\n        )\n\n        result = await sdk.xotp.stage_autopay(stage_autopay_payload)\n        print(result)\n\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n```python\n# Example 6: Delete Autopay\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.exceptions import ApiException\nfrom paymentus_xotp.models import AutopayFailedResponse\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        reference_number = '3420'\n\n        result = await sdk.xotp.delete_autopay(reference_number)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found\n        if e.status == 400 or e.status == 404:\n            error_response = AutopayFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n\n\n\n### Account Examples\n```python\n# Example 1: Account Inquiry\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions, LoggingOptions\nfrom paymentus_xotp.models import AccountInquiryRequest\nfrom paymentus_xotp.logging import LogLevel, MaskingLevel\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            ),\n            logging=LoggingOptions(\n                level=LogLevel.VERBOSE, # maximum logging\n                masking=MaskingLevel.NONE # no masking\n            ),\n        )\n\n        sdk = SDK(config)\n\n        payload = AccountInquiryRequest(\n            account_number='6759370',\n            payment_type_code='UTILITY',\n            auth_token1='12345',\n            include_schedules=True,\n            include_last_used_pm=True,\n            detailed_info=True\n        )\n\n        result = await sdk.xotp.account_inquiry(payload)\n        print(result)\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n```python\n# Example 2: Account Info by Account Number\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        account_number = '6759370'\n\n        result = await sdk.xotp.get_account_info_by_account_number(account_number)\n        print(result)\n\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n```python\n# Example 3: Account Info by Email\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        email = 'user@example.com'\n\n        result = await sdk.xotp.get_account_info_by_email(email)\n        print(result)\n\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n\n### User Examples\n```python\n# Example 1: Create User\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    UserRequest,\n    UserProfileInfo,\n    UserInfo,\n    ClientAccountItem,\n    UserRequestItem,\n    UserFailedResponse\n)\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        profile = UserProfileInfo(\n            first_name = \"Python\",\n            last_name = \"User\",\n            email = \"python-user@example.com\" \n        )\n\n        user_info = UserInfo(\n            login_id = \"python-user@example.com\",\n            password = \"SecretPassword123\",\n            force_password_change = True,\n            profile = profile\n        )\n\n        client_account = ClientAccountItem(\n            account_number = \"6759370\",\n            payment_type_code = \"UTILITY\",\n            auth_token1 = \"12345\"\n        )\n\n        user_profile = UserRequestItem(\n            user_info = user_info,\n            client_account = [client_account]\n        )\n\n        user_request = UserRequest(\n            user_profile = user_profile,\n        )\n\n        result = await sdk.xotp.create_user(user_request)\n        print(result)\n    except ApiException as e:\n        # 400 bad request\n        if e.status == 400:\n            error_response = UserFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 2: Update User\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    UserUpdateRequest,\n    UserUpdateRequestItem,\n    UserInfo,\n    UserProfileInfo,\n    UserLoginId,\n    UserFailedResponse\n)\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        profile = UserProfileInfo(\n            day_phone_nr=\"5559098888\",\n            zip_code=\"28202\"\n        )\n\n        user_info = UserInfo(\n            login_id=\"python-user@example.com\",\n            profile=profile\n        )\n\n        user_with_permission = UserLoginId(\n            login_id=\"admin@example.com\"\n        )\n\n        user_profile = UserUpdateRequestItem(\n            user_info=user_info,\n            user=user_with_permission\n        )\n\n        update_request = UserUpdateRequest(\n            user_profile=user_profile\n        )\n\n        result = await sdk.xotp.update_user(update_request)\n        print(result)\n    except ApiException as e:\n        # 400 bad request\n        if e.status == 400:\n            error_response = UserFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 3: Get User\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import UserFailedResponse\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        login_id = \"python-user@example.com\"\n        \n        include_contact_info = True\n\n        result = await sdk.xotp.get_user(login_id, include_contact_info)        \n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found error\n        if e.status == 400 or e.status == 404:\n            error_response = UserFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 4: Delete User\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    UserDeleteRequest,\n    UserDeleteRequestItem,\n    UserLoginId, \n    UserFailedResponse\n)\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        user_to_delete = UserLoginId(\n            login_id=\"python-user@example.com\"\n        )\n\n        user_with_permission = UserLoginId(\n            login_id=\"admin@example.com\"\n        )\n\n        user = UserDeleteRequestItem(\n            user_info=user_to_delete,\n            user=user_with_permission\n        )\n\n        delete_request = UserDeleteRequest(\n            user_profile=user\n        )\n\n        result = await sdk.xotp.delete_user(delete_request)        \n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found error\n        if e.status == 400 or e.status == 404:\n            error_response = UserFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n\n### Profile Examples\n\n```python\n# Example 1: Create Profile\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    ProfileRequest,\n    ProfileRequestItem,\n    ProfileUserInfo,\n    ProfileCustomer,\n    PaymentMethod,\n    CreditCardExpiryDate,\n    ProfileFailedResponse\n)\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:profile']\n            )\n        )\n\n        sdk = SDK(config)\n\n        payment_method = PaymentMethod(\n            type=\"VISA\",\n            account_number=\"4444444444444448\",\n            credit_card_expiry_date=CreditCardExpiryDate(\n                month=12,\n                year=2035\n            ),\n            card_holder_name=\"Python User\"\n        )\n\n        user_info = ProfileUserInfo(\n            login_id=\"user@example.com\"\n        )\n\n        customer = ProfileCustomer(\n            first_name=\"Python\",\n            last_name=\"User\"\n        )\n\n        profile_item = ProfileRequestItem(\n            payment_method=payment_method,\n            customer=customer,\n            user_info=user_info\n        )\n\n        profile_request = ProfileRequest(\n            profile=profile_item\n        )\n\n        result = await sdk.xotp.create_profile(profile_request)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request\n        if e.status == 400 or e.status == 404:\n            error_response = ProfileFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 2: Update Profile\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import ProfileUpdateRequest, ProfileUpdateItem, ProfileFailedResponse\nfrom paymentus_xotp.exceptions import ApiException\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:profile']\n            )\n        )\n        \n        sdk = SDK(config)\n\n        profile_item = ProfileUpdateItem(\n            profile_description=\"Main Payment Profile\",\n            default_flag=True\n        )\n\n        update_request = ProfileUpdateRequest(\n            profile=profile_item\n        )\n\n        profile_token = \"some-token\"\n\n        result = await sdk.xotp.update_profile(profile_token, update_request)\n        print(result)\n    except ApiException as e:\n        # 400 bad request or 404 not found error\n        if e.status == 400 or e.status == 404:\n            error_response = ProfileFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 3: Get Profile\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.exceptions import ApiException\nfrom paymentus_xotp.models import ProfileFailedResponse\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:profile']\n            )\n        )\n\n        sdk = SDK(config)\n\n        profile_token = \"some-token\"\n\n        result = await sdk.xotp.get_profile(profile_token)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found error\n        if e.status == 400 or e.status == 404:\n            error_response = ProfileFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 4: List Profile\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.exceptions import ApiException\nfrom paymentus_xotp.models import ProfileFailedResponse\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n\n        login_id = \"user@example.com\"\n\n        result = await sdk.xotp.get_profiles(login_id)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found error\n        if e.status == 400 or e.status == 404:\n            if e.body != '':\n                error_response = ProfileFailedResponse.from_json(e.body)\n                print(f\"Error: {error_response}\")\n            else:\n                print(f\"Error: No profiles found for login ID: {login_id}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 5: Delete Profile\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.exceptions import ApiException\nfrom paymentus_xotp.models import ProfileFailedResponse\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp:profile', 'xotp:profile:delete']\n            )\n        )\n\n        sdk = SDK(config)\n\n        profile_token = \"some-token\"\n\n        result = await sdk.xotp.delete_profile(profile_token)\n        print(result)\n\n    except ApiException as e:\n        # 400 bad request or 404 not found error\n        if e.status == 400 or e.status == 404:\n            error_response = ProfileFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n\n### Other Examples\n```python\n# Example 1: Get Bank Info\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.exceptions import ApiException\nfrom paymentus_xotp.models import BankInfoFailedResponse\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n        \n        routing_number = \"021000128\"\n        \n        result = await sdk.xotp.get_bank_info(routing_number)\n        print(result)\n    except ApiException as e:\n        # 404 invalid routing number\n        if e.status == 404:\n            error_response = BankInfoFailedResponse.from_json(e.body)\n            print(f\"Error: {error_response}\")\n        else:\n            # Handle other API exceptions\n            print(f\"API Exception: {e.status} - {e.reason}\")\n            print(f\"Response Body: {e.body}\")\n    except Exception as e:\n        print(f\"Exception: {str(e)}\")\n\nasyncio.run(main())\n```\n```python\n# Example 2: Resend Email Confirmation\nimport asyncio\n\nfrom paymentus_core import SDK, CoreConfig, AuthOptions\nfrom paymentus_xotp.models import (\n    ResendEmailRequest, \n    ResendEmailRequestItem, \n    ResendEmailRequestHeader\n)\n\nasync def main():\n    try:\n        config = CoreConfig(\n            base_url='https://<environment>.paymentus.com',\n            pre_shared_key='shared-256-bit-secret',\n            tla='ABC',\n            auth=AuthOptions(\n                scope=['xotp']\n            )\n        )\n\n        sdk = SDK(config)\n        \n        header = ResendEmailRequestHeader(\n            account_number=\"6759370\",\n            reference_number=\"731358\"\n        )\n        \n        payment = ResendEmailRequestItem(\n            header=header\n        )\n        \n        resend_request = ResendEmailRequest(\n            payment=payment\n        )\n\n        result = await sdk.xotp.resend_email_confirmation(resend_request)\n        print(result)\n    except Exception as error:\n        print(f\"Error occurred: {error}\")\n\nasyncio.run(main())\n```\n\n## Custom Logging\n\nYou can implement custom logging middleware by creating a class that implements the Logger interface:\n\n```python\nfrom paymentus_core import CoreConfig, AuthOptions, LoggingOptions, SDK\nfrom paymentus_xotp.logging import Logger\nfrom paymentus_xotp.middlewares.logging_middleware import LogLevel, MaskingLevel\n\nclass MyCustomLogger(Logger):\n    \"\"\"Custom logger implementation that formats log messages with custom prefixes.\"\"\"\n\n    def info(self, message, *args):\n        formatted_message = message % args if args else message\n        print(f\"[[INFO]] -- {formatted_message}\")\n\n    def error(self, message, *args):\n        formatted_message = message % args if args else message\n        print(f\"[[ERROR]] -- {formatted_message}\")\n\n    def warn(self, message, *args):\n        formatted_message = message % args if args else message\n        print(f\"[[WARN]] -- {formatted_message}\")\n\n    def debug(self, message, *args):\n        formatted_message = message % args if args else message\n        print(f\"[[DEBUG]] -- {formatted_message}\")\n\nconfig = CoreConfig(\n    base_url='https://<environment>.paymentus.com',\n    pre_shared_key='shared-256-bit-secret',\n    tla='ABC',\n    auth=AuthOptions(\n           scope=['xotp']\n        ),\n    logging=LoggingOptions(\n        logger=MyCustomLogger # Provide custom logger\n    )\n)\n```\n\n### Available Log Levels\n\nThe SDK supports the following log levels to control the verbosity of logging output:\n\n#### SILENT\nSuppresses all logging output. Use this in production environments where you want to minimize overhead and don't need operational visibility.\n```python\nconfig = CoreConfig(\n    # ... other config options\n    logging=LoggingOptions(\n        level=LogLevel.SILENT  # For No logging\n    )\n)\n```\n\n#### MINIMAL\nLogs only essential information such as request initiation and completion status with response codes. Use this for basic operational monitoring with minimal verbosity.\n```python\nconfig = CoreConfig(\n    # ... other config options\n    logging=LoggingOptions(\n        level=LogLevel.MINIMAL  # For Minimal logging\n    )\n)\n```\n\n#### NORMAL\nThe default log level. Logs request/response information including basic request bodies and error details. Suitable for most development and staging environments.\n```python\nconfig = CoreConfig(\n    # ... other config options\n    logging=LoggingOptions(\n        level=LogLevel.NORMAL  # Default logging mode\n    )\n)\n```\n\n#### VERBOSE\nMaximum logging level that includes all request/response details, headers, and timing information. Ideal for debugging integration issues in development environments.\n```python\nconfig = CoreConfig(\n    # ... other config options\n    logging=LoggingOptions(\n        level=LogLevel.VERBOSE  # For Maximum logging\n    )\n)\n```\n\n### Available Masking Levels\n\nThe SDK also supports data masking to protect sensitive information in logs:\n\n- **NONE**: No data masking is applied. Only use in secure environments where logs are properly protected.\n```python\nconfig = CoreConfig(\n    # ... other config options\n    logging=LoggingOptions(\n        masking=MaskingLevel.NONE  # No masking in logs\n    )\n)\n```\n\n- **PCI_ONLY**: Masks payment card information (account numbers, CVV) while preserving other data for debugging.\n```python\nconfig = CoreConfig(\n    # ... other config options\n    logging=LoggingOptions(\n        masking=MaskingLevel.PCI_ONLY  # Default Mode\n    )\n)\n```\n\n- **ALL_PII**: Maximum protection that masks all personally identifiable information including names, addresses, and payment data.\n```python\nconfig = CoreConfig(\n    # ... other config options\n    logging=LoggingOptions(\n        masking=MaskingLevel.ALL_PII  # Maximum masking while logging\n    )\n)\n```\n\n## Error Handling\n\nThe SDK provides comprehensive error handling:\n\n```python\nfrom paymentus_core.exceptions import (\n    ServerError, \n    NetworkError\n)\n\ntry:\n    result = await sdk.xotp.make_payment(payment_payload)\nexcept NetworkError as e:\n    print(f\"Network Error: {e}\")\n    # Handle network issues\nexcept ServerError as e:\n    print(f\"Server Error: {e}\")\n    # Handle server issues\n```\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## API Reference\n\n### SDK Class\n\n#### Constructor\n\n```python\nSDK(config: CoreConfig)\n```\n\nCreates a new SDK instance with the provided configuration.\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 Core SDK",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://www.paymentus.com/",
        "Source": "https://developer.paymentus.io/"
    },
    "split_keywords": [
        "paymentus",
        " core",
        " client",
        " sdk",
        " api",
        " http",
        " rest"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ebd5482a106a3237e74cef1db9189af0f35be13659a43667048234345186ef9c",
                "md5": "bd48635c99d2eafb3e29b01108018630",
                "sha256": "7ce47a654e9af3e7ded9e8d58d21c53e8daffb58acaaea8e90df23ab1bbbc762"
            },
            "downloads": -1,
            "filename": "paymentus_core-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bd48635c99d2eafb3e29b01108018630",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 12698,
            "upload_time": "2025-08-12T12:30:45",
            "upload_time_iso_8601": "2025-08-12T12:30:45.090766Z",
            "url": "https://files.pythonhosted.org/packages/eb/d5/482a106a3237e74cef1db9189af0f35be13659a43667048234345186ef9c/paymentus_core-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "41941b0b9cdef4781c95414ff3cdc3308cb2855dba0767fb1ba150b3f621db6e",
                "md5": "08c4d9b8f9eaf5370e6d7700690cbbbd",
                "sha256": "cf2163861776c6c6b93b8e92c9ba8b705800223ecc6f9b864bd88148f788c6b7"
            },
            "downloads": -1,
            "filename": "paymentus_core-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "08c4d9b8f9eaf5370e6d7700690cbbbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 23515,
            "upload_time": "2025-08-12T12:30:47",
            "upload_time_iso_8601": "2025-08-12T12:30:47.518183Z",
            "url": "https://files.pythonhosted.org/packages/41/94/1b0b9cdef4781c95414ff3cdc3308cb2855dba0767fb1ba150b3f621db6e/paymentus_core-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-12 12:30:47",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "paymentus-core"
}
        
Elapsed time: 0.93270s