Skip to main content

Cardberg Service Bindings for Python

Project description

Cardberg Bindings for Python

Python library for Cardberg's API to work with gift cards.

The bindings currently allow you to:

  1. Get information on a specific card
  2. 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.

Setup

You can install this package by using pip:

pip install cardberg

If you fancy pipenv use:

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:

git+git://github.com/palosopko/cardberg-python.git#egg=cardberg

Usage

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 id, name, surname, status and available credits and 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.

Example:

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")
)

Contributing

  1. Check for open issues or open a new issue for a feature request or a bug.
  2. Fork the repository and make your changes to the master branch (or branch off of it).
  3. Send a pull request.

Development

Run all tests on all supported Python versions:

make test

Run the linter with:

make lint

The client library uses Black for code formatting. Code must be formatted with Black before PRs are submitted. Run the formatter with:

make fmt

Changelog

v0.2.0: 03/10/2019

Python 3 compatibility, code formatting covered by Black and various small fixes and formal changes to make everything better.

v0.1.1: 21/03/2016

Added rounding to two decimal places on credits and points returned from Cardberg's API.

v0.1.0: 14/03/2016

Initial version with support for card_info and create_transaction API methods.

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

cardberg-0.2.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distributions

cardberg-0.2.0-py3.7.egg (9.9 kB view details)

Uploaded Source

cardberg-0.2.0-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2 Python 3

cardberg-0.2.0-py2.7.egg (9.7 kB view details)

Uploaded Source

File details

Details for the file cardberg-0.2.0.tar.gz.

File metadata

  • Download URL: cardberg-0.2.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16

File hashes

Hashes for cardberg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 122d3aabc1236feff12f8d6516b7b020cfe6c3cdae5ac397d52f2a4a8ce5869e
MD5 338a9cc35044537abc4ec4bd6a6130ec
BLAKE2b-256 d94a67bc96a7f399155ccd52bca21a19b8506a9769af7f6a637db0eb052af803

See more details on using hashes here.

File details

Details for the file cardberg-0.2.0-py3.7.egg.

File metadata

  • Download URL: cardberg-0.2.0-py3.7.egg
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16

File hashes

Hashes for cardberg-0.2.0-py3.7.egg
Algorithm Hash digest
SHA256 53309ca93971a669e9a7976aef763ba9469c14d14fa505e98805cf29d385f6fd
MD5 b8f8b0e874a996239a7b35a2d6545054
BLAKE2b-256 5f9521a4baab96ba9eca932e859ab238cd77adfbb99a45c89f46d0bd1a9c8656

See more details on using hashes here.

File details

Details for the file cardberg-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: cardberg-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16

File hashes

Hashes for cardberg-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8bdf58933183aa7aa8481f60018d88130b4b6031d66e55ac9a65b1e9006bbb00
MD5 816d078ae3f5856d9b26de83b5d83f56
BLAKE2b-256 f969713f1bcca7b687c2c1fb7578d332b382cced290b9a91ddc6ce8f17327567

See more details on using hashes here.

File details

Details for the file cardberg-0.2.0-py2.7.egg.

File metadata

  • Download URL: cardberg-0.2.0-py2.7.egg
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16

File hashes

Hashes for cardberg-0.2.0-py2.7.egg
Algorithm Hash digest
SHA256 ba3bb2fe3f301ace757783467d86f366f57d54fd33c930e0702e0bc88cdcecdc
MD5 95c62a301cee0894a29f7d24074fdf45
BLAKE2b-256 5a375786e5cb06ad72a6f0136f32d3a7cfd6b6a0ef10d9ccc1be2966d296e551

See more details on using hashes here.

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