Skip to content

Models

korapay_client.models

Models help to keep related data compact and is used by korapay_client client methods to accept compact data required to process a request to Korapay. All client methods in korapay_client all return a Response which is also a model. Models are pydantic models as the korapay_client uses pydantic internally for validation and data representation.

The models package contains all the internal and public models used by korapay_client package.

Note

All public models can be imported directly from korapay_client. E.g.,

from korapay_client import Authorization, PayoutOrder
# `Authorization` and `PayoutOrder` are both models and can be used in client methods requiring them.
auth = Authorization(pin='1234')
You can use this models as you would use dataclasses although it can do a lot more. korapay_client only requires you to use them for data representations

korapay_client.models.public

AVS dataclass

Bases: BaseModel

A pydantic model for representing the address information of a debit card for Address Verification Service.

Attributes:

Name Type Description
state str

The state of the customer.

city str

The city of the customer.

country str

The country of the customer.

address str

The address of the customer.

zip_code str

The zip code of the customer.

Example
from korapay_client import AVS, Country
avs = AVS(state='lagos',city='alimosho',
country=Country.NIGERIA.value,address='404 anonymous street',zip_code='253359')
# OR
data = {
    'state': 'lagos',
    'city':'alimosho',
    'country':'NG',
    'address':'404 anonymous street',
    'zip_code':'253359'
}
avs = AVS.model_validate(data)
Source code in src/korapay_client/models/public.py
@dataclass
class AVS(BaseModel):
    """A pydantic model for representing the address information of a debit card for
    Address Verification Service.

    Attributes:
        state: The state of the customer.
        city: The city of the customer.
        country: The country of the customer.
        address: The address of the customer.
        zip_code: The zip code of the customer.

    Example:
        ```python
        from korapay_client import AVS, Country
        avs = AVS(state='lagos',city='alimosho',
        country=Country.NIGERIA.value,address='404 anonymous street',zip_code='253359')
        # OR
        data = {
            'state': 'lagos',
            'city':'alimosho',
            'country':'NG',
            'address':'404 anonymous street',
            'zip_code':'253359'
        }
        avs = AVS.model_validate(data)
        ```
    """

    state: str
    city: str
    country: str
    address: str
    zip_code: str

Authorization

Bases: BaseModel

A pydantic model for representing additional information required by Korapay for authorizing a charge on the card.

Attributes:

Name Type Description
pin str | None

The debit card pin of the customer.

otp str | None

The one time password/pin obtained from the customer.

avs AVS | None

The AVS of the customer

Example
from korapay_client import Authorization
auth = Authorization(pin='1234')
Note

For the different authorization flow, you'll only need to provide one of the fields

Source code in src/korapay_client/models/public.py
class Authorization(BaseModel):
    """A pydantic model for representing additional information required by Korapay for
    authorizing a charge on the card.

    Attributes:
        pin: The debit card pin of the customer.
        otp: The one time password/pin obtained from the customer.
        avs: The AVS of the customer

    Example:
        ```python
        from korapay_client import Authorization
        auth = Authorization(pin='1234')
        ```

    Note:
        For the different authorization flow, you'll only need to provide one of the fields
    """

    pin: str | None = None
    otp: str | None = None
    avs: AVS | None = None

BankAccount

Bases: BaseModel

A pydantic model for representing bank account information.

Attributes:

Name Type Description
bank_code str

The code representing the bank e.g., 035.

account_number str

The account number of the customer.

Example
from korapay_client import BankAccount
account = BankAccount(bank_code='033', account_number='0000000000')
Source code in src/korapay_client/models/public.py
class BankAccount(BaseModel):
    """A pydantic model for representing bank account information.

    Attributes:
        bank_code: The code representing the bank e.g., 035.
        account_number: The account number of the customer.

    Example:
        ```python
        from korapay_client import BankAccount
        account = BankAccount(bank_code='033', account_number='0000000000')
        ```
    """

    bank_code: str
    account_number: str

Customer

Bases: BaseModel

A pydantic model for representing customer's information.

