Skip to main content

A Python client for the WaafiPay API

Project description

WaafiPay Python Client

WaafiPay Logo

Overview

The WaafiPay Python Client is a simple and intuitive library for integrating with the WaafiPay payment gateway. It allows you to perform various payment operations such as preauthorizing payments, committing transactions, and canceling preauthorizations, all while managing your API requests seamlessly.

Features

  • Preauthorize Payments: Easily initiate payment preauthorizations with just a few lines of code.
  • Commit Transactions: Securely commit preauthorized payments to finalize transactions.
  • Cancel Preauthorizations: Cancel any pending preauthorizations quickly and efficiently.
  • Easy to Use: Designed with simplicity in mind, making integration straightforward.
  • Secure: Handles sensitive payment information with care.

Installation

You can install the WaafiPay package via pip:

pip install waafipay

Usage

1. Import the Client

First, import the WaafiPayClient class from the package:

from waafipay import WaafiPayClient

2. Initialize the Client

client = WaafiPayClient(
    merchant_uid="XXXXXXX",  # Your merchant UID
    api_user_id="XXXXXX",     # Your API user ID
    api_key="API-XXXXXXXX"  # Your API key
)

3. Preauthorize a Payment

client.preauthorize_payment(
    payer_account="61XXXXXXX", # Payer Account
    amount="0.01", # Amount
    )

4. Commit the Preauthorization

response = client.preauthorize(
    payer_account="61XXXXXXXX", 
    amount="0.01",
    )

response_code = response['responseCode']
if response_code == '2001':
    transaction_id = response['transactionId']
    client.commit(transaction_id=transaction_id)
else:
    errorMessage = response['responseMsg']
    print(errorMessage)

5. Cancel the Preauthorization

response = client.preauthorize(
    payer_account="61XXXXXXXX", 
    amount="0.01",
    )

response_code = response['responseCode']
if response_code == '2001':
    transaction_id = response['transactionId']
    client.cancel(transaction_id=transaction_id)
else:
    errorMessage = response['responseMsg']
    print(errorMessage)

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

waafipay-0.0.8.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

waafipay-0.0.8-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file waafipay-0.0.8.tar.gz.

File metadata

  • Download URL: waafipay-0.0.8.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for waafipay-0.0.8.tar.gz
Algorithm Hash digest
SHA256 986771c8ccc79a8a63b6add192e5a228d7e4d0e04d89c4a07796bb13098babcc
MD5 52dd1f0d81cab94e82af7df7ceab5f8f
BLAKE2b-256 de42b1db361b543e3b0f650c3bb1b76a30e6fd49c228a37f92a3a7034660d652

See more details on using hashes here.

File details

Details for the file waafipay-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: waafipay-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for waafipay-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 be0c73c9ae3554d1a4ecd5b13fc3790fcf4a1309d3314073607d9d16016d87d9
MD5 2381497cd5bb7c018b35bceea08a6afc
BLAKE2b-256 898e610b3278731fd93fa2482bbae607f6d6b34e90ce0e0b5eb5d83c20851748

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