Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Python client for ModulBank REST API

Project Description

Python client for ModulBank REST API

Installation

Install modulbank package from PyPI

pip install modulbank

Getting started

Make sure to include this lines in the beginning of your code:

from modulbank.client import ModulbankClient
import modulbank.structs as structs

Set your API Token and choose sandbox mode on or off:

client = ModulbankClient(token=MODULBANK_TOKEN, sandbox_mode=True)

Make queries:

print([str(acc) for acc in client.accounts()])
print(client.balance('58c20343-5d3b-422c-b98b-a5ec037df782'))
print([str(op) for op in client.operations('58c20343-5d3b-422c-b98b-a5ec037df782')])

Or send payment order:

p = structs.PaymentOrder(
    doc_num='994720', account_num='40802810670010011008', amount=Decimal(100.00), purpose='Для теста',
    payer=structs.Contractor(name='Индивидуальный предприниматель Александров Александр Александрович',
                             inn='770400372208', kpp='',
                             bank=structs.BankShort(account='40802810670010011008',
                                                    name='МОСКОВСКИЙ ФИЛИАЛ АО КБ "МОДУЛЬБАНК"',
                                                    bic='044525092', corr_acc='30101810645250000092')),
    recipient=structs.Contractor(name='МОСКОВСКИЙ ФИЛИАЛ АО КБ "МОДУЛЬБАНК"',
                                 inn='2204000595', kpp='771543001',
                                 bank=structs.BankShort(account='30102810675250000092',
                                                        name='МОСКОВСКИЙ ФИЛИАЛ АО КБ "МОДУЛЬБАНК"',
                                                        bic='044525092', corr_acc='30102810675250000092')))
res = client.create_payment_draft(p)
assert len(res.errors) == 0
assert res.total_loaded == 1

Helper class for processing web-hooks

Sample usage of class NotifyRequest:

@app.route('/modulbank', methods=['POST'])
def notify():
  client = ModulbankClient(token=MODULBANK_TOKEN)

  if not request.is_json:
      return make_response(render_template('template.json'), 400)

  nr = structs.NotifyRequest(request.json)

  # Filter only needed company's operations
  if nr.inn != INN or nr.kpp != KPP:
      return make_response(render_template('template.json'), 200)

  # Check signature in `SHA1Hash` field
  if not nr.check_signature(MODULBANK_TOKEN):
      return make_response(render_template('template.json'), 403)

  #
  # Make something with `nr`
  #

  make_response(render_template('template.json'), 200)

TODO

  • OAuth 2 authorization.

Release History

This version
History Node

0.0.9

History Node

0.0.8

History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
modulbank-0.0.9-py2.py3-none-any.whl
(17.0 kB) Copy SHA256 Hash SHA256
py2.py3 Wheel May 16, 2017
modulbank-0.0.9.tar.gz
(13.7 kB) Copy SHA256 Hash SHA256
Source May 16, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting