Now, in most shopping carts or order forms, an routine will exist for
checking the credit card and either successfully completing the checkout
process or returning an error. In whatever file this processing occurs, the
Anacom function must be included:
checking the credit card and either successfully completing the checkout
process or returning an error. In whatever file this processing occurs, the
Anacom function must be included:
<XMP>
<? include(“PostAnacom.php”); ?>
<? include(“PostAnacom.php”); ?>
and then called like this:
<?php
$result
= PostAnacom("1.00",
"12345",
"Michael Reynolds",
"123 Lakeview Drive",
"New York",
"NY",
"12345",
"USA",
"555-555-1212",
"[email protected]",
"sale",
"testaccount",
"1111111111111111",
"01",
"2002");
?>
</XMP>
After the customer information is passed to the function, the variable
$result will be an array which contains some information. The first array
element ($result[0]) will contain either the string “approved” or “error”.
Approved means that the card was successfully charged, and error means there
was a problem with the charge. The array elements that follow actually
contain more verbose information about the transaction, such as why the
charge was unsuccessful. If the credit card number was invalid or the charge
attempt was declined, this information will be contained in the additional
array elements. This is useful if visual feedback is desired to give some
information to the user regarding what happened. For instance, to return the
error message from Anacom to the browser in the event of a rejected
transaction, the following would work:
$result will be an array which contains some information. The first array
element ($result[0]) will contain either the string “approved” or “error”.
Approved means that the card was successfully charged, and error means there
was a problem with the charge. The array elements that follow actually
contain more verbose information about the transaction, such as why the
charge was unsuccessful. If the credit card number was invalid or the charge
attempt was declined, this information will be contained in the additional
array elements. This is useful if visual feedback is desired to give some
information to the user regarding what happened. For instance, to return the
error message from Anacom to the browser in the event of a rejected
transaction, the following would work:
<XMP>
</XMP>
<?php
if($result[0] == "error")
{
// error, return the error message
echo "There was an error processing your credit card. ";
echo "The error was:";
echo "<P>";
// print out the error message
for($i=0;$<count($result);$i++)
{
echo "$result[$i]";
}
echo
"</P>";
}
else
{
// success, do finishing stuff
}
?>
</XMP>
This is all that is needed to complete online credit card transactions using
PHP and Anacom.
PHP and Anacom.