Forums

MyGate integration

deons1@iafrica.com 26 Apr, 2009
Please can you advice, how do i integrate the following coding, the for.php file does a call to process.php, below is the code:

form.php coding as follows:

<html>
	<head>
	</head>
	<body>

	<form action="process.php" method="POST">
	<table width="500" height="92" border="1" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
    <!--DWLayoutTable-->
	    <tr>
	     	<td height="31" colspan="3" valign="top" bgcolor="#F3F3F3"><div align="center"> Payment Options </div></td>
	    </tr>
	    <tr>
	    	<td width="114" height="9" valign="middle" bgcolor="#F3F3F3">Credit Card </td>
	     	<td width="59" height="9" colspan="2" valign="middle" bgcolor="#F3F3F3"><input id="cc" name="paymentOption" type="radio" value="Credit Card" /></td>
	    </tr>
	    <tr>
	      	<td height="9" colspan="2" valign="middle" bgcolor="#F3F3F3">Credit Card Number </td>
	      	<td width="289" height="9" valign="middle" bgcolor="#F3F3F3"><label>
	        <input name="cc_no" type="text" id="cc_no" size="40" maxlength="16" />
	        <br />
	      	(no spaces, no dashes, i.e. 4100111100001111)</label></td>
	    </tr>
	    <?
	    // current month and year
	    $year = date("Y");
	    $month = date("m");
	    ?>
	    <tr>
	     	<td height="9" colspan="2" valign="middle" bgcolor="#F3F3F3">Expiry Date</td>
	     	<td height="9" valign="middle" bgcolor="#F3F3F3">Month
	     		<select name="cc_expiry_month">
	     			<option value="01" <?= $month == "01" ? "selected" : ""; ?>>01</option>
	     			<option value="02" <?= $month == "02" ? "selected" : ""; ?>>02</option>
	     			<option value="03" <?= $month == "03" ? "selected" : ""; ?>>03</option>
	     			<option value="04" <?= $month == "04" ? "selected" : ""; ?>>04</option>
	     			<option value="05" <?= $month == "05" ? "selected" : ""; ?>>05</option>
	     			<option value="06" <?= $month == "06" ? "selected" : ""; ?>>06</option>
	     			<option value="07" <?= $month == "07" ? "selected" : ""; ?>>07</option>
	     			<option value="08" <?= $month == "08" ? "selected" : ""; ?>>08</option>
	     			<option value="09" <?= $month == "09" ? "selected" : ""; ?>>09</option>
	     			<option value="10" <?= $month == "10" ? "selected" : ""; ?>>10</option>
	     			<option value="11" <?= $month == "11" ? "selected" : ""; ?>>11</option>
	     			<option value="12" <?= $month == "12" ? "selected" : ""; ?>>12</option>
	     		</select>
	     		Year
	     		<select name="cc_expiry_year">
	     			<option value="2009" <?= $year == "2009" ? "selected" : ""; ?>>2009</option>
	     			<option value="2010" <?= $year == "2010" ? "selected" : ""; ?>>2010</option>
	     			<option value="2011" <?= $year == "2011" ? "selected" : ""; ?>>2011</option>
	     			<option value="2012" <?= $year == "2012" ? "selected" : ""; ?>>2012</option>
	     			<option value="2013" <?= $year == "2013" ? "selected" : ""; ?>>2013</option>
	     			<option value="2014" <?= $year == "2014" ? "selected" : ""; ?>>2014</option>
	     			<option value="2015" <?= $year == "2015" ? "selected" : ""; ?>>2015</option>
	     			<option value="2016" <?= $year == "2016" ? "selected" : ""; ?>>2016</option>
	     			<option value="2017" <?= $year == "2017" ? "selected" : ""; ?>>2017</option>
	     			<option value="2018" <?= $year == "2018" ? "selected" : ""; ?>>2018</option>
	     			<option value="2019" <?= $year == "2019" ? "selected" : ""; ?>>2019</option>
	     			<option value="2020" <?= $year == "2020" ? "selected" : ""; ?>>2020</option>
	     			<option value="2021" <?= $year == "2021" ? "selected" : ""; ?>>2021</option>
	     			<option value="2022" <?= $year == "2022" ? "selected" : ""; ?>>2022</option>
	     			<option value="2023" <?= $year == "2023" ? "selected" : ""; ?>>2023</option>
	     		</select>
	     	</td>
	    </tr>
    	<tr>
      		<td height="9" colspan="2" valign="middle" bgcolor="#F3F3F3">CVV Number:<br />
      		(the last 3/4 digits on the back of the card</td>
      		<td height="9" valign="middle" bgcolor="#F3F3F3"><input name="cvv" type="text" id="cvv" size="40" maxlength="3" /></td>
    	</tr>
	    <tr>
	    	<td height="9" colspan="2" valign="middle" bgcolor="#F3F3F3">Name exactly as it appears on the card:</td>
	    	<td height="9" valign="middle" bgcolor="#F3F3F3"><input name="cc_name" type="text" id="cc_name" size="40" /></td>
	    </tr>
    	<tr>
      		<td height="9" colspan="2" rowspan="2" valign="middle" bgcolor="#F3F3F3">Card Type </td>
      		<td height="4" valign="middle" bgcolor="#F3F3F3"><input name="cardType" id="cc_visa" type="radio" value="Visa" />
      		Visa </td>
    	</tr>
	    <tr>
	    	<td height="5" valign="middle" bgcolor="#F3F3F3"><input name="cardType" id="cc_mastercard" type="radio" value="MasterCard" />
	      	Master Card </td>
	    </tr>
  	</table>
  	<table>
  		<tr>
  			<td><input type="submit" value="submit" /></td>
  		</tr>
  	</table>
	</form>

	</body>
</html>


Process.php file data as follows:

<?
//-------------------------------------------------------------------------------------------------------
// Credit card values
//-------------------------------------------------------------------------------------------------------
$credit_cardnr 	= isset($_REQUEST["cc_no"]) ? $_REQUEST["cc_no"] : 0;
$cc_expiry_month= isset($_REQUEST["cc_expiry_month"]) ? $_REQUEST["cc_expiry_month"] : "";
$cc_expiry_year= isset($_REQUEST["cc_expiry_year"]) ? $_REQUEST["cc_expiry_year"] : "";
$cvvnr			= isset($_REQUEST["cvv"]) ? $_REQUEST["cvv"] : 0;
$ccholder_name	= isset($_REQUEST["cc_name"]) ? $_REQUEST["cc_name"] : "";
$card_type		= isset($_REQUEST["cardType"]) ? $_REQUEST["cardType"] : "";
$invoice_total	= isset($_REQUEST["total"]) ? $_REQUEST["total"] : 0.99;

$card_typenr	= $card_type == "Visa" ? "4" : $card_type == "MasterCard" ? "3" : 0;
$cc_month 		= 0;
$cc_year		= 0;

$cc_month		= $cc_expiry_month;
$cc_year		= $cc_expiry_year;

echo $cc_month . " | " . $cc_year;
exit();
//-------------------------------------------------------------------------------------------------------

// Other form variables
//-------------------------------------------------------------------------------------------------------
$ref_no			= isset($_REQUEST["ref_no"]) ? $_REQUEST["ref_no"] : time();
//-------------------------------------------------------------------------------------------------------

// payment gateway details
//-------------------------------------------------------------------------------------------------------
$url 			= "https://www.mygate.co.za/enterprise/3x0x0/ePayService.cfc?wsdl";
$mode 			= "0";
$merchantID 	= "79958a8d-0c7b-4038-8e2e-8948e1d678e1";
$applicationID 	= "4b775479-a264-444c-b774-22d5521852d8";

$gatewayID		= "fnblive";
$terminal		= "MyGate";
$currency 		= "ZAR";

$merchant_REF	= $ref_no;
//-------------------------------------------------------------------------------------------------------

// process payment - action 1 (authorization)
//-------------------------------------------------------------------------------------------------------
$client = new SoapClient($url);

$arrResults = @$client->fProcess(
	$gatewayID, 				//Gateway
	$merchantID,  				//MerchantID
	$applicationID, 			//ApplicationID
	'1',						//Action
	'',							//TransactionIndex
	$terminal,					//Terminal
	$mode,						//Mode 0 = test | 1 = live
	$merchant_REF,				//MerchantReference
	$invoice_total,				//Amount
	$currency,					//Currency
	'',							//CashBackAmount
	$card_typenr,				//CardType
	'',							//AccountType
	$credit_cardnr,				//CardNumber
	$ccholder_name,				//CardHolder
	$cvvnr,						//CCVNumber
	$cc_month,					//ExpiryMonth
	$cc_year,					//ExpiryYear
	'0',						//Budget
	'',							//BudgetPeriod
	'',							//AuthorizationNumber
	'',							//PIN
	'',							//DebugMode
	'06',						//eCommerceIndicator
	'',							//verifiedByVisaXID
	'',							//verifiedByVisaCAFF
	'',							//secureCodeUCAF
	'',							//Unique Client Index - this is used to uniquely identify the client and is used by the MyGate Fraud module. It is an optional parameter. Please see online documentation for details.
	'',							//IP Address - this is the IP address of the user using the online gateway (retrieved by yourselves), and is used by the MyGate Fraud module. It is an optional parameter.	 Please see online documentation for details.
	''							//Shipping Country Code - this is the 2-digit shipping country code of the user, and is used by the MyGate Fraud module. It is an optional parameter. Please see online documentation for details.
);
//-------------------------------------------------------------------------------------------------------

// process payment - action 3 (process payment if authorization returned 0)
//-------------------------------------------------------------------------------------------------------
list($ResultName, $ResultValue) = explode("||",$arrResults[0]);
if ($ResultValue == 0) {
	list($ResultName, $ResultValue) = explode("||",$arrResults[1]);
	$arrResults = @$client->fProcess(
		$gatewayID, 		//Gateway
		$merchantID,  		//MerchantID
		$applicationID, 	//ApplicationID
		'3',				//Action
		$ResultValue,		//TransactionIndex
		'',					//Terminal
		'',					//Mode
		'',					//MerchantReference
		'',					//Amount
		'',					//Currency
		'',					//CashBackAmount
		'',					//CardType
		'',					//AccountType
		'',					//CardNumber
		'',					//CardHolder
		'',					//CCVNumber
		'',					//ExpiryMonth
		'',					//ExpiryYear
		'',					//Budget
		'',					//BudgetPeriod
		'',					//AuthorizationNumber
		'',					//PIN
		'',					//DebugMode
		'',					//eCommerceIndicator
		'',					//verifiedByVisaXID
		'',					//verifiedByVisaCAFF
		''					//secureCodeUCAF
	);

	list($ResultName, $ResultValue) = explode("||",$arrResults[0]);
	if ($ResultValue == 0) {
		echo("<br />");
		echo("Successful Authorization <br />");
		list($ResultName, $ResultValue) = explode("||",$arrResults[0]);
		echo($ResultValue);
		echo("<br />");
	}
	else {
		echo("<br />");
		echo("Failed Authorization");
		echo("<br />");

		foreach ($arrResults as $result) {
			echo($result);
			echo("<br />");
		}
	}
}
else {
	echo("<br />");
	echo("Failed Authorization");
	echo("<br />");

	foreach ($arrResults as $result) {
		echo($result);
		echo("<br />");
	}
}
//-------------------------------------------------------------------------------------------------------
?>
GreyHead 26 Apr, 2009
Hi deons1,

First - please change your username here so that your email is not exposed :-)

First step with this is to create a new form, copy and paste the code from form.php ****between the <form> tags**** but not including the tags into the Form HTML box on the Form Code tab.

SEcond, paste the code from process.php into the OnSubmit After code box on the same tab.

Give the form a name, save and publish it, click the link - cross your fingers - and with luck it will work.

Bob

PS In practice it will probably need debugging and may need some extra files to support the Soapxml - but basically that is it.
This topic is locked and no more replies can be posted.