Async Customers Module

This wrapper class facilitates asynchronous interaction with Paystack Customers API. The Customers API allows you to create and manage customers on your integration.

To access the Customers API methods, you need to call the customers instance method from AsyncPayStackBase.

Check example on Asynchronous Paystack Wrapper


class AsyncCustomerClientAPI(secret_key: str = None)

Paystack Customer API Reference: Customer

async create_customer(email: str, first_name: str, last_name: str, phone: str, metadata: Dict[str, Any] | None = None)→ PayStackResponse

Create a new customer.

Parameters:
  • email (str) – The customer’s email address.

  • first_name (str) – The customer’s first name.

  • last_name (str) – The customer’s last name.

  • phone (str) – The customer’s phone number.

  • metadata (dict, optional) – The metadata of the customer in JSON format.

Returns:

The response from the API.

Return type:

PayStackResponse object

async deactivate_authorization(authorization_code: str)→ PayStackResponse

Deactivate an authorization.

Parameters:

authorization_code (str) – The authorization code.

Returns:

The response from the API.

Return type:

PayStackResponse object

async fetch_customer(email_or_code: str)→ PayStackResponse

Fetch a customer.

Parameters:

email_or_code (str) – The customer’s email or code.

Returns:

The response from the API

Return type:

PayStackResponse object

async list_customers(per_page: int | None = 50, page: int | None = 1, from_date: date | None = None, to_date: date | None = None)→ PayStackResponse

List customers.

Parameters:
  • per_page (int, optional) – The number of customers to return per page (default: 50).

  • page (int, optional) – The page to return (default: 1).

  • from_date (date, optional) – The customer’s from date.

  • to_date (date, optional) – The customer’s to date.

Returns:

The response from the API

Return type:

PayStackResponse object

async update_customer(customer_code: str, first_name: str | None = None, last_name: str | None = None, phone: str | None = None, metadata: Dict[str, Any] | None = None)→ PayStackResponse

Update a customer.

Parameters:
  • customer_code (str) – The customer’s code.

  • first_name (str, optional) – The customer’s first name.

  • last_name (str, optional) – The customer’s last name.

  • phone (str, optional) – The customer’s phone number.

  • metadata (dict, optional) – The customer’s metadata.

Returns:

The response from the API.

Return type:

PayStackResponse object

async validate_customer(email_or_code: str, first_name: str, last_name: str, account_type: str, country: str, bank_code: str, account_number: str, bvn: str, customer_id_num: str | None = None, middle_name: str | None = None)→ PayStackResponse

Validate a customer.

Parameters:
  • email_or_code (str) – The customer’s code.

  • first_name (str) – The customer’s first name.

  • last_name (str) – The customer’s last name.

  • account_type (str) – The type of account. Only "bank_account" is currently supported.

  • country (str) – The country of the customer. 2-letter country code of identification issuer

  • bank_code (str) – The customer’s bank code.

  • account_number (str) – The customer’s account number.

  • bvn (str) – The customer’s bvn [Bank Verification Number]

  • customer_id_num (str, optional) – The customer identification number

  • middle_name (str, optional) – The customer’s middle name.

Returns:

The response from the API.

Return type:

PayStackResponse object

async whitelist_blacklist_customer(email_or_code: str, risk_action: str | None = None)→ PayStackResponse

Whitelist or blacklist a customer.

Parameters:
  • email_or_code (str) – The customer’s code.

  • risk_action (str, optional) – The action to take on the customer

Returns:

The response from the API

Return type:

PayStackResponse object

In creating a customer, the metadata parameter is of the key-value pair metadata type. See more on What are the metadata to be passed in the request data?.

>>> {
>>>     "metadata": {
>>>         'key': "value"
>>>     }
>>> }

The risk_action parameter takes in a string value of the Risk Action enum member. See more on Tool kit module

>>> from paystackease import RiskAction
>>> risk_action = RiskAction.DENY.value
>>> print(risk_action)
$ python
>>> 'deny'