Skip to main content

This is a simple api wrapper that implements both asynchronous and synchronous http requests to interact with Paystack APIs.

Project description

PayStackEase Library


Python Versions License pypi

PayStackEase API Library is a Python library that simplifies interacting with the Paystack API. It provides both asynchronous and synchronous wrappers for various Paystack functionalities, making it easier to integrate payment processing into your Python projects.

📝: Read more on paystack api documentation: Paystack API DOCUMENTATION

📝: Read more on paystackease api documentation: PayStackEase DOCUMENTATION

Getting Started

You should create a Paystack account to generate a Paystack Secret Key. You can see this in the settings page >> API keys and Webhook section.

⚠️: Warning: Do not expose your secret key or commit your secret key to git, or use them in client-side code.

💡: Take Note: Public key is to be used from your front-end when integrating using Paystack Inline. In this case you have to use you secret key

✅: Good: Set your secret key in environment variables as seen: PAYSTACK_SECRET_KEY=your-secret-key

Create a Virtual Environment

  1. For Windows:

    • Create virtual environment

          py -m venv <environment_name>
      
    • Activate the virtual environment

          <environment_name>\Scripts\activate
      
  2. For Unix/macOS

    • Create virtual environment

          python3 -m venv <environment_name>
      
    • Activate the virtual environment

          <environment_name>/bin/activate
      

Install paystackease library:

  • Install paystackease using pip.

pip install paystackease

  • Install paystackease using pipx.

pipx install paystackease

  • Install paystackease using poetry.

poetry add paystackease

If you want to download the sdist packages directly:

Download the wheel distribution file and install using pip

pip install paystackease-2.0.0-py3-none-any.whl

Download the source distribution file, and install using pip

pip install paystackease-2.0.0.tar.gz

To get a development version of paystackease

Clone from the dev branch GitHub repository, unzip and install:

git clone -b dev https://github.com/cla-bit/PayStackEase.git

cd PayStackEase

pip install paystackease


API usage


Making a Transaction [Synchronous]

If after setting your secret key in environment variables, for a synchronous transaction process all you need to do is use the transaction API to make a transaction.

To create a transaction or initialize a transaction:

  • import the Paystack API wrapper.
    from paystackease import PayStackBase
  • Create an instance to use the PaystackBase wrapper to interact with the Transaction API.
    paystack_client = PayStackBase()
  • Use the instance and call the transaction method to initialize a transaction
    create_transaction = paystack_client.transactions.initialize(
        email="johndoe@email.com",
        amount=10000000)
    
    print(f"Transaction Created: {create_transaction}")

✅: Good: You can check your Paystack account, go to the Transaction page, and you will see the transaction just created.

Other Tools

Similar to calling the PayStackBase, you can also call other tools to make your work easy. For example:

  • Account Type

    from paystackease import AccountType
    
    val1 = AccountType.PERSONAL.value
    
    print(val1)

"personal"

  • Convert units to subunits:

    from paystackease import convert_to_subunit
    
    # amount should be in subunit in this case 10000 kobo = 100 naira
    money = convert_to_subunit(100, Currency.NGN)
    print(money)

10000

  • Channels

    from paystackease import Channels
    
    bank = Channels.BANK.value
    
    print(bank)

"bank"

  • Currency

    from paystackease import Currency
    
    val1 = Currency.NGN.value
    
    print(val1)

"NGN"

  • Document Type

    from paystackease import DocumentType
    
    val1 = DocumentType.IDENTITY_NUMBER.value
    
    print(val1)

"identityNumber"

Others are: EventType, Interval, MobileMoney, PWT, QRCODE, RecipientType, ResendOTP, Resolution, RiskAction, SplitType, STATUS, etc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paystackease-2.3.5.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paystackease-2.3.5-py3-none-any.whl (83.9 kB view details)

Uploaded Python 3

File details

Details for the file paystackease-2.3.5.tar.gz.

File metadata

  • Download URL: paystackease-2.3.5.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.25 Linux/6.11.0-1018-azure

File hashes

Hashes for paystackease-2.3.5.tar.gz
Algorithm Hash digest
SHA256 a58f1966e826e70a7e2610b36f325f145edb4c81116b836102a2b201deb7127c
MD5 e6455bf5c53ad038277347148588f12e
BLAKE2b-256 fbc84ffc85198e80bf6bd7862bbb1e7f0aed8a4d4604018edd5c6aa36714bbef

See more details on using hashes here.

File details

Details for the file paystackease-2.3.5-py3-none-any.whl.

File metadata

  • Download URL: paystackease-2.3.5-py3-none-any.whl
  • Upload date:
  • Size: 83.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.25 Linux/6.11.0-1018-azure

File hashes

Hashes for paystackease-2.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 589a0a5e89283a1caf149ed1b00eeb483ddd6c9360a333895681cd5b38b98f9a
MD5 531346c7cfab29f78fab43e00c0fc2c4
BLAKE2b-256 391e85708d5c56b99fb28021a617c09f58f6faa437c33d9e6f6a730b85e4219c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page