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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc8695a5c4567a3267f1bb6f38e1f2ef96b3a3f142cf9d61e5647dba793b895a
|
|
| MD5 |
3483d3358f3b5fddf6b9568b45b60980
|
|
| BLAKE2b-256 |
75f2c1c33337313e390e8591cf91b4001ebf5b190bba66624f9e32c2c8b61c68
|
Provenance
The following attestation bundles were made for xpresspay-0.2.1.tar.gz:
Publisher:
publish.yml on praisegee/xpresspay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpresspay-0.2.1.tar.gz -
Subject digest:
fc8695a5c4567a3267f1bb6f38e1f2ef96b3a3f142cf9d61e5647dba793b895a - Sigstore transparency entry: 976345695
- Sigstore integration time:
-
Permalink:
praisegee/xpresspay@5318330f6744976f1f9fe877c8267a920e53706c -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/praisegee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5318330f6744976f1f9fe877c8267a920e53706c -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ca2565186464b3f8ebf22dcf561df78b0fc192490d5e13154d78c61af26d555
|
|
| MD5 |
6d6898ada09fc25b63913e59d36460a4
|
|
| BLAKE2b-256 |
bd2d3985c8026f0545625d3ef988d2f89f8d7f1bd6e7799a1f9e92be58639351
|
Provenance
The following attestation bundles were made for xpresspay-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on praisegee/xpresspay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpresspay-0.2.1-py3-none-any.whl -
Subject digest:
6ca2565186464b3f8ebf22dcf561df78b0fc192490d5e13154d78c61af26d555 - Sigstore transparency entry: 976345696
- Sigstore integration time:
-
Permalink:
praisegee/xpresspay@5318330f6744976f1f9fe877c8267a920e53706c -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/praisegee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5318330f6744976f1f9fe877c8267a920e53706c -
Trigger Event:
push
-
Statement type: