Skip to main content

Przelewy24 payment gateway integration for python-getpaid ecosystem.

Project description

getpaid-przelewy24

PyPI Python Version License

Przelewy24 payment gateway plugin for the python-getpaid ecosystem. Provides an async HTTP client (P24Client) and a payment processor (P24Processor) that integrates with getpaid-core's BaseProcessor interface. Authentication uses HTTP Basic Auth against the Przelewy24 REST API.

Architecture

The plugin is split into two layers:

  • P24Client — low-level async HTTP client wrapping the Przelewy24 REST API. Uses httpx.AsyncClient with HTTP Basic Auth (pos_id / api_key). Can be used standalone or as an async context manager for connection reuse.
  • P24Processor — high-level payment processor implementing BaseProcessor. Orchestrates transaction registration, callback verification, payment confirmation, status polling, and refunds. Integrates with the getpaid-core FSM for state transitions.

Key Features

  • Register transaction — create a payment session and get a redirect URL
  • Verify transaction — mandatory confirmation after P24 callback (without this, P24 treats the payment as advance only)
  • Refund — batch refund support via P24 API
  • Get transaction info — look up transaction by session ID
  • Get refund info — look up refunds by P24 order ID
  • Get payment methods — retrieve available payment methods for a language
  • Test access — verify API credentials
  • PUSH and PULL — callback-based notifications with optional status polling
  • SHA-384 signatures — automatic sign calculation and verification

Quick Usage

Standalone Client

import anyio
from decimal import Decimal
from getpaid_przelewy24 import P24Client

async def main():
    async with P24Client(
        merchant_id=12345,
        pos_id=12345,
        api_key="your-api-key",
        crc_key="your-crc-key",
        sandbox=True,
    ) as client:
        # Test connection
        ok = await client.test_access()
        print(f"Connection OK: {ok}")

        # Register a transaction
        response = await client.register_transaction(
            session_id="order-001",
            amount=Decimal("49.99"),
            currency="PLN",
            description="Order #001",
            email="buyer@example.com",
            url_return="https://shop.example.com/return/order-001",
            url_status="https://shop.example.com/callback/order-001",
        )
        token = response["data"]["token"]
        redirect_url = client.get_transaction_redirect_url(token)
        print(f"Redirect buyer to: {redirect_url}")

anyio.run(main)

With django-getpaid

Register the plugin via entry point in pyproject.toml:

[project.entry-points."getpaid.backends"]
przelewy24 = "getpaid_przelewy24.processor:P24Processor"

Then configure in your Django settings (or config dict):

GETPAID_BACKEND_SETTINGS = {
    "przelewy24": {
        "merchant_id": 12345,
        "pos_id": 12345,
        "api_key": "your-api-key",
        "crc_key": "your-crc-key",
        "sandbox": True,
        "url_status": "https://shop.example.com/payments/{payment_id}/callback/",
        "url_return": "https://shop.example.com/payments/{payment_id}/return/",
        "refund_url_status": "https://shop.example.com/payments/{payment_id}/refund-callback/",
    }
}

Configuration Reference

Key Type Default Description
merchant_id int required Merchant ID from P24 panel
pos_id int required POS ID (often same as merchant_id)
api_key str required REST API key from P24 panel
crc_key str required CRC key for signature calculation
sandbox bool True Use sandbox (sandbox.przelewy24.pl) or production (secure.przelewy24.pl)
url_status str "" Callback URL template; use {payment_id} placeholder
url_return str "" Return URL template; use {payment_id} placeholder
refund_url_status str "" Refund callback URL template; use {payment_id} placeholder

Supported Currencies

PLN, EUR, GBP, CZK, USD, BGN, DKK, HUF, NOK, SEK, CHF, RON, HRK (13 total).

Limitations

Przelewy24 does not support pre-authorization. The charge() and release_lock() methods raise NotImplementedError.

Requirements

  • Python 3.12+
  • python-getpaid-core >= 0.1.0
  • httpx >= 0.27.0

Related Projects

License

MIT

Disclaimer

This project has nothing in common with the getpaid plone project. It is part of the django-getpaid / python-getpaid ecosystem.

Credits

Created by Dominik Kozaczko.

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

python_getpaid_przelewy24-0.1.2.tar.gz (62.8 kB view details)

Uploaded Source

Built Distribution

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

python_getpaid_przelewy24-0.1.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file python_getpaid_przelewy24-0.1.2.tar.gz.

File metadata

  • Download URL: python_getpaid_przelewy24-0.1.2.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for python_getpaid_przelewy24-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f8854b9b8751630c7c5a0ab178f189f18880872ce9fc5c5616454c248ce0ac98
MD5 0baed6db9025305d087a75d701e8c45a
BLAKE2b-256 21b0f2e3240c0cfab1fbfbb328d9056ce6bdaa3b5206df6462bf7fa4cf2dd9fa

See more details on using hashes here.

File details

Details for the file python_getpaid_przelewy24-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: python_getpaid_przelewy24-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for python_getpaid_przelewy24-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5df016f94088e286f25332d7aaebcd5ff81fd034fd672d3023d2856f07e4bec7
MD5 a7e1e95bc4c96802a553a8301b37631e
BLAKE2b-256 d64ef467fd73466c94c90c09914457ff007f114df28269a362dc65ac44b27061

See more details on using hashes here.

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