Skip to content

Subaccounts

SubAccountClient

Bases: BaseAPIClient

Provides a wrapper for paystack Subaccounts API

The Subaccounts API allows you to create and manage subaccounts on your integration. Subaccounts can be used to split payment between two accounts (your main account and a sub account). https://paystack.com/docs/api/subaccount/

Source code in src/pypaystack2/sub_clients/sync_clients/subaccounts.py
class SubAccountClient(BaseAPIClient):
    """Provides a wrapper for paystack Subaccounts API

    The Subaccounts API allows you to create and manage subaccounts on your integration.
    Subaccounts can be used to split payment between two accounts
    (your main account and a sub account).
    https://paystack.com/docs/api/subaccount/
    """

    def create(
        self,
        business_name: str,
        settlement_bank: str,
        account_number: str,
        percentage_charge: float | int,
        description: str | None = None,
        primary_contact_email: str | None = None,
        primary_contact_name: str | None = None,
        primary_contact_phone: str | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[SubAccount] | Response[PaystackDataModel]:
        """Create a subacount on your integration.

        Args:
            business_name: Name of business for subaccount
            settlement_bank: Bank Code for the bank. You can get the
                list of Bank Codes by calling the ``.get_banks``
                method from the Miscellaneous API wrapper
            account_number: Bank Account Number
            percentage_charge: The default percentage charged when receiving on behalf of this subaccount
            description: A description for this subaccount
            primary_contact_email: A contact email for the subaccount
            primary_contact_name: A name for the contact person for this subaccount
            primary_contact_phone: A phone number to call for this subaccount
            metadata: Add a custom_fields attribute which has a list of dictionaries if
                you would like the fields to be added to your transaction when
                displayed on the dashboard.
                Sample: ``{"custom_fields":[{"display_name":"Cart ID",
                "variable_name": "cart_id","value": "8393"}]}``
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url("/subaccount")
        payload = {
            "business_name": business_name,
            "settlement_bank": settlement_bank,
            "account_number": account_number,
            "percentage_charge": percentage_charge,
            "description": description,
        }
        optional_params = [
            ("primary_contact_email", primary_contact_email),
            ("primary_contact_name", primary_contact_name),
            ("primary_contact_phone", primary_contact_phone),
            ("metadata", metadata),
        ]
        payload = add_to_payload(optional_params, payload)
        return self._handle_request(  # type: ignore
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class or SubAccount,
        )

    def get_subaccounts(
        self,
        start_date: str | None = None,
        end_date: str | None = None,
        page: int = 1,
        pagination: int = 50,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[list[SubAccount]] | Response[PaystackDataModel]:
        """Fetch subaccounts available on your integration.

        Args:
            start_date: A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
            end_date: A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
            page: Specifies exactly what page you want to retrieve. If not specified we use a default value of 1.
            pagination: Specifies how many records you want to retrieve per page.
                If not specified we use a default value of 50.
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """
        url = self._full_url(f"/subaccount?perPage={pagination}")
        query_params = [
            ("from", start_date),
            ("to", end_date),
            ("page", page),
        ]
        url = append_query_params(query_params, url)
        return self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or SubAccount,
        )

    def get_subaccount(
        self,
        id_or_code: int | str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[SubAccount] | Response[PaystackDataModel]:
        """Get details of a subaccount on your integration.

        Args:
            id_or_code: The subaccount ``ID`` or ``code`` you want to fetch
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url(f"/subaccount/{id_or_code}")
        return self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or SubAccount,
        )

    def update(
        self,
        id_or_code: int | str,
        business_name: str | None = None,
        settlement_bank: str | None = None,
        account_number: str | None = None,
        active: bool | None = None,
        percentage_charge: float | int | None = None,
        description: str | None = None,
        primary_contact_email: str | None = None,
        primary_contact_name: str | None = None,
        primary_contact_phone: str | None = None,
        settlement_schedule: Schedule | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[SubAccount] | Response[PaystackDataModel]:
        """Update a subaccount details on your integration.

        Args:
            id_or_code: Subaccount's ID or code
            business_name: Name of business for subaccount
            settlement_bank: Bank Code for the bank. You can get the
                list of Bank Codes by calling the ``.get_banks``
                method from the Miscellaneous API wrapper
            account_number: Bank Account Number
            active: Activate or deactivate a subaccount.
            percentage_charge: The default percentage charged when
                receiving on behalf of this subaccount
            description: A description for this subaccount
            primary_contact_email: A contact email for the subaccount
            primary_contact_name: A name for the contact person for this subaccount
            primary_contact_phone: A phone number to call for this subaccount
            settlement_schedule: ``Schedule.AUTO`` means payout is T+1 and manual means payout to the
                subaccount should only be made when requested.
                Defaults to ``Schedule.AUTO``
            metadata: Add a custom_fields attribute which has a list of dictionaries if you would
                like the fields to be added to your transaction when displayed on the
                dashboard. Sample: ``{"custom_fields":[{"display_name":"Cart ID",
                "variable_name": "cart_id","value": "8393"}]}``
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        payload = {
            "id_or_code": id_or_code,
            "business_name": business_name,
            "settlement_bank": settlement_bank,
        }
        optional_params = [
            ("account_number", account_number),
            ("active", active),
            ("percentage_charge", percentage_charge),
            ("description", description),
            ("primary_contact_email", primary_contact_email),
            ("primary_contact_name", primary_contact_name),
            ("primary_contact_phone", primary_contact_phone),
            ("settlement_schedule", settlement_schedule),
            ("metadata", metadata),
        ]
        payload = add_to_payload(optional_params, payload)
        url = self._full_url(f"/subaccount/{id_or_code}")
        return self._handle_request(  # type: ignore
            HTTPMethod.PUT,
            url,
            payload,
            response_data_model_class=alternate_model_class or SubAccount,
        )

create(business_name, settlement_bank, account_number, percentage_charge, description=None, primary_contact_email=None, primary_contact_name=None, primary_contact_phone=None, metadata=None, alternate_model_class=None)

Create a subacount on your integration.

Parameters:

Name Type Description Default
business_name str

Name of business for subaccount

required
settlement_bank str

Bank Code for the bank. You can get the list of Bank Codes by calling the .get_banks method from the Miscellaneous API wrapper

required
account_number str

Bank Account Number

required
percentage_charge float | int

The default percentage charged when receiving on behalf of this subaccount

required
description str | None

A description for this subaccount

None
primary_contact_email str | None

A contact email for the subaccount

None
primary_contact_name str | None

A name for the contact person for this subaccount

None
primary_contact_phone str | None

A phone number to call for this subaccount

None
metadata dict[str, Any] | None

Add a custom_fields attribute which has a list of dictionaries if you would like the fields to be added to your transaction when displayed on the dashboard. Sample: {"custom_fields":[{"display_name":"Cart ID", "variable_name": "cart_id","value": "8393"}]}

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[SubAccount] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/sync_clients/subaccounts.py
def create(
    self,
    business_name: str,
    settlement_bank: str,
    account_number: str,
    percentage_charge: float | int,
    description: str | None = None,
    primary_contact_email: str | None = None,
    primary_contact_name: str | None = None,
    primary_contact_phone: str | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[SubAccount] | Response[PaystackDataModel]:
    """Create a subacount on your integration.

    Args:
        business_name: Name of business for subaccount
        settlement_bank: Bank Code for the bank. You can get the
            list of Bank Codes by calling the ``.get_banks``
            method from the Miscellaneous API wrapper
        account_number: Bank Account Number
        percentage_charge: The default percentage charged when receiving on behalf of this subaccount
        description: A description for this subaccount
        primary_contact_email: A contact email for the subaccount
        primary_contact_name: A name for the contact person for this subaccount
        primary_contact_phone: A phone number to call for this subaccount
        metadata: Add a custom_fields attribute which has a list of dictionaries if
            you would like the fields to be added to your transaction when
            displayed on the dashboard.
            Sample: ``{"custom_fields":[{"display_name":"Cart ID",
            "variable_name": "cart_id","value": "8393"}]}``
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url("/subaccount")
    payload = {
        "business_name": business_name,
        "settlement_bank": settlement_bank,
        "account_number": account_number,
        "percentage_charge": percentage_charge,
        "description": description,
    }
    optional_params = [
        ("primary_contact_email", primary_contact_email),
        ("primary_contact_name", primary_contact_name),
        ("primary_contact_phone", primary_contact_phone),
        ("metadata", metadata),
    ]
    payload = add_to_payload(optional_params, payload)
    return self._handle_request(  # type: ignore
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class or SubAccount,
    )

get_subaccount(id_or_code, alternate_model_class=None)

Get details of a subaccount on your integration.

Parameters:

Name Type Description Default
id_or_code int | str

The subaccount ID or code you want to fetch

required
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[SubAccount] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/sync_clients/subaccounts.py
def get_subaccount(
    self,
    id_or_code: int | str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[SubAccount] | Response[PaystackDataModel]:
    """Get details of a subaccount on your integration.

    Args:
        id_or_code: The subaccount ``ID`` or ``code`` you want to fetch
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url(f"/subaccount/{id_or_code}")
    return self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or SubAccount,
    )

get_subaccounts(start_date=None, end_date=None, page=1, pagination=50, alternate_model_class=None)

Fetch subaccounts available on your integration.

Parameters:

Name Type Description Default
start_date str | None

A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21

None
end_date str | None

A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21

None
page int

Specifies exactly what page you want to retrieve. If not specified we use a default value of 1.

1
pagination int

Specifies how many records you want to retrieve per page. If not specified we use a default value of 50.

50
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[list[SubAccount]] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/sync_clients/subaccounts.py
def get_subaccounts(
    self,
    start_date: str | None = None,
    end_date: str | None = None,
    page: int = 1,
    pagination: int = 50,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[list[SubAccount]] | Response[PaystackDataModel]:
    """Fetch subaccounts available on your integration.

    Args:
        start_date: A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
        end_date: A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
        page: Specifies exactly what page you want to retrieve. If not specified we use a default value of 1.
        pagination: Specifies how many records you want to retrieve per page.
            If not specified we use a default value of 50.
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """
    url = self._full_url(f"/subaccount?perPage={pagination}")
    query_params = [
        ("from", start_date),
        ("to", end_date),
        ("page", page),
    ]
    url = append_query_params(query_params, url)
    return self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or SubAccount,
    )

update(id_or_code, business_name=None, settlement_bank=None, account_number=None, active=None, percentage_charge=None, description=None, primary_contact_email=None, primary_contact_name=None, primary_contact_phone=None, settlement_schedule=None, metadata=None, alternate_model_class=None)

Update a subaccount details on your integration.

Parameters:

Name Type Description Default
id_or_code int | str

Subaccount's ID or code

required
business_name str | None

Name of business for subaccount

None
settlement_bank str | None

Bank Code for the bank. You can get the list of Bank Codes by calling the .get_banks method from the Miscellaneous API wrapper

None
account_number str | None

Bank Account Number

None
active bool | None

Activate or deactivate a subaccount.

None
percentage_charge float | int | None

The default percentage charged when receiving on behalf of this subaccount

None
description str | None

A description for this subaccount

None
primary_contact_email str | None

A contact email for the subaccount

None
primary_contact_name str | None

A name for the contact person for this subaccount

None
primary_contact_phone str | None

A phone number to call for this subaccount

None
settlement_schedule Schedule | None

Schedule.AUTO means payout is T+1 and manual means payout to the subaccount should only be made when requested. Defaults to Schedule.AUTO

None
metadata dict[str, Any] | None

Add a custom_fields attribute which has a list of dictionaries if you would like the fields to be added to your transaction when displayed on the dashboard. Sample: {"custom_fields":[{"display_name":"Cart ID", "variable_name": "cart_id","value": "8393"}]}

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[SubAccount] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/sync_clients/subaccounts.py
def update(
    self,
    id_or_code: int | str,
    business_name: str | None = None,
    settlement_bank: str | None = None,
    account_number: str | None = None,
    active: bool | None = None,
    percentage_charge: float | int | None = None,
    description: str | None = None,
    primary_contact_email: str | None = None,
    primary_contact_name: str | None = None,
    primary_contact_phone: str | None = None,
    settlement_schedule: Schedule | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[SubAccount] | Response[PaystackDataModel]:
    """Update a subaccount details on your integration.

    Args:
        id_or_code: Subaccount's ID or code
        business_name: Name of business for subaccount
        settlement_bank: Bank Code for the bank. You can get the
            list of Bank Codes by calling the ``.get_banks``
            method from the Miscellaneous API wrapper
        account_number: Bank Account Number
        active: Activate or deactivate a subaccount.
        percentage_charge: The default percentage charged when
            receiving on behalf of this subaccount
        description: A description for this subaccount
        primary_contact_email: A contact email for the subaccount
        primary_contact_name: A name for the contact person for this subaccount
        primary_contact_phone: A phone number to call for this subaccount
        settlement_schedule: ``Schedule.AUTO`` means payout is T+1 and manual means payout to the
            subaccount should only be made when requested.
            Defaults to ``Schedule.AUTO``
        metadata: Add a custom_fields attribute which has a list of dictionaries if you would
            like the fields to be added to your transaction when displayed on the
            dashboard. Sample: ``{"custom_fields":[{"display_name":"Cart ID",
            "variable_name": "cart_id","value": "8393"}]}``
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    payload = {
        "id_or_code": id_or_code,
        "business_name": business_name,
        "settlement_bank": settlement_bank,
    }
    optional_params = [
        ("account_number", account_number),
        ("active", active),
        ("percentage_charge", percentage_charge),
        ("description", description),
        ("primary_contact_email", primary_contact_email),
        ("primary_contact_name", primary_contact_name),
        ("primary_contact_phone", primary_contact_phone),
        ("settlement_schedule", settlement_schedule),
        ("metadata", metadata),
    ]
    payload = add_to_payload(optional_params, payload)
    url = self._full_url(f"/subaccount/{id_or_code}")
    return self._handle_request(  # type: ignore
        HTTPMethod.PUT,
        url,
        payload,
        response_data_model_class=alternate_model_class or SubAccount,
    )

AsyncSubAccountClient

Bases: BaseAsyncAPIClient

Provides a wrapper for paystack Subaccounts API

The Subaccounts API allows you to create and manage subaccounts on your integration. Subaccounts can be used to split payment between two accounts (your main account and a sub account). https://paystack.com/docs/api/subaccount/

Source code in src/pypaystack2/sub_clients/async_clients/subaccounts.py
class AsyncSubAccountClient(BaseAsyncAPIClient):
    """Provides a wrapper for paystack Subaccounts API

    The Subaccounts API allows you to create and manage subaccounts on your integration.
    Subaccounts can be used to split payment between two accounts
    (your main account and a sub account).
    https://paystack.com/docs/api/subaccount/
    """

    async def create(
        self,
        business_name: str,
        settlement_bank: str,
        account_number: str,
        percentage_charge: float | int,
        description: str | None = None,
        primary_contact_email: str | None = None,
        primary_contact_name: str | None = None,
        primary_contact_phone: str | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[SubAccount] | Response[PaystackDataModel]:
        """Create a subacount on your integration.

        Args:
            business_name: Name of business for subaccount
            settlement_bank: Bank Code for the bank. You can get the
                list of Bank Codes by calling the ``.get_banks``
                method from the Miscellaneous API wrapper
            account_number: Bank Account Number
            percentage_charge: The default percentage charged when receiving on behalf of this subaccount
            description: A description for this subaccount
            primary_contact_email: A contact email for the subaccount
            primary_contact_name: A name for the contact person for this subaccount
            primary_contact_phone: A phone number to call for this subaccount
            metadata: Add a custom_fields attribute which has a list of dictionaries if
                you would like the fields to be added to your transaction when
                displayed on the dashboard.
                Sample: ``{"custom_fields":[{"display_name":"Cart ID",
                "variable_name": "cart_id","value": "8393"}]}``
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url("/subaccount")
        payload = {
            "business_name": business_name,
            "settlement_bank": settlement_bank,
            "account_number": account_number,
            "percentage_charge": percentage_charge,
            "description": description,
        }
        optional_params = [
            ("primary_contact_email", primary_contact_email),
            ("primary_contact_name", primary_contact_name),
            ("primary_contact_phone", primary_contact_phone),
            ("metadata", metadata),
        ]
        payload = add_to_payload(optional_params, payload)
        return await self._handle_request(  # type: ignore
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class or SubAccount,
        )

    async def get_subaccounts(
        self,
        start_date: str | None = None,
        end_date: str | None = None,
        page: int = 1,
        pagination: int = 50,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[list[SubAccount]] | Response[PaystackDataModel]:
        """Fetch subaccounts available on your integration.

        Args:
            start_date: A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
            end_date: A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
            page: Specifies exactly what page you want to retrieve. If not specified we use a default value of 1.
            pagination: Specifies how many records you want to retrieve per page.
                If not specified we use a default value of 50.
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """
        url = self._full_url(f"/subaccount?perPage={pagination}")
        query_params = [
            ("from", start_date),
            ("to", end_date),
            ("page", page),
        ]
        url = append_query_params(query_params, url)
        return await self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or SubAccount,
        )

    async def get_subaccount(
        self,
        id_or_code: int | str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[SubAccount] | Response[PaystackDataModel]:
        """Get details of a subaccount on your integration.

        Args:
            id_or_code: The subaccount ``ID`` or ``code`` you want to fetch
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url(f"/subaccount/{id_or_code}")
        return await self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or SubAccount,
        )

    async def update(
        self,
        id_or_code: int | str,
        business_name: str | None = None,
        settlement_bank: str | None = None,
        account_number: str | None = None,
        active: bool | None = None,
        percentage_charge: float | int | None = None,
        description: str | None = None,
        primary_contact_email: str | None = None,
        primary_contact_name: str | None = None,
        primary_contact_phone: str | None = None,
        settlement_schedule: Schedule | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[SubAccount] | Response[PaystackDataModel]:
        """Update a subaccount details on your integration.

        Args:
            id_or_code: Subaccount's ID or code
            business_name: Name of business for subaccount
            settlement_bank: Bank Code for the bank. You can get the
                list of Bank Codes by calling the ``.get_banks``
                method from the Miscellaneous API wrapper
            account_number: Bank Account Number
            active: Activate or deactivate a subaccount.
            percentage_charge: The default percentage charged when
                receiving on behalf of this subaccount
            description: A description for this subaccount
            primary_contact_email: A contact email for the subaccount
            primary_contact_name: A name for the contact person for this subaccount
            primary_contact_phone: A phone number to call for this subaccount
            settlement_schedule: ``Schedule.AUTO`` means payout is T+1 and manual means payout to the
                subaccount should only be made when requested.
                Defaults to ``Schedule.AUTO``
            metadata: Add a custom_fields attribute which has a list of dictionaries if you would
                like the fields to be added to your transaction when displayed on the
                dashboard. Sample: ``{"custom_fields":[{"display_name":"Cart ID",
                "variable_name": "cart_id","value": "8393"}]}``
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        payload = {
            "id_or_code": id_or_code,
            "business_name": business_name,
            "settlement_bank": settlement_bank,
        }
        optional_params = [
            ("account_number", account_number),
            ("active", active),
            ("percentage_charge", percentage_charge),
            ("description", description),
            ("primary_contact_email", primary_contact_email),
            ("primary_contact_name", primary_contact_name),
            ("primary_contact_phone", primary_contact_phone),
            ("settlement_schedule", settlement_schedule),
            ("metadata", metadata),
        ]
        payload = add_to_payload(optional_params, payload)
        url = self._full_url(f"/subaccount/{id_or_code}")
        return await self._handle_request(  # type: ignore
            HTTPMethod.PUT,
            url,
            payload,
            response_data_model_class=alternate_model_class or SubAccount,
        )

create(business_name, settlement_bank, account_number, percentage_charge, description=None, primary_contact_email=None, primary_contact_name=None, primary_contact_phone=None, metadata=None, alternate_model_class=None) async

Create a subacount on your integration.

Parameters:

Name Type Description Default
business_name str

Name of business for subaccount

required
settlement_bank str

Bank Code for the bank. You can get the list of Bank Codes by calling the .get_banks method from the Miscellaneous API wrapper

required
account_number str

Bank Account Number

required
percentage_charge float | int

The default percentage charged when receiving on behalf of this subaccount

required
description str | None

A description for this subaccount

None
primary_contact_email str | None

A contact email for the subaccount

None
primary_contact_name str | None

A name for the contact person for this subaccount

None
primary_contact_phone str | None

A phone number to call for this subaccount

None
metadata dict[str, Any] | None

Add a custom_fields attribute which has a list of dictionaries if you would like the fields to be added to your transaction when displayed on the dashboard. Sample: {"custom_fields":[{"display_name":"Cart ID", "variable_name": "cart_id","value": "8393"}]}

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[SubAccount] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/async_clients/subaccounts.py
async def create(
    self,
    business_name: str,
    settlement_bank: str,
    account_number: str,
    percentage_charge: float | int,
    description: str | None = None,
    primary_contact_email: str | None = None,
    primary_contact_name: str | None = None,
    primary_contact_phone: str | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[SubAccount] | Response[PaystackDataModel]:
    """Create a subacount on your integration.

    Args:
        business_name: Name of business for subaccount
        settlement_bank: Bank Code for the bank. You can get the
            list of Bank Codes by calling the ``.get_banks``
            method from the Miscellaneous API wrapper
        account_number: Bank Account Number
        percentage_charge: The default percentage charged when receiving on behalf of this subaccount
        description: A description for this subaccount
        primary_contact_email: A contact email for the subaccount
        primary_contact_name: A name for the contact person for this subaccount
        primary_contact_phone: A phone number to call for this subaccount
        metadata: Add a custom_fields attribute which has a list of dictionaries if
            you would like the fields to be added to your transaction when
            displayed on the dashboard.
            Sample: ``{"custom_fields":[{"display_name":"Cart ID",
            "variable_name": "cart_id","value": "8393"}]}``
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url("/subaccount")
    payload = {
        "business_name": business_name,
        "settlement_bank": settlement_bank,
        "account_number": account_number,
        "percentage_charge": percentage_charge,
        "description": description,
    }
    optional_params = [
        ("primary_contact_email", primary_contact_email),
        ("primary_contact_name", primary_contact_name),
        ("primary_contact_phone", primary_contact_phone),
        ("metadata", metadata),
    ]
    payload = add_to_payload(optional_params, payload)
    return await self._handle_request(  # type: ignore
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class or SubAccount,
    )

get_subaccount(id_or_code, alternate_model_class=None) async

Get details of a subaccount on your integration.

Parameters:

Name Type Description Default
id_or_code int | str

The subaccount ID or code you want to fetch

required
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[SubAccount] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/async_clients/subaccounts.py
async def get_subaccount(
    self,
    id_or_code: int | str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[SubAccount] | Response[PaystackDataModel]:
    """Get details of a subaccount on your integration.

    Args:
        id_or_code: The subaccount ``ID`` or ``code`` you want to fetch
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url(f"/subaccount/{id_or_code}")
    return await self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or SubAccount,
    )

get_subaccounts(start_date=None, end_date=None, page=1, pagination=50, alternate_model_class=None) async

Fetch subaccounts available on your integration.

Parameters:

Name Type Description Default
start_date str | None

A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21

None
end_date str | None

A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21

None
page int

Specifies exactly what page you want to retrieve. If not specified we use a default value of 1.

1
pagination int

Specifies how many records you want to retrieve per page. If not specified we use a default value of 50.

50
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[list[SubAccount]] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/async_clients/subaccounts.py
async def get_subaccounts(
    self,
    start_date: str | None = None,
    end_date: str | None = None,
    page: int = 1,
    pagination: int = 50,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[list[SubAccount]] | Response[PaystackDataModel]:
    """Fetch subaccounts available on your integration.

    Args:
        start_date: A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
        end_date: A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
        page: Specifies exactly what page you want to retrieve. If not specified we use a default value of 1.
        pagination: Specifies how many records you want to retrieve per page.
            If not specified we use a default value of 50.
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """
    url = self._full_url(f"/subaccount?perPage={pagination}")
    query_params = [
        ("from", start_date),
        ("to", end_date),
        ("page", page),
    ]
    url = append_query_params(query_params, url)
    return await self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or SubAccount,
    )

update(id_or_code, business_name=None, settlement_bank=None, account_number=None, active=None, percentage_charge=None, description=None, primary_contact_email=None, primary_contact_name=None, primary_contact_phone=None, settlement_schedule=None, metadata=None, alternate_model_class=None) async

Update a subaccount details on your integration.

Parameters:

Name Type Description Default
id_or_code int | str

Subaccount's ID or code

required
business_name str | None

Name of business for subaccount

None
settlement_bank str | None

Bank Code for the bank. You can get the list of Bank Codes by calling the .get_banks method from the Miscellaneous API wrapper

None
account_number str | None

Bank Account Number

None
active bool | None

Activate or deactivate a subaccount.

None
percentage_charge float | int | None

The default percentage charged when receiving on behalf of this subaccount

None
description str | None

A description for this subaccount

None
primary_contact_email str | None

A contact email for the subaccount

None
primary_contact_name str | None

A name for the contact person for this subaccount

None
primary_contact_phone str | None

A phone number to call for this subaccount

None
settlement_schedule Schedule | None

Schedule.AUTO means payout is T+1 and manual means payout to the subaccount should only be made when requested. Defaults to Schedule.AUTO

None
metadata dict[str, Any] | None

Add a custom_fields attribute which has a list of dictionaries if you would like the fields to be added to your transaction when displayed on the dashboard. Sample: {"custom_fields":[{"display_name":"Cart ID", "variable_name": "cart_id","value": "8393"}]}

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[SubAccount] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/async_clients/subaccounts.py
async def update(
    self,
    id_or_code: int | str,
    business_name: str | None = None,
    settlement_bank: str | None = None,
    account_number: str | None = None,
    active: bool | None = None,
    percentage_charge: float | int | None = None,
    description: str | None = None,
    primary_contact_email: str | None = None,
    primary_contact_name: str | None = None,
    primary_contact_phone: str | None = None,
    settlement_schedule: Schedule | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[SubAccount] | Response[PaystackDataModel]:
    """Update a subaccount details on your integration.

    Args:
        id_or_code: Subaccount's ID or code
        business_name: Name of business for subaccount
        settlement_bank: Bank Code for the bank. You can get the
            list of Bank Codes by calling the ``.get_banks``
            method from the Miscellaneous API wrapper
        account_number: Bank Account Number
        active: Activate or deactivate a subaccount.
        percentage_charge: The default percentage charged when
            receiving on behalf of this subaccount
        description: A description for this subaccount
        primary_contact_email: A contact email for the subaccount
        primary_contact_name: A name for the contact person for this subaccount
        primary_contact_phone: A phone number to call for this subaccount
        settlement_schedule: ``Schedule.AUTO`` means payout is T+1 and manual means payout to the
            subaccount should only be made when requested.
            Defaults to ``Schedule.AUTO``
        metadata: Add a custom_fields attribute which has a list of dictionaries if you would
            like the fields to be added to your transaction when displayed on the
            dashboard. Sample: ``{"custom_fields":[{"display_name":"Cart ID",
            "variable_name": "cart_id","value": "8393"}]}``
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    payload = {
        "id_or_code": id_or_code,
        "business_name": business_name,
        "settlement_bank": settlement_bank,
    }
    optional_params = [
        ("account_number", account_number),
        ("active", active),
        ("percentage_charge", percentage_charge),
        ("description", description),
        ("primary_contact_email", primary_contact_email),
        ("primary_contact_name", primary_contact_name),
        ("primary_contact_phone", primary_contact_phone),
        ("settlement_schedule", settlement_schedule),
        ("metadata", metadata),
    ]
    payload = add_to_payload(optional_params, payload)
    url = self._full_url(f"/subaccount/{id_or_code}")
    return await self._handle_request(  # type: ignore
        HTTPMethod.PUT,
        url,
        payload,
        response_data_model_class=alternate_model_class or SubAccount,
    )