Hello,
I am trying to use the Direct Post Method but am having no luck. I have kept the code as close to the manual as possible to try for a successful transaction, but it is still not working. I have done a print_r($response); on relay_response.php and all the values are blank except for the api login id field. When it gets to the receipt_page.php it goes to receipt_page.php it only displays "Sorry, an error occurred:" with no reason or error code and the url fields are blank ( http://www.mydomain.com/receipt_page.php?response_code=&response_reason_text= ). Any help is much appreciated.
Here is my code for the 3 pages:
checkout_form.php
<?php require_once 'shoppingcart/AuthorizeNet.php';
$relay_response_url = "http://mydomain.com/relay_response.php";
$api_login_id = 'abababababab';
$transaction_key = 'abababababababab';
$amount = "5.99";
$fp_sequence = "123";
echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $relay_response_url,$api_login_id, $transaction_key, false);
/*
I set last variable to false so that the form will POST to Auth.Net's secure form instead of the test form, as I have a live account (although the account is in test mode at the moment).
*/
?>
relay_responst.php
<?php require_once 'shoppingcart/AuthorizeNet.php'; // The SDK
$redirect_url = "http://mydomain.com/receipt_page.php"; //Where the user will end up.
$api_login_id = 'ababababab';
$md5_setting = ""; // Your MD5 Setting
$response = new AuthorizeNetSIM($api_login_id, $md5_setting);
/*
Note: I do have a MD5 setting set in the account settings, but will not use it so I removed the if ($response->isAuthorizeNet()) portion
*/
if ($response->approved)
{
// Do your processing here.
$redirect_url .= '?response_code=1&transaction_id='.$response->transaction_id;
}
else
{
$redirect_url .= '?response_code='.$response->response_code.'&response_reason_text=' . $response->response_reason_text;
}
// Send the Javascript back to AuthorizeNet, which will redirect user back to your site.
echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url);
?>
receipt_page.php
<?php
if ($_GET['response_code'] == 1)
{
echo "Thank you for your purchase! Transaction id: ".htmlentities($_GET['transaction_id']);
}
else
{
echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']);
}
?>