post
https://secure.fusebill.com/v1/Invoices/Reverse
This request reverses an invoice. You can choose the invoice along with if you want the Full invoice reversed, unearned charges, or the amount or net amount.
URL Parameters
| Parameter | Type | Description |
|---|---|---|
invoiceId | Integer | The ID of the invoice you want to retrieve. |
reverseChargeOptions | Enum: {Full, Unearned} | "Full" will fully reverse all charges for the invoice, regardless of how much has been earned. "Unearned" will reverse the unearned deferred revenue of the current period's charges. This is typically a partial reversal based on daily or monthly earning rules set on the plan product at the time the subscription was created. |
reference | String | Optional description or reference data point |
Request Parameters
Invoice collection options
Examples
curl –X POST https://secure.fusebill.com/v1/Invoices/Reverse/
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d '{
"invoiceId": 1,
"reverseChargeOption": "Full",
"reference": "Reversing all charges in Full"
}'//Json data for payload
string jsonData = "{}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/draftInvoices/PostReadyCharges?customerId={customerId}");
//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 = {}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/draftInvoices/PostReadyCharges?customerId={customerId}', data=json.dumps(payload), headers=headers)
print(r.content){
"invoiceId": 82991155,
"reverseChargeOption": "Full",
"reference": "Voided invoice from Finance"
}Response
{
"invoiceNumber": 283,
"invoiceSignature": "<p><img src=\"https://fbhostedpagesdev.blob.core.windows.net/local/logo-636308250883322560.png\" alt=\"{user}\"> <strong>mattLtest</strong> \n</p>\n<p><em>{user} | | [][1]</em></p>\n<p>[1]: </p>\n",
"poNumber": null,
"effectiveTimestamp": "2017-06-09T13:16:43",
"postedTimestamp": "2017-06-09T13:16:43",
"charges": [
{
"quantity": 1,
"unitPrice": 22,
"amount": 22,
"name": "Tiered product 2",
"description": null,
"glCode": "",
"effectiveTimestamp": "2017-06-09T13:16:43",
"proratedUnitPrice": null,
"startServiceDate": "2017-06-09T13:16:43",
"endServiceDate": "2017-06-25T04:00:00",
"rangeQuantity": null,
"isReversable": true,
"discount": null,
"discounts": [],
"subscriptionProduct": {
"id": 123456,
"uri": "https://secure.fusebill.com/v1/subscriptionProducts/{ID}"
},
"purchase": null,
"chargeTiers": [
{
"label": "0-2",
"quantity": 1,
"unitPrice": 22,
"amount": 22
}
],
"id": 123456,
"uri": null
}
],
"subtotal": 22,
"invoiceAmount": 22,
"totalPayments": 0,
"outstandingBalance": 22,
"terms": "Net10",
"customerId": 123456,
"invoiceCustomer": {
"firstName": "John",
"middleName": null,
"lastName": "Smith",
"companyName": null,
"suffix": null,
"primaryEmail": null,
"primaryPhone": null,
"secondaryEmail": null,
"secondaryPhone": null,
"title": "",
"reference": null,
"status": null,
"customerAccountStatus": null,
"currency": "USD",
"customerReference": null,
"customerAcquisition": null,
"monthlyRecurringRevenue": 0,
"netMonthlyRecurringRevenue": 0,
"salesforceId": null,
"salesforceAccountType": null,
"salesforceSynchStatus": null,
"netsuiteId": null,
"netsuiteCustomerType": null,
"portalUserName": null,
"parentId": null,
"quickBooksLatchType": null,
"quickBooksId": null,
"quickBooksSyncToken": null,
"id": 0,
"uri": null
},
"invoiceCustomerAddressPreference": {
"contactName": null,
"shippingInstructions": null,
"useBillingAddressAsShippingAddress": false,
"billingAddress": null,
"shippingAddress": null,
"id": 0,
"uri": null
},
"sumOfCreditNotes": 0,
"totalWriteoffs": 0,
"taxes": [],
"totalDiscount": 0,
"paymentSchedules": [
{
"dueDateTimestamp": "2017-06-19T13:16:43",
"status": "Due",
"amount": 22,
"outstandingBalance": 22,
"daysDueAfterTerm": 0
}
],
"notes": "api test",
"customerReferenceValue": "",
"openingArBalance": 0,
"closingArBalance": 22,
"invoiceInMemoryOnly": false,
"invoiceRevisions":[],
"id": 162281,
"uri": "https://secure.fusebill.com/v1/Invoices/{ID}"
}{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "Must supply a reversal amount when NetAmount reversal type is chosen."
}
]
}