A modern Python SDK for SIBS Gateway payment integrations.
Project description
PySIBS
A modern, typed, developer-friendly Python SDK for SIBS Gateway payment integrations.
PySIBS provides a clean API for payments, refunds, captures, cancellations, status checks and webhook verification. It is framework-agnostic and works in Django, FastAPI, Flask, Celery, CLI scripts — anywhere Python runs.
Project status: Alpha. The public API surface is intentionally small and stable, but endpoint/field details are still being validated against SIBS' official documentation. Every response exposes a
raw_responseso you are never blocked by a field PySIBS has not yet normalized. See Caveats.
Features
- Synchronous (
SIBSClient) and asynchronous (AsyncSIBSClient) clients - Create payments, check status, refund, capture and cancel
- Typed Pydantic models with normalized statuses (
PaymentStatus) - Safe money handling with
Decimal(floats are rejected) - Webhook parsing and configurable signature verification
- A clear exception hierarchy — raw
httpxerrors never leak out - Fully typed (
py.typed),ruff+mypy --strictclean
Installation
pip install pysibs
Requires Python 3.10+.
Configuration
Construct a client directly:
from pysibs import SIBSClient
client = SIBSClient(
api_key="your_api_key",
terminal_id="your_terminal_id",
environment="sandbox", # or "production"
)
…or from environment variables (SIBS_API_KEY, SIBS_TERMINAL_ID,
SIBS_ENVIRONMENT, and optionally SIBS_CLIENT_ID, SIBS_WEBHOOK_SECRET):
client = SIBSClient.from_env()
The core library never reads .env — only the bundled examples do, via
python-dotenv. See .env.example.
Create a payment
payment = client.create_payment(
amount="10.00", # str, int or Decimal — never float
currency="EUR",
merchant_transaction_id="ORDER-123",
return_url="https://example.com/payment/success",
cancel_url="https://example.com/payment/cancel",
payment_methods=["CARD", "MBWAY", "MULTIBANCO"],
)
print(payment.id)
print(payment.status) # normalized PaymentStatus
print(payment.redirect_url)
print(payment.raw_response) # untouched SIBS response
Check payment status
status = client.get_payment_status("payment_123")
print(status.status) # normalized PaymentStatus
print(status.raw_status) # original value from SIBS
Refunds
# Full refund
client.refund_payment(payment_id="payment_123")
# Partial refund
client.refund_payment(payment_id="payment_123", amount="10.00", merchant_refund_id="REF-1001")
Capture & cancel
client.capture_payment(payment_id="payment_123", amount="25.50")
client.cancel_payment("payment_123")
Async usage
from pysibs import AsyncSIBSClient
async with AsyncSIBSClient.from_env() as client:
payment = await client.create_payment(amount="10.00", merchant_transaction_id="ORDER-1")
Webhooks
from pysibs import parse_webhook, verify_webhook_signature
event = parse_webhook(raw_body) # bytes, str or dict
print(event.payment_id, event.status, event.raw_payload)
is_valid = verify_webhook_signature(
payload=raw_body,
signature=request.headers.get("X-SIBS-Signature"),
secret="webhook_secret",
)
SIBS' webhook signing scheme is not uniformly documented and may differ per
product/environment. verify_webhook_signature defaults to HMAC-SHA256, but you can
pass a custom verifier callable that matches whatever SIBS actually uses for your
integration. Always confirm the scheme against the official documentation.
Error handling
All exceptions inherit from SIBSError:
| Exception | Raised when |
|---|---|
SIBSConfigurationError |
The client is misconfigured (missing credentials, bad environment). |
SIBSValidationError |
Input fails local validation (e.g. a float amount, empty id). |
SIBSAuthenticationError |
SIBS rejects credentials (HTTP 401/403). |
SIBSAPIError |
Other API errors (carries status_code and response_body). |
SIBSTimeoutError |
The request times out (or HTTP 408). |
SIBSConnectionError |
SIBS cannot be reached (DNS/TCP/TLS). |
SIBSInvalidWebhookSignature |
A webhook signature fails verification. |
from pysibs import SIBSError, SIBSAuthenticationError
try:
client.create_payment(amount="10.00", merchant_transaction_id="ORDER-1")
except SIBSAuthenticationError:
... # bad credentials
except SIBSError as exc:
... # any other PySIBS failure
PCI DSS note
This SDK does not store or process cardholder data by itself. However, some SIBS server-to-server card payment flows may require the merchant environment to be PCI DSS compliant. Always validate your integration scope with SIBS and your PCI advisor.
PySIBS deliberately:
- never stores PAN or CVV,
- never logs
Authorizationheaders or credentials, - ships no examples containing real card data.
Caveats — unverified details
SIBS' public documentation does not pin down every endpoint, field name and signing detail unambiguously, and they can vary by product/environment. Where there was ambiguity, PySIBS:
- keeps the wire format isolated in
pysibs/_payloads.pyand base URLs inpysibs/config.py, so they are trivial to adjust in one place; - preserves the full
raw_response/raw_payloadon every model; - never sends undocumented headers (e.g. idempotency — see
pysibs/idempotency.py).
Before going to production, verify the endpoints, payloads and webhook signature scheme against the current official SIBS documentation.
Python compatibility
Tested on CPython 3.10, 3.11, 3.12 and 3.13.
Roadmap
0.1.0—SIBSClient/AsyncSIBSClient, create/status/refund/capture/cancel, webhook parsing + verification, typed models, docs.0.2.0— richer payment-method specific models (MB WAY, MULTIBANCO references).1.0.0— stable API once the SIBS contract is fully confirmed end-to-end.
Contributing
See CONTRIBUTING.md. Security issues: see SECURITY.md.
License
MIT © Robert Benitez
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 pysibs-0.1.0.tar.gz.
File metadata
- Download URL: pysibs-0.1.0.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
659b47a9e677da21920999b4db51b0d379dd14218aa2b0c53a5177d9d4bf11f0
|
|
| MD5 |
5bc7619d5b5226fb7857c27665662e56
|
|
| BLAKE2b-256 |
fa301a726c5c1a6d1762cc076757a93aa06ccc9bd8b0ac271771e1d0d89fe63c
|
Provenance
The following attestation bundles were made for pysibs-0.1.0.tar.gz:
Publisher:
publish.yml on robertruben98/sibs-gateway-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysibs-0.1.0.tar.gz -
Subject digest:
659b47a9e677da21920999b4db51b0d379dd14218aa2b0c53a5177d9d4bf11f0 - Sigstore transparency entry: 1871333918
- Sigstore integration time:
-
Permalink:
robertruben98/sibs-gateway-python@726639480a03a3ec64be8017de2c3b3b9e83c9b9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/robertruben98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@726639480a03a3ec64be8017de2c3b3b9e83c9b9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pysibs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pysibs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5cbbb468b0ae94f125ab2ab586a1f28144f34f34f9854aae25476e9de618d29
|
|
| MD5 |
c6b91f2866b17628641bb31c3e3a9286
|
|
| BLAKE2b-256 |
4c6fe8180356eaf903b01350ee939e9bd2494474117462862c4f9685a5c23f6f
|
Provenance
The following attestation bundles were made for pysibs-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on robertruben98/sibs-gateway-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysibs-0.1.0-py3-none-any.whl -
Subject digest:
b5cbbb468b0ae94f125ab2ab586a1f28144f34f34f9854aae25476e9de618d29 - Sigstore transparency entry: 1871333954
- Sigstore integration time:
-
Permalink:
robertruben98/sibs-gateway-python@726639480a03a3ec64be8017de2c3b3b9e83c9b9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/robertruben98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@726639480a03a3ec64be8017de2c3b3b9e83c9b9 -
Trigger Event:
push
-
Statement type: