Coupon

Coupons can be applied to subscriptions.

Coupon / Create

Create | Delete | List | Find | Update

Examples

Create Coupon
PaymentsApi.PUBLIC_KEY = "YOUR_PUBLIC_API_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR_PRIVATE_API_KEY";

Coupon coupon = Coupon.create(new PaymentsMap()
        .set("couponCode", "20off")
        .set("description", "20% off!")
        .set("endDate", 64063288800000L)
        .set("maxRedemptions", 100)
        .set("percentOff", 20L)
        .set("startDate", 2394829384000L)
);

System.out.println(coupon);
require 'simplify'

Simplify::public_key = "YOUR_PUBLIC_API_KEY"
Simplify::private_key = "YOUR_PRIVATE_API_KEY"

coupon = Simplify::Coupon.create({
        "startDate" => "2394829384000",
        "description" => "20% off!",
        "maxRedemptions" => "100",
        "couponCode" => "20off",
        "endDate" => "64063288800000",
        "percentOff" => "20"
})

puts coupon.inspect
import simplify

simplify.public_key = "YOUR_PUBLIC_API_KEY"
simplify.private_key = "YOUR_PRIVATE_API_KEY"

coupon = simplify.Coupon.create({
        "startDate" : "2394829384000",
        "description" : "20% off!",
        "maxRedemptions" : "100",
        "couponCode" : "20off",
        "endDate" : "64063288800000",
        "percentOff" : "20"

})

print coupon
<?php

require_once("./lib/Simplify.php");

Simplify::$publicKey = 'YOUR_PUBLIC_API_KEY';
Simplify::$privateKey = 'YOUR_PRIVATE_API_KEY';

$coupon = Simplify_Coupon::createCoupon(array(
        'startDate' => '2394829384000',
        'description' => '20% off!',
        'maxRedemptions' => '100',
        'couponCode' => '20off',
        'endDate' => '64063288800000',
        'percentOff' => '20'
));

print_r($coupon);

?>
use Net::Simplify;

$Net::Simplify::public_key = "YOUR_PUBLIC_API_KEY";
$Net::Simplify::private_key = "YOUR_PRIVATE_API_KEY";

my $coupon = Net::Simplify::Coupon->create({
    startDate => "2394829384000",
    description => "20% off!",
    maxRedemptions => "100",
    couponCode => "20off",
    endDate => "64063288800000",
    percentOff => "20"
});

print "Coupon ID ", $coupon->{id}, "\n";
using SimplifyCommerce.Payments;

PaymentsApi.PublicApiKey = "YOUR_PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR_PRIVATE_KEY";

PaymentsApi api = new PaymentsApi();

Coupon coupon = new Coupon();
coupon.CouponCode = "20off";
coupon.Description = "20% off!";
coupon.EndDate = 64063288800000;
coupon.MaxRedemptions = 100;
coupon.PercentOff = 20;
coupon.StartDate = 2394829384000;

try
{
    coupon = (Coupon)api.Create(coupon);
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}
var Simplify = require("simplify-commerce"),
    client = Simplify.getClient({
        publicKey: 'YOUR_PUBLIC_API_KEY',
        privateKey: 'YOUR_PRIVATE_API_KEY'
    });

