BillingRouter
Inherits: Initializable, ContextUpgradeable, HubOwnableUUPSUpgradeable, ERC165Upgradeable, IBillingRouter
Author: Daniel Yamagata & Jerry Qi
A contract for sending and paying invoices
This contract uses ContextUpgradeable to allow for future versions to use a gas relayer if desired
State Variables
BillingRouterStorageLocation
Functions
_getBillingRouterStorage
onlyVendor
Reverts if the caller is not the vendor of 'invoiceId' or if the invoice does not exist
constructor
sendInvoice
Sends an invoice to a billable party. Returns the invoice ID
Anyone can pay the invoice on behalf of the billable party
Parameters
billableParty
address
The address of the billable party
denominationAsset
address
The address of the denomination asset used for the invoice
amount
uint256
The amount of the denomination asset to be paid
dueDate
uint256
The due date of the invoice. Must be in the future
categoryId
bytes32
The category ID of the invoice. Should be the keccak256 hash of the category name. For example, the category ID of "Transportation Services" is keccak256("Transportation Services")
description
string
The description of the invoice
documentName
string
The name of the document associated with the invoice
documentUri
string
The URI of the document associated with the invoice
Returns
<none>
bytes32
The ID of the invoice
payInvoice
Pays the invoice with 'invoiceId'
The amount paid to the vendor may be different from the amount specified in the invoice. This is due to some ERC20s having fees built into the transfer function of ERC20s.
Parameters
invoiceId
bytes32
The ID of the invoice to be paid
Returns
<none>
uint256
The amount of the denomination asset paid to the vendor
cancelInvoice
Cancels the invoice with 'invoiceId'
Can only be called by the invoice's vendor
Parameters
invoiceId
bytes32
The ID of the invoice to be cancelled
updateInvoiceDocument
Updates the document related to the invoice with 'invoiceId' in the Document Registry
Can only be called by the invoice's vendor
Parameters
invoiceId
bytes32
The ID of the invoice whose document is to be updated
updatedDocumentName
string
The updated name of the document
updatedDocumentUri
string
The updated URI of the document
Returns
<none>
uint256
The new version of the document
hashInvoice
Returns the ID of an invoice given the invoice's parameters
The description hash can be queried via event emission
isInvoicePaid
Returns true if the invoice with 'invoiceId' has been paid, false otherwise
isInvoicePastDue
Returns true if the invoice with 'invoiceId' is past due, false otherwise
getInvoiceById
Returns the invoice with 'invoiceId' as a DataTypes.Invoice struct
_validateDenominationAsset
Reverts if 'denominationAsset' is invalid
_validateCallerIsVendor
_validateInvoiceExists
supportsInterface
ERC165 support