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

MIT

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.0.tar.gz (72.6 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.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xpresspay-0.2.0.tar.gz
  • Upload date:
  • Size: 72.6 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.0.tar.gz
Algorithm Hash digest
SHA256 2b76d6221ce43bdb250328e416ef8ee5fcdb75a2c1df984430dc0be8e828a6fa
MD5 100419e67ac336441fbe3507792b9f80
BLAKE2b-256 0aeeb497d213e70d381b0ae896131b1a319b656a9c69a539a7d2baa85c22207c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: xpresspay-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd5917f73aa8cabec95f28b891e00fc2558a7ff05bfa2ea303d7eb541fef5ab5
MD5 89276b063fd6e0ed3f11e0970ea68f15
BLAKE2b-256 d3e71207d06ccae651b9c5edf9241b485cace693ac8a96aa45baba485baea780

See more details on using hashes here.

Provenance

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