client.coupon.create({
    startDate : "2394829384000",
    description : "20% off!",
    maxRedemptions : "100",
    couponCode : "20off",
    endDate : "64063288800000",
    percentOff : "20"
}, function(errData, data){

    if(errData){
        console.error("Error Message: " + errData.data.error.message);
        // handle the error
        return;
    }

    console.log("Success Response: " + JSON.stringify(data));
});
INPUT PARAMETERS
amountOff Amount off of the price of the product in the smallest units of the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00
[min value: 1, max value: 9999900]
optional
couponCode Code that identifies the coupon to be used.
[min length: 2]
required
description A brief section that describes the coupon. optional
durationInMonths DEPRECATED - Duration in months that the coupon will be applied after it has first been selected.
[min value: 1, max value: 9999]
optional
endDate Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone. optional
maxRedemptions Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
[min value: 1]
optional
numTimesApplied The number of times a coupon will be applied on a customer's subscription.
[min value: 1, max value: 9999]
optional
percentOff Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number.
[min value: 1, max value: 100]
optional
startDate First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. required
OUTPUT
id Unique ID of the coupon
amountOff Amount off of the price of the product in the smallest unit of your currency in the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00
couponCode Code that identifies the coupon to be used.
dateCreated Date in UTC millis the coupon was created in the system
description A brief section that describes the coupon.
durationInMonths DEPRECATED - Duration in months that the coupon will be applied after it has first been selected.
endDate Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
maxRedemptions Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
numTimesApplied The number of times a coupon will be applied on a customer's subscription.
percentOff Percentage off of the price of the product. The percent off is a whole number.
startDate First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone.
timesRedeemed Number of times the coupon has been redeemed. A redemption is defined as when the coupon is applied to the subscription for the first time.
total Total amount of the coupon in the smallest unit of your currency. Example: 100 = $1.00

Coupon / Delete

Create | Delete | List | Find | Update

Examples

Delete Coupon
PaymentsApi.PUBLIC_KEY = "YOUR_PUBLIC_API_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR_PRIVATE_API_KEY";

Coupon coupon = Coupon.find("4TR6Bc");

coupon = coupon.delete();

System.out.println(coupon);
require 'simplify'

Simplify::public_key = "YOUR_PUBLIC_API_KEY"
Simplify::private_key = "YOUR_PRIVATE_API_KEY"

coupon = Simplify::Coupon.find('4TR6Bc')

coupon = coupon.delete()

puts coupon.inspect
import simplify

simplify.public_key = "YOUR_PUBLIC_API_KEY"
simplify.private_key = "YOUR_PRIVATE_API_KEY"

coupon = simplify.Coupon.find('4TR6Bc')
coupon.delete()
<?php

require_once("./lib/Simplify.php");

Simplify::$publicKey = 'YOUR_PUBLIC_API_KEY';
Simplify::$privateKey = 'YOUR_PRIVATE_API_KEY';

$obj  = Simplify_Coupon::findCoupon('4TR6Bc');

$obj = $obj->deleteCoupon();

?>
use Net::Simplify;

$Net::Simplify::public_key = "YOUR_PUBLIC_API_KEY";
$Net::Simplify::private_key = "YOUR_PRIVATE_API_KEY";

$coupon = Net::Simplify::Coupon->find('4TR6Bc');

$coupon->delete();

using SimplifyCommerce.Payments;

PaymentsApi.PublicApiKey = "YOUR_PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR_PRIVATE_KEY";

PaymentsApi api = new PaymentsApi();


try
{
    String id = "1234";

    Coupon coupon = (Coupon)api.Find(typeof(Coupon), id);

    coupon = (Coupon)api.Delete(typeof(Coupon), coupon.Id);

    Console.WriteLine (coupon.Id);
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}

var Simplify = require("simplify-commerce"),
    client = Simplify.getClient({
        publicKey: 'YOUR_PUBLIC_API_KEY',
        privateKey: 'YOUR_PRIVATE_API_KEY'
    });

client.coupon.delete("4TR6Bc", function(errData, data){

    if(errData){
        console.error("Error Message: " + errData.data.error.message);
        // handle the error
        return;
    }

    console.log("Success Response: " + JSON.stringify(data));
});
INPUT PARAMETERS
id Object ID required
OUTPUT
id Unique ID of the coupon
amountOff Amount off of the price of the product in the smallest unit of your currency in the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00
couponCode Code that identifies the coupon to be used.
dateCreated Date in UTC millis the coupon was created in the system
description A brief section that describes the coupon.
durationInMonths DEPRECATED - Duration in months that the coupon will be applied after it has first been selected.
endDate Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
maxRedemptions Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
numTimesApplied The number of times a coupon will be applied on a customer's subscription.
percentOff Percentage off of the price of the product. The percent off is a whole number.
startDate First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone.
timesRedeemed Number of times the coupon has been redeemed. A redemption is defined as when the coupon is applied to the subscription for the first time.
total Total amount of the coupon in the smallest unit of your currency. Example: 100 = $1.00

