Skip to main content

modulbank

https://travis-ci.org/Otetz/modulbank.svg?branch=master Documentation Status https://badge.fury.io/py/modulbank.svg https://coveralls.io/repos/github/Otetz/modulbank/badge.svg?branch=master Code Climate

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.

Metadata

Release files for modulbank 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modulbank 0.0.9
File Size Uploaded
modulbank-0.0.9.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modulbank 0.0.9
File Interpreter ABI Platform
modulbank-0.0.9-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 30.7 kB

Release files / modulbank-0.0.9.tar.gz

Download URL modulbank-0.0.9.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5d81ecebf8def0ad974f5fab02bc461724b3d4872685dd86cca716918e5ea5a6
BLAKE2b-256 checksum
How to use checksums
2296f5137ce52daa5a958c111157f72ed9dc9bc9f71c7617bfec9fb94ca953af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / modulbank-0.0.9-py2.py3-none-any.whl

Download URL modulbank-0.0.9-py2.py3-none-any.whl
Size 17.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
98308280e24ef7e0e6707dff1a80419d3237fda2bed638f757c827083c0e5e54
BLAKE2b-256 checksum
How to use checksums
5b2f9c03876c188b1c048caffa50102d7cc4fbd4368a60b2aff8d1f74ecbad4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page