Skip to main content

Mvola is a light open source module for quicly configure your Mvola API.

Project description



A light Python module for quickly configure your Mvola API.

Documentation | Report bugs | Contribute

Installation

You can consult the link on pypi.org Click here.

pip install mvola==1.0.0

Usage

Check the demo file here

Start the API

Create your login and create your first application here. After your create application , you should have Consummer_key and Consummer_secret.

# Import the module mvola
from mvola import API

# Initiate the api => API(Consummer_key, Consummer_secret)
api = API("{consummer_key}","{consummer_secret}")

Generate token

Check the documentation here

res = api.generate_token()
if res.success :
    api.token = res
    print(res)
else :
    print(f"Status_code[{res.status_code}] \n {res.error}")
OUTPUT

Success

eyJ4NXQiOiJPRE5tWkRFMll6UTRNVEkxTVRZME1tSmhaR00yTUdWa1lUZGhOall5TWpnM01XTmpNalJqWWpnMll6bGpNRGRsWWpZd05ERmhZVGd6WkRoa1lUVm1OZyIsImtpZCI6Ik9ETm1aREUyWXpRNE1USTFNVFkwTW1KaFpHTTJNR1ZrWVRkaE5qWXlNamczTVdOak1qUmpZamcyWXpsak1EZGxZall3TkRGaFlUZ3paRGhrWVRWbU5nX1JTMjU2IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJyaXZvMjMwMkBnbWFpbC5jb21AY2FyYm9uLnN1cGVyIiwiYXV0IjoiQVBQTElDQVRJT04iLCJhdWQiOiIwekw3ZVRyU0VmWGY2a2t3SjUzRFNlZ0NiQndhIiwibmJmIjoxNjUxNzk1NTUyLCJhenAiOiIwekw3ZVRyU0VmWGY2a2t3SjUzRFNlZ0NiQndhIiwic2NvcGUiOiJFWFRfSU5UX01WT0xBX1NDT1BFIiwiaXNzIjoiaHR0cHM6XC9cL2FwaW0ucHJlcC50ZWxtYS5tZzo5NDQzXC9vYXV0aDJcL3Rva2VuIiwiZXhwIjoxNjUxNzk5MTUyLCJpYXQiOjE2NTE3OTU1NTIsImp0aSI6IjFjNWEwNDY3LTk5NWMtNDFiNi05M2I2LWJjNzY2YTA0ZDdiZCJ9.PCijTounfH2y2-LNaRaKQleYFEV-voBb0ES-ayYRSG8NyT8GVt6BOXWFdPh4V7MNN5ArBtErVifx5MastxKRqE1-rYnekt51iynCXknEPM3hxjFepOPHPR3rIDtRrNJ0raa0oEkVcHjn6Gl9wUiai-4zepwFaR7GP3xAr6Rz42szCQo4AjDiuJkGMNEhQqgL17AYpjOHE8mXf_Jeth7VpcgUTXDwRRNAGhCzUEHqwQpW-7TPryeTHFzj8HPySy3RWBI5bUjYfVoXWL_yg__RxM0YlPX7JE3ycs75yANbWyQ4WdSc3vZhPCkKusERajxlQCIwBxmVUmALp9YRn0wjfg

Failed (example)

Status_code[401] 
{'error_description': 'A valid OAuth client could not be found for client_id: 0zL7eTrSEfXf6kwJ53DSegCbBwa', 'error': 'invalid_client'}

The token generated by this function must expire after 3600s by default, to manage app go to the dashboard of Mvola API Application.

Generate token

Check the documentation here

from mvola.tools import Transaction

transaction = Transaction(
    token="{{token}}" #[Token] Requiered fields,
    UserLanguage="FR", # MG or FR
    UserAccountIdentifier="0343500003" #[UserAccountIdentifier] Requiered fields ,
    partnerName="Marketbot" #Name of your application,
    amount="1500",
    currency="Ar" # Possible Values : Ar only,
    descriptionText="Unedescription" #String(len<50Characters)without special character. ,
    requestDate="2022-05-06T02:14:59.567Z",
    debit="0343500003" #[Debit] Required fields | Phone number of subscriber .In preprod it’s fixed: 034350003 or 0343500004,
    credit="0343500004" #[Credit] Required fields | Phone number of merchant. In preprod it’s fixed: 034350003 or 0343500004
)

#The function to init the transaction
init = api.init_transaction(transaction.headers,transaction.dataJson)

if init.success :
    print(init.value)
else :
    print(f"Status_code [{init.status_code}] \n {init.error}")
OUTPUT

Success :

{'status': 'pending', 'serverCorrelationId': '6f10a6a4-9daf-4d37-b373-80cab3bed1e7', 'notificationMethod': 'polling'}

Failed (example):

Status_code:[401] 
{'fault': {'code': 900901, 'message': 'Invalid Credentials', 'description': 'Invalid Credentials. Make sure you have given the correct access token'}}

How contribute

  • Make a fork of the repository
  • Clone the repos
  • TODO List
  • Create a Pull Request

Contributors

Image des contributeurs GitHub

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-1.0.0.tar.gz (7.0 kB view hashes)

Uploaded Source

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