Create Coupon

Example Request

<?php
//Set up API path and method
$base_url = "https://app.paykickstart.com/api/";
$route = "coupons";
$url = $base_url . $route;
$post = true;

//Create request data string
$data = http_build_query([
    'auth_token' => '3A0CKDSETE',
    'coupon_name' => 'My Coupon Name',
    'coupon_code' => 'discountcode',
    'coupon_rate' => '25',
    'coupon_type' => 'amount',
    'coupon_is_recurring' => 0,
    'coupon_start_date' => '06/20/2017 11:00 PM',
    'coupon_end_date' => '06/30/2017 11:00 AM',
    'coupon_max_redemption' => null,
    'plan_ids' => [
        2382, 2391
    ],
    'product_id' => 223
]);

//Execute cURL request
$ch = curl_init();
if ($post) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
} else {
    $url = $url . "?" . $data;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);

//Output Response
echo json_decode($output);

Example Response

{
    "success": true,
    "coupon_id": 27,
    "message": "Coupon was created successfully"
}

Creates a new coupon.

ARGUMENTS

auth_token

The Paykickstart vendor’s API Key. This field is required.


coupon_name

The display name for your coupon.

coupon_code

The Unique coupon code for your coupon.


coupon_rate

The value of your coupon.


coupon_type

The type of value – accepted arguments are: “amount” and “percentage”


coupon_is_recurring

Determines if the coupon should be applied to first charge, recurring or all (excludes split pay). Accepted arguments are:

  • 0: first charge
  • 1: rebills
  • 2: all

coupon_start_date

The start date of when the coupon is active


coupon_end_date

The end date of when the coupon is active


coupon_max_redemption

The maximum number of times a coupon may be redeemed


plan_ids

An array of plan ids which the coupon should be applied to


coupon_product_id

The campaign id which the coupon should be applied to