Skip to main content

Generate EMV QRCPS / PY-QR (SIP) payment QR payloads for Paraguay. Standalone local generation; optional HubAdapter for PSP integration.

Project description

pysip-qr

Python library to generate EMV® QRCPS merchant-presented QR payloads with a Paraguay SIP / PY-QR profile.

PyPI package: pysip-qr
Import: import sip_qr

Important: generation vs QR Hub

  1. Generating a PY-QR–compatible payload (and optional QR image) does not require access to the BCP QR Hub. Standalone mode works fully offline.
  2. Processing / settling interoperable QR payments through the SIP / QR Hub does require a registered PSP/participant and integration with that entity.
  3. This library defaults to standalone. integrated mode is opt-in via a HubAdapter you configure — the library does not ship BCP endpoints or claim direct BCP connectivity.
  4. PSPs that offer QR payments must register with the BCP/SGGOF and follow the official PY-QR implementation guide. This package helps with payload construction; it does not replace regulatory onboarding.

Install

pip install pysip-qr
# optional QR image rendering
pip install pysip-qr[image]

From source (editable):

pip install -e ".[image]"

Quick start (standalone)

from sip_qr.profiles.sip import SipQrBuilder
from sip_qr import validate_payload, to_qr_image

payload = (
    SipQrBuilder()
    .merchant_account(
        guid="com.example.psp",          # from your PSP — not invented by this lib
        psp_fields={"01": "MERCHANT001"}, # PSP-specific subtags
        root_tag=26,
    )
    .merchant(name="Farmacia Demo", city="Asuncion", mcc="5912")
    .dynamic()
    .amount("150000.00")
    .currency_pyg()
    .reference("VENTA-123")
    .build()
)

assert validate_payload(payload) == []
to_qr_image(payload, path="qr.png")  # requires pysip-qr[image]

Static QR without amount:

payload = (
    SipQrBuilder()
    .merchant_account(guid="com.example.psp", psp_fields={"01": "M1"})
    .merchant(name="Farmacia Demo", city="Asuncion", mcc="5912")
    .static()
    .build()
)

Integrated mode (optional)

from sip_qr import OperatingMode, SipQrClient
from sip_qr.exceptions import MissingHubCredentials

# Provide your own HubAdapter implementation (PSP SDK / private API).
# No BCP URLs are hardcoded in this library.

client = SipQrClient(mode=OperatingMode.INTEGRATED, adapter=None)
try:
    client.submit_payment(payment_reference="ORD-1")
except MissingHubCredentials:
    ...

Implement sip_qr.adapters.HubAdapter (is_configured, supports_participant, submit_payment, check_status) using credentials and base URLs supplied by your approved PSP.

CLI (offline)

python -m sip_qr generate --input examples/dynamic_with_amount.json
python -m sip_qr generate --input examples/static.json --output qr.png
python -m sip_qr validate --payload "000201..."

Assumptions (until official PY-QR guide field map is wired)

  • Country default: PY
  • Currency default: 600 (PYG)
  • Merchant Account Information GUID and PSP subtags are injector-provided
  • Dynamic QR (POI 12) requires amount by default; static (POI 11) does not
  • CRC: CRC-16/CCITT-FALSE over payload including 6304
  • PY-QR logo overlay is optional and not claimed as official branding compliance without the visual spec/asset

Development

pip install -e ".[dev,image]"
python -m unittest discover -s tests -v

Release

GitHub Actions:

  • ci.yml — runs unittest on push/PR
  • release.yml — manual workflow_dispatch with bump patch|minor|major: bump version, tag vX.Y.Z, build, publish to PyPI (Trusted Publishing)

Configure a PyPI Trusted Publisher for repo Piuliss/pysip-qr, workflow release.yml, environment pypi.

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

pysip_qr-0.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

pysip_qr-0.1.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file pysip_qr-0.1.0.tar.gz.

File metadata

  • Download URL: pysip_qr-0.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pysip_qr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 84350d9b36768a44381664f59253c025bb4fd993af5d167804dbe85b49573b29
MD5 f0739ce005a151c3d5ee30a1e0b4e689
BLAKE2b-256 b8aa7bae73e2bec55c88b5f384387b9f5b209686b2fa0194f1ae47636a4c32e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysip_qr-0.1.0.tar.gz:

Publisher: release.yml on Piuliss/pysip-qr

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

File details

Details for the file pysip_qr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pysip_qr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pysip_qr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54747b43f2e89daef8b76aa8d25cb23841c896cdc664a7d30412f39554f6593d
MD5 0f65328836d7992a67582e6491db3687
BLAKE2b-256 29efacbea3aba09784c2310964abc2d00bc26355fd2742c60eb8742b49cacfd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysip_qr-0.1.0-py3-none-any.whl:

Publisher: release.yml on Piuliss/pysip-qr

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