Coupon / List

Create | Delete | List | Find | Update

Examples

List Coupon
PaymentsApi.PUBLIC_KEY = "YOUR_PUBLIC_API_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR_PRIVATE_API_KEY";

ResourceList<Coupon> coupon = Coupon.list(new PaymentsMap("max", 30));

System.out.println ("Total: " + coupon.getTotal());
for (Coupon o: coupon.getList()) {
    System.out.println(o.toString());
}
require 'simplify'

Simplify::public_key = "YOUR_PUBLIC_API_KEY"
Simplify::private_key = "YOUR_PRIVATE_API_KEY"

val = Simplify::Coupon.list({"max" => 30})

puts "Total: #{val['total']}"
val['list'].each do |o|
    puts o.inspect
end
import simplify

simplify.public_key = "YOUR_PUBLIC_API_KEY"
simplify.private_key = "YOUR_PRIVATE_API_KEY"

coupons = simplify.Coupon.list({"max": 30})

print "Total: " + str(coupons.total)
for o in coupons.list:
    print o
<?php

require_once("./lib/Simplify.php");

Simplify::$publicKey = 'YOUR_PUBLIC_API_KEY';
Simplify::$privateKey = 'YOUR_PRIVATE_API_KEY';

$coupon = Simplify_Coupon::listCoupon(array("max" => 30));

print "Total: " . $coupon->total . "\n";
foreach ($coupon->list as $o) {
    print_r($o);
}

?>
use Net::Simplify;

$Net::Simplify::public_key = "YOUR_PUBLIC_API_KEY";
$Net::Simplify::private_key = "YOUR_PRIVATE_API_KEY";

$coupons = Net::Simplify::Coupon->list({max => 30});

print "Total: ", $coupons->total, "\n";
foreach my $coupon ($coupons->list) {
    print $coupon->{id}, "\n";
}
using SimplifyCommerce.Payments;

PaymentsApi.PublicApiKey = "YOUR_PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR_PRIVATE_KEY";

PaymentsApi api = new PaymentsApi();


try
{
    ResourceList<Coupon> coupon = (ResourceList<Coupon>)api.List(typeof(Coupon));

    Console.WriteLine ("Total: " + coupon.Total);
    Console.WriteLine ("List: " + coupon.List.ToString());

}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}

var Simplify = require("simplify-commerce"),
    client = Simplify.getClient({
        publicKey: 'YOUR_PUBLIC_API_KEY',
        privateKey: 'YOUR_PRIVATE_API_KEY'
    });

client.coupon.list({max: 30}, function(errData, data){

    if(errData){
        console.error("Error Message: " + errData.data.error.message);
        // handle the error
        return;
    }

    console.log("Total: " + data.total);

    for(var i=0; i < data.list.length; i++){
        console.log("Amount: " + data.list[i].amount);
    }
});
INPUT PARAMETERS
filter
filter.idFilter by the coupon Id
filter.textFilter by the coupon code
filter.dateCreatedMin*Filter by the minimum created date you are searching for - Date in UTC millis
filter.dateCreatedMax*Filter by the maximum created date you are searching for - Date in UTC millis
filter.startDateMinFilter by the minimum coupon start date you are searching for - Date in UTC millis
filter.startDateMaxFilter by the maximum coupon start date you are searching for - Date in UTC millis
filter.endDateMinFilter by the minimum coupon end date you are searching for - Date in UTC millis
filter.endDateMaxFilter by the maximum coupon end date you are searching for - Date in UTC millis

