Skip to main content

Python SDK for integrating the Xpress payment gateway (xpresspayments.com)

Project description

xpresspay

A Python SDK for integrating the Xpress payment gateway into your application.

Supports hosted payment page initialization and server-side payment verification. Built on httpx.

Full documentation

Requirements

  • Python 3.9+
  • uv (recommended) or pip

Installation

uv add xpresspay
# or
pip install xpresspay

Security

  • Your public key (XPPUBK-…) is sent as a Bearer token in every request.
  • Store credentials in environment variables, never in source code.

Quick start

from xpresspay import XpressPay

# Reads XPRESSPAY_PUBLIC_KEY from the environment automatically
client = XpressPay(sandbox=True)  # False for production

# Or pass the key explicitly
client = XpressPay(public_key="XPPUBK-...", sandbox=True)

Initialize a payment

from xpresspay import InitializeRequest

response = client.payments.initialize(
    InitializeRequest(
        amount="1000.00",
        email="customer@example.com",
        transaction_id="ORDER-001",
        callback_url="https://yourdomain.com/payment/callback",
    )
)

if response.is_successful:
    # Redirect the customer to the hosted payment page
    print(response.payment_url)
    print(response.reference)

Verify a payment (server-side)

Always verify server-side before fulfilling an order.

from xpresspay import VerifyRequest

result = client.payments.verify(
    VerifyRequest(transaction_id="ORDER-001")
)

if result.is_successful and result.amount == "1000.00":
    print("Payment confirmed:", result.gateway_response)
else:
    print("Not confirmed:", result.status)

Exception handling

from xpresspay import (
    XpressPayError,
    AuthenticationError,
    ValidationError,
    NetworkError,
)

try:
    response = client.payments.initialize(...)
except AuthenticationError:
    ...  # invalid / missing API key
except ValidationError as e:
    print(e.message, e.error_type)
except NetworkError:
    ...  # timeout — safe to retry
except XpressPayError:
    ...  # catch-all

Exception reference

Exception Trigger
XpressPayError Base class
AuthenticationError HTTP 401
ValidationError HTTP 400
NotFoundError HTTP 404
ProcessingError HTTP 5xx
NetworkError Timeout / connection error

Development

git clone https://github.com/praisegee/xpresspay
cd xpresspay
uv sync --group dev
uv run pytest
uv run ruff check xpresspay/ tests/

Environment variables

Variable Description
XPRESSPAY_PUBLIC_KEY Public key (XPPUBK-…) — picked up automatically if public_key is not passed to the client

License

Released under the MIT License.

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

xpresspay-0.2.2.tar.gz (73.7 kB view details)

Uploaded Source

Built Distribution

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

xpresspay-0.2.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file xpresspay-0.2.2.tar.gz.

File metadata

  • Download URL: xpresspay-0.2.2.tar.gz
  • Upload date:
  • Size: 73.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xpresspay-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e17572cc583ccfed62fe807ed5ee4768709fabdd7bf13eb3167aebf4ba132964
MD5 ceb9cbf6a28c533017ca128eba271df9
BLAKE2b-256 e7a3f6882cc09961d229c1cf1cb83bdbcfcfb856bd174c8de30000b656b62f73

See more details on using hashes here.

Provenance

The following attestation bundles were made for xpresspay-0.2.2.tar.gz:

Publisher: publish.yml on praisegee/xpresspay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xpresspay-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: xpresspay-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xpresspay-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b248a67fdab626d72d0c0bc6f43e601219e7444f294331598fdd1d8c90962a04
MD5 46ed5484093b198faaa0f60ce0b30bb9
BLAKE2b-256 b2d165d7eaf337278064a03347b0f79875863a4e8064a46d384887c1e4a5b0c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for xpresspay-0.2.2-py3-none-any.whl:

Publisher: publish.yml on praisegee/xpresspay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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