post https://secure.fusebill.com/v1/purchases/cancel
This method allows a purchase to be cancelled after it has moved from draft to purchased. If the purchase is in draft status, then remove it with the Delete Draft Purchase request
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
cancellationOption | Enum:{None, Unearned, Full} | "None" means reverse none of the charges generated by the purchase. "Unearned" means reverse the charges only for the unearned amounts. "Full" means reverse all the generated charges regardless of earning. | Yes |
purchaseId | Integer | The ID of the purchase | Yes |
Examples
curl –X POST https://secure.fusebill.com/v1/purchases/cancel\
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{purchaseId:164359,cancellationOption:'None'}"
//Json data for payload
string jsonData = "{'purchaseId':164359,'cancellationOption':'None'}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/purchases/cancel");
//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,'cancellationOption':'None'}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/purchases/cancel, data=json.dumps(payload), headers=headers)
print(r.content)
{
"purchaseId": 123456789,
"cancellationOption": "Unearned"
}
Response
This call returns a 204 no content response upon success
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "purchaseCancel.CancellationOption",
"Value": "Allowable Cancel Options are: None, Unearned, Full"
}
]
}