Cryptocurrency payment gateway for telegram bots and websites – Telegram 简体版

Haley

Cryptocurrency payment gateway for telegram bots and websites

With the Cryptocurrency popularity this days, Allowing users to pay with Cryptocurrency for goods and stuffs is a undeniable growing demand in the market. But implementing the payment solution is one of the major challenges, with ease of use.

CryptoBot is a cryptocurrency market and payment API with benefit of a fast and easy implementation.

To use this payment gateway, all you need is just to start this telegram bot to create an account.

Step one:

to setup, run the following command to install php SDK:

composer require sarani/cryptopay

Step Two:

Start the Cryptobot and from main menu, select CryptoPay and create a new app from the menu.

Cryptobot main menu
Cryptobot Main menu

From the Crypto Pay menu, Select create App to create a new app. the name chosen by random but you can edit it.

Created App Menu

here you can set the Weebhook, get API Token, rename app name or withdraw.

Step Three:

init the client

# init
$cryp_payment_token = 'token';
$mode = ''; // empty for real account
$crypto = new Sarani\CryptoPay\Api($cryp_payment_token, $mode);

and create your first invoice. the return data is Invoice type Object.

# create invoice, return Invoices object 
$inv = $crypto->createInvoice($params = [
'asset' => 'USDT',
'amount' => '2.50',
'payload' => '11158', # subscription id
'allow_comments' => False,
'allow_anonymous' => True,
'paid_btn_name' => 'openBot',
'paid_btn_url' => 'https://t.me/demobot',
'hidden_message' => 'Thanks for your payment',
'description' => 'Monthly Subscription'
]);
echo $inv->id();
echo $inv->url();

url is the link that the user can click on it and it will open the telegram cryptobot bot where user can pay the invoice.

to get an invoice to check if it is paid or not use the getInvoices method

# get invoice, return array of Invoices object 
$res = $crypto->getInvoices($params = [
'asset' => 'TON', // Crypto symbols
'invoice_ids' => '12600,12626,12745', // ids seperated by comma
]);

you can pass one invoice id or multiple separated by “,” Comma sign.

After successful payment you receive a hook from the bot about the invoice status.

you can get the hook on webhook.php page by using the following code.

# webhook, return Webhook object with Update and Invoice 
$hook = new Sarani\CryptoPay\Webhook();
$update = $hook->getUpdate(); // Update object
$nvoice = $update->getPayload(); // Invoice Object
echo( $nvoice->status());

you can set the hook link in the cryptobot’s setting.

for full code, setup and guide, you can read the sdk readme document.

Ten articles before and after

7 Builders For No-Code Creation of Chatbots in Telegram – Telegram 简体版

Telegram Bot 2: OCR. Python + AWS Lambda + AWS API Gateway – Telegram 简体版

telegram登录收不到短信验证码 | – Telegram 简体版

Telegram 中国手机号收不到短信怎么办?(2022 更新) | – Telegram 简体版

Telegram迎来Payments 2.0支付服务、语音群聊预约功能和Web新版本 | – Telegram 简体版telegram中文网页版

Telegram Reminder Bot. Telegram along with messaging feature… – Telegram 简体版

Telegram将迎来两个重要更新 | – Telegram 简体版

Mac电脑ss/ssr时Telegram无法连接正常使用的3分钟解决方法 – – Telegram 简体版

如何绕过Telegram(tg) 频道封锁的解决方法(macOS版) – – Telegram 简体版

Как закрепить сообщение в Телеграм. Что нужно сделать? – Telegram 简体版

About Me

Pretium lorem primis senectus habitasse lectus donec ultricies tortor adipiscing fusce morbi volutpat pellentesque consectetur risus curae malesuada dignissim lacus convallis massa mauris.