Jump to content

Custom payment gateway not working after update to v6


fralazar

Recommended Posts

Hi Fralazar,

This error indicates that your module needs updating for compatibility with v6.0.

The dbconnect.php file referenced in the error message was depreciated back in v5.2 and finally removed in v6.0. The module will need updating to use init.php instead.

 

Please contact the vendor of the module for an update to their code.

Link to comment
Share on other sites

  • 2 weeks later...

Hajim thanks for your answer.

Contacted support and they told me the same and sent me the updated callback used in the SDK.

 

<?php

use WHMCS\Module\Gateway;
use WHMCS\Terminus;

/** @type WHMCS\Application $whmcs */

# Required File Includes
include "../../../init.php";
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/functions.php';
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/gatewayfunctions.php';
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/invoicefunctions.php';

$gatewayModule = 'gateway'; # Enter your gateway module name here replacing template

/**
* Ensure that the module is active before attempting to run any code
*/
$gateway = new Gateway();
if (!$gateway->isActiveGateway($gatewayModule) || !$gateway->load($gatewayModule)) {
   Terminus::getInstance()->doDie('Module not Active');
}

$GATEWAY = $gateway->getParams();

$status = $whmcs->get_req_var('x_response_code');
$invoiceId = $whmcs->get_req_var('x_invoice_num');
$transactionId = $whmcs->get_req_var('x_trans_id');
$amount = $whmcs->get_req_var('x_amount');
$fee = $whmcs->get_req_var('x_fee');

/**
* Check the invoice id is valid or die
*/
$invoiceId = checkCbInvoiceID($invoiceId, $GATEWAY["name"]);

/**
* Check transaction Id is unique or die
*/
checkCbTransID($transactionId);

if ($status=="1") {
   /**
    * Successful payment.
    * Apply Payment to Invoice: invoiceId, transactionId, amount paid, fees, moduleName
    */
   addInvoicePayment(
       $invoiceId,
       $transactionId,
       $amount,
       $fee,
       $gatewayModule
   );
   /**
    * Save log entry to the Gateway Log. Name, data (as array) and status
    */
   logTransaction(
       $GATEWAY["name"],
       $_POST,
       "Successful"
   );
} else {
   /**
    * Unsuccessful payment.
    * Save log entry to the Gateway Log. Name, data (as array) and status
    */
   logTransaction(
       $GATEWAY["name"],
       $_POST,
       "Unsuccessful"
   );
}

 

Working fine now.

Regards.

Link to comment
Share on other sites

  • 2 weeks later...

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.

  • 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