Async Charge Module

This wrapper class facilitates asynchronous interaction with Paystack Charges API. The Charge API allows you to configure payment channel of your choice when initiating a payment.

To access the Charges API methods, you need to call the charges instance method from AsyncPayStackBase.

Check example on Asynchronous Paystack Wrapper


class AsyncChargesClientAPI(secret_key: str = None)

Paystack Charges API Reference: Charges

async check_pending_charge(reference: str)→ PayStackResponse

Check pending charge

Parameters:

reference (str) – The reference to check

Returns:

The response from the API.

Return type:

PayStackResponse object

async create_charge(email: str, amount: int, metadata: Dict[str, List[Dict[str, str]]], pin: int | None = None, authorization_code: str | None = None, reference: str | None = None, device_id: str | None = None, bank: Dict[str, str] | None = None, bank_transfer: Dict[str, Any] | None = None, qr: Dict[str, str] | None = None, ussd: Dict[str, str] | None = None, mobile_money: Dict[str, str] | None = NoneisPayStackResponse

Create a new charge

Parameters:
  • email (str) – The email of the customer

  • amount (int) – The amount to charge

  • metadata (dict) – The metadata of the charge. A JSON object

  • pin (int, optional) – The pin of the customer

  • authorization_code (str, optional) – The authorization code of the customer

  • reference (str, optional) – The reference of the charge

  • device_id (str, optional) – The device id of the customer

  • bank (dict, optional) – Bank account to charge

  • bank_transfer (dict, optional) – Takes the settings for the Pay with Transfer (PwT) channel

  • qr (dict, optional) – QR type to charge

  • ussd (dict, optional) – USSD type to charge

  • mobile_money (dict, optional) – The mobile money details

Returns:

The response from the API.

Return type:

PayStackResponse object

async submit_address(reference: str, address: str, city: str, state: str, zipcode: str)→ PayStackResponse

Submit address to continue a charge

Parameters:
  • reference (str) – The reference of the charge

  • address (str) – The address of the customer

  • city (str) – The city of the customer

  • state (str) – The state of the customer

  • zipcode (str) – The zipcode of the customer

Returns:

The response from the API.

Return type:

PayStackResponse object

async submit_birthday(birthday: date, reference: str)→ PayStackResponse

Submit birthday when required

Parameters:
  • birthday (date) – The birthday of the customer

  • reference (str) – The reference of the charge

Returns:

The response from the API.

Return type:

PayStackResponse object

async submit_otp(otp: int, reference: str)→ PayStackResponse

Submit otp to complete a charge

Parameters:
  • otp (int) – The otp of the customer

  • reference (str) – The reference of the charge

Returns:

The response from the API.

Return type:

PayStackResponse object

async submit_phone(phone: str, reference: str)→ PayStackResponse

Submit a phone number to complete a charge

Parameters:
  • phone (str) – The phone of the customer

  • reference (str) – The reference of the charge

Returns:

The response from the API.

Return type:

PayStackResponse object

async submit_pin(pin: int, reference: str)→ PayStackResponse

Submit a PIN for a charge

Parameters:
  • pin (int) – The pin of the customer

  • reference (str) – The reference of the charge

Returns:

The response from the API.

Return type:

PayStackResponse object

The bank parameter is a dictionary with the following set as keys: code and account_number. This feature is only available in Nigeria.

See example:

>>> "bank": {
>>>     "code": "057",
>>>     "account_number": "1234567890"
>>> }

The bank_transfer parameter is a dictionary with the PWT enum string value set as key: PWT.ACCOUNT_EXPIRES_AT.value. This feature is only available in Nigeria and contact support@paystack.com to enable it on their integration.

See example:

>>> "bank_transfer": {
>>>     "account_expires_at": "2023-09-12T13:10:00Z"
>>> }

The qr parameter is a dictionary with key set to: provider. This feature is only available in South Africa and Nigeria.

See example:

>>> "qr": {
>>>     "provider": "visa"  # Nigeria provider. For South Africa provider use "scan-to-pay"
>>> }

Note

The scan-to-pay provider supports both SnapScan and Scan to Pay (formerly Masterpass) supported apps for completing a payment.

The ussd parameter is a dictionary with key set to: type. This feature is only available in Nigeria.

See example:

>>> "ussd": {
>>>     "type": "737"
>>> }

The mobile_money parameter is a dictionary with the following set as keys: phone and provider. This feature is only available in Ghana and Kenya*.

See example:

>>> "mobile_money": {
>>>     "phone": "0551234987",
>>>     "provider": "mtn"
>>> }

Refer to this documentation for more information: Tool kit module.

The metadata parameter is a JSON object that uses the custom_fields type of metadata. See What are the metadata to be passed in the request data? for more information.

To ensure a successful API request to Paystack for creating a charge, follow these essential rules:

  1. Do not send or use the following if charging an authorization code:
    • bank

    • ussd

    • mobile_money

  2. Do not send or use the following if charging an authorization code, bank or card:
    • ussd

    • mobile_money

  3. Send with a non-reusable authorization code:
    • pin

Kindly note that authorization_code is gotten after a successful card transaction. Refer here to read more Async Transactions Module.