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 asyncio
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}")

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_getpaid_przelewy24-0.1.0.tar.gz
  • Upload date:
  • Size: 62.7 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.0.tar.gz
Algorithm Hash digest
SHA256 e316346c4c24c8c1d81bc00dd3cfa0f35a185a7c5b7196c0f089309eceb67d5b
MD5 e37defc71000d9ee14ff7313d3dd9088
BLAKE2b-256 d3aed5849c2fabd0fe4ff38b7d5e8c038d25448c2d6aeb913d3d926d9037575d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_getpaid_przelewy24-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c200786bd5103bef8f919332ec12063df505e31173e27d6160e42ac824cc6b3
MD5 a6e23c02db15909a63a218117b8867e8
BLAKE2b-256 c37df7864356997edba189a32d7436a0f9e9463f2701024ad1b04812cf085e90

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