Skip to main content

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.

Metadata

Release files for cardberg 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cardberg 0.2.0
File Size Uploaded Provenance Actions
cardberg-0.2.0.tar.gz 6.3 kB Without provenance Details for cardberg-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cardberg 0.2.0
File Interpreter ABI Platform Actions
cardberg-0.2.0-py3.7.egg Legacy Egg format - - Details for cardberg-0.2.0-py3.7.egg
cardberg-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for cardberg-0.2.0-py2.py3-none-any.whl
cardberg-0.2.0-py2.7.egg Legacy Egg format - - Details for cardberg-0.2.0-py2.7.egg

Total release size: 31.9 kB

Release files / cardberg-0.2.0.tar.gz

Download URL cardberg-0.2.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
122d3aabc1236feff12f8d6516b7b020cfe6c3cdae5ac397d52f2a4a8ce5869e
BLAKE2b-256 checksum
How to use checksums
d94a67bc96a7f399155ccd52bca21a19b8506a9769af7f6a637db0eb052af803
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / cardberg-0.2.0-py3.7.egg

Download URL cardberg-0.2.0-py3.7.egg
Size 9.9 kB
Tags Egg
SHA-256 checksum
How to use checksums
53309ca93971a669e9a7976aef763ba9469c14d14fa505e98805cf29d385f6fd
BLAKE2b-256 checksum
How to use checksums
5f9521a4baab96ba9eca932e859ab238cd77adfbb99a45c89f46d0bd1a9c8656
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / cardberg-0.2.0-py2.py3-none-any.whl

Download URL cardberg-0.2.0-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8bdf58933183aa7aa8481f60018d88130b4b6031d66e55ac9a65b1e9006bbb00
BLAKE2b-256 checksum
How to use checksums
f969713f1bcca7b687c2c1fb7578d332b382cced290b9a91ddc6ce8f17327567
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / cardberg-0.2.0-py2.7.egg

Download URL cardberg-0.2.0-py2.7.egg
Size 9.7 kB
Tags Egg
SHA-256 checksum
How to use checksums
ba3bb2fe3f301ace757783467d86f366f57d54fd33c930e0702e0bc88cdcecdc
BLAKE2b-256 checksum
How to use checksums
5a375786e5cb06ad72a6f0136f32d3a7cfd6b6a0ef10d9ccc1be2966d296e551
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for cardberg 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

4 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page