I included the our payment gateway providers iframe in merchantgateway.php. And I capture the token inside callback according to the WHMCS payment gateway sample code. Initial payment is working and a token is returned. I tried to test recurring payment by changing the next due date to yesterday date and run the cron. But the automatic recurring payment does not happen. I tried to implement whmcs hook on callback to do the recurring payment. Am going the right direction? I would be much grateful to you if could help on this
My code is given below
payment module
<?php
function paybank_config()
{
$configarray = array(
"FriendlyName" => array("Type" => "System", "Value" => "XXXX Bank"),
);
return $configarray;
}
function paybank_link($params)
{
$client_hash = 'xxxxxxxxxxxxxxxxxxxxxxxx';
$code = '<iframe id="showEntry" width="100%" height="350" src="https://[payment-gateway-url]?clientIdHash='.$client_hash.'&paymentAmount='.$params['amount'].'"></iframe>';
$_SESSION['paybank_amount'] = $params['amount'];
$_SESSION['paybank_invoiceid'] = $params['invoiceid'];
return $code;
}
function paybank_refund($params)
{
# Gateway Specific Variables
$gatewayusername = $params['username'];
$gatewaytestmode = $params['testmode'];
# Invoice Variables
$transid = $params['transid']; # Transaction ID of Original Payment
$amount = $params['amount']; # Format: ##.##
$currency = $params['currency']; # Currency Code
# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];
# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];
# Perform Refund Here & Generate $results Array, eg:
$results = array();
$results["status"] = "success";
$results["transid"] = "12345";
# Return Results
if ($results["status"] == "success")
{
return array("status" => "success", "transid" => $results["transid"], "rawdata" => $results);
}
elseif ($gatewayresult == "declined")
{
return array("status" => "declined", "rawdata" => $results);
}
else
{
return array("status" => "error", "rawdata" => $results);
}
}
?>
callback file
<?php
# Required File Includes
include("../../../init.php");
include("../../../includes/functions.php");
include("../../../includes/gatewayfunctions.php");
include("../../../includes/invoicefunctions.php");
$gatewaymodule = "paybank"; # Enter your gateway module name here replacing template
$GATEWAY = getGatewayVariables($gatewaymodule);
if (!$GATEWAY["type"]) die("Module Not Activated");
//echo $_SESSION['paybank_amount'];die;
//echo $_POST["amount"]. '%%%%';die;
$table = "tblinvoices";
$fields = "userid";
$where = array("id"=>$invoiceid);
$result = select_query($table,$fields,$where);
$data = mysql_fetch_array($result);
$sql = "SELECT userid FROM tblinvoices WHERE id = {$invoiceid}";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
update_query(
"tblclients",
array(
"cardnum" => "",
"gatewayid" => $req_response->token
),
array("id" => $data['userid'])
);
header('Location:http://express-web.negete.net/order/successful/'.$req_response->txnReference.'');
}
else
{
echo "Invalid Invoice Number";
}
} else {
echo ("The response have been altered along the way. Please contact us immediately");
}