This guide is intended for use by developers who are not using existing shopping cart software, and are looking for the quickest and easiest way to code a custom solution for use with Payment Pages. This document will not cover the creation of a shopping cart or "Buy Now" button, just the payment process itself.
The Payment Form
The first thing you'll need to set up is the payment form on the site. The example HTML form code below only contains the essential fields required for a valid transaction; additional fields are available for use and can be referenced here. Note that if you'd like to use Relay Response, additional fields are required. Otherwise the Return Link Method defined in the Receipt Page settings area of the Payment Pages interface will be used.
<form method="post" action="https://checkout.e-xact.com/payment">
<input type="hidden" name="x_login" value="WSPTEST001" /> <!-- Payment Page ID located in the Payment Pages administration interface -->
<input type="hidden" name="x_fp_sequence" value="1337" /> <!-- Random number used in the x_fp_hash calculation -->
<input type="hidden" name="x_fp_timestamp" value="1287098097" /> <!-- Current UTC timestamp -->
<input type="hidden" name="x_currency_code" value="USD" />
<!--
The x_currency_code field isn’t actually required, but is here for clarity.
By default, the currency defined in the Payment Page administration interface will be used.
If you are specifying a currency code, it must also be used in the x_fp_hash calculation (see the PHP example below).
-->
<input type="hidden" name="x_amount" value="19.95" /> <!-- Order amount -->
<input type="hidden" name="x_fp_hash" value="0688a6886e25775ddf6b2947b578f793" /> <!-- Calculated hash value -->
<input type="hidden" name="x_show_form" value="PAYMENT_FORM" /> <!-- Required to stay compatible with the Authorize.net protocol -->
<input type="submit" name="checkout" value="Checkout with E-xact Now" />
</form>
So, if you were setting up the above form in PHP, your script might look something like this:
<form method="post" action="https://checkout.e-xact.com/payment">
<!--
NOTE: if you're using a DEMO account, the form should post here:
https://rpm.demo.e-xact.com/payment
-->
<input type="hidden" name="x_login" value="<?php echo $pageid = 'WSPTEST001'; ?>" />
<input type="hidden" name="x_fp_sequence" value="<?php echo $sequence = rand(1,9999); ?>" />
<input type="hidden" name="x_fp_timestamp" value="<?php echo $timestamp = time(); ?>" />
<input type="hidden" name="x_currency_code" value="<?php echo $currency = 'USD'; ?>" />
<input type="hidden" name="x_amount" value="<?php echo $amount = 19.95; ?>" />
<input type="hidden" name="x_fp_hash" value="<?php echo hash_hmac("md5", $pageid . "^" . $sequence . "^" . $timestamp . "^" . $amount . "^" . $currency, $key = 'KJsk~87HOljEpJFK0Njl0KT2'); ?>" />
<!--
The $key variable is set to the Transaction Key, which can be
located on the Security tab when viewing an individual Payment Page
in the Payment Pages administration interface.
NOTE: it's insecure and unnecessary to send the transaction key as its
own form variable, so make sure this isn't included in your form markup.
-->
<input type="hidden" name="x_show_form" value="PAYMENT_FORM" />
<input type="submit" name="checkout" value="Checkout with E-xact Now" />
</form>
At this point, you should be able to submit payments successfully. However, you won't be able to do anything with returned transaction data unless you write a handler for that.
The Handler
A very basic handler written in PHP might look like this:
<?php
if ($_REQUEST['x_response_code'] == '1') { echo 'Your payment was successful'; }
elseif ($_REQUEST['x_response_code'] == '2') { echo 'Your payment was declined'; }
elseif ($_REQUEST['x_response_code'] == '3') { echo 'Your payment encountered an error'; }
?>
This handler will perform different actions based on the response it receives from E-xact: whether a transaction was successful, declined, or encountered an error during processing. You'll likely want to do more than just print text to the browser though - you can make use of the returned data to update your inventory database, empty the customer's shopping cart, send out notification emails, and so on. A list of the returned variables can be found here.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article