Interacting with Invoice

When working with the store, you had a chance to get the invoice. Here you'll learn what you can do with it.

Edit an invoice

To edit your invoice, just call the edit() on the invoice object like so:

await invoice.edit(
  true, // has customer or not
  "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N", // customer address or ZERO_ADDRESS
  "in_abcderf654321", // invoice id
  "some metadata", // invoice metadata
  6.9, // invoice amount
  Currencies.TON // currency of the invoice from the supported currencies set
);

After confirming the transaction, the invoice will be updated in a couple of seconds. Note that this operation requires you to provide functional sender to the SDK.

Invoice can't be edited once it's paid, or if it's inactive.

Manage active status

To activate or deactivate your invoice, call the respective methods like so:

After confirming the transaction, the invoice will be activated/deactivated.

When the invoice is deactivated, it won't accept any payments and it can't be edited.

Paying the invoice

After the invoice is issued, the customer needs to pay for it. This can be handled in 2 ways:

  • providing customer with the payment link (not the same one as for the store!)

  • send a payment to the invoice programmatically

As you may have noticed, we already had a payment link in the previous chapter. The difference is that this one will work only for the invoice that's already issued using the store.issueInvoice() or the merchant portal, and the previous one works without creating the invoice beforehand.

The easiest way is to provide a payment link like so:

After retrieving the link, you can present it to your customer in any way you want (button, QR code, etc.)

If you use TON Connect 2.0 in your app (to have your store inside user's wallet for example 😏) and provided a sender to the SDK, you can directly call the corresponding method which will prompt the payment in the user's wallet, like so:

If the invoice's currency is other than TON, then you must specify the customer wallet address:

And that's it! When the user confirms the transaction, consider your invoice paid (assuming all data is correct).

Get invoice info

If you want to fetch the data about your invoice, you can use a set of methods for that:

It's recommended to just use the getData() to save up on requests.

Last updated

Was this helpful?