Official Voucherify SDK for Python
Setup | Contributing | Changelog
API: Vouchers | Distributions | Redemptions | Customers | Utils
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'
)
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
)
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.
Methods are provided within client.vouchers.*
namespace.
- Create Voucher
- Get Voucher
- Update Voucher
- List Vouchers
- Enable Voucher
- Disable Voucher
- Release Validation Session
client.vouchers.create(voucher)
Check voucher object.
client.vouchers.get(code)
client.vouchers.update(voucher)
client.vouchers.list(params)
client.vouchers.enable(code)
client.vouchers.disable(code)
client.vouchers.releaseValidationSession(code, sessionKey)
Methods are provided within client.distributions.*
namespace.
client.distributions.publish(params)
Methods are provided within client.validations.*
namespace.
client.validations.validateVoucher(code, params)
client.validations.validateStackable(params)
Methods are provided within client.redemptions.*
namespace.
client.redemptions.redeem(code, tracking_id)
client.redemptions.redeemStackable(params)
client.redemptions.list(params)
client.redemptions.getForVoucher(code)
client.redemptions.rollback(redemptionId)
client.redemptions.rollback(redemptionId, reason)
Check redemption rollback object.
Methods are provided within client.customers.*
namespace.
client.customers.create(customer)
Check customer object.
client.customers.get(customerId)
customer
object must contain id
or source_id
.
client.customers.update(customer)
client.customers.delete(customerId)
from voucherify import utils
utils.calculate_price(base_price, voucher, unit_price)
utils.calculate_discount(base_price, voucher, unit_price)
Bug reports and pull requests are welcome through GitHub Issues.
- 2022-04-06 -
2.2.2
- Added
client.vouchers.releaseValidationSession
method - Added
client.redemptions.redeemStackable
method - Added
client.validations.validateStackable
method
- Added
- 2021-05-26 -
2.2.1
- Upload new version to pypi.org. No changes compared to
2.2.0
- Upload new version to pypi.org. No changes compared to
- 2021-05-20 -
2.2.0
- Added
client.validations*
member - Added method
validateVoucher
toclient.validations
- Changed default timeout from 500 minutes to 3 minutes. Made timeout configurable
- Bugfix: Fixed raising exception when response json contains property "error"
- Added
- 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.*
toclient.customers.*
- Removed outdated
client.distributions.publish(campaignName)
method interface - Fixed utils methods to accept vouchers with
None
gift
- Moved vouchers related methods to
- 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