Handling relay response using PHP

The Relay Response sample code below shows how the merchant could respond upon receiving the transaction results from E-xact.  In this PHP example, the developer would change each merchant.com placeholder URL to the merchant's absolute URL equivalent.

<!DOCTYPE html
   PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Receipt</title>
<script type="text/javascript" src="http://merchant.com/javascript.js" ></script>
<link rel="stylesheet" href="http://merchant.com/style.css" type="text/css" />
</head>
<body>
<h1>Merchant.com Online Store</h1>

<h2>
<?php echo $_REQUEST['x_response_reason_text'] ?>
</h2>

<?php
 if ($_REQUEST['x_response_code'] == '1') {
   echo "<p>";
   echo "Your order was processed successfully. Here is your receipt.";
   echo "Your order will be shipped in two business days.";
   echo "</p>";
   echo "<pre>";
   echo $_REQUEST["exact_ctr"];
   echo "</pre>";
   if (!empty($_REQUEST["exact_issname"])) {
     echo "<p>";
     echo "Issuer: " .$_REQUEST["exact_issname"] . "<br/>";
     echo "Confirmation Number: " . $_REQUEST["exact_issconf"];
     echo "</p>";
   }
   echo "<p>";
   $track_url = "http://merchant.com/order_tracking/" . $_REQUEST["x_invoice_num"];
   echo "You can track it at <a href=\"" . $track_url . "\">" .
$track_url . "</a>";
   echo "</p>";
 } elseif ($_REQUEST['x_response_code'] == '2') {
   echo "<p>";
   echo "Your payment failed.";
   echo "Here is your receipt.";
   echo "</p>";
   echo "<pre>";
   echo $_REQUEST["exact_ctr"];
   echo "</pre>";
 } else {
   echo "<p>";
   echo "An error occurred while processing your payment.";
   echo "Please try again later.";
   echo "</p>";
 }
?>
</body>
</html>
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk