Giter VIP home page Giter VIP logo

momoapi-python's People

Contributors

arthurarty avatar mossplix avatar okellogabrielinnocent avatar raybesiga avatar spekulatius avatar xkmato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

momoapi-python's Issues

Add Unit Testing

Problem

Most of the code currently in master is not tested. This means it will be hard to detect when this library starts to fail.

Solution

To ensure that the library behaves as expected, we need to add tests.

Tasks

  • setup testing suite
  • add unit tests for collections, disbursements, remittances
  • add unit tests for users

Remove phone number validation or make it optional

Before sending a request to the MoMo API the phone number validated is and 256 is appended.
However, this makes testing in sandbox with the numbers provided for testing difficult. Phone number validation should be made optional.

Add Collections

The client does not fully support the Collections API. We need to add a module to support the following operations:

  • POST /token (we need to already have an authorizer for this)
  • POST /requesttopay
  • GET /requesttopay/{referenceId}
  • GET /v1_0/account/balance
  • GET /v1_0/accountholder/{accountHolderIdType}/{accountHolderId}/active

Reference

Add Validation

Is your feature request related to a problem? Please describe.

Currently, we don't have any validation to ensure users are invoking functions with the right parameters. The only validation we get is from the API. Ideally, we should identify errors and fail fast before they reach the API

Describe the solution you'd like

We need to add assertions on functions and constructors to ensure that the correct information is being given.

Continuous Integration and Testing

We need to add CI to facilitate automation of testing and publishing. We shall use Travis CI.
For the start, the CI should publish to pip when a PR is reviewed and merged to master.

Progress

  • configure pylint
  • configure testing
  • configure semantic versioning
  • configure travis ci
  • add appropriate pypi token and github token to Travis CI secrets

Update README

The README needs to be updated to reflect the changes that are being made and will be made in the production library.

Handle global and product specific variables

Some of the variables required to initialize the library are global, while others are product specific.

The global variables are;

  • Base URL (Sandbox or Production URL)
  • Platform Environment (Sandbox or Production)
  • Callback Host

The product specific ones are;

  • Subscription Key (Primary or Secondary)
  • User ID
  • User/API Secret

Describe the solution you'd like

We should initialize the library with global variables and then initialize the product clients with product-specific variables.

Add Disbursements

The library does not fully support the Disbursements API. We need to add a module to support disbursements. The module must support the following operations:

  • POST /token (we need to create an authorizer for this)
  • POST /transfer
  • GET /transfer/{referenceId}
  • GET /v1_0/account/balance
  • GET /v1_0/accountholder/{accountHolderIdType}/{accountHolderId}/active

Reference

MOMO api error

Getting this error ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer')) after submitting the callback host and Ocp-Apim-Subscription-Key for my transaction yet I have a steady network connection

ENVIRONMENT is missing in the configuration

Why does the momo API keep throwing me the ENVIRONMENT is missing in the configuration, Exception. after i had provided one in the config={

        'ENVIRONMENT': os.environ.get("https://sandbox.momodeveloper.mtn.com/collection/v1_0/bc-authorize"),
        'BASE_URL': os.environ.get("BASE_URL"),
        'CALLBACK_HOST': os.environ.get("http://127.0.0.1:8000"),}

The documentation stated that it was optional but when left blank or provided with one i get that Exception.....whenever i make client.requestToPay(amount='100',
mobile ='233247854320', external_id='324445335').

what could possibly be the case ....?

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Why I am getting JsonDecodeError with disbursements even when the http response is 202?
This is what I am getting back after calling transfer method;

return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is the data I am pushing through;

headers
Out[9]: 
{'X-Target-Environment': 'sandbox',
 'Content-Type': 'application/json',
 'Ocp-Apim-Subscription-Key': 'hidden',
 'X-Reference-Id': 'hidden'}
data
Out[10]: 
{'amount': '600',
 'currency': 'EUR',
 'externalId': '123456789',
 'payee': {'partyIdType': 'MSISDN', 'partyId': '256772123456'},
 'payerMessage': 'dd',
 'payeeNote': 'dd'}

And these are the values of the resp variable;

resp
Out[20]: <Response [202]>
resp.headers
Out[21]: {'Content-Length': '0', 'Date': 'Thu, 23 May 2019 11:08:30 GMT'}
resp.status_code
Out[22]: 202
resp.text
Out[23]: ''

Sample code for disbursement in README file.

Is your feature request related to a problem? Please describe.
The README section talking about how to use the Disbursements imports the Disbursement class from the mtnmomo.collection however this class is actually found in mtnmomo.disbursement.
image

Describe the solution you'd like
I would like to correct the two code snippets that have this error in the README.

Add Custom Errors

Is your feature request related to a problem? Please describe.

The library needs to throw custom errors depending on what errors are returned by MTN

Describe the solution you'd like

We should add custom error classes and throw them when the corresponding error occurs

Tasks

  • Add error classes for all possible MTN errors
  • Throw the correct exceptions depending on errors that occur

Add Remittances

This library doesn't currently support the Remittances API. We need to add a module to support remittances. It should support the following operations:

  • POST /token (we need to add an authorizer for this)
  • POST /transfer
  • GET /transfer/{referenceId}
  • GET /v1_0/account/balance
  • GET /v1_0/accountholder/{accountHolderIdType}/{accountHolderId}/active

Reference

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.