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
Name | Type | Description |
---|---|---|
flags | # | Flags, see TL conditional fields |
formId | long | Form ID |
peer | InputPeer | The peer where the payment form was sent |
msgId | int | Message ID of form |
requestedInfoId | flags.0?string | ID of saved and validated order info |
shippingOptionId | flags.1?string | Chosen shipping option ID |
credentials | InputPaymentCredentials | Payment credentials |
tipAmount | flags.2?long | Tip, 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
Possible errors
Code | Type | Description |
---|---|---|
400 | MESSAGE_ID_INVALID | The provided message id is invalid. |
Can bots use this method?
No
Related pages
payments.ValidatedRequestedInfo
Validated user-provided info