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')
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
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 |
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
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
Source code in src/korapay_client/models/public.py
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
Source code in src/korapay_client/models/public.py
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 |
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
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. |