Invoices

How I know a discount is going to be applied on the next invoice?

Discounts are applied to subscription products and can be reviewed by retrieving them as part of a subscription or directly with the Fusebill-generated subscription product ID. This is the direct request:

GET https://secure.fusebill.com/v1/SubscriptionProducts/{subscriptionProductId}

In the response body there is a field called subscriptionProductDiscounts which lists discount objects. This is where you can find the fields remainingUsage and remainingUsageUntilStart.

remainingUsageUntilStart gives the number of periods until the discount is applied. 0 means the discount will applied on the next invoice.

remainingUsage gives the number of periods until the discount expires. Assuming remainingUsageUntilStart is 0, then If remainingUsage is also 0 this means the discount will not be used on the upcoming invoice. If remainingUsageUntilStart is 0 and remainingUsage is 1 or more the discount will be applied to the upcoming invoice. For remainingUsage, a value of null means the discount has an indefinite number of usages.

Combining this, if remainingUsageUntilStart is 0 and remainingUsage is anything other than 0, the discount will be applied to the upcoming invoice.

How do I check coupon usage?

Assuming you have the name of the coupon you want to check, this should return the coupon:

GET https://secure.fusebill.com/v1/Coupons?query=name:{couponName}

This request returns a list of coupons with that name. The list should only have one element unless you have given multiple coupons the exact same name. Contained in the coupon is a list of coupon codes each with a timesUsed field showing usage so far.

What is the status on a given invoice?

Invoices can either be in draft form or be posted. If the invoice is a draft then this request will return you the draft invoice object based on the Fusebill generated draft invoice ID:

GET https://secure.fusebill.com/v1/draftinvoices/{DraftInvoiceId}

Included in the response object is a status field which can be "Ready", "Pending", or "Projected" and a list of draft charges.

If the invoice is posted then the Fusebill generated invoice ID can be used in this request to get the invoice object:

GET https://secure.fusebill.com/v1/Invoices/{InvoiceId}

Included is a field called paymentSchedules which is a list of amounts, due dates, and the statuses to indicate which are due and which are paid.

What invoices are currently outstanding (overdue)?

Invoice statuses can be filtered on in the invoice summaries endpoint:

GET https://secure.fusebill.com/v1/invoiceSummaries?query=invoiceStatus:overdue&pageSize=40&pageNumber=0

If charge by charge details are needed, the value of the id from the invoice summary can be used for a call to GET https://secure.fusebill.com/v1/invoices/{id}

How can I display an invoice the way it looks in the UI?

This can be done by retrieving the invoice as HTML over API. Use the invoice ID for this call:

GET https://secure.fusebill.com/v1/Invoices/html/{Invoice ID}?showTrackedItems={Boolean value}

Instead of JSON being returned like with most of Fusebill's API methods, this will return an HTML file. Opening that HTML file in a browser will display the invoice the way it would look in the Fusebill UI.

How do I get the same data as presented on an invoice?

All of the data visible via the UI of a posted invoice is part of the response to this request:

GET https://secure.fusebill.com/v1/Invoices/{InvoiceId}

What invoices were posted last month?

For this the query parameter postedTimestamp can be used with a date range. If last month was May 2019 then this request would return the list of invoices.

GET https://secure.fusebill.com/v1/Invoices?query=postedTimestamp:2019-05-01|2019-06-01&pageSize=20&pageNumber=0