Skip to main content

Python SDK for maib MIA API

Project description

Python SDK for maib MIA API

Installation

To easily install or upgrade to the latest release, use pip:

pip install --upgrade maib-mia-sdk

Getting started

Import SDK:

from maib_mia_sdk import MaibMiaSdk, MaibMiaAuthRequest, MaibMiaApiRequest

Add project configuration:

import os, datetime

MAIB_MIA_CLIENT_ID = os.getenv('MAIB_MIA_CLIENT_ID')
MAIB_MIA_CLIENT_SECRET = os.getenv('MAIB_MIA_CLIENT_SECRET')
MAIB_MIA_SIGNATURE_KEY = os.getenv('MAIB_MIA_SIGNATURE_KEY')

SDK usage examples

Get Access Token with Client ID and Client Secret

maib_mia_auth = MaibMiaAuthRequest \
    .create(base_url=MaibMiaSdk.SANDBOX_BASE_URL) \
    .generate_token(client_id=MAIB_MIA_CLIENT_ID, client_secret=MAIB_MIA_CLIENT_SECRET)

maib_mia_token = maib_mia_auth['accessToken']

Create a dynamic order payment QR

maib_mia_qr_data = {
    'type': 'Dynamic',
    'expiresAt': (datetime.datetime.now() + datetime.timedelta(hours=24)).isoformat(),
    'amountType': 'Fixed',
    'amount': 50.00,
    'currency': 'MDL',
    'orderId': '123',
    'description': 'Order #123',
    'callbackUrl': 'https://example.com/callback',
    'redirectUrl': 'https://example.com/success'
}

maib_mia_api_request = MaibMiaApiRequest.create(base_url=MaibMiaSdk.SANDBOX_BASE_URL)
maib_mia_create_qr_response = maib_mia_api_request.qr_create(
    data=maib_mia_qr_data,
    token=maib_mia_token)

Create a RTP (Request To Pay)

maib_mia_rtp_data = {
    'alias': '3736xxxxxxx',
    'amount': 50.00,
    'currency': 'MDL',
    'expiresAt': (datetime.datetime.now() + datetime.timedelta(hours=24)).isoformat(),
    'description': f'Order #123',
    'orderId': '123',
    'callbackUrl': 'https://example.com/callback',
    'redirectUrl': 'https://example.com/success'
}

maib_mia_create_rtp_response = maib_mia_api_request.rtp_create(
    data=maib_mia_rtp_data,
    token=maib_mia_token)

Validate callback signature

callback_data = {
    "result": {
        "qrId": "c3108b2f-6c2e-43a2-bdea-123456789012",
        "extensionId": "3fe7f013-23a6-4d09-a4a4-123456789012",
        "qrStatus": "Paid",
        "payId": "eb361f48-bb39-45e2-950b-123456789012",
        "referenceId": "MIA0001234567",
        "orderId": "123",
        "amount": 50.00,
        "commission": 0.1,
        "currency": "MDL",
        "payerName": "TEST QR PAYMENT",
        "payerIban": "MD88AG000000011621810140",
        "executedAt": "2025-04-18T14:04:11.81145+00:00",
        "terminalId": null
    },
    "signature": "fHM+l4L1ycFWZDRTh/Vr8oybq1Q1xySdjyvmFQCmZ4s="
}

validate_callback_result = MaibMiaSdk.validate_callback_signature(
    callback_data=callback_data,
    signature_key=MAIB_MIA_SIGNATURE_KEY)

Perform a test QR payment

maib_test_pay_data = {
    'qrId': maib_mia_create_qr_response['qrId'],
    'amount': maib_mia_qr_data['amount'],
    'iban': 'MD88AG000000011621810140',
    'currency': maib_mia_qr_data['currency'],
    'payerName': 'TEST QR PAYMENT'
}

maib_mia_test_pay_response = maib_mia_api_request.test_pay(
    data=maib_test_pay_data,
    token=maib_mia_token)

Get payment details

maib_mia_payment_details_response = maib_mia_api_request.payment_details(
    pay_id=maib_mia_test_pay_response['payId'],
    token=maib_mia_token)

Refund payment

maib_mia_pay_refund_data = {
    'reason': 'Test refund reason'
}

maib_mia_refund_details_response = maib_mia_api_request.payment_refund(
    pay_id=maib_mia_test_pay_response['payId'],
    data=maib_mia_pay_refund_data,
    token=maib_mia_token)

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

maib_mia_sdk-1.1.2.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

maib_mia_sdk-1.1.2-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file maib_mia_sdk-1.1.2.tar.gz.

File metadata

  • Download URL: maib_mia_sdk-1.1.2.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for maib_mia_sdk-1.1.2.tar.gz
Algorithm Hash digest
SHA256 563eb77b86292c7a6df4301124c5b42b16b1fb00b9dc2e674b258a36a9325ef1
MD5 50f3157086d6341d98bffd96910a599b
BLAKE2b-256 097fb4113ec1f210c77cb601404db919ddbcfc9d3d213c0345f079c3d97cb6df

See more details on using hashes here.

Provenance

The following attestation bundles were made for maib_mia_sdk-1.1.2.tar.gz:

Publisher: action-pypi-publish.yml on alexminza/maib-mia-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file maib_mia_sdk-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: maib_mia_sdk-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for maib_mia_sdk-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0ef0e5ffa166d4d80eec892b2fd5150224fad5a4d19bd9ba109d9f4301fd7749
MD5 882dc36c07083bc459e545b4070730d5
BLAKE2b-256 fca8ecd977710fe06504f6c73503bbcc59589706fd079cfd022f828721a78081

See more details on using hashes here.

Provenance

The following attestation bundles were made for maib_mia_sdk-1.1.2-py3-none-any.whl:

Publisher: action-pypi-publish.yml on alexminza/maib-mia-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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