Hello,
I want to send customer data to a 3rd party webhook (Pabbly Connect) after checkout complete. I have written the following
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
// Your pabbly webhook endpoint
$webhook_url = 'https://connect.pabbly.com/workflow/sendXXXXXXXXXXXXXXXXX';
/**
* Post the request to pabbly webhook endpoint
*/
function sendData($vars){
$ch = curl_init($webhook_url);
$jsonData = array(
'OrderId' => $vars['orderid'],
'amount' => $vars['amount']
);
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
logModuleCall('Pabbly-WHMCS', 'Send response to pabbly webhook endpoint', json_encode($jsonDataEncoded), print_r($output, true));
curl_close($ch);
}
add_hook("ShoppingCartCheckoutCompletePage", 1, function($vars) {
if($vars['ispaid'] == true) {
sendData($vars);
}
});
I am getting the following logs in module log but nothing in pabbly end point. Can someone check and let me know if I miss anything?
Thanks in advance.