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"),
      invoice: new Api.InputInvoiceMessage({
        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"),
      invoice: new Api.InputInvoiceMessage({
        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
formIdlongForm ID
peerInputPeerThe peer where the payment form was sent
msgIdintMessage ID of form
requestedInfoIdflags.0?stringID of saved and validated order info
shippingOptionIdflags.1?stringChosen shipping option ID
credentialsInputPaymentCredentialsPayment credentials
tipAmountflags.2?longTip, in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

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

Bot Payments API