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

import os
from xpresspay import XpressPay

client = XpressPay(
    public_key=os.environ["XPRESSPAY_PUBLIC_KEY"],
    sandbox=True,   # False for production
)

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-…)

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.1.tar.gz (73.4 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.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xpresspay-0.2.1.tar.gz
  • Upload date:
  • Size: 73.4 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.1.tar.gz
Algorithm Hash digest
SHA256 fc8695a5c4567a3267f1bb6f38e1f2ef96b3a3f142cf9d61e5647dba793b895a
MD5 3483d3358f3b5fddf6b9568b45b60980
BLAKE2b-256 75f2c1c33337313e390e8591cf91b4001ebf5b190bba66624f9e32c2c8b61c68

See more details on using hashes here.

Provenance

The following attestation bundles were made for xpresspay-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: xpresspay-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ca2565186464b3f8ebf22dcf561df78b0fc192490d5e13154d78c61af26d555
MD5 6d6898ada09fc25b63913e59d36460a4
BLAKE2b-256 bd2d3985c8026f0545625d3ef988d2f89f8d7f1bd6e7799a1f9e92be58639351

See more details on using hashes here.

Provenance

The following attestation bundles were made for xpresspay-0.2.1-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