Get Invoice

Resolving an invoice to make a payment

Once an invoice is created, it is essential to provide a means for another party to receive the invoice and proceed with the payment. The response from the "/invoice" endpoint, typically in JSON format, can be utilized to extract the relevant information required for this process. There are 2 ways to resolve an invoice:

  • Using an internal invoice ID query for any invoices that may be stored locally.

  • Using the URL extension in the /URI endpoint that can be resolved externally.

Get Invoice by paymentRequest invoice endpoint

In this method simply pass in the invoice Id value returned from the create invoice step which will return an invoice JSON related to that service ID.

var parameters = {
    invoiceId : "8f9f4c27-3782-46e2-b76f-1ef956f52c61"
}
const response = await relysia.transaction.v1.paymentRequest(parameters)

Get invoice JSON

GET https://api.relysia.com/v1/paymentRequest/:invoiceId

Return Invoice JSON from an internal service using the invoice Id value.

Headers

Name
Type
Description

invoiceId*

String

Invoice Id provided from creating invoice

Get Invoice by URI endpoint

In this method, invoices can be obtained by utilizing a URI endpoint with a specific URL extension. This approach serves as a way to externally receive invoices from the system. Here is an example of the URL extended format that is used in the URI endpoint to resolve the invoice and can be found in the "uri" field when creating the invoice.

var parameters = {
    uri: "pay:?r=https://api.relysia.com/v1/paymentRequest/8f9f4c27-3782-46e2-b76f-1ef956f52c61"
}
const response = await relysia.utility.v1.uri(parameters)

Resolve address, paymail aliias and invoice information

GET https://api.relysia.com/v1/URI

The URI endpoint helps developers to resolve addresses, paymails and invoices and puts them into a standardized response format.

Headers

Name
Type
Description

URI*

Invoice URI provided in the /invoice response in the "uri" field

Response types

Depending whether your invoice is DPP or BIP270 will determine the type of response returned. Here are both examples.

{
  "statusCode": 200,
  "status": "success",
  "msg": "Operation Completed Successfully",
  "network": "mainnet",
  "uri": "pay:?r=https://api.relysia.com/v1/paymentRequest/8f9f4c27-3782-46e2-b76f-1ef956f52c61",
  "memo": "paying for testing",
  "type": "bip272",
  "paymentUrl": "https://api.relysia.com/v1/paymentRequest/pay/8f9f4c27-3782-46e2-b76f-1ef956f52c61",
  "mainProtocol": "bip272",
  "creationTimestamp": 1686814941,
  "modes": {
    "ef63d9775da5": {
      "PaymentOption_0": {
        "transactions": [
          {
            "outputs": {
              "stas": [
                {
                  "tokenId": "00b91626e0a4b97f624bc1f0d8fa3a3ef35ac664-TIGLdA",
                  "tokenAmount": 1,
                  "tokenRecipient": "1HQKnJ5FfCjcgvr6AAqNPYhY7NKuZXByMF"
                }
              ]
            },
            "policies": {
              "fees": {
                "standard": {
                  "bytes": 1000,
                  "satoshis": 50
                },
                "data": {
                  "bytes": 1000,
                  "satoshis": 50
                }
              }
            }
          }
        ]
      }
    }
  },
  "beneficiary": {
    "name": "vaionex test",
    "email": "test@vaionex.com",
    "paymentReference": "8f9f4c27-3782-46e2-b76f-1ef956f52c61",
    "address": "19702 Newark, Delaware, USA"
  },
  "expirationTimestamp": 1686816741,
  "version": "2.0.0"
}

These responses can be directly used to make a payment. In the next section we will see how to use these response values.

Last updated