Cardberg Service Bindings for Python
Cardberg Bindings for Python
Python library for Cardberg's API to work with gift cards.
The bindings currently allow you to:
- Get information on a specific card
- Create a transaction on a specific card
Detailed information of Cardberg's API can be found at their website. If you feel like you need covering additional API methods, please open an issue or create a pull request.
You can install this package by using
pip install cardberg
If you fancy
pipenv install cardberg
To install from source, run:
python setup.py install
For the API client to work you would need Python 2.7+ or Python 3.4+.
To install via
requirements file from your project, add the following for the moment before updating dependencies:
First off, you need to require the library and set the authentication information by providing your user handle and shared secret you got from the provider.
import cardberg cardberg.api_credentials = ("partner_id", "shared_secret")
Getting card information is accomplished by calling
cardberg.Card.get(). The method returns a
Card object that includes
status and available
points. On this
Card object we may create a transaction (whether positive or negative) by calling
create_transaction() method with transaction type, decimal value of the transaction and optional bill ID for further reference.
Possible transaction types are either "credits" or "points" depending on what budget do we use. If you want to make a debit (for example your user is buying something) then provide a negative value.
import cardberg from decimal import Decimal cardberg.api_credentials = ("partner_id", "shared_secret") card = cardberg.Card.get("D1nd17h") card.create_transaction( cardberg.Card.TRANSACTION_CREDITS, Decimal("-1.00") )
- Check for open issues or open a new issue for a feature request or a bug.
- Fork the repository and make your changes to the master branch (or branch off of it).
- Send a pull request.
Run all tests on all supported Python versions:
Run the linter with:
The client library uses Black for code formatting. Code must be formatted with Black before PRs are submitted. Run the formatter with:
Python 3 compatibility, code formatting covered by Black and various small fixes and formal changes to make everything better.
Added rounding to two decimal places on credits and points returned from Cardberg's API.
Initial version with support for
create_transaction API methods.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size cardberg-0.2.0-py2.7.egg (9.7 kB)||File type Egg||Python version 2.7||Upload date||Hashes View|
|Filename, size cardberg-0.2.0-py2.py3-none-any.whl (6.0 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size cardberg-0.2.0-py3.7.egg (9.9 kB)||File type Egg||Python version 3.7||Upload date||Hashes View|
|Filename, size cardberg-0.2.0.tar.gz (6.3 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for cardberg-0.2.0-py2.py3-none-any.whl