Skip to main content

ErcasPay

A python package that simplifies https://docs.ercaspay.com/ payment api integration into your python projects.

Installation

This package requires the request library to be installed

pip install requests==2.32.3
pip install python-ercas-ng

Usage

from Ercasng.ercaspay import ErcasPay

## Do not hardcode your secret key inside your code

## Instanstiate ErcasPay Object with your ercasPay secret key

ercas_object = ErcasPay(ercas_pay_secret_key: str)

Initiate Transaction Demo

#This function/method could be a view for django, flask, fastapi or something else.

def initialize_transaction(request):
    amount = 100.00 # Amount for the transaction. Mandatory
    payment_refrence = "R5md7gd9b4s3h2j5d67g" # Payment refrence for the transaction. Mandatory
    customer_name = "FirstName LastName" # Customer name. Mandatory
    customer_email = "customer@example.com" # Customer email. Mandatory
    customer_phone = "08012345678" # Customer phone number. Optional
    redirect_url = "http://redirect.example.com" #Redirect URL. Optional
    description = "Description" # Description. Optional

    ## if the target customer will pay in naira:
        # use the ngn_init method
    # else 
        # use the usd_init method.

    ## Initiate Naira Transaction
    ngn_init = ercas_object.naira_initiate_transaction(self, amount:float, payment_reference:str,
                                   customer_name:str, customer_email:str,
                                   customer_phone:str = None, redirect_url:str=None,
                                   descrption:str = None)

    ## Initiate USD Transaction
    usd_init = ercas_object.usd_initiate_transaction(self, amount:float, payment_reference:str,
                                   customer_name:str, customer_email:str,
                                   customer_phone:str = None, redirect_url:str=None,
                                   descrption:str = None)


     ## handle Successful response for any of the above methods
     if ngn_init["tx_status"]:
        return {
            "tx_status": True,
            "tx_code": "success",
            "tx_body": {
                "payment_reference": "R5md7gd9b4s3h2j5d67g",
                "tx_reference": "ERCS|20231113082706|1699860426792",
                "checkoutUrl": "https://sandbox-checkout.ercaspay.com/ERCS|20231113082706|1699860426792"
            }
        }

        ## The Checkout URL is required and should be returned to and loaded from the frontend to complete the payment checkout

    ## Handle Unsuccessful Response
    return {
                "tx_status": False,
                "tx_code": "failed",
                "error_message": "Actual error that occurred",
                "tx_body": []
            }

Verify Transaction Demo

#This function/method could be a view for django, flask, fastapi or something else.

def verify_transaction(request):
    transaction_reference = "transaction_reference"
    verify_tx = ercas_object.verify_transaction(transaction_reference)

    ## Handle Successful Response
    if verify_tx["tx_status"]:
        return {
            "tx_status": True,
            "tx_code": "success",
            "tx_message": "Transaction fetched successfully",
            "tx_body": {
                "domain": "test",
                "status": "SUCCESSFUL",
                "ercs_reference": "ERCS|20231112152333|1699799013942",
                "tx_reference": "CSHM|WLTP|48606GWR",
                "amount": 100,
                "description": null,
                "paid_at": "2023-11-12T14:24:58.000000Z",
                "created_at": "2023-11-12T14:23:33.000000Z",
                "channel": "BANK_TRANSFER",
                "currency": "NGN",
                "metadata": "{\"firstname\":\"\",\"lastname\":\"Benson\",\"email\":\"iie@mail.com\"}",
                "fee": 1.4,
                "fee_bearer": "customer",
                "settled_amount": 100,
                "customer": {
                "name": "FirstName LastName",
                "phone_number": "09061628409",
                "email": "customer@email.com",
                "reference": "ZEKvFI-N8lMHY"
                }
            }

        ## Handle Unccessful Response
        if not verify_tx["tx_status"]:
            return {
                "tx_status": False,
                "error_message": "Actual error message",
                "tx_code": "failed",
                "tx_body": []
                }

Metadata

Release files for python-ercas-ng 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-ercas-ng 1.0.0
File Size Uploaded Provenance Actions
python_ercas_ng-1.0.0.tar.gz 4.6 kB Without provenance Details for python_ercas_ng-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-ercas-ng 1.0.0
File Interpreter ABI Platform Actions
python_ercas_ng-1.0.0-py3-none-any.whl Python 3 none any Details for python_ercas_ng-1.0.0-py3-none-any.whl

Total release size: 9.7 kB

Release files / python_ercas_ng-1.0.0.tar.gz

Download URL python_ercas_ng-1.0.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ed8214c52b0364280522211cb913bd4441dc15cfa76adf637b4c205245dfe91c
BLAKE2b-256 checksum
How to use checksums
caeeeee5c409d60cf6b25fbbfea91754058dfba76904106bc4b5ccc3f57affd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / python_ercas_ng-1.0.0-py3-none-any.whl

Download URL python_ercas_ng-1.0.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ca52c25f4bdeb02cc6ab744c4fc74040364ee8897e0899163a1c67f850ffe5a
BLAKE2b-256 checksum
How to use checksums
4e756c88bb4202662371f9b5f34ab8464edf69041f66fb993932e1d0fd8d9b3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Security for python-ercas-ng 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page