Jump to content

Custom Gateway does not redirect


chrismberi

Recommended Posts

I made a custom gateway which does not seem to redirect to gateway site. Upon initiating payment, gateway returns status and url to which client browser should be redirected. instead of reditecting to that site, the replay string just appears in the browser and thats it

 

 

My custom module files are as follows:

 

<?php

# Required File Includes
include("../../../dbconnect.php");
include("../../../includes/functions.php");
include("../../../includes/gatewayfunctions.php");
include("../../../includes/invoicefunctions.php");

$gatewaymodule = "mygate"; # Enter your gateway module name here replacing template

$GATEWAY = getGatewayVariables($gatewaymodule);
if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback

# Get Returned Variables - Adjust for Post Variable Names from your Gateway's Documentation
$browserurl = $_POST['browserurl'];
$hash = $_POST['hash'];
$pollurl = $_POST['pollurl'];
$status = $_POST["status"];
$invoiceid = $_POST["reference"];
$transid = $_POST["mygatereference"];
$amount = $_POST["amount"];

$invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing

checkCbTransID($transid); # Checks transaction number isn't already in the database and ends processing if it does

if ($status=="Ok") {
   # Successful
   addInvoicePayment($invoiceid,$transid,$amount,$gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, fees, modulename
logTransaction($GATEWAY["name"],$_POST,"Successful"); # Save to Gateway Log: name, data array, status
} else {
# Unsuccessful
   logTransaction($GATEWAY["name"],$_POST,"Unsuccessful"); # Save to Gateway Log: name, data array, status
}
?>



<?php

function mygate_config() {
   $configarray = array(
    "FriendlyName" => array("Type" => "System", "Value"=>"mygate"),
 "intkey" => array("FriendlyName" =>"Key","Type" => "text", "Size"=>"70"),
    "userid" => array("FriendlyName" => "User ID", "Type" => "text", "Size" => "20"),
    "testmode" => array("FriendlyName" => "Test Mode", "Type" => "yesno", "Description" => "Tick this to test")
   );
return $configarray;
}


function mygate_link($params) {

# Gateway Specific Variables
$gatewayusername = $params['userid'];
$gatewaytestmode = $params['testmode'];
$GatewayKey = $params['intkey'];

# Invoice Variables
$invoiceid = $params['invoiceid'];
//$description = $params['description'];
   $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'];

# System Variables
$companyname = $params['companyname'];
$systemurl = $params['systemurl'];
$currency = $params['currency'];


# Enter your code submit to the gateway...
$values=array("$gatewayusername","$invoiceid","$amount","$systemurl","http://www.easysites.co/wed/modules/gateways/callback/mygate.php","Message");
function CreateHash($values, $GatewayKey){
					$string = "";
					foreach($values as $key=>$value){
						if($key != '6'){
							$string.=$value;
						}
					}
					$string .= $GatewayKey;
					$hash = hash('sha512', $string);
					return strtoupper($hash);
}

$hashh = CreateHash($values,$GatewayKey);
$code = '<form method="post" action="https://www.mygate.co/interface/initiatetransaction">
<input type="hidden" name="id" value="'.$gatewayusername.'"/>
<input type="hidden" name="reference" value="'.$invoiceid.'" />
<input type="hidden" name="amount" value="'.$amount.'" />
<input type="hidden" name="returnurl" value="'.$systemurl.'"/>
<input type="hidden" name="resulturl" value="http://www.getnames.co.zw/wed/modules/gateways/callback/mygate.php"/>
<input type="hidden" name="status" value="'.Message.'"/>
<input type="hidden" name="hash" value="'.$hashh.'"/>
<input type="submit" value="Pay Now" />
</form>';

return $code;
}
?>

Link to comment
Share on other sites

  • 5 months later...

I am coding a custom gateway which uses a third party merchant gateway. After successful payment the code is returning to the callback page and the invoice marked as paid, but then remaining on the same page. It is not redirecting to an invoice page.

 

What could be the reason for the same?

 

- - - Updated - - -

 

I am coding a custom gateway which uses a third party merchant gateway. After successful payment the code is returning to the callback page and the invoice marked as paid, but then remaining on the same page. It is not redirecting to an invoice page.

 

What could be the reason for the same?

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.

  • 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