Invoices

To get paid in cryptocurrency, you first need to create an invoice, which includes details on the buyer, the product or service purchased, the price, taxes, and how you would like to get paid.
After creating the invoice off-chain, it needs to be converted into an on-chain request using another endpoint introduced further below.
The Request Network protocol is all about creating payment requests. They are stored on-chain. Invoices are what you will be manipulating with the Request Finance API. Invoices are simply an implementation of requests with a predefined schema for their content. If you wish to learn more about this, please visit this page.

Creating an Off-Chain Invoice

post
https://api.request.finance
/invoices
Creates an off-chain invoice for the account
Example Request
Let’s assume you sold 2 TVs, each worth $99.99, to your customer, Acme Wholesaler Ltd. on the 22nd of December 2022. The tax is 20%, so that’s $119.99 including tax. The total invoice amount will thus be $239.98 (=2x $119.99) and it’s payable by the 21st of January 2023.
Your contact at Acme Wholesaler Ltd. is Justin Walton, so you want to send the invoice to his email address, [email protected].
Finally, you want to be paid in USDC on Polygon.
To create an invoice for this, you would pass the following body with the request:
{
"creationDate": "2022-12-22T14:38:16.916Z",
"invoiceItems": [
{
"currency": "USD",
"name": "Television",
"quantity": 2,
"tax": {
"type": "percentage",
"amount": "20"
},
"unitPrice": "9999"
}
],
"invoiceNumber": "13",
"buyerInfo": {
"businessName": "Acme Wholesaler Ltd.",
"address": {
"streetAddress": "4933 Oakwood Avenue",
"extendedAddress": "",
"city": "New York",
"postalCode": "10038",
"region": "New York",
"country": "US"
},
"email": "[email protected]",
"firstName": "Justin",
"lastName": "Walton",
"taxRegistration": "985-80-3313"
},
"paymentTerms": {
"dueDate": "2023-01-21T23:59:59.999Z"
},
"paymentAddress": "0x4886E85E192cdBC81d42D89256a81dAb990CDD74",
"paymentCurrency": "USDC-matic",
"tags": [
"my_tag"
]
}
In the JSON response, you will get an id field. Please save it in a variable or your database. In the next section, you will need it to convert the invoice into an on-chain request.

Converting an Off-Chain Invoice into an On-Chain Request

To make an invoice payable, it must be converted to an on-chain request. Once the invoice is created, convert it into an on-chain request using the endpoint below. Replace [id] with the ID of the invoice you saved previously. You don’t need to pass anything in the request body.
post
https://api.request.finance
/invoices/[id]
Converts off-chain invoice into on-chain request
In the JSON response, you will get a requestId field. This is the ID of the newly created request. Please save it in your database, as you will need it to be informed of when the request has been paid. You may use this value in place of the invoiceId for future HTTP requests.

Sharing your Invoice and Getting Paid

To get paid by your customer, you need to redirect them to a payment page hosted by Request Finance. You can get the links to the payment page from the response after creating an on-chain request and embed them in your application or an email.
Using the invoiceLinks.signUpAndPay link, you can redirect your customers to a page that looks like the one below, where they can pay your invoice or sign into their Request Finance account, if they have one.
When your customers pay through this page using Request Finance, they can enjoy the convenience and security of our platform, which includes measures to prevent accidental double payments. Additionally, this payment method ensures that the invoice status is automatically updated, simplifying invoice tracking for both you and your customers.
Sign up & pay page

Fetching an Invoice

To check the status of an invoice and understand if it has been paid, please poll the endpoint below regularly. Replace [id] with the requestId of the Request (recommended), or the invoiceId.
get
https://api.request.finance
/invoices/[id]
Fetch an invoice by its ID
You can check the status field of the JSON response. The different statuses of an invoice are the following:
  • open – The request associated with the invoice has been created on-chain. The buyer has not yet paid the invoice.
  • accepted – The invoice has been approved by the buyer.
  • declaredPaid – The buyer declared the invoice as paid. The seller has to confirm before the invoice can move into the paid status. This is necessary for currencies, where the Request Network does not yet support payment detection.
  • paid – Final state. The buyer paid the invoice.
  • canceled – Final state. The seller canceled the invoice.
  • rejected – Final state. The buyer rejected the invoice.
  • scheduled – Status for recurring invoices. Indicates that an invoice will be created on a specific date in the future.
  • draft – The invoice is in draft status. It can still be edited and was not yet converted into an on-chain request. This status is currently only supported when creating an invoice in the Request Finance UI.
When creating an on-chain request with the previously described process, you should end up with a pending status while the request is being persisted on-chain (this process is asynchronous), followed by an open status once the request is actually created.
You can use the value paid to classify the Request as "fulfilled" and stop polling for a new status.
When the value matches rejected or canceled you can also stop polling: it means that the request has been manually canceled out by the payer or the payee respectively, and thus will not get paid.

Listing Invoices

Fetch a list of the user's invoices. Use the creationDateRange parameter to filter for invoices created in a date range. Other filters are listed below for your convenience. For example, the search=tx_hash filter is a valuable filter to use when presenting the user with a list of invoices associated with a transaction hash.
get
https://api.request.finance
/invoices
List invoices

Approving/Rejecting/Canceling an Invoice

Approving:
  • As a buyer, if you received an invoice from one of your supplier/contractors, you can approve it prior to paying. Approved invoices will show up in the "Approved" tab of the "Pay" menu in the Request Finance app and indicate that the invoice has been accepted by you and is ready for payment. Only open invoices can be approved.
  • As a seller, you cannot approve an invoice. Once a buyer approves your invoice, it will show up in the "Approved" tab of the "Get paid" menu.
Rejecting
  • As a buyer, if you received an incorrect invoice from one of your supplier/contractors, you can reject it. Rejected invoices will show up in the "Rejected" tab of the "Pay" menu in the Request Finance app and indicate that the invoice has been rejected by you and won't be paid. Only open and accepted invoices can be rejected.
  • As a seller, you cannot reject an invoice. Once a buyer rejects your invoice, it will show up in the "Rejected" tab of the "Get paid" menu.
Canceling:
  • As a seller, if you issued an invoice to your client but realised a mistake, you can cancel it. Canceled invoices will show in the "Voided" tab of the "Get paid" menu. Only open and accepted invoices can be canceled.
  • As a buyer, you cannot cancel an invoice. Once a seller cancels an invoice, it will show up in the "Voided" tab of the "Pay" menu.
post
https://api.request.finance
/invoices/[id]/changes
Approve, reject or cancel an invoice
Last modified 2mo ago