PHP – E-xact SIM Hosted Payment Gateway

An E-xact Payment is a securely hosted web payment form designed to accept Internet-based
E-commerce transactions.

How can I setup my account with E-xact SIM Account?

   1. Log into your E-xact account at https://pos.e-xact.com/
      and for test https://rpm-demo.e-xact.com
   2. Click on the Payment Pages.
   3. Click on Payment Page ID link.
   4. Click on Hash Calculator link.
   5. Enter Login(x_login) value into shop E-xact Login field.
   6. Enter Transaction Key value into shop E-xact Transaction Key field.
   7. Click on Receipt Page link.
   8. Set the Allow Relay Response checkbox as checked under
      Authorize.Net Protocol - Relay Response Settings.
   9. In the Relay Response URL enter this value: http://www.yoursite.com/response.php
  10. Set the Allow HTTP Redirect to Merchant Website checkbox as checked.

Code Example: Download Example
For more help visit: https://hostedcheckout.zendesk.com/entries/207209-hosted-checkout-integration-manual#7

index.php
<?php
$loginID		= "LOGIN_ID";
$transactionKey = "TRANSACTION_KEY";
$amount 		= 45.56;
$description 	= "Sample Transaction";
$invoice		= "12345";
$sequence		= rand(1, 9999);
$timeStamp		= time();
$currency_code 	= "USD";
$test_mode 		= 1;

if( phpversion() >= '5.1.2' ){
	$fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^" . $currency_code , $transactionKey);
}
else {
	$fingerprint = bin2hex(mhash(MHASH_MD5, $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^" . $currency_code, $transactionKey));
}

if($test_mode){
	$url = "https://rpm-demo.e-xact.com/payment\" method=\"POST\">";
	$x_test_request = "TRUE"; // Process payment in test mode. Case-sensitive.
}
else{
	$url = "https://checkout.e-xact.com/payment\" method=\"POST\">";
	$x_test_request = "FALSE"; // Process payment in test mode. Case-sensitive.
}
?>
<form method='post' action='<?php echo $url; ?>' >
<input type='hidden' name='x_login' 			value='<? echo $loginID; ?>' />
<input type='hidden' name='x_amount' 			value='<? echo $amount; ?>' />
<input type='hidden' name='x_description' 		value='<? echo $description; ?>' />
<input type='hidden' name='x_invoice_num' 		value='<? echo $invoice; ?>' />
<input type='hidden' name='x_fp_sequence' 		value='<? echo $sequence; ?>' />
<input type='hidden' name='x_fp_timestamp' 		value='<? echo $timeStamp; ?>' />
<input type='hidden' name='x_fp_hash' 			value='<? echo $fingerprint; ?>' />
<input type='hidden' name='x_test_request' 		value='<?=$x_test_request?>' />
<input type='hidden' name='x_show_form' 		value='PAYMENT_FORM' />
<input type='hidden' name='x_type' 				value='AUTH_CAPTURE' />

<input type='hidden' name='x_receipt_link_method' VALUE='POST'>
<input type='hidden' name='x_receipt_link_text' 	VALUE='Complete Your Order'>
<input type='hidden' name='x_receipt_link_url' 	VALUE='www.yoursite.com/response.php'>

<input type='hidden' name="x_relay_response" VALUE="TRUE">
<input type='hidden' name="x_relay_url" VALUE="www.yoursite.com/response.php">

<input type='hidden' name= 'x_currency_code'	value ='<?=$currency_code;?>'>
<input type='hidden' name='x_first_name' 		value='Bill'>
<input type='hidden' name='x_last_name' 		value='M'>
<input type='hidden' name='x_company' 			value='Test Company'>
<input type='hidden' name='x_address' 			value='123 St. John'>
<input type='hidden' name='billTo_street1' 		value='123 St. John'>
<input type='hidden' name='billTo_street2' 		value='123 St. John'>
<input type='hidden' name='x_city' 				value='Escodia'>
<input type='hidden' name='x_state' 			value='CA'>
<input type='hidden' name='x_country' 			value='US'>
<input type='hidden' name='x_phone' 			value='111-111-1111'>
<input type='hidden' name='x_zip' 				value='92030'>
<input type='hidden' name='x_email' 			value='youremail@test.com'>
<input type='hidden' name='x_cust_id' 			value='123'>
<input type='hidden' name='x_ship_to_first_name' 	value='Tim'>
<input type='hidden' name='x_ship_to_last_name' 	value='Q'>
<input type='hidden' name='x_ship_to_company' 		value='Test Company 2'>
<input type='hidden' name='x_ship_to_address' 		value='789 Montgomery'>
<input type='hidden' name='x_ship_to_city' 			value='California City'>
<input type='hidden' name='x_ship_to_state'			value='CA'>
<input type='hidden' name='x_ship_to_country' 		value='US'>
<input type='hidden' name='x_ship_to_zip'			value='92082'>
<input type='hidden' name='x_header_html_payment_form'	value="Please click on the 'Complete Your Order' button after your payment is completed.">
<input type='hidden' name='x_footer_html_payment_form'	value="Footer HTML">

<input type= "hidden" name = "user_value_1"					value  = "custom value 1">
<input type= "hidden" name = "user_value_2"					value  = "custom value 2">
</form>
response.php
<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";

$x_response_code   =      $_POST['x_response_code'];
if($x_response_code == 1){
  // SUCCESS
  // do insert record
}
else{
	// ERROR
	echo "There was a problem with your transaction.";
}
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

1 Comment

  1. avatarQasim

    good work man!

Leave a Comment

Your email address will not be published. Required fields are marked *