Skip to content
Switch branches/tags


Failed to load latest commit information.
Latest commit message
Commit time

Official Voucherify SDK for PHP

Migration from 0.x | Setup | Error handling | Contributing | Changelog

API: Vouchers | Campaigns | Distributions | Validations | Redemptions | Customers | Orders | Products | Validation Rules | Segments | Promotions | Utils


Add Voucherify dependency into your composer.json:

"rspective/voucherify": "v2.0.*"

Update project dependencies:

$ composer install

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


use Voucherify\VoucherifyClient;
use Voucherify\ClientException;


$client = new VoucherifyClient($apiID, $apiKey);


All requests will use your account API settings, unless you override the API version. The changelog lists every available version.

$apiVersion = "v2018-08-01";

$client = new VoucherifyClient($apiID, $apiKey, $apiVersion);

Check versioning.

Custom API URL

By default client is sending request to You can override $apiUrl while creating client instance if you want to use Voucherify running in a specific region

$apiVersion = null;
$apiUrl = "https://<region>";

$client = new VoucherifyClient($apiID, $apiKey, $apiVersion, $apiUrl);

PHP autoloading

When you aren't using composer you can load Voucherify module by including autoload.php file from /src directory.


use Voucherify\VoucherifyClient;
use Voucherify\ClientException;

$client = new VoucherifyClient($apiID, $apiKey);


This SDK is fully consistent with restufl API Voucherify provides. Detalied description and example responses you will find at official docs. Method headers point to more detalied params description you can use.

Vouchers API

Methods are provided within $client->vouchers->* namespace.

Check voucher object.

Create Voucher


Get Voucher


Update Voucher


Delete Voucher

$client->vouchers->delete($code, $force);

List Vouchers


Enable Voucher


Disable Voucher


Add balance to Gift-Card Voucher

$client->vouchers->addBalance($code, $balance);

Import Vouchers


Campaigns API

Methods are provided within $client->campaigns->* namespace.

Create Campaign


Get Campaign


Add Voucher to Campaign

$client->campaigns->addVoucher($campaignName, $params);

Add Voucher with certain code to Campaign

$client->campaigns->addVoucherWithCode($campaignName, $code);
$client->campaigns->addVoucherWithCode($campaignName, $code, $params);

Import Vouchers to Campaign

$client->campaigns->importVouchers($campaignName, $vouchers);

Delete Campaign


Distributions API

Methods are provided within $client->distributions->* namespace.

Publish Voucher


Create Export


Get Export


Delete Export


List Publications


Validations API

Methods are provided within $client->validations->* namespace.

Validate Voucher

$client->validations->validate($code, $params);

// OR

$client->validations->validateVoucher($code, $params);

Validate Promotion Campaign


Redemptions API

Methods are provided within $client->redemptions->* namespace.

Check redemption rollback object.

Redeem Voucher

$client->redemptions->redeem($code, $params);

Redeem Promotion's Tier

$client->redemptions->redeem($promotionsTier, $params);

Get Redemption


List Redemptions


Get Voucher's Redemptions


Rollback Redemption

$client->redemptions->rollback($redemption_id, $params);
$client->redemptions->rollback($redemption_id, $reason);

Customers API

Methods are provided within $client->customers->* namespace.

Check customer object.

Create Customer


Get Customer


Update Customer


Delete Customer


List Customers


Orders API

Methods are provided within $client->orders->* namespace.

Check customer object.

Create Order


Get Order


Update Order


List Orders


Products API

Methods are provided within $client->products->* namespace.

Check product object.

Check sku object.

Create Product


Get Product


List Products


Update Product


Delete Product

$client->products->delete($product_id, $force);

Create SKU

$client->products->createSku($product_id, $sku);


$client->products->getSku($product_id, $sku_id);

List SKUs


Update SKU

$client->products->updateSku($product_id, $sku_update);

Delete SKU

$client->products->deleteSku($product_id, $sku_id);
$client->products->deleteSku($product_id, $sku_id, $force);

Validation Rules API

Methods are provided within $client->validationRules->* namespace.

Check validation rule object.

Create Validation Rule


Get Validation Rule


List Validation Rules


Update Validation Rule


Delete Validation Rule


Create Validation Rule Assignment

$client->validationRules->createAssignment($rule_id, $assignment);

List Validation Rule Assignments


Delete Validation Rule Assignment

$client->validationRules->deleteAssignment($rule_id, $assignment_id);

Segments API

Methods are provided within $client->segments->* namespace.

Check segment object.

Create Segment


Get Segment


Delete Segment


Promotions API

Methods are provided within $client->promotions->* namespace.

Check promotion campaign object.

Check promotion's tier object.

Create Promotion Campaign


Validate Promotion Campaign


List Promotion's Tiers


Create Promotion's Tier

$client->promotions->tiers->create($promotionCampaignId, $promotionsTier);

Redeem Promotion's Tier

$client->promotions->tiers->redeem($promotionsTierId, $redemptionContext);

Update Promotion's Tier


Delete Promotion's Tier


List Available Promotion Tiers



To use utils you have to import Voucherify Utils class.


use Voucherify\Utils;

Available methods:

Verify Webhook Signature

Utils::verifyWebhookSignature($signature, $message, $secretKey)

Migration from 0.x

Version 1.x of the PHP is fully backward compatible with version 0.x. Changes made in version 1.x mostly relate to grouping methods within namespaces. So all you need to do is to follow the list bellow and just replace deprecated methods with their namespaced equivalent.

Deprecated methods

Error handling

VoucherifyClient will throw custom ClientException object. To get sutructure described in our API reference please use:

try {
catch (ClientException $e) {
    $error = $e->getError();


VoucherifyClient has method setLogger() which can be used to set PSR-3 logger interface.

Set own logger if you want to preview curl request and response data.

$logger = /* Initialaze logger i.e Monolog, Analog */

$client = new VoucherifyClient($apiID, $apiKey);

Connection Options

Use setConnectionOptions() method to set client connection options.


  • timeout - curl 'CURLOPT_TIMEOUT_MS'
  • connectTimeout - curl 'CURLOPT_CONNECTTIMEOUT'
$options = [
    "timeout" => 1500,
    "connectTimeout" => 2

$client = new VoucherifyClient($apiID, $apiKey);

Use case - CodeIgniter

Simple example of adding Voucherify to your CodeIgniter project.


Download voucherify /src directory to application/third_party/voucherify.

Custom Library

Create new library file in /application/libraries directory, i.e. Coupons.php.

<?php defined('BASEPATH') OR exit('No direct script access allowed');

$src_voucherify = APPPATH . "third_party/voucherify/autoload.php";


use Voucherify\VoucherifyClient;
use Voucherify\ClientException;

class Coupons {

    public $voucherify;

    public function __construct() {
        $apiID  = "YOUR-APPLICATION-ID";
        $apiKey = "YOUR-CLIENT-SECRET-KEY";

        $this->voucherify = new VoucherifyClient($apiId, $apiKey);

Using Voucherify

Load new library and start using voucherify client.

<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Voucher extends CI_Controller {

    public function index()

        $voucherCode = "TEST-VOUCHER-CODE";
        $voucher = $this->coupons->voucherify->get($voucherCode);



Bug reports and pull requests are welcome through GitHub Issues.


  • 2019-07-19 - 2.0.0 - Hide API versioning in $apiUrl param
  • 2018-12-28 - 1.7.10 - Add Validation Rule Assignments
  • 2018-03-18 - 1.7.9 - Add Utils with verifyWebhookSignature method
  • 2018-02-18 - 1.7.8 - Product delete force option support
  • 2018-02-13 - 1.7.7 - Fix Promotions Tiers getAvailable method param
  • 2018-02-13 - 1.7.6 - Promotions Tiers getAvailable method
  • 2018-02-11 - 1.7.4 - Customers getList method
  • 2018-01-14 - 1.7.3 - Promotions API
  • 2017-07-24 - 1.7.2 - Fix get publications missing params
  • 2017-07-23 - 1.7.1 - Api Client conneciton options
  • 2017-07-12 - 1.7.0 - Orders API
  • 2017-07-10 - 1.6.2 - PHP autoloading support
  • 2017-07-07 - 1.6.1 - Remove Psr/Log dependency
  • 2017-06-26 - 1.6.0 - Api Client logger support
  • 2017-06-21 - 1.5.0 - Custom API URL support
  • 2017-05-02 - 1.4.0 - API Version Header support
  • 2017-05-02 - 1.3.0 - Validation rules API, Segments API, Products API
  • 2017-04-27 - 1.2.0 - Validations API, Redemptions-Get, Distributions-Export
  • 2017-04-26 - 1.1.0 - Campaigns API, Vouchers import method
  • 2017-04-19 - 1.0.2 - Unit tests, bug fixes
  • 2017-03-17 - 1.0.1 - Vouchers addBalance method
  • 2017-02-19 - 1.0.0 - Namespace refectoring
  • 2016-09-13 - 0.11.0 - Added new API method for voucher - publish
  • 2016-09-13 - 0.10.0 - Added new API method for voucher - delete
  • 2016-09-13 - 0.9.1 - Fix to maintain builder pattern.
  • 2016-07-20 - 0.9.0 - Voucher code pattern.
  • 2016-07-19 - 0.8.0 - Voucher update method.
  • 2016-06-23 - 0.7.0 - Gift vouchers.
  • 2016-04-27 - 0.6.0 - Added new API methods for customer - create, get, update, delete.
  • 2016-04-27 - 0.5.0 - Rollback redemption.
  • 2016-04-18 - 0.4.0 - List vouchers. Filter by customer.
  • 2016-04-07 - 0.3.0 - List redemptions.
  • 2016-04-04 - 0.2.2 - Updated API URL.
  • 2016-03-03 - 0.2.1 - Fixed a typo (diasble -> disable).
  • 2016-01-21 - 0.2.0 - Added new API methods - create, disable and enable.
  • 2015-12-11 - 0.1.1 - New discount model. Added UNIT - a new discount type.
  • 2015-12-02 - 0.1.0 - First version:
    • Authentication
    • Voucher informations: get, redemption
    • Voucher operations: redeem


PHP SDK for Voucherify - coupons, vouchers, promo codes




No packages published