Skip to main content

Python client for ČSOB Payment Gateway

Project description

https://circleci.com/gh/whit/pycsob.svg?style=svg https://badge.fury.io/py/pycsob.svg

Install:

pip install pycsob

Run tests:

python setup.py test

Basic usage:

from pycsob.client import CsobClient
c = CsobClient('MERCHANT_ID', 'https://iapi.iplatebnibrana.csob.cz/api/v1.6/',
               '/path/to/your/private.key',
               '/path/to/mips_iplatebnibrana.csob.cz.pub')

Initialize payment. Outputs are requests’s responses enriched by some properties like payload or extensions.

r = c.payment_init(14, 1000000, 'http://twisto.dev/', 'Tesovaci nakup', customer_id='a@a.aa',
                   return_method='GET', pay_operation='payment')
r.payload
#[Out]# OrderedDict([('payId', 'b627c1e4e60fcBF'),
#[Out]#              ('dttm', '20160615104254'),
#[Out]#              ('resultCode', 0),
#[Out]#              ('resultMessage', 'OK'),
#[Out]#              ('paymentStatus', 1)])

After payment init get URL to redirect to for payId obtained from previous step.

c.get_payment_process_url('b627c1e4e60fcBF')
#[Out]# 'https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/process/MERCHANT_ID/b627c1e4e60fcBF/20160615104318/bla-bla-bla'

After user have payment processed, browser redirects him to URL provided in payment_init(). You can check payment status.

c.payment_status('b627c1e4e60fcBF').payload
#[Out]# OrderedDict([('payId', 'b627c1e4e60fcBF'),
#[Out]#              ('dttm', '20160615104501'),
#[Out]#              ('resultCode', 0),
#[Out]#              ('resultMessage', 'OK'),
#[Out]#              ('paymentStatus', 7),
#[Out]#              ('authCode', '042760')])

You can also use one-click payment methods. For this ypou need to call c.payment_init(pay_operation='oneclickPayment'). After this transaction confirmed you can use obtained payId as template for one-click payment.

r = c.oneclick_init('1e058ff1d0d5aBF', 666, 10000)
r.payload
#[Out]# OrderedDict([('payId', 'ff7d3e7c6c4fdBF'),
#[Out]#              ('dttm', '20160615104532'),
#[Out]#              ('resultCode', 0),
#[Out]#              ('resultMessage', 'OK'),
#[Out]#              ('paymentStatus', 1)])

r = c.oneclick_start('ff7d3e7c6c4fdBF')
r.payload
#[Out]# OrderedDict([('payId', 'ff7d3e7c6c4fdBF'),
#[Out]#              ('dttm', '20160615104619'),
#[Out]#              ('resultCode', 0),
#[Out]#              ('resultMessage', 'OK'),
#[Out]#              ('paymentStatus', 2)])

r = c.payment_status('ff7d3e7c6c4fdBF')
r.payload
#[Out]# OrderedDict([('payId', 'ff7d3e7c6c4fdBF'),
#[Out]#              ('dttm', '20160615104643'),
#[Out]#              ('resultCode', 0),
#[Out]#              ('resultMessage', 'OK'),
#[Out]#              ('paymentStatus', 7),
#[Out]#              ('authCode', '168164')])

Of course you can use standard requests’s methods on response object.

r.json()
#[Out]# {'authCode': '047256',
#[Out]#  'dttm': '20160615104717',
#[Out]#  'payId': '1e058ff1d0d5aBF',
#[Out]#  'paymentStatus': 7,
#[Out]#  'resultCode': 0,
#[Out]#  'resultMessage': 'OK',
#[Out]#  'signature': 'foh4asfoxy40QRmwChJQwNkfT+PBmI3a7jQ+g2M75RpE2uJNqWCCmrhF8TPhcJ6rcyKSttB/ZZrd0gh9BQDgByMtyPG/rv0Jn3kQeuAryJfOW4nuFj86tr/queHD8ZZ248PwOkT5Zo2uTz+QRCrv/n4he+TWkFoVsm94AoSTK3O1SBDyLiOi3njv/ZWm+z/Z9iK55xBwuSs0v5lzxNJ9vJpjIwWlAB1qEkrWZuGZHrNtAib9NxytO0ruWyG3U4H+B8ioJOUlWrAbCHhmKvmArmYi23fup2486v/9s5SCl0fS7PQUNdiDJpZHxnRkVZZXwZM2sPyacgayvYb+khlBRg=='}

r = c.payment_status('1e058ff1d0d5aBF')

r.request.url
#[Out]#  'https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/status/M1E3CB2577/1e058ff1d0d5aBF/20160615111034/HQKDHz7DTHL0lCn6OrAv%2BKQjGEr8KtdF42czAGCngCG0gWbuYTfJfO%2B5rHwAEWCl1XKiClYngLBI7Lu2mCJG8AP2Od7%2BAa5VXWcIjs0mSAsP60irR7M4Xl1NsXPe4bEhXAvAJU4yz3oV2vZ68QRB9vE7mk6OaLQade48yEFmX83FJPDQ4RSBOUqD3JPrKMMZ%2BkNEz0%2FMh94X7Zx3DrtwUVdKEyuX8Zf2MYwqzQh7mNBW6EZKxt7yKwS%2B0108GalXoD1n7ctjbtcyrbFAFKKLDgPNf%2BMlLBt8cwSSQ6J2xigI3P9T32L5YUg25kKr%2B4Dy%2FnwOKDntDszbGXQZdIBnTQ%3D%3D'

r.status_code
#[Out]# 200

Please look at the code for other available methods and their usage.

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

pycsob-0.2.3.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

pycsob-0.2.3-py2.py3-none-any.whl (13.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pycsob-0.2.3.tar.gz.

File metadata

  • Download URL: pycsob-0.2.3.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pycsob-0.2.3.tar.gz
Algorithm Hash digest
SHA256 93a3450e23a3d4fc1322b323108a4c2b6d891238aa43a83733d32e54c144d439
MD5 a5c2e9ecc2676925d9b8a05661699ef4
BLAKE2b-256 c64b107ba7284dc7e0cc6804eaab9d8571e6a82208b033158422489f7139e7ca

See more details on using hashes here.

File details

Details for the file pycsob-0.2.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pycsob-0.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7e6517fcbf08e960033a04e49c40d8f1743bff464b9b3bff13199165aa5bd37b
MD5 d585e33abc9e82c130bc55a482e8fdc7
BLAKE2b-256 daa7041c0479dc7bdfde5b9aa62b0cb481d0126df4a892ea7697cb7ceee365c2

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