Skip to main content

Python package for MVola API

Project description

Python package for MVOLA API

###Installation

    python -m pip install mvola_api

###Exemple

import os
import uuid
from datetime import datetime as dt
from pathlib import Path
from mvola_api import MVolaMerchantPayAPI, AUthResult, Config, MvolaTransactionData, HashedMap,PRODUCTION_URL
from dotenv import dotenv_values
#load .env
config = dotenv_values(Path(os.getcwd(), '.env'))

# for sandbox
api: MVolaMerchantPayAPI = MVolaMerchantPayAPI()

# for production 
api: MVolaMerchantPayAPI = MVolaMerchantPayAPI(PRODUCTION_URL)

# revoke token

api.revoke_token(config.get('CONSUMER_KEY'), config.get('CONSUMER_SECRET'), True)

# The third parameter fro revoke_token is to auto update Bearer token for the API, So, no need to call set_access_token 
# If you want to load access token

auth_data = api.revoke_token(config.get('CONSUMER_KEY'), config.get('CONSUMER_SECRET'), True)

print(auth_data.access_token)

#Transaction
#create transaction config

transaction_config: Config = Config(**{
    'version': "1.0",
    'xCorrelationID': f'{uuid.uuid4()}',
    'userLanguage': "MG",
    'userAccountIdentifier': "msisdn;034350003",
    'partnerName': "Mvola API"
})
#  init transaction  config
api.init_config(transaction_config)

transaction: MvolaTransactionData = MvolaTransactionData(**{
    'amount': 500,
    'currency': "Ar",
    'descriptionText': "Description",
    'requestDate': dt.now().isoformat(),
    'debitParty': [
        HashedMap(**{
            'key': "msisdn",
            'value': "034350003",
        })
    ],
    'creditParty': [
        HashedMap(**{
            'key': "msisdn",
            'value': "034350003",
        }),
    ],
    'metadata': [
        HashedMap(**{
            'key': "partnerName",
            'value': "Mvola API",
        }),
        HashedMap(**{
            'key': "fc",
            'value': "USD",
        }),
        HashedMap(**{
            'key': "amountFc",
            'value': "1",
        }),
    ],
    'requestingOrganisationTransactionReference': f'{uuid.uuid4()}',
    'originalTransactionReference': f'{uuid.uuid4()}',
})
# start transaction
transaction_response = api.initiate_transaction(transaction)
print(transaction_response)

# get details

transaction_details = api.get_details(transactionId)

#get status
transaction_status = api.get_status(serverCorrelationId)

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

mvola-api-1.0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

mvola_api-1.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file mvola-api-1.0.2.tar.gz.

File metadata

  • Download URL: mvola-api-1.0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.2 Windows/10

File hashes

Hashes for mvola-api-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5a9e8ab286fe4590c96fe1ea5ad2734e78123703ca959c955ceb544a5a540bbf
MD5 26943d1a403e8404a76248e7829e0099
BLAKE2b-256 7bebae84305f33303e2b6da8fc6d3bc1f737693485bec72dae272c0ea02c24ea

See more details on using hashes here.

File details

Details for the file mvola_api-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: mvola_api-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.2 Windows/10

File hashes

Hashes for mvola_api-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7bc6f9fd9f70c787b22c9c73adf006c91e1f079805c846dc18812ee768ab484d
MD5 40248146c90cd34212792b7806499ac9
BLAKE2b-256 c0fe52df3940a7370b9529e34035fdcc0f4eb7e3f112d8e4ca643988a2229638

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