post https://secure.fusebill.com/v1/Invoices?draftInvoiceId=
This call is used to take a ready draft invoice and post it so that the customer can be charged. The only requirement is that you provide the draftInvoiceId in the request. Optionally, a specified subset of the draft ready charges on the draft invoice can be posted.
URL Parameters
Property | Type | Description | Required |
---|---|---|---|
draftInvoiceId | Integer | This is the unique ID of the draft invoice you would like to activate. | Yes |
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
draftChargeIds | List of Integers | The specific subset of draft charges that you wish to post from the draft invoice. | Optional |
preview | Boolean | Whether or not to preview the effects of posting the invoice. | Optional |
Examples
curl -X POST "https://secure.fusebill.com/v1/Invoices?draftInvoiceId={draftInvoiceId}" \
-H "Content-Type: application/json" \
-H "Content-Length: 0" \
-H "Authorization: Basic {APIKey}"
//Json Payload
long draftInvoiceId = {draftInvoiceId};
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/Invoices?draftInvoiceId=" + draftInvoiceId);
//Set Content Length
request.ContentLength = 0;
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
//Set request method
request.Method = "POST";
//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 Requests
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
#Pass in your URI, and Headers
r = requests.post('https://secure.fusebill.com/v1/Invoices?draftInvoiceId={id}', headers=headers)
print(r.content)
{
"draftChargeIds": [
900001,
900002,
900003
],
"preview": true
}
Response
{
"invoiceNumber":74,
"invoiceSignature":"<p><strong>Kennedy Consulting</strong> \r</p>\n<p>, \r</p>\n<p><em>Kennedy Consulting | | [][1]</em></p>\n<p>[1]: </p>\n",
"poNumber":null,
"effectiveTimestamp":"2017-01-24T20:07:22.0007721Z",
"postedTimestamp":"2017-01-24T20:07:22.0007721Z",
"charges":[
{
"quantity":1.000000,
"unitPrice":15.9900,
"amount":15.9900,
"name":"Monthly Charge",
"description":null,
"glCode":"",
"effectiveTimestamp":"2017-01-24T20:07:22.0007721Z",
"proratedUnitPrice":null,
"startServiceDate":"2017-01-24T20:06:48",
"endServiceDate":"2017-02-11T05:00:00",
"rangeQuantity":null,
"isReversable":true,
"discount":null,
"discounts":[
],
"subscriptionProduct":{
"id":653431,
"uri":"https://secure.fusebill.com/v1/subscriptionProducts/653431"
},
"purchase":null,
"id":7573304,
"uri":null
}
],
"subtotal":15.9900,
"invoiceAmount":15.9900,
"totalPayments":0.0,
"outstandingBalance":15.9900,
"terms":"Net5",
"customerId":172677,
"invoiceCustomer":{
"firstName":"John",
"middleName":null,
"lastName":"Doe",
"companyName":"Stolen Bikes",
"suffix":null,
"primaryEmail":"[email protected]",
"primaryPhone":"613-555-5555",
"secondaryEmail":null,
"secondaryPhone":null,
"title":"Mr",
"reference":"1337",
"status":null,
"customerAccountStatus":null,
"currency":"USD",
"customerReference":null,
"customerAcquisition":null,
"monthlyRecurringRevenue":0.0,
"netMonthlyRecurringRevenue":0.0,
"salesforceId":null,
"salesforceAccountType":null,
"salesforceSynchStatus":null,
"netsuiteId":null,
"netsuiteCustomerType":null,
"portalUserName":null,
"parentId":null,
"quickBooksLatchType":null,
"quickBooksId":null,
"quickBooksSyncToken":null,
"id":-2,
"uri":null
},
"invoiceCustomerAddressPreference":{
"contactName":"Mr John Doe",
"shippingInstructions":null,
"useBillingAddressAsShippingAddress":true,
"billingAddress":null,
"shippingAddress":null,
"id":0,
"uri":null
},
"sumOfCreditNotes":0.0,
"totalWriteoffs":0.0,
"taxes":[
],
"totalDiscount":0.0,
"paymentSchedules":[
{
"dueDateTimestamp":"2017-01-29T20:07:22.0007721Z",
"status":"Due",
"amount":15.9900,
"outstandingBalance":15.9900,
"daysDueAfterTerm":0
}
],
"notes":null,
"customerReferenceValue":"1337",
"openingArBalance":-10.0000,
"closingArBalance":5.9900,
"invoiceInMemoryOnly":false,
"id":110742,
"uri":"https://secure.fusebill.com/v1/Invoices/110742"
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "Cannot post a draft invoice from status Pending"
}
]
}