Skip to main content

Python library for implementing Omnikassa

Project description

Omnikassa

https://travis-ci.org/RobWouters/omnikassa.png?branch=master

Python library for implementing Omnikassa.

Generating payment request

from omnikassa import Omnikassa
from omnikassa.constants import Currency

settings = {
    'currencyCode': Currency.EURO,  # Default value, can be overriden per request
    'automaticResponseUrl': 'https://example.com/callback',
    'normalReturnUrl': 'https://example.com/omnikassa',
    'merchantId': '0123456789',
}
secret = 'secret key'  # set this to None to use test environment

omnikassa = Omnikassa(settings, secret)
data = omnikassa.generate_request({
    'transactionReference': 'transaction123',  # unique reference
    'amount': 456,  # in cents
    'orderId': 123,  # optional
})

data contains relevant info to create a form:

<form action="${url}" method="post" id="form">
    <input type="hidden" name="Seal" value="${seal}">
    <input type="hidden" name="InterfaceVersion" value="${version}">
    <input type="hidden" name="Data" value="${data}">
    <button type="submit">
        Start payment
    </button>
</form>

Handling return

from omnikassa import Omnikassa
from omnikassa.constants import Currency

settings = {
    'currencyCode': Currency.EURO,
    'automaticResponseUrl': 'https://example.com/callback',
    'normalReturnUrl': 'https://example.com/omnikassa',
    'merchantId': '0123456789',
}
secret = 'secret key'

omnikassa = Omnikassa(settings, secret)
try:
    data = omnikassa.verify_callback(request.POST)
except InvalidSeal:
    ...
except InvalidResponseCode as exc:
    # `exc.data` contains responseData
    ...

# `data` is a dict of validated omnikassa data

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

omnikassa-0.0.4.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file omnikassa-0.0.4.tar.gz.

File metadata

  • Download URL: omnikassa-0.0.4.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for omnikassa-0.0.4.tar.gz
Algorithm Hash digest
SHA256 377dd0e1a90e84ebac889d65e577b87e2bdfda840ca848a6dc1b76a10f5ea6ab
MD5 038b736372efcd0f817f96d64c01df19
BLAKE2b-256 cac8516d0b0a5fb4c782002ca80e6da85ce28ce7061e8f8942eb3682cc61a3d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page