Jump to content
  • 0

Debugging callback


hasajacykacperek

Question

Hello, I want to debug my payment callback, there is no logs in panel, code:

<?php
/**
 * Paynow Payment Gateway Callback handler for WHMCS
 */

require_once __DIR__ . '/../../../init.php';
require_once __DIR__ . '/../paynow/vendor/autoload.php';

use Paynow\Notification;
use WHMCS\Database\Capsule;

$whmcs->load_function('gateway');
$whmcs->load_function('invoice');

$gatewayModuleName = basename(__FILE__, '.php');
$gatewayParams = getGatewayVariables($gatewayModuleName);

if (!$gatewayParams['type']) {
    die("Module Not Activated");
}

//Select the api credentials by gateway mode
$gatewayMode = $gatewayParams['gatewayMode'];
if ($gatewayMode == 'Test') {
    $consumer_key = $gatewayParams['testConsumerKey'];
    $consumer_secret = $gatewayParams['testConsumerSecret'];
} else {
    $consumer_key = $gatewayParams['liveConsumerKey'];
    $consumer_secret = $gatewayParams['liveConsumerSecret'];
}

$payload = trim(file_get_contents('php://input'));
$headers = getallheaders();
$notificationData = json_decode($payload, true);
logTransaction($gatewayParams["name"], var_dump($notificationData), "Unsuccessful");

$invoiceId = checkCbInvoiceID($notificationData['externalId'], $gatewayParams['name']);
$transactionId = checkCbTransID($notificationData['paymentId']);
logTransaction($gatewayParams["name"], var_dump($invoiceId), "Unsuccessful");
logTransaction($gatewayParams["name"], var_dump($transactionId), "Unsuccessful");

try {
    new Notification($consumer_secret, $payload, $headers);
    $isVerificationSuccessful = true;
    logTransaction($gatewayParams['name'], ['Invoice ID' => $invoiceId], 'Success');
    //Add payment information to given invoice ID
    addInvoicePayment(
        $invoiceId,
        $transactionId,
        100,
        0, // Payment Fee
        $gatewayModuleName
    );
} catch (Exception $exception) {
    logTransaction($gatewayParams["name"], $exception, "Unsuccessful");
    header('HTTP/1.1 400 Bad Request', true, 400);
}

logTransaction($gatewayParams["name"], $_POST, "Success");
header('HTTP/1.1 202 Accepted', true, 202);

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

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

Guest
Answer this question...

×   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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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