Giter VIP home page Giter VIP logo

paydunya-python's Introduction

PAYDUNYA Python Client Library

This is a Python library for accessing the PAYDUNYA HTTP API.

Installation

$ sudo pip install paydunya
$ OR git clone https://github.com/paydunya/paydunya-python
$ cd paydunya-python; python setup.py install
$ nosetests tests/  # run unit tests

Usage

import paydunya
from paydunya import InvoiceItem, Store

# runtime configs
PAYDUNYA_ACCESS_TOKENS = {
    'PAYDUNYA-MASTER-KEY': "Your PAYDUNYA master key",
    'PAYDUNYA-PRIVATE-KEY': "Your PAYDUNYA private key",
    'PAYDUNYA-TOKEN': "Your PAYDUNYA token"
}
# defaults to False
paydunya.debug = True
# set the access/api keys
paydunya.api_keys = PAYDUNYA_ACCESS_TOKENS

# Invoice
store = Store(name='Magasin Chez Sandra')
items = [
    InvoiceItem(
        name="Clavier DELL",
        quantity=2,
        unit_price="3000",
        total_price="6000",
        description="Best Keyboard of the 2015 year"
    ),
    InvoiceItem(
        name="Ordinateur Lenovo L440",
        quantity=1,
        unit_price="400000",
        total_price="400000",
        description="Powerful and slim"
    ),
]
invoice = paydunya.Invoice(store)
invoice.add_items(items)
# taxes are (key,value) pairs
invoice.add_taxes([("Other TAX", 5000), ("TVA (18%)", 700)])
invoice.add_custom_data([
    ("first_name", "Alioune"),
    ("last_name", "Badara"),
    ("cart_id", 97628),
    ("coupon", "NOEL"),
])

# you can also pass the items, taxes, custom to the `create` method
successful, response = invoice.create()
if successful:
    do_something_with_resp(response)

# confirm invoice
invoice.confirm('YOUR_INVOICE_TOKEN')


# PSR
opr_data = {
    'account_alias': 'EMAIL_OU_NUMERO_DU_CLIENT_PAYDUNYA',
    'description': 'Hello World',
    'total_amount': 6500
}
store = paydunya.Store(name='Magasin Chez Sandra')
opr = paydunya.OPR(opr_data, store)
# You can also pass the data to the `create` function
successful, response = opr.create()
if successful:
   do_something_with_response(response)
status, _ = opr.charge({
    'token': token,
    'confirm_token': user_submitted_token
})

# Direct Pay
account_alias =  "EMAIL_OU_NUMERO_DU_CLIENT_PAYDUNYA"
amount =  6500
# toggle debug switch to True
direct_pay = paydunya.DirectPay(account_alias, amount)
status, response = direct_pay.process()

License

see LICENSE.txt

Contributing

Issues, forks, and pull requests are welcome!

Note

  • Some of the API calls require formal approval from PAYDUNYA
  • For more information, please read the PAYDUNYA HTTP API
  • Tested on Python 2.6, 2.7, and 3+.

Authors

PAYDUNYA <[email protected]>

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.