*Use dateCreatedMin with dateCreatedMax in the same filter if you want to search between two created dates
optional
max Allows up to a max of 50 list items to return.
[min value: 0, max value: 50, default: 20]
optional
offset Used in paging of the list. This is the start offset of the page.
[min value: 0, default: 0]
optional
sorting Allows for ascending or descending sorting of the list. The value is a map between the property name and the sorting direction (either 'asc' for ascending or 'desc' for descending). Sortable properties are:dateCreated, maxRedemptions, timesRedeemed, id, startDate, endDate, percentOff, couponCode, durationInMonths, numTimesApplied, amountOff optional
OUTPUT
filter Filters to apply to the list.
list Object list
max Allows up to a max of 50 list items to return.
offset Used in paging of the list. This is the start offset of the page.
sorting Allows for ascending or descending sorting of the list.
total Total number of records available

Coupon / Find

Create | Delete | List | Find | Update

Examples

Find Coupon
PaymentsApi.PUBLIC_KEY = "YOUR_PUBLIC_API_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR_PRIVATE_API_KEY";

Coupon coupon = Coupon.find("4TR6Bc");

System.out.println (coupon);
require 'simplify'

Simplify::public_key = "YOUR_PUBLIC_API_KEY"
Simplify::private_key = "YOUR_PRIVATE_API_KEY"

coupon = Simplify::Coupon.find('4TR6Bc')

puts coupon.inspect

import simplify

simplify.public_key = "YOUR_PUBLIC_API_KEY"
simplify.private_key = "YOUR_PRIVATE_API_KEY"

coupon = simplify.Coupon.find('4TR6Bc')

print coupon
<?php

require_once("./lib/Simplify.php");

Simplify::$publicKey = 'YOUR_PUBLIC_API_KEY';
Simplify::$privateKey = 'YOUR_PRIVATE_API_KEY';

$obj  = Simplify_Coupon::findCoupon('4TR6Bc');

print_r($obj);

?>
use Net::Simplify;

$Net::Simplify::public_key = "YOUR_PUBLIC_API_KEY";
$Net::Simplify::private_key = "YOUR_PRIVATE_API_KEY";

$coupon = Net::Simplify::Coupon->find('4TR6Bc');

print $coupon->{id}, "\n";
using SimplifyCommerce.Payments;
using Newtonsoft.Json;

PaymentsApi.PublicApiKey = "YOUR_PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR_PRIVATE_KEY";

PaymentsApi api = new PaymentsApi();


try
{
    String id = "1234";

    Coupon coupon = (Coupon)api.Find(typeof(Coupon), id);

    // output all properties
    Console.WriteLine(JsonConvert.SerializeObject(coupon).ToString());
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}

var Simplify = require("simplify-commerce"),
    client = Simplify.getClient({
        publicKey: 'YOUR_PUBLIC_API_KEY',
        privateKey: 'YOUR_PRIVATE_API_KEY'
    });

client.coupon.find("4TR6Bc", function(errData, data){

    if(errData){
        console.error("Error Message: " + errData.data.error.message);
        // handle the error
        return;
    }

    console.log("Success Response: " + JSON.stringify(data));
});
INPUT PARAMETERS
None
OUTPUT
id Unique ID of the coupon
amountOff Amount off of the price of the product in the smallest unit of your currency in the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00
couponCode Code that identifies the coupon to be used.
dateCreated Date in UTC millis the coupon was created in the system
description A brief section that describes the coupon.
durationInMonths DEPRECATED - Duration in months that the coupon will be applied after it has first been selected.
endDate Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
maxRedemptions Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
numTimesApplied The number of times a coupon will be applied on a customer's subscription.
percentOff Percentage off of the price of the product. The percent off is a whole number.
startDate First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone.
timesRedeemed Number of times the coupon has been redeemed. A redemption is defined as when the coupon is applied to the subscription for the first time.
total Total amount of the coupon in the smallest unit of your currency. Example: 100 = $1.00

Coupon / Update

Create | Delete | List | Find | Update

Examples

