send_payment_form()

Client.send_payment_form()

Send a filled-out payment form to the bot for final verification.

Usable by Users Bots
Parameters:
  • payment_form_id (int) – Payment form identifier returned by get_payment_form().

  • input_invoice (InputInvoice) – The invoice.

  • credentials (InputCredentials, optional) – The credentials chosen by user for payment. Pass None for a payment in Telegram Stars.

Returns:

PaymentResult – On success, the payment result is returned.

Example

# Pay regular invoice from message
invoice = types.InputInvoiceMessage(
    chat_id=chat_id,
    message_id=123
)

form = await app.get_payment_form(invoice)

await app.send_payment_form(
    payment_form_id=form.id,
    input_invoice=invoice,
    credentials=types.InputCredentialsNew(
        data=json.dumps({"token": "...", "type": "card"}), # Pass the token received from the payment provider
    )
)

# Pay star invoice from message
invoice = types.InputInvoiceMessage(
    chat_id=chat_id,
    message_id=123
)

form = await app.get_payment_form(invoice)

await app.send_payment_form(
    payment_form_id=form.id,
    input_invoice=invoice
)