Attributes:

Name Type Description
email EmailStr

The email address of the customer.

name Optional[str]

The name of the customer.

Example
from korapay_client import Customer
cus = Customer(email='johndoe@example.com', name='John Doe')
Source code in src/korapay_client/models/public.py
class Customer(BaseModel):
    """A pydantic model for representing customer's information.

    Attributes:
        email: The email address of the customer.
        name: The name of the customer.

    Example:
        ```python
        from korapay_client import Customer
        cus = Customer(email='johndoe@example.com', name='John Doe')
        ```
    """

    email: EmailStr
    name: Optional[str] = None

PayoutOrder

Bases: SerializeAmountMixin, BaseModel

A pydantic model for representing individual transactions in a bulk payout.

Attributes:

Name Type Description
reference str

The reference of the transaction.

amount int | float | Decimal

The amount to pay the recipient.

bank_account BankAccount

The bank account information of the recipient.

customer Customer

The information about the recipient.

narration Optional[str]

The description of the transaction.

type Literal['bank_account', 'mobile_money']

The payment channel of the payout. defaults to bank_account as it is the only payout payment channel supported by Korapay.

Example
from korapay_client import PayoutOrder
data = {
    'reference': 'qqwerefdvifogirfguitheopwe',
    'amount' 100_000,
    'bank_account': {'bank_code':'033', 'account_number': '0000000000'},
    'customer': {'email': 'johndoe@example.com' , 'name': 'John Doe'},
    'narration': 'A test payout',
    }
payout_order = PayoutOrder.model_validate(data)
Source code in src/korapay_client/models/public.py
class PayoutOrder(SerializeAmountMixin, BaseModel):
    """A pydantic model for representing individual transactions in a bulk payout.

    Attributes:
        reference: The reference of the transaction.
        amount: The amount to pay the recipient.
        bank_account: The bank account information of the recipient.
        customer: The information about the recipient.
        narration: The description of the transaction.
        type: The payment channel of the payout. defaults to `bank_account`
            as it is the only payout payment channel supported by Korapay.

    Example:
        ```python
        from korapay_client import PayoutOrder
        data = {
            'reference': 'qqwerefdvifogirfguitheopwe',
            'amount' 100_000,
            'bank_account': {'bank_code':'033', 'account_number': '0000000000'},
            'customer': {'email': 'johndoe@example.com' , 'name': 'John Doe'},
            'narration': 'A test payout',
            }
        payout_order = PayoutOrder.model_validate(data)
        ```
    """

    reference: str
    amount: int | float | Decimal
    bank_account: BankAccount
    customer: Customer
    narration: Optional[str] = None
    type: Literal["bank_account", "mobile_money"] = "bank_account"

Response

Bases: BaseModel

A pydantic model for representing the response returned from making a request to Korapay by calling any of the client methods.

This model is the return type of all client methods that make REST API calls to Korapay.

Attributes:

Name Type Description
status_code int

The HTTP status code of the response.

status bool

The status of the response.

message str

The message of the response.

data dict | list | None

The data returned by Korapay as a result of making the request.

Example
from korapay import KorapayClient, Country
client = KorapayClient() # assumes the credentials are in the environmental variables
response = client.get_banks(country=Country.NIGERIA)
print(response.status_code)
print(response.data)
print(response)
Source code in src/korapay_client/models/public.py
class Response(BaseModel):
    """A pydantic model for representing the response returned from making a request to Korapay
    by calling any of the client methods.

    This model is the return type of all client methods that make REST API calls to Korapay.

    Attributes:
        status_code: The HTTP status code of the response.
        status: The status of the response.
        message: The message of the response.
        data: The data returned by Korapay as a result of making the request.

    Example:
        ```python
        from korapay import KorapayClient, Country
        client = KorapayClient() # assumes the credentials are in the environmental variables
        response = client.get_banks(country=Country.NIGERIA)
        print(response.status_code)
        print(response.data)
        print(response)
        ```
    """

    status_code: int
    status: bool
    message: str
    data: dict | list | None