Update Coupon
PaymentsApi.PUBLIC_KEY = "YOUR_PUBLIC_API_KEY";
PaymentsApi.PRIVATE_KEY = "YOUR_PRIVATE_API_KEY";

Coupon coupon = Coupon.find("4TR6Bc");

coupon.set("endDate", 2394849384000L);
coupon.set("maxRedemptions", 1000);

coupon.update();

require 'simplify'

Simplify::public_key = "YOUR_PUBLIC_API_KEY"
Simplify::private_key = "YOUR_PRIVATE_API_KEY"


coupon = Simplify::Coupon.find('4TR6Bc')

updates = {
        "maxRedemptions" => "1000",
        "endDate" => "2394849384000"

}

coupon.merge!(updates)

coupon = coupon.update()
puts coupon.inspect
import simplify

simplify.public_key = "YOUR_PUBLIC_API_KEY"
simplify.private_key = "YOUR_PRIVATE_API_KEY"

coupon = simplify.Coupon.find('4TR6Bc')

coupon["maxRedemptions"] = '1000'
coupon["endDate"] = '2394849384000'

coupon.update()
<?php

require_once("./lib/Simplify.php");

Simplify::$publicKey = 'YOUR_PUBLIC_API_KEY';
Simplify::$privateKey = 'YOUR_PRIVATE_API_KEY';

$coupon  = Simplify_Coupon::findCoupon('4TR6Bc');

$updates = array(
        'maxRedemptions' => '1000',
        'endDate' => '2394849384000'

);

$coupon->setAll($updates);

$coupon->updateCoupon();

?>
use Net::Simplify;

$Net::Simplify::public_key = "YOUR_PUBLIC_API_KEY";
$Net::Simplify::private_key = "YOUR_PRIVATE_API_KEY";

$coupon = Net::Simplify::Coupon->find('4TR6Bc');

$coupon->{maxRedemptions} = "1000";
$coupon->{endDate} = "2394849384000";

$coupon->update();
using SimplifyCommerce.Payments;

PaymentsApi.PublicApiKey = "YOUR_PUBLIC_KEY";
PaymentsApi.PrivateApiKey = "YOUR_PRIVATE_KEY";

PaymentsApi api = new PaymentsApi();

string id = "1234";

Coupon coupon = (Coupon)api.Find(typeof(Coupon), id);

coupon.EndDate = 2394849384000;
coupon.MaxRedemptions = 1000;


try
{
    coupon = (Coupon)api.Update(coupon);
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
}


var Simplify = require("simplify-commerce"),
    client = Simplify.getClient({
        publicKey: 'YOUR_PUBLIC_API_KEY',
        privateKey: 'YOUR_PRIVATE_API_KEY'
    });

client.coupon.update({
    id: "4TR6Bc", // ID of object to update
    maxRedemptions : "1000",
    endDate : "2394849384000"
}, function(errData, data){

    if(errData){
        console.error("Error Message: " + errData.data.error.message);
        // handle the error
        return;
    }

    console.log("Success Response: " + JSON.stringify(data));
});
INPUT PARAMETERS
id A brief section that describes the coupon. required
endDate The ending date in UTC millis for the coupon. This must be after the starting date of the coupon. optional
maxRedemptions Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
[min value: 1]
optional
OUTPUT
id Unique ID of the coupon
amountOff Amount off of the price of the product in the smallest unit of your currency in the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00
couponCode Code that identifies the coupon to be used.
dateCreated Date in UTC millis the coupon was created in the system
description A brief section that describes the coupon.
durationInMonths DEPRECATED - Duration in months that the coupon will be applied after it has first been selected.
endDate Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
maxRedemptions Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
numTimesApplied The number of times a coupon will be applied on a customer's subscription.
percentOff Percentage off of the price of the product. The percent off is a whole number.
startDate First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone.
timesRedeemed Number of times the coupon has been redeemed. A redemption is defined as when the coupon is applied to the subscription for the first time.
total Total amount of the coupon in the smallest unit of your currency. Example: 100 = $1.00