GramJS

payments.SendPaymentForm

Send compiled 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.SendPaymentForm({
      formId: BigInt("-4156887774564"),
      peer: "username",
      msgId: 43,
      credentials: new Api.InputPaymentCredentialsSaved({
        id: "some string here",
        tmpPassword: Buffer.from("arbitrary data here"),
      }),
      requestedInfoId: "some string here",
      shippingOptionId: "some string here",
      tipAmount: BigInt("-4156887774564"),
    })
  );
  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.PaymentResult = await client.invoke(
    new Api.payments.SendPaymentForm({
      formId: BigInt("-4156887774564"),
      peer: "username",
      msgId: 43,
      credentials: new Api.InputPaymentCredentialsSaved({
        id: "some string here",
        tmpPassword: Buffer.from("arbitrary data here"),
      }),
      requestedInfoId: "some string here",
      shippingOptionId: "some string here",
      tipAmount: BigInt("-4156887774564"),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
msgIdintMessage ID of form
requestedInfoIdflags.0?stringID of saved and validated order info
shippingOptionIdflags.1?stringChosen shipping option ID
credentialsInputPaymentCredentialsPayment credentials

Result

payments.PaymentResult

Possible errors

CodeTypeDescription
400MESSAGE_ID_INVALIDThe provided message id is invalid

Can bots use this method?

No

payments.ValidatedRequestedInfo

Validated user-provided info