post https://secure.fusebill.com/v1/BillingPeriodDefinitions/Preview
This call previews a billing period definition
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
customerId | Integer | Id from the target customer | Yes |
interval | Enum {Yearly, Monthly} | Defines the base interval to build from. | Yes |
numberOfIntervals | Integer | How many of the base interval within a period. | Yes |
invoiceDay | Integer | Which day of the month to bill on. | Yes |
InvoiceMonth | Integer | Which month of the year to invoice on. | Yes, if interval is "Yearly" |
autoPost | Boolean | A billing period definition can override whether its generated invoices should be posted, or remain in ready draft. Since this is an override, NULL means to use the customer's default setting. | Optional |
autoCollect | Boolean | A billing period definition can override whether its resulting invoices are eligible for automatic collection attempts. Since this is an override, NULL means to use the customer's default setting. | Optional |
term | Enum:{Net0, Net5, Net7, Net10, Net15, Net21, Net30, Net45, Net60, Net75, Net90, MFI1, DayOfMonth1, DayOfMonth2, DayOfMonth3, ... DayOfMonth29, DayOfMonth30, DayOfMonth31} | A billing period definition can override what the billing term will be on its resulting invoices. Since this is an override, NULL or the empty string means to use the customer's default setting. | Optional |
poNumber | String [Max Length: 255 characters] | A billing period definition can override what the PO number will be on its resulting invoices. Since this is an override, NULL or the empty string means to use the customer's default setting. | Optional |
paymentMethodId | Number | A billing period definition can have a specific payment method associated with it. If so, then this is the Fusebill generated ID of the payment method. This is an override, so NULL means to use the customer default method. This is relevant only for automatic collection. | Optional |
Examples
curl –X POST https://secure.fusebill.com/v1/BillingPeriodDefinitions/Preview\
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{customerId: 12345, interval: "Monthly", numberOfIntervals: 3, invoiceDay: 4}"
//Json data
string jsonData = "{'customerId': 12345, 'interval': 'Monthly', 'numberOfIntervals': 3, 'invoiceDay': 4}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/BillingPeriodDefinitions/Preview");
//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 = {'customerId': 12345, 'interval': 'Monthly', 'numberOfIntervals': 3, 'invoiceDay': 4}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/BillingPeriodDefinitions/Preview, data=json.dumps(payload), headers=headers)
print(r.content)
{
"customerId":12,
"interval":"Yearly",
"numberOfIntervals":2,
"invoiceDay":2,
"invoiceMonth":12
}
Response
{
"currentBillingPeriodStartDate": "2014-09-13T20:58:03.0006122Z",
"currentBillingPeriodEndDate": "2014-12-04T05:00:00Z",
"nextRechargeDate": "2019-11-29T05:00:00Z",
"invoiceDay": 4,
"invoiceMonth": null,
"cycle": "Monthly",
"billingPeriodType": "SpecifiedDate",
"createdDate": "2014-09-13T20:58:03.0006122Z",
"numberOfIntervals": 3,
"numberOfBillingPeriods": 0,
"invoiceInAdvance": 5,
"manuallyCreated": false,
"paymentMethodId": 214098,
"autoCollect": true,
"autoPost": true,
"term": "Net10",
"poNumber":null,
"subscriptions": null,
"id": 0,
"uri": "https://secure.fusebill.com/v1/BillingPeriodDefinitions/0"
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "entity",
"Value": "Required property 'customerId' not found in JSON. Path '', line 7, position 1."
},
{
"Key": "entity.CustomerId",
"Value": "The field CustomerId must be between 1 and 1.84467440737096E+19."
}
]
}