Bill metered usage
When registering metered usage with a contract you have to provide a dueDate
.
Metered usage is billed in regular recurring billings. All unbilled entries with dueDate
<= NextBillingDate
will be billed in this process.
Metered usage will be billed even from previous billing periods, so you can simply post it with the correct DueDate
, even if far in the past.
If DueDate
< LastBillingDate
, then the free quota defined in the PlanVariant
will we not be considered.
Sample request
POST /Orders
{
"ContractId": "5e563b344de08409ace88ecb",
"Cart": {
"MeteredUsages": [
{
"ComponentId": "5cb5c38e4de0842368ea6e32",
"Quantity": 5
}
],
"ComponentSubscriptions": [],
"DiscountSubscriptions": [],
"RatedItems": [],
"Quantity": 1
},
"ChangeDate": null,
"TriggerInterimBilling": true,
}
By setting TriggerInterimBilling
to "true" all unbilled metered usage entries with DueDate
<= current date/time in the contract will be billed instantly.
POST Contracts/{contractId}/usage
{"DueDate":"2020-02-26T09:32:36.123Z","ComponentId":"5cb5c38e4de0842368ea6e32","Quantity":5}
Alternatively metered usage can be posted to a contract without an order. When adding metered usage like this, an interim billing has to be triggered separately, if applicable.
Sample response
{
"Id": "5e56923d9cc9ba14fc9c1e41",
"ContractId": "5e563b344de08409ace88ecb",
"TransferredAt": "2020-02-26T15:43:57.0000000Z",
"ComponentId": "5cb5c38e4de0842368ea6e32",
"Quantity": 5,
"Key": "",
"DueDate": "2020-02-26T09:32:36.1230000Z"
}