Skip to main content

Connect to Moadian API

Project description

moadian

import json
from moadian import Moadian

with open("private.key", "r") as f:
    private_key = f.read()

moadian = Moadian("YourFiscalID", key)
moadian.get_server_information()
...
#{'signature': None, 'signatureKeyId': None, 'timestamp': 1693947922222, 'result':{'uid': 'c4f374f6-2fe7-4df2-9b39-150310a5dec1', 'packetType': 'SERVER_INFORMATION', 'data': {'serverTime': 1693947922222, 'publicKeys': [{'key': 'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxdzREOEfk3vBQogDPGTMqdDQ7t0oDhuKMZkA+Wm1lhzjjhAGfSUOuDvOKRoUEQwP8oUcXRmYzcvCUgcfoRT5iz7HbovqH+bIeJwT4rmLmFcbfPke+E3DLUxOtIZifEXrKXWgSVPkRnhMgym6UiAtnzwA1rmKstJoWpk9Nv34CYgTk8DKQN5jQJqb9L/Ng0zOEEtI3zA424tsd9zv/kP4/SaSnbbnj0evqsZ29X6aBypvnTnwH9t3gbWM4I9eAVQhPYClawHTqvdaz/O/feqfm06QBFnCgL+CBdjLs30xQSLsPICjnlV1jMzoTZnAabWP6FRzzj6C2sxw9a/WwlXrKn3gldZ7Ctv6Jso72cEeCeUI1tzHMDJPU3Qy12RQzaXujpMhCz1DVa47RvqiumpTNyK9HfFIdhgoupFkxT14XLDl65S55MF6HuQvo/RHSbBJ93FQ+2/x/Q2MNGB3BXOjNwM2pj3ojbDv3pj9CHzvaYQUYM1yOcFmIJqJ72uvVf9Jx9iTObaNNF6pl52ADmh85GTAH1hz+4pR/E9IAXUIl/YiUneYu0G4tiDY4ZXykYNknNfhSgxmn/gPHT+7kL31nyxgjiEEhK0B0vagWvdRCNJSNGWpLtlq4FlCWTAnPI5ctiFgq925e+sySjNaORCoHraBXNEwyiHT2hu5ZipIW2cCAwEAAQ==', 'id': '6a2bcd88-a871-4245-a393-2843eafe6e02', 'algorithm': 'RSA', 'purpose': 1}]}, 'encryptionKeyId': None, 'symmetricKey': None, 'iv': None}}
moadian.get_economic_code_information("14007650912")
...
#{'signature': None, 'signatureKeyId': None, 'timestamp': 1693948551814, 'result': {'uid': '2c176d39-f90d-4e34-8629-3812716a5803', 'packetType': 'ECONOMIC_CODE_INFORMATION', 'data': {'nameTrade': 'گروه تجارت الکترونیک دیجی کالا', 'taxpayerStatus': 'ENABLED', 'taxpayerType': 'LEGAL', 'postalcodeTaxpayer': '1917763913', 'addressTaxpayer': 'استان تهران - شهر تهران محله جردن بلوار نلسون ماندلا بلوار صبا غربی پلاک 38 طبقه دوم'}, 'encryptionKeyId': None, 'symmetricKey': None, 'iv': None}}
# replace invoice with your invoice json and make sure you generate 'taxid' correctly.
invoice = '{"header": {}, "body": [{}], "payments": [{}]}'
invoice = json.loads(invoice)
moadian.send_invoice(invoice)

#{'signature': None, 'signatureKeyId': None, 'timestamp': 1693947237, 'result': [{'uid': '88a4e907-10f4-429f-ae89-3327579df***', 'referenceNumber': '395655e5-7830-4b68-bdf8-31ed1f098***', 'errorCode': None, 'errorDetail': None}]}
moadian.inquiry_by_reference_number("395655e5-7830-4b68-bdf8-31ed1f098***")
# this is just an example of inquiry response, your errors will be different.
...
#'signature': None, 'signatureKeyId': None, 'timestamp': 1693947277561, 'result': {'uid': None, 'packetType': 'INQUIRY_RESULT', 'data': [{'referenceNumber': '395655e5-7830-4b68-bdf8-31ed1f098***', 'uid': '88a4e907-10f4-429f-ae89-3327579df***', 'status': 'FAILED', 'data': {'confirmationReferenceId': None, 'error': [{'code': '010504', 'message': 'در مقدار وارد شده در فیلد «سریال صورتحساب» الگو(^[a-fA-F0-9]{10}$) رعایت نشده است.', 'errorType': 'ERROR'}, {'code': '011204', 'message': 'در مقدار وارد شده در فیلد «شماره اقتصادی خریدار» الگو(^\\d{14}$) رعایت نشده است.', 'errorType': 'ERROR'}], 'warning': [], 'success': False}, 'packetType': 'receive_invoice_confirm', 'fiscalId': 'YourFiscalId'}], 'encryptionKeyId': None, 'symmetricKey': None, 'iv': None}}

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

moadian-1.0.4.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

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

moadian-1.0.4-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file moadian-1.0.4.tar.gz.

File metadata

  • Download URL: moadian-1.0.4.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for moadian-1.0.4.tar.gz
Algorithm Hash digest
SHA256 81c72da81ff500983a7217487735abd8e07b7aed8de57bf12bf01f5ee6cc7962
MD5 1e84f65d4d8631569f9e4ac5a1174eac
BLAKE2b-256 c9151bfec8636a2860758e74197810b541c8bbbd26d7818cb53d3091381485f6

See more details on using hashes here.

File details

Details for the file moadian-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: moadian-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for moadian-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1f0fc2f0da0eab4651f4cdbfb30b6120d98cf162b2bcdce094e8904f62ca8c63
MD5 ad3a067835c7fa8dbf461f51653a77da
BLAKE2b-256 eec0a06703abb1007f97a4913d8ff902080043ede0b5c6cfc89c3830f2642e82

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