Skip to main content

Installation

pip install pesepay

Getting Started

Import the library into your project/application

from pesepay import Pesepay

Create an instance of the Pesepay class using your integration key and encryption key as supplied by Pesepay.

pesepay = Pesepay("INTEGRATION KEY", "ENCRYPTION KEY");

Set return and result urls

pesepay.result_url = 'https://example.com/result'
pesepay.return_url = 'https://example.com/return'

Sandbox

Pass True as the third argument to send all requests to the sandbox environment. It defaults to False (production).

pesepay = Pesepay("SANDBOX INTEGRATION KEY", "SANDBOX ENCRYPTION KEY", True)

Sandbox base URL: https://api.test.sandbox.pesepay.com/payments-engine Production base URL: https://api.pesepay.com/api/payments-engine

Use sandbox keys with the sandbox URL and production keys with the production URL. The sandbox only supports USD and the PZW211 (EcoCash), PZW204 (Visa) and PZW205 (Mastercard) payment methods.

Make seamless payment

Create the payment

NB: Customer email or number should be provided
payment = pesepay.create_payment('CURRECNCY_CODE', 'PAYMENT_METHOD_CODE', 'CUSTOMER_EMAIL', 
   'CUSTOMER_PHONE_NUMBER(OPTIONAL)', 'CUSTOMER_NAME(OPTIONAL)')

Create a dict of the required fields (if any)

required_fields = {'requiredFieldName': 'requiredFieldValue'}

Send of the payment

response = pesepay.make_seamless_payment(payment, 'PAYMENT_REASON', 1.00, required_fields)

if response.success:
    # Save the reference number and/or poll url (used to check the status of a transaction)
    poll_url = response.pollUrl
    reference_number = response.referenceNumber

else:
    # Get Error Message
    message = response.message

Make redirect payment

Create a transaction

transaction = pesepay.create_transaction(amount, 'CURRENCY_CODE', 'PAYMENT_REASON')

Initiate the transaction

response = pesepay.initiate_transaction(transaction)

if response.success:
    # Save the reference number and/or poll url (used to check the status of a transaction)
    poll_url = response.pollUrl
    reference_number = response.referenceNumber
    # Get the redirect url and redirect user to complete transaction   
    redirect_url = response.redirectUrl

else:
    # Get Error Message
    message = response.message

Check Payment Status

Method 1: Check using reference number

response = pesepay.check_payment(reference_number)
if response.success:
    if response.paid:
        # Payment was successful
else:
    # Get Error Message
    message = response.message

Method 2: Check using poll url

response = pesepay.poll_transaction(poll_url)
if response.success:
    if response.paid:
        # Payment was successful
else:
    # Get Error Message
    message = response.message

Split payments

A split payment settles part of every payment to a second Pesepay merchant (the beneficiary). Set the split on the transaction (redirect flow) or the payment (seamless flow) before sending it.

# Redirect flow
transaction = pesepay.create_transaction(100.00, 'USD', 'Order #1042')
transaction.set_split_payment('vendor@example.com')

# Seamless flow
payment = pesepay.create_payment('USD', 'PZW211', 'customer@example.com')
payment.set_split_payment('vendor@example.com')

The split amount mode is optional and defaults to PRINCIPAL:

transaction.set_split_payment('vendor@example.com', Transaction.SPLIT_AMOUNT_MODE_ADD_ON)
  • PRINCIPAL takes the master merchant's share out of the amount you submit.
  • ADD_ON adds the master merchant's share on top, so the customer is charged more than the amount you send.

The aliases PRINCIPAL_AMOUNT, ADDON, ADDED_ON_TOP and ON_TOP are also accepted. Once your application has an accepted split beneficiary, every transaction must carry the beneficiary email or initiation will fail.

For full control over the metadata, use set_payment_metadata with the raw dict:

transaction.set_payment_metadata({'beneficiaryMerchantEmail': 'vendor@example.com'})

Metadata

Release files for pesepay 1.1.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 pesepay 1.1.0
File Size Uploaded Provenance
pesepay-1.1.0.tar.gz 5.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pesepay 1.1.0
File Interpreter ABI Platform
pesepay-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / pesepay-1.1.0.tar.gz

Download URL pesepay-1.1.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
35d7dc917f8f4b8533b51154c7be1f367383eea57d17a06efac194813729bf5e
BLAKE2b-256 checksum
How to use checksums
f20f7f99083838d57465108e8010db75f71d94f7545148c9759458308516cfd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / pesepay-1.1.0-py3-none-any.whl

Download URL pesepay-1.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb43fdcb671cc6de4d1a4af5721770f7c63f2efb86b5f8a997d9bbf096b4a553
BLAKE2b-256 checksum
How to use checksums
745f29e37e773795ff5ce7dd502daa663518a67f8ea82fc56e7d9ffc8c1d67f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for pesepay 1.1.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pesepay-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

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.

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