Skip to main content

Library to manage payments using the KASS API

Project description

Helper for the KASS payment gateway. Written for python 3.8.5 (probably works on versions >= 3.6).

See the KASS API docs for more info.

This module is not affiliated with KASS.

TODO

  • [x] Create payment

  • [ ] Retreive payment info

  • [ ] Retreive payment status

  • [ ] Cancel payment

  • [ ] Add concurrency with RQ when dispatching multiple payments

Usage

Here is a short guide to get you started.

This will dispatch a payment to the KASS API.

poetry add kass-flow
# or
pip install kass-flow
from kass_flow.kass import KassBilling
from kass_flow.interfaces import KassRequestPaymentDict

kass_token: str = "some-token"
kass_url: str = "https://api.kass.is/v1/payments"
instance = KassBilling(kass_token, kass_url)

payload: KassRequestPaymentDict = {
    "amount": 2199,
    "description": "Kass bolur",
    "image_url": "https://photos.kassapi.is/kass/kass-bolur.jpg",
    "order": "ABC123",
    "recipient": "7798217",
    "terminal": 1,
    "expires_in": 90,
    "notify_url": "https://example.com/callbacks/kass",
}

result, is_valid = instance.dispatch(payload)

When the recipient cancels or pays the requested order KASS will send a callback to the notify_url, which you need to catch on your server and probably validate the signature that is included in the POST payload.

At some point in time the user will pay/reject the requested order. Here is an example on how to validate the payload.

from kass_flow.kass import KassBilling
from kass_flow.interfaces import KassRequestPaymentDict

def some_view_that_handles_kass_callback(request):
    payload = request.data
    kass_token: str = "some-token"
    kass_url: str = "https://api.kass.is/v1/payments"
    instance = KassBilling(kass_token, kass_url)

    if instance.is_signature_valid(payload):
        # process the payload.

Development

pip install poetry
 # to manage envs yourself
poetry config virtualenvs.create false
poetry install
pytest tests

If you are using VSCode for development there is a .vscode/settings.example.json for sensible defaults. Since mypy is used you need to install the mypyls language server.

poetry install "https://github.com/matangover/mypyls/archive/master.zip#egg=mypyls[default-mypy]"
# or
pip install "https://github.com/matangover/mypyls/archive/master.zip#egg=mypyls[default-mypy]"

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

kass-flow-0.2.6.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

kass_flow-0.2.6-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file kass-flow-0.2.6.tar.gz.

File metadata

  • Download URL: kass-flow-0.2.6.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.4.0-42-generic

File hashes

Hashes for kass-flow-0.2.6.tar.gz
Algorithm Hash digest
SHA256 14f49cd413a902b5e6c8df49b5c18b25235f103a586b2e5bf209d92d7203e334
MD5 cc690ff1390ad4f64e86f486182aee1b
BLAKE2b-256 f505d46502019beb408e4f8854bd7fb2aa4bd7f1d0697fc040f89b62482c4a7e

See more details on using hashes here.

File details

Details for the file kass_flow-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: kass_flow-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.4.0-42-generic

File hashes

Hashes for kass_flow-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 983ea162b33966456aa14420e69003bff2e1985c4e5774e166a92bd095144567
MD5 521f8cca13564cc75a3ba0ec8b767cfc
BLAKE2b-256 a6317bc32bf22a60ef61d801ae47a8ce2035849eea034da956a36489ae90bca1

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