Add Purchase Discount

This call is used to create and add a purchase discount to an existing draft purchase

Request Parameters

PropertyTypeDescriptionRequired
purchaseIdIntegerID of the draft purchaseYes
discountTypeEnum: {Percentage, Amount, AmountPerUnit}Indicates how amount is interpreted for calculating the discountYes
amountDecimalThe percentage for the discount if discountType is "Percentage", the fixed amount if the it is "Amount", or the fixed amount per unit of quantity if it is "AmountPerUnit"Yes

Sample Requests

POST https://secure.fusebill.com/v1/purchaseDiscounts 
Authorization: Basic {{apikey}} 
Content-Type: application/json 
{ 
"purchaseId" : 164359, 
"discountType" : "Amount", 
"amount" : 150.0 
}
POST https://secure.fusebill.com/v1/purchaseDiscounts 
Authorization: Basic {{apikey}} 
Content-Type: application/json 
{ 
"purchaseId" : 164359, 
"discountType" : "Percentage", 
"amount" : 30.0 
}
POST https://secure.fusebill.com/v1/purchaseDiscounts 
Authorization: Basic {{apikey}} 
Content-Type: application/json 
{ 
"purchaseId" : 164359, 
"discountType" : "AmountPerUnit", 
"amount" : 15.0 
}
Examples
curl –X POST https://secure.fusebill.com/v1/purchasediscounts\ 
-H "Content-Type: application/json" \ 
-H "Authorization: Basic {APIKey}" \ 
-d "{purchaseId:164359,discountType:'Percentage':amount:10.0}"
//Json data for payload 
string jsonData = "{'purchaseId':164359,'discountType':'Percentage':'amount':10.0}"; 
//Setup API key 
string apiKey = "{APIKey}"; 
//Configure URI 
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/purchasediscounts"); 
//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 dict to the Payload parameter 
payload = {'purchaseId':164359,'discountType':'Percentage':'amount':10.0} 
#Pass in your URI, Payload and Headers 
r = requests.post('https://secure.fusebill.com/v1/purchasediscounts, data=json.dumps(payload), headers=headers) 
print(r.content)
{
  "purchaseId": 165549,
  "discountType": "Percentage",
  "amount": 10.0
}
Response
{
  "purchaseId": 164359,
  "discountType": "Percentage",
  "amount": 10,
  "id": 598462,
  "uri": "https://secure.fusebill.com/v1/purchasediscounts/598462"
}
{
    "ErrorId": 0,
    "HttpStatusCode": 400,
    "Errors": [
        {
            "Key": "purchase.Amount",
            "Value": "Amount must be a positive number and cannot exceed six decimal places"
        }
    ]
}
Language
Authorization