Skip to content

voucherifyio/voucherify-python-sdk

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Official Voucherify SDK for Python

Setup | Contributing | Changelog

API: Vouchers | Distributions | Redemptions | Customers | Utils


Setup

pip install 'Voucherify'

Log-in to Voucherify web interface and obtain your Application Keys from Configuration:

from voucherify import Client as voucherifyClient

client = voucherifyClient(
    application_id='YOUR-APPLICATION-ID',
    client_secret_key='YOUR-CLIENT-SECRET-KEY'
)

API Endpoint

Optionally, you can add api_endpoint to the client options if you want to use Voucherify running in a specific region. Optionally, you can add timeout to specify request's timeout in seconds. Default value is set to 3 minutes.

from voucherify import Client as voucherifyClient

client = voucherifyClient(
    application_id='YOUR-APPLICATION-ID',
    client_secret_key='YOUR-CLIENT-SECRET-KEY',
    api_endpoint='https://<region>.api.voucherify.io',
    timeout=180
)

API

This SDK is consistent with restful API Voucherify provides. Not all API methods are currently supported in this SDK, but they are coming soon.

You will find detailed description and example responses at official docs. Method headers point to more detailed descriptions of params you can use.

Vouchers API

Methods are provided within client.vouchers.* namespace.

Create Voucher

client.vouchers.create(voucher)

Check voucher object.

Get Voucher

client.vouchers.get(code)

Update Voucher

client.vouchers.update(voucher)

List Vouchers

client.vouchers.list(params)

Enable Voucher

client.vouchers.enable(code)

Disable Voucher

client.vouchers.disable(code)

Release Validation Session

client.vouchers.releaseValidationSession(code, sessionKey)

Distributions API

Methods are provided within client.distributions.* namespace.

Publish Voucher

client.distributions.publish(params)

Validations API

Methods are provided within client.validations.* namespace.

Validate Voucher

client.validations.validateVoucher(code, params)

Validate Stackable

client.validations.validateStackable(params)

Redemptions API

Methods are provided within client.redemptions.* namespace.

Redeem Voucher

client.redemptions.redeem(code, tracking_id)

Redeem Stackable

client.redemptions.redeemStackable(params)

List Redemptions

client.redemptions.list(params)

Get Voucher's Redemptions

client.redemptions.getForVoucher(code)

Rollback Redemption

client.redemptions.rollback(redemptionId)
client.redemptions.rollback(redemptionId, reason)

Check redemption rollback object.


Customers API

Methods are provided within client.customers.* namespace.

Create Customer

client.customers.create(customer)

Check customer object.

Get Customer

client.customers.get(customerId)

Update Customer

customer object must contain id or source_id.

client.customers.update(customer)

Delete Customer

client.customers.delete(customerId)

Utils

from voucherify import utils

Available methods

  • utils.calculate_price(base_price, voucher, unit_price)
  • utils.calculate_discount(base_price, voucher, unit_price)

Contributing

Bug reports and pull requests are welcome through GitHub Issues.

Changelog

  • 2022-04-06 - 2.2.2
    • Added client.vouchers.releaseValidationSession method
    • Added client.redemptions.redeemStackable method
    • Added client.validations.validateStackable method
  • 2021-05-26 - 2.2.1
    • Upload new version to pypi.org. No changes compared to 2.2.0
  • 2021-05-20 - 2.2.0
    • Added client.validations* member
    • Added method validateVoucher to client.validations
    • Changed default timeout from 500 minutes to 3 minutes. Made timeout configurable
    • Bugfix: Fixed raising exception when response json contains property "error"
  • 2019-06-19 - 2.1.0 Added support for custom API endpoint, that allows to connect to projects created in specific Voucherify region.
  • 2018-01-20 - 2.0.0
    • Moved vouchers related methods to client.vouchers.* namespace
    • Moved redemptions related methods to client.redemptions.* namespace
    • Moved distributions related methods to client.distributions.* namespace
    • Renamed client.customer.* to client.customers.*
    • Removed outdated client.distributions.publish(campaignName) method interface
    • Fixed utils methods to accept vouchers with None gift
  • 2016-12-02 - 1.4.2 - Support gift vouchers in utils
  • 2016-10-04 - 1.4.1 - Publish update
  • 2016-07-18 - 1.4.0 - Voucher code pattern
  • 2016-07-18 - 1.3.0 - Update voucher
  • 2016-06-23 - 1.2.1 - Gift vouchers
  • 2016-06-16 - 1.2.0 - Unified naming convention
  • 2016-06-16 - 1.1.0 - Added customer methods
  • 2016-06-08 - 1.0.0 - Release version
  • 2016-05-31 - 0.1.0 - First version:
    • Authentication
    • Voucher informations: get, usage
    • Voucher operations: use
    • Utils

About

Voucherify Python SDK | Use cases: online coupons, prepaid vouchers, in-app promo codes

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published