Skip to main content

Paynow payment gateway integration for python-getpaid ecosystem.

Project description

python-getpaid-paynow

PyPI version License: MIT Python versions

Paynow payment processor for python-getpaid ecosystem. Paynow is a modern Polish payment provider and a subsidiary of mBank.

Architecture

The plugin is split into two layers:

  • PaynowClient -- low-level async HTTP client wrapping the Paynow V3 REST API. Uses httpx.AsyncClient with API Key authentication and HMAC-SHA256 request signing. Can be used standalone or as an async context manager for connection reuse.
  • PaynowProcessor -- high-level payment processor implementing BaseProcessor. Orchestrates payment creation, callback/notification handling, status polling, and refunds using semantic payment updates.

Key Features

  • Create payment -- register a payment and get a redirect URL
  • Notification handling -- verify HMAC-SHA256 signature and process status changes
  • Status polling -- fetch current payment status via API (PULL flow)
  • Refund -- create, check, and cancel refunds
  • Payment methods -- retrieve available payment methods
  • Sandbox mode -- full support for testing environment

Note: Paynow does not support pre-authorization flows. Immediate capture is used for all transactions. The charge() and release_lock() methods raise NotImplementedError.

Supported Currencies

The processor supports the following 4 currencies:

  • PLN (Polish Złoty)
  • EUR (Euro)
  • GBP (British Pound)
  • USD (US Dollar)

Installation

Install the package using pip:

pip install python-getpaid-paynow

Install simulator support only when you want this package to register its local simulator plugin with python-getpaid-simulator:

pip install python-getpaid-paynow[simulator]

This extra installs the simulator host and Litestar dependencies, then exposes the paynow plugin through the getpaid.simulator.providers entry point.

Simulator Plugin

When python-getpaid-paynow[simulator] is installed alongside python-getpaid-simulator, the simulator host auto-discovers the PayNow plugin.

Typical local setup:

pip install python-getpaid-simulator python-getpaid-paynow[simulator]
getpaid-simulator

The plugin contributes:

  • PayNow payment and refund simulator API routes under /paynow/v3/...
  • PayNow authorization UI at /sim/paynow/authorize/{payment_id}
  • PayNow-specific webhook signing and state transitions

Useful simulator environment variables:

  • SIMULATOR_PAYNOW_API_KEY
  • SIMULATOR_PAYNOW_SIGNATURE_KEY
  • SIMULATOR_PAYNOW_NOTIFY_URL
  • SIMULATOR_PLUGIN_FAILURE_MODE (warn or strict)

Quick Usage

Standalone Client

import anyio
from decimal import Decimal
from getpaid_paynow import PaynowClient

async def main():
    async with PaynowClient(
        api_key="your-api-key",
        signature_key="your-signature-key",
        api_url="https://api.sandbox.paynow.pl",
    ) as client:
        # Create a payment
        response = await client.create_payment(
            amount=Decimal("49.99"),
            currency="PLN",
            external_id="order-001",
            description="Order #001",
            buyer_email="buyer@example.com",
            continue_url="https://shop.example.com/return/order-001",
        )
        redirect_url = response["redirectUrl"]
        print(f"Redirect buyer to: {redirect_url}")

anyio.run(main)

With python-getpaid

Register the plugin via entry point in pyproject.toml (if not using the pre-packaged version):

[project.entry-points."getpaid.backends"]
paynow = "getpaid_paynow.processor:PaynowProcessor"

Then configure in your project settings:

GETPAID_BACKEND_SETTINGS = {
    "paynow": {
        "api_key": "your-api-key",
        "signature_key": "your-signature-key",
        "sandbox": True,
        "notification_url": "https://your-site.com/payments/{payment_id}/callback/",
        "continue_url": "https://your-site.com/payments/{payment_id}/return/",
    }
}

Configuration Reference

Key Type Default Description
api_key str required API key from Paynow merchant panel
signature_key str required Signature key for HMAC calculation
sandbox bool True Use sandbox or production API
notification_url str "" Notification URL template; use {payment_id} placeholder
continue_url str "" Return URL template; use {payment_id} placeholder

Requirements

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

Links

License

This project is licensed under the MIT License.

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_paynow-3.0.0a4.tar.gz (29.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_paynow-3.0.0a4-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file python_getpaid_paynow-3.0.0a4.tar.gz.

File metadata

  • Download URL: python_getpaid_paynow-3.0.0a4.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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_paynow-3.0.0a4.tar.gz
Algorithm Hash digest
SHA256 f509389d4a30a76264cfdd136a13c55dd51299e66f800001eebac3172f3b75ae
MD5 9bf1822c2d5c50aeeeffbd3e56c0b692
BLAKE2b-256 dc4db71d845f792199f2957f76c219d763ade6cb4ab52fbf2e25b3a6fab7c292

See more details on using hashes here.

File details

Details for the file python_getpaid_paynow-3.0.0a4-py3-none-any.whl.

File metadata

  • Download URL: python_getpaid_paynow-3.0.0a4-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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_paynow-3.0.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 523b4bf78b4cdcde206000c0c7cd2ddae6bee78f73e060264237ea418071c128
MD5 1ad340767306fe62d61b4a22056c3236
BLAKE2b-256 0cda097bf348d46e9cf0007b8ac9959c29d657bd5a07159eed883119b4b4f10f

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