post https://secure.fusebill.com/v1/Debits
This function is used to create a debit. It can be allocated across multiple invoices if the original credit was allocated across multiple invoices.
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
reference | String | The text reference that is added to the debit [Max 500 characters] | Optional |
originalCreditId | Integer | The transaction ID for the credit being reversed or partially reversed by this debit | Yes |
amount | Decimal | The amount (in units of the customer's currency) being reversed. | Yes |
effectiveTimestamp | DateTime | The timestamp that represents the time this transaction is to occur. | Optional |
debitAllocations | List of objects. Defined below | This is an optional list of debit allocations which tells Fusebill how to split the value of this credit reversal over many invoices. | Required only if the amount exceeds the allocated credit amount |
Debit Allocations Resource Properties
Property | Type | Description |
---|---|---|
invoiceID | Integer | This is the Fusebill generated Invoice Id for the invoice payment allocation this applies against |
amount | Decimal | The amount (in units of the customer's currency) of the total being applied on this invoice. |
Examples
curl –X POST https://secure.fusebill.com/v1/Debits \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{reference:"a custom string",originalCreditId:15884967,amount:10.00,effectiveTimestamp:"2019-04-16T10:59:44"}"
//Json data, with the transaction ID to match the original credit
string jsonData = "{'reference':"a custom string",'originalCreditId':15884967,'amount':10.00,'effectiveTimestamp':"2019-04-16T10:59:44"}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/Debits");
//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 = {'reference':"a custom string",'originalCreditId':15884967,'amount':10.00,'effectiveTimestamp':"2019-04-16T10:59:44"}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/Debits, data=json.dumps(payload), headers=headers)
print(r.content)
{
"reference": "ref",
"originalCreditId": 66889205,
"amount": 3.0,
"effectiveTimestamp": "2019-12-01",
"debitAllocations": [
{
"invoiceId": 565624,
"amount": 3.0
}
]
}
Response
{
"reference": "a custom string",
"effectiveTimestamp": "2019-04-16T10:59:44",
"description": "Reversal of credit 15884967",
"customerId": 4865197,
"originalCreditId": 15884967,
"amount": 67.95,
"currency": "CAD",
"invoiceAllocations": [],
"id": 63282695,
"uri": "https://secure.fusebill.com/v1/Debits/63282695"
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "The debit for $10.00 USD exceeds the unallocated credit amount of $0.00 USD. Please assign the remaining $10.00 USD to an invoice(s)"
}
]
}