Skip to content

juanrossi/mango-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyMango

This is a Python library that allows interaction with Mango API.

Install

You can get the library from PyPI using pip:

$ pip install pymango

If you want clone the repository, point it directly into our GitHub project:

$ git clone https://github.com/Mango/mango-python.git

Documentation

Documentation is available at https://developers.getmango.com/en/api/?platform=python

Usage

Import the library and set your secret API key:

>>> import pymango as mango
>>> mango.api_key = "your Mango secret API key"

Create a charge

In order to create a Charge, you must call the create() method with the required arguments (see API documentation):

>>> charge = mango.Charges.create(amount=2000, email="test@example.org", token="token_mwhushs06o62aruq9n3pmvu7f0ia696y")
>>> print charge.get("uid")
charge_72t1r7vmb9pknrl4otg6xy3wrkwrrpzt
>>> print charge.get("paid")
True

Get single Charge

When you have a Charge uid, you can get a full detail using the get() method:

>>> mango.Charges.get("charge_72t1r7vmb9pknrl4otg6xy3wrkwrrpzt")
{
    u'customer': u'',
    u'deposit_eta': u'2013-04-09',
    u'queue_uid': u'',
    u'fee': 12,
    u'annual_interest_pct': u'',
    u'refunded': False,
    u'created_at': u'2013-09-04 20:23:28',
    u'live': False,
    u'amount_gross': 1212,
    u'paid': False,
    u'failure_message': u'',
    u'origin': u'api',
    u'amount': 1212,
    u'installments': 1,
    u'plastic': {
        u'last4': u'4242',
        u'exp_year': 2015,
        u'exp_month': 11,
        u'type': u'visa',
        u'holdername': u'Test Test'
    },
    u'uid': u'charge_72t1r7vmb9pknrl4otg6xy3wrkwrrpzt',
    u'email': u'test@getmango.com',
    u'card': u'',
    u'description': u''
}

You can also work with all the other resources authenticated with a secret API Key:

Tests

Install testing dependencies:

$ pip install nose

To run the tests you'll need Mango API keys (mode Sandbox):

$ export MANGO_SECRET_TEST_KEY=secret_test_qawsedrftgyhujikolp
$ export MANGO_PUBLIC_TEST_KEY=public_test_aqswdefrgthyjukilon

Run the tests

Use nosetests to run the complete tests suite:

$ nosetests pymango/tests/

License

MIT, see LICENSE file.

About

This is a Python library that allows interaction with Mango API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%