Skip to content

Invoice

Implements Telegram invoices functionality.

Initialization

To initialize the component, use the initInvoice function:

typescript
import { initInvoice } from '@telegram-apps/sdk';

const invoice = initInvoice();

Opening Invoice

To open an invoice, it is required to use the open method. This method allows opening invoices using their URLs or slugs.

Opening an invoice in URL mode requires passing the second argument equal to url, so the method will interpret the passed value as a URL.

To interpret the passed value as a slug, omit the second argument.

typescript
invoice
  .open('abIIks213')
  .then((status) => {
    // Output: 'paid'
    return console.log(status);
  });
typescript
invoice
  .open('https://t.me/invoice/abIIks213', 'url')
  .then((status) => {
    // Output: 'paid'
    return console.log(status);
  });

Events

List of events, which could be tracked:

EventListenerTriggered when
change() => voidSomething in component changed
change:isOpened(value: boolean) => voidisOpened property changed

Methods Support

List of methods, which could be used in support checks: open

Released under the MIT License.