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
Name | Type | Description |
---|---|---|
|
| The address of the billable party |
|
| The address of the denomination asset used for the invoice |
|
| The amount of the denomination asset to be paid |
|
| The due date of the invoice. Must be in the future |
|
| 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") |
|
| The description of the invoice |
|
| The name of the document associated with the invoice |
|
| The URI of the document associated with the invoice |
Returns
Name | Type | Description |
---|---|---|
|
| 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
Name | Type | Description |
---|---|---|
|
| The ID of the invoice to be paid |
Returns
Name | Type | Description |
---|---|---|
|
| 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
Name | Type | Description |
---|---|---|
|
| 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
Name | Type | Description |
---|---|---|
|
| The ID of the invoice whose document is to be updated |
|
| The updated name of the document |
|
| The updated URI of the document |
Returns
Name | Type | Description |
---|---|---|
|
| 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