post https://secure.fusebill.com/v1/Coupons/Validate
This function is used to validate that a coupon can be applied to a specific plan. This lets you ensure the coupon is allowed to be used on a customer's subscription.
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
planId | Integer | This is the Fusebill generated ID value which uniquely identifies the Plan record in the Fusebill system. This is the ID of the Plan you want to apply the Coupon to. | Yes |
couponCode | String | This is the Coupon Code which uniquely identifies the Coupon you want to apply to the Subscription. | Yes |
Examples
curl -X POST "https://secure.fusebill.com/v1/Coupons/Validate" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{planId:{planId},couponCode:'{couponCode}'}"
//Json Payload
string jsonData = "{planId:{planId},couponCode:'{couponCode}'}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/Coupons/Validate");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "POST";
//Add the json data to request
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(jsonData);
streamWriter.Flush();
streamWriter.Close();
}
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}
#Import library JSON
import json
#Import library Requests
import requests
#Pass in a dictionary to the Headers parameter
headers = {'Authorization' : 'Basic {APIKey}', 'Content-Type' : 'application/json'}
#Pass in a dictionary to the Payload parameter
payload = {"planId":{id},"couponCode":'ApplyThis'}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/Coupons/validate', data=json.dumps(payload), headers=headers)
print(r.content)
{
"couponCode": "YD09",
"planId": 212345
}
Response
{
"valid":true,
"reason":"Coupon is valid"
}
{
"valid": false,
"reason": "Coupon not applicable to plan"
}