Reply
Member
Posts: 4
Registered: ‎01-17-2012

DPM - Response array empty and no error codes on receipt page

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']);
}

?>

 

Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: DPM - Response array empty and no error codes on receipt page

I think you're confusing test mode and sandbox. Setting the account to test mode means that nothing is going to simulate terribly well. Setting the last argument of getCreditCardForm() to false just means that you're submitting to the production URL (which makes sense since you're using a production account). If you want to test code, get a developer (also known as sandbox) account, set it to live mode, and then use that login ID and trans key and set the last argument of getCreditCardForm() to true. If it still doesn't work properly, let me know.

Member
Posts: 4
Registered: ‎01-17-2012

Re: DPM - Response array empty and no error codes on receipt page

TJPride,

 

Thank you for your reply.  I created a test account (it is in live mode) and changed the api login id. transaction key values and removed the false argument from the getCreditCardForm() function.  The results are the same as the production account, I end up with a error on the receipt page with no error code or reason text.  The only difference is that I can now see the transaction posted in the reports->unsettled transactions area of the account and all the data I submitted is correct there.

Highlighted
Member
Posts: 4
Registered: ‎01-17-2012

Re: DPM - Response array empty and no error codes on receipt page

Ok, I uploaded the same files to a different server and it is giving me response codes and reasons.  I was able to send successful transactions and receive errors for incorrect credit cards etc.  So this appears to be an issue with the server.  What do I need to do to make sure all the settings on the server are correct?  I know it said port 80 needs to be open, I am not sure how to test for that, but from what I've read, http is access through there, so if I can access the pages authorize.net needs in my browser that should be ok, right?  Anything else I need to check for?

 

Thank you.

Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: DPM - Response array empty and no error codes on receipt page

And if you log print_r($response, true) to a file on the relay response page, it still doesn't give you any useful data? It's hard to diagnose the problem without any error messages. Authorize.net is obviously communicating with the server if it's making it to the receipt page.

Member
Posts: 4
Registered: ‎01-17-2012

Re: DPM - Response array empty and no error codes on receipt page

Thanks again TJPride for your help.

 

I believe I found the solution.  It was an .htaccess problem on the server that was interfering.  The test account is working now so I will begin implementing the live version soon.