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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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