GramJS

payments.GetPaymentForm

Get a payment form

Example

const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.payments.GetPaymentForm({
      invoice: new Api.InputInvoiceMessage({
        peer: "username",
        msgId: 43,
      }),
      themeParams: new Api.DataJSON({
        data: "some string here",
      }),
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.payments.PaymentForm = await client.invoke(
    new Api.payments.GetPaymentForm({
      invoice: new Api.InputInvoiceMessage({
        peer: "username",
        msgId: 43,
      }),
      themeParams: new Api.DataJSON({
        data: "some string here",
      }),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
peerInputPeerThe peer where the payment form was sent
msgIdintMessage ID of payment form
themeParamsflags.0?DataJSONA JSON object with the following keys, containing color theme information (integers, RGB24) to pass to the payment provider, to apply in eventual verification pages: bg_color - Background color text_color - Text color hint_color - Hint text color link_color - Link color button_color - Button color button_text_color - Button text color

Result

payments.PaymentForm

Possible errors

CodeTypeDescription
400MESSAGE_ID_INVALIDThe provided message id is invalid.

Can bots use this method?

No