Jump to content

Send data to 3rd party webhook by Pabbly Connect


rabijit

Recommended Posts

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.

pabbly.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated