PHP incoming webhook handling PHP incoming webhook handling wordpress wordpress

PHP incoming webhook handling


I would do this to test the webhook.

<?php $fWrite = fopen("log.txt","a");$wrote = fwrite($fWrite, var_dump($_POST));fclose($fWrite);?>

This will return var_dump data in log.txt file, since as rickdenhaan said 36 mins ago, your current webhook.php return data to the webhook not your view.

You may need to create log.txt manually if you don't have right on directory (755)

I'm currently working with a payment API that use webhook. Webhook send data to X url then do action and return code to webhook. so webhook.php is the place where my order if ispaid or not is proceed or not... here what I did:

if ($payment->isPaid() == TRUE){    /*     * At this point you'd probably want to start the process of delivering the product to the customer.     */    $con->query("UPDATE orders SET bankno = '$bankno', status = 'paid' WHERE ordertr = '$ids'");}elseif ($payment->isOpen() == FALSE){    /*     * The payment isn't paid and isn't open anymore. We can assume it was aborted.     */    $con->query("UPDATE orders SET bankno = '$bankno', status = 'closed' WHERE ordertr = '$ids'");}

So if order paid mark as paid in database if not mark as closed. This show webhook usage. Doing action according to what the webhook data send.


here is how i get content sent to my app:

$varname = json_decode(file_get_contents('php://input'));

well my content are JSON encoded, but I think this would be fine:

$varname = file_get_contents('php://input');