Custom Pay button for Telegram bot - IT NEWS

Latest

Programming PHP tutorials for beginners. Technology and product reviews.

Friday, June 9, 2017

Custom Pay button for Telegram bot

Adv
telegram bot

Custom Pay button for Telegram bot

How to make custom pay button for Telegram bot invoice. You can type another text except Pay word. You can also add more button for Telegram bot invoice. 1 button must me button with pay function, another buttons can be links to web-site or start_parameter buttons. If you are not using pay button with custom name, under invoice will be showing button with Pay name.

telegram bot

You must include Pay => true to activate pay function, then you can rename button, just change TEXT field.
Telegram Bot PHP example

$chat_id = "*****"; // telegram chat id
$bot_id = "*****"; // telegram bot id
$stripe_token = "***"; // stripe token

$url = "https://api.telegram.org/$bot_id/sendInvoice";

$LabeledPrice = array(array('label' => "Nike Shoes", 'amount' => 1100));

$keyboard = array("inline_keyboard" => array(array(array("pay" => True,"text" => "Make A Payment"))));


$postfields = array(
'chat_id' => "$chat_id",
'title' => "NIKE SHOES",
'description' => "The best running shoes 2017",
'photo_url' => "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioApqmqY2mdeZ_ejbHC9uoU-z_ZRmbguxL5Qj5QZ_yNHpZncrbAF9X5u3ojtpnXvVmNw536F9pTU2KI0IpSf70uESHIp9bBSme9tlmS9tKDZNivU_bf4ZnvKmk50AiHpnAQ-y_pZGUmNs/s320/1.png",
'photo_width' => 90,
'photo_height' => 50,
'payload' => "telebot-test-invoice",
'provider_token' => "$stripe_token",
'start_parameter' => "pay",
'currency' => "EUR",
'prices' => json_encode($LabeledPrice),
'reply_markup' => json_encode($keyboard)
);

print_r($postfields);

if (!$curld = curl_init()) {
exit;
}

curl_setopt($curld, CURLOPT_POST, true);
curl_setopt($curld, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curld, CURLOPT_URL,$url);
curl_setopt($curld, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($curld);

curl_close ($curld);

How to make 2 or 3 buttons?

Repeat inline_keyboard Array of Array for each next button. 1 button must be pay button, 2 and other buttons can be links.
PHP example Telegram bot

$chat_id = "*****"; // telegram chat id
$bot_id = "*****"; // telegram bot id
$stripe_token = "***"; // stripe token

$url = "https://api.telegram.org/$bot_id/sendInvoice";

$LabeledPrice = array(array('label' => "Nike Shoes", 'amount' => 1100));

$keyboard = array("inline_keyboard" => array(array(array("pay" => True,"text" => "Make A Payment"),array("text" => "Go to web-site","url" => "www.google.com"))));


$postfields = array(
'chat_id' => "$chat_id",
'title' => "NIKE SHOES",
'description' => "The best running shoes 2017",
'photo_url' => "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioApqmqY2mdeZ_ejbHC9uoU-z_ZRmbguxL5Qj5QZ_yNHpZncrbAF9X5u3ojtpnXvVmNw536F9pTU2KI0IpSf70uESHIp9bBSme9tlmS9tKDZNivU_bf4ZnvKmk50AiHpnAQ-y_pZGUmNs/s320/1.png",
'photo_width' => 90,
'photo_height' => 50,
'payload' => "telebot-test-invoice",
'provider_token' => "$stripe_token",
'start_parameter' => "pay",
'currency' => "EUR",
'prices' => json_encode($LabeledPrice),
'reply_markup' => json_encode($keyboard)
);

print_r($postfields);

if (!$curld = curl_init()) {
exit;
}

curl_setopt($curld, CURLOPT_POST, true);
curl_setopt($curld, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curld, CURLOPT_URL,$url);
curl_setopt($curld, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($curld);

curl_close ($curld);

telegram bot telegram bot

https://www.facebook.com/chakabiz
https://www.youtube.com/channel/UCYuMRNb_SRZ4FMsZjnHRZUA

1 comment:

  1. If you have the skill and the experience, then you do not have to be in the rat race. cursos de ti

    ReplyDelete