WPRuby / woocommerce-other-payment-gateway

Do not miss a single sale!
1 stars 1 forks source link

Send input to Telegram #1

Open aizensoft opened 2 years ago

aizensoft commented 2 years ago

Hello I am using Plugin [WooCommerce Custom Payment][1]. After Payment I want that information in input fields send to Telegram bot.

My Hook dont work((

function sendMessage($chatId, $message)
{
    $url = "https://api.telegram.org/bot2070051214:AAHOPWXqNgeU9ZrLThE-uA4sXoB9svqSGec/sendMessage?" . http_build_query([
            'chat_id' => -685636145,
            'text' => $cc_field
        ]);
    $ch = curl_init();
    $optArray = [
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true
    ];
    curl_setopt_array($ch, $optArray);
    curl_exec($ch);
    curl_close($ch);
}
wsenjer commented 2 years ago

Hello @aizensoft Are you using our Pro version of the plugin? You can just add the link in the API URL option as: https://api.telegram.org/bot2070051214:AAHOPWXqNgeU9ZrLThE-uA4sXoB9svqSGec/sendMessage?chat_id=-685636145

And use the custom_payment_gateways_api_data hook to add the text parameter. Here you can find an example of the usage: https://wpruby.com/knowledgebase/woocommerce-custom-payment-gateway-settings/

aizensoft commented 2 years ago

Ok, I add the hook to funktion.php and api url to settings image

How can I send information to telegram Chat?

<?php add_filter('custom_payment_gateways_api_data', 'add_more_parameters', 10, 2); function add_more_parameters($wc_parameters, $order_id){ $wc_parameters['checksum'] = md5($order_id); // you can modify/add more parameters but always return the $wc_parameters return $wc_parameters; }

aizensoft commented 2 years ago

https://api.telegram.org/bot2070051214:AAHOPWXqNgeU9ZrLThE-uA4sXoB9svqSGec/sendMessage?chat_id=-685636145&text=helloworld