post
https://secure.fusebill.com/v1/ReverseCharges?preview=
This function allows you to create a reversal on a specific customer for a specific amount applied to a specific charge.
Request Parameters
| Property | Type | Description | Required |
|---|---|---|---|
chargeId | Integer | This is the Fusebill charge ID of the charge the reversal will apply against. | Yes |
reverseChargeAmount | Decimal | This is the amount of the reversal. | Yes if reverseChargeOption is "Amount" or "NetAmount" |
reverseChargeOption | Enum: {Full, Unearned, Amount, NetAmount} | This option tells Fusebill how to perform this reversal. The system can reverse all of the charge, the unearned (prorated) value of the charge, a specific amount of the charge, or a specific net amount of the charge. These options correspond to "Full", "Unearned", "Amount", and "NetAmount" respectively.* | Yes |
reference | String | This is a custom string. The intended use is to indicate the reason for the reversal. | Optional |
- When reversing with the net amount option, the discounts and taxes on the charge may make it impossible to reverse the value as requested. In these cases Fusebill will get as close as possible. Use the
previewURL parameter to see what will occur. The value ofreverseChargePreview.reversalAmountWarningFlagindicates if the exact amount is impossible.
Examples
curl -X POST "https://secure.fusebill.com/v1/ReverseCharges/" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{chargeId:{chargeId},reverseChargeAmount:5.5,reverseChargeOption:'Amount'}"//Json Payload
string jsonData = "{chargeId:{chargeId},reverseChargeAmount:5.5,reverseChargeOption:'Amount'}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/ReverseCharges/");
//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 = {"chargeId":{id},"reverseChargeAmount":278,"reverseChargeOption":'Amount'}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/reverseCharges', data=json.dumps(payload), headers=headers)
print(r.content)// Sample Payload Full Reversal
{
"chargeId":66799853,
"reverseChargeOption":"Full",
"reference":"Accidental product inclusion"
}// Sample Payload Partial Reversal
{
"chargeId":667992375,
"reverseChargeOption":"Amount",
"reverseChargeAmount":50.0,
"reference":"Item arrived with dent"
}Response
{
"reference": "Accidental product inclusion",
"amount": 283.330000,
"originalChargeId": 66799853,
"id": 66799859,
"uri": "https://secure.fusebill.com/v1/ReverseCharges/66799859"
}// Sample Response -Preview
{
"reference": "Explanation in Customer Support Ticket #472",
"amount": 2.00,
"originalChargeId": 0,
"reverseChargePreview": {
"chargeAmount": 200.000000,
"discountAmount": null,
"taxAmount": 10.000000,
"netChargeAmount": 210.000000,
"netInvoiceAmount": 262.5000,
"outstandingBalance": 210.0000,
"reversalAmountWarningFlag": false
},
"id": 0,
"uri": "https://stg-secure.fusebill.com/v1/ReverseCharges/0"
}// Sample Error
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "reverseCharge.Reference",
"Value": "The field Reference must be a string with a maximum length of 500."
}
]
} 200