cancel
Showing results for 
Search instead for 
Did you mean: 

Redirect Problems - DPM & PHP

Folks,

 

I have searched the boards and not found this exact problem, and I've looked at my code multiple times and not found the errors, so I thought I might ask for help.

 

I've created the files (checkout_form.php, relay_response.php, order_receipt.php & CR_response.php [my receipt display code]) and submitted purchases on the test system and received approved purchase email confirmation of these purchases.  But the relay continually sends the browser back to the home page of my directory (index.php) and since it leaves https://test.authorize.net/gateway/transact.dll in the browser URL I don't know if any arguments are coming through.

 

If I paste the redirect URL as I set it in the code into a browser window it goes to the correct page and lists the expected error (there are no arguments so it has errors).  Ditto with the receipt page.  So I know these are valid URLs that are passed to Authorize.Net.  But there are no diagnostics coming up that I can debug by.  I tried replacing the line:

echo AuthorizeNetDPM::getRelayResponseSnippet( $redirect_url );

 

with

echo $redirect_url;

 

to see what the redirected URL coming back is, but it was never executed.

 

Removing the wrappers (page formating) here is the code:

 

checkout_form.php

                    <?php
                      $relay_response_url = "http://MyHomeURL/relay_response.php"; // Response File
                      $api_login_id = 'xxxx';
                      $transaction_key = 'xxxxxx';
                      $amount = dbldec( $cost );
$transaction_key<br />";
                      echo AuthorizeNetDPM::getCreditCardForm( $amount, $transaction_number, $relay_response_url, $api_login_id, $transaction_key );
                    ?>

 

 

 

relay_response.php
                    <?php
                      $redirect_url = "http://MyHomeURL/CR_receipt.php"; // Where the user will end up. 
                      $api_login_id = 'xxxx';
                      $md5_setting = ""; // Your MD5 Setting 
                      $response = new AuthorizeNetSIM($api_login_id, $md5_setting); 
                      if ($response->isAuthorizeNet()) 
                      { 
                        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; 
                        }
//                        echo $redirect_url;
                        // Send the Javascript back to AuthorizeNet, which will
                        // redirect user back to your site. 
                        echo AuthorizeNetDPM::getRelayResponseSnippet( $redirect_url ); 
                      } 
                      else 
                      { 
                        echo "Error. Check your MD5 Setting."; 
                      }
                    ?>

 

 

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

 

 

 

CR_receipt.php

                    <?php
                      if ( $_GET['response_code'] == 1 ) 
                      {
                        $trans = $_GET['transaction_id'];
                        echo "Thank you for your purchase! Transaction id: $trans<br />";
                        // DB processing of transaction & user receipt formatting
                        ...
                        // end processing
                      } 
                      else 
                      {
                        $reason = $_GET['response_reason_text'];
                        echo "Sorry, an error occurred: " . $reason; 
                      }
                    ?>

 

 

I would appreciate any insights you can give me.

 

Thanks.

 

Tom Condon

 

condonia13
Member
1 ACCEPTED SOLUTION

Accepted Solutions

Problem resolved.

 

In fact, it happened because I didn't read enough of the manual.  I had not set the default URL for redirect in the account setup, so the value I gave it was ignored as not being in that list.

 

Besides that, I had wrapped my code in relay_response.php in my usual web page wrapper.  Since the system was expecting this to be only what is needed to process the response code only, not what creates a pretty web page, it was choking on the extra html.  My bad.  Perhaps a note somewhere that the processing code is all that is allowed in the relay_response file is in order.  Or, if such does exist, a better display (bold caps larger font in color, maybe?) of that information.

 

Thanks.

View solution in original post

3 REPLIES 3

Have you look at the browser page source on your checkout_form.php before you submit the form?

Check to see if x_relay_url is set correctly?

RaynorC1emen7
Expert

x_relay_url is set correctly in the checkout_form.php page source.

Problem resolved.

 

In fact, it happened because I didn't read enough of the manual.  I had not set the default URL for redirect in the account setup, so the value I gave it was ignored as not being in that list.

 

Besides that, I had wrapped my code in relay_response.php in my usual web page wrapper.  Since the system was expecting this to be only what is needed to process the response code only, not what creates a pretty web page, it was choking on the extra html.  My bad.  Perhaps a note somewhere that the processing code is all that is allowed in the relay_response file is in order.  Or, if such does exist, a better display (bold caps larger font in color, maybe?) of that information.

 

Thanks.