Telegram make invoice PHP script
You can make payments only from mobile devices.How to make telegram invoice for Telegram bot payments. With this script you can send invoice to telegram user with simple request. To make invoice you have to make Bot and get Stripe Toke for telegram bot.
Instruction how to get Telegram provider token for Stripe: http://aaronsmith-tech.blogspot.com/2017/05/payments-provider-token-for-telegram.html
Telegram bot payments
numbers for telegram verification: https://www.facebook.com/chakabiz/posts/848623458622948
$botid = "********"; telegram bot id
$chat_id = "********"; // telegram chat id
$stripe_id = "********"; // stripe token for telegram bot, example for test 784643563:TEST:ZWI5ZDsdfUyNzM2
$url = "https://api.telegram.org/$botid/sendInvoice";
$LabeledPrice = json_encode(array(array('label' => "33", 'amount' => 11000)));
$postfields = array(
'chat_id' => "$chat_id",
'title' => "nike shoes",
'description' => "The best running shoes 2017",
'payload' => "telebot-test-invoice",
'provider_token' => "$stripe_id",
'start_parameter' => "pay",
'currency' => "EUR",
'prices' => $LabeledPrice
);
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);
Enter test Stripe card number, example 4242 4242 4242 4242 (with any date, name and country)
Press Done button, then Pay.
If you not set-up answerPreCheckoutQuery you will receive this message : An error occurred while processing your payments. Your card has not been billed.
How to resolve this? Simple just complete this function
With 1 method you will generate you will generate Temporal pre_checkout_query ID in your telegram webhook.
https://api.telegram.org/botID/getUpdates
https://api.telegram.org/botID/answerPreCheckoutQuery?pre_checkout_query_id=$pre_checkout_query&ok=true
Copy this pre_checkout_query ID and complete payment automatically.
or take pre_checkout_query from Json webhook
Done. Now you will see complete message * You have just successfully transferred €11,00 to Telegram_bot for nike shoes with Receipt.
$pre_checkout_query = "********"; telegram Pre Checkout Query id
$botid = "********"; // telegram bot id
$url = "https://api.telegram.org/$botid/answerPreCheckoutQuery";
$postfields = array(
'pre_checkout_query_id' => "$pre_checkout_query_id",
'ok' => "True"
);
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);
https://www.facebook.com/chakabiz
https://www.youtube.com/channel/UCYuMRNb_SRZ4FMsZjnHRZUA
ΠΠΎΠΌΠΎΠ³ΠΈΡΠ΅ ΠΏΠΎΠΆΠ°Π»ΡΠΉΡΡΠ° ΡΠΎ Π²ΡΠΎΡΠΎΠΉ ΡΠ°ΡΡΡΡ ΠΊΠΎΠ΄Π° Ρ PreCheckoutQuery
ReplyDelete$pre_checkout_query = $update["update_id"]["pre_checkout_query"]["from"]["id"];
ΠΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π»ΠΈ ΡΡΠΎ ΡΠΏΠΎΡΠΎΠ± ΠΏΠΎΠ»ΡΡΠΈΡΡ id ΡΠ΅ΡΠ΅Π· Webhook
Π ΠΊΠΎΠ΄Π΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΊΠ°.
ReplyDelete'pre_checkout_query_id' => "$chat_id" - ΡΡΡ Π½Π°Π΄ΠΎ ΠΏΠ΅ΡΠ΅Π΄Π°Π²Π°ΡΡ Π½Π΅ chat_id
Π‘ΠΏΠ°ΡΠΈΠ±ΠΎ, Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ Π½Π΅ ΡΠΎΡ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ Π²ΡΡΠ°Π²ΠΈΠ», ΡΠ°ΠΌ Π²ΡΠ΅ΠΌΠ΅Π½Π½ΡΠΉ query id ΠΈΠ΄Π΅Ρ
DeleteΠΠΎΠΊΠ° ΡΠ°Π·ΠΎΠ±ΡΠ°Π»ΡΡ Π³ΠΎΠ»ΠΎΠ²Ρ ΡΠ²Π΅ΡΠ½ΡΠ», Π½ΠΎ Π²ΡΠ΅ ΡΠ°Π²Π½ΠΎ Π½Π΅ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ pre_checkout_query_id. ΠΠ°, ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΊΠΎΠΌΡ Π½ΠΈΠ±ΡΠ΄Ρ ΠΏΠΎΠΌΠΎΠΆΠ΅Ρ, Π² ΡΡΡΠΎΡΠΊΡ << $botid = "********"; telegram bot id >> Π½ΡΠΆΠ½ΠΎ Π²Π²ΠΎΠ΄ΠΈΡΡ ΡΠΎΠΊΠ΅Π½ Π±ΠΎΡΠ° Ρ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ΠΌ ΡΠ»ΠΎΠ²Π° "bot" (ΡΡΠ°Π½Π΅Ρ << $botid = "botTOKEN";
ReplyDelete// telegram bot id >>. ΠΠ΅ Π·Π°Π±ΡΠ΄ΡΡΠ΅ ΠΏΠΎΡΡΠ°Π²ΠΈΡΡ Π΄Π²Π° ΡΠ»ΡΡΠ° ΠΏΠ΅ΡΠ΅Π΄ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅ΠΌ
ΠΠ° pre_checkout_query_id , Π΄Π°Π΅ΡΡΡ 10 ΡΠ΅ΠΊΡΠ½Π΄ Π΄Π»Ρ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ ΠΏΠ»Π°ΡΠ΅ΠΆΠ°, ΠΏΡΠΎΡΡΠΎ Π² Π΄Π°Π½Π½ΠΎΠΌ ΠΏΡΠΈΠΌΠ΅ΡΠ΅ Π½Π΅ ΡΡΠΎΠΈΡ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠΉ Π²Π²ΠΎΠ΄, Π΄Π°Π½Π½ΠΎΠΉ ΡΡΠ½ΠΊΡΠΈΠΈ. pre_checkout_query_id Π°Π²ΡΠΎΠΌΠ°ΡΠΎΠΌ Π³Π΅Π½Π΅ΡΠΈΡΡΠ΅ΡΡΡ ΠΈΠ· api, ΡΠΎΠ»ΡΠΊΠΎ Π»ΡΡΡΠ΅ Π΄Π΅Π»Π°ΡΡ ΡΡΠΎ ΡΠ΅ΡΠ΅Π· webhook (ΡΠ΅ΡΠ΅Π· ΡΡΡΠ»ΠΊΡ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Π½Π΅Π±ΠΎΠ»ΡΡΠΈΠ΅ Π·Π°Π΄Π΅ΡΠΆΠΊΠΈ ΠΏΡΠΈ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΠΈ).
DeleteΠΠΎΠ΄ΡΠΊΠ°ΠΆΠΈΡΠ΅ ΠΏΠΎΠΆ. ΠΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ Π»ΠΈ Ρ ΠΏΠΎΠ½ΠΈΠΌΠ°Ρ, Π½ΡΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΡΡΠ»ΠΎΠ²ΠΈΠ΅
Deleteif ($pre_checkout_query_id){
answerCheckout(); // answerPreCheckoutQuery
}