Reply
Highlighted
Contributor
Posts: 20
Registered: ‎11-06-2012

DPM - Custom Receipt Page

I am using ASP .NET and have everything working up to the point of the receipt page. I took the asp example and converted it to .NET but I get a "Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.<br>Inner: Object reference not set to an instance of an object." when accessing the Request.Form variables.

 

Any ideas?

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: DPM - Custom Receipt Page

which variable? or are you looping thru what is in the Request.Form?

Highlighted
Contributor
Posts: 20
Registered: ‎11-06-2012

Re: DPM - Custom Receipt Page

It seems like all of them, but at this time I have everything commented out but this one and am getting the error.

 

Request.Form["x_response_code"]

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: DPM - Custom Receipt Page

You mean the receipt page as in the relay response page?

Highlighted
Contributor
Posts: 20
Registered: ‎11-06-2012

Re: DPM - Custom Receipt Page

Yes, that is what I mean. That is where I am trying to display the receipt for the customer to print. Is that not the correct place to do this?

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: DPM - Custom Receipt Page

So it getting the Error message?

 

An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is a result of the attempt to charge your credit card.

 

 

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: DPM - Custom Receipt Page

Are you trying to run the page without post anything to it?

Highlighted
Contributor
Posts: 20
Registered: ‎11-06-2012

Re: DPM - Custom Receipt Page

No, I am not getting that error - "An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is a result of the attempt to charge your credit card."

 

I am getting an object reference error from .NET, I believe because the Request variable is null. The payment gets posted to the Authorize .NET account (developer - test account) correctly. The only issue seems to be in getting the information returned from Authorize .NET to show the receipt on screen to the client.

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: DPM - Custom Receipt Page

Can you post the code that you changed to make it c#.

Highlighted
Contributor
Posts: 20
Registered: ‎11-06-2012

Re: DPM - Custom Receipt Page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Thanks.aspx.cs" Inherits="Public_Registration_Secure_Authorize_Thanks" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%
    //Response.Expires = 0;

    string ResponseCode, ResponseReasonText, ResponseReasonCode, ResponseSubcode, AVS, ReceiptLink, TransID;
    string Amount, AuthCode, Description, InvoiceID, BillingInfo;
    
    // Retrieving and defining Form Data from Post command body from Authorize.Net
    ResponseCode = "1"; // Request.Form["x_response_code"].Trim();
    ResponseReasonText = "reason-text"; // Request.Form["x_response_reason_text"].Trim();
    ResponseReasonCode = "reason-code"; // Request.Form["x_response_reason_code"].Trim();
    AVS = "avs"; // Request.Form["x_avs_code"].Trim();
    TransID = "0"; // Request.Form["x_Trans_ID"].Trim();
    AuthCode = "auth-code"; // Request.Form["x_Auth_Code"].Trim();
    Amount = "amount"; // Request.Form["x_Amount"].Trim();
    ReceiptLink = "http://www.authorizenet.com";
    Description = "description";
    InvoiceID = "1";
    BillingInfo = "John Doe<br />123 Main St<br />Somewhereville, XX 99999<br />email@email.com<br />555-555-5555";    
    // Print a receipt page
%>

    <html>
        <head>
            <title>Transaction Receipt Page</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <style type="text/css">
                table td {padding-left:10px;}
            </style>
        </head>
        <body bgcolor="#FFFFFF">

        <% // Test to see if this is a test transaction.
            if (TransID == "0" && ResponseCode == "1")
            {
                // If so, print it to the screen, so we know that the transaction will not be processed. %>
    
                <table align="center">
                    <tr>
                        <th><font size="5" color="red" face="arial">TEST MODE</font></th>
                    </tr>                                                
                    <tr>
                        <th valign="top"><font size="1" color="black" face="arial">This transaction will <u>NOT</u> be processed because your account is in Test Mode.</font></th>
                    </tr>
                </table>                
        <% } %>
        <br />
        <br />
        <table style="width:600px;">
                
        <% // Test to see if the transaction resulted in Approval, Decline or Error
            switch (ResponseCode)
            {
                case "1": %>
            
                <tr>
                    <td colspan="2" style="font-size:14pt;color:#000000;text-align:center;">Thank you for your order!</td>
                </tr>

        <%      break;
                case "2": %>

                <tr>
                    <td colspan="2" style="font-size:14pt;color:#000000;text-align:center;">This transaction has been declined.</td>
                </tr>

        <%      break;
                default: %>

                <tr>
                    <td colspan="2" style="font-size:14pt;color:#000000;text-align:center;">There was an error processing this transaction.</td>
                </tr>
            
        <%      break;
                }        %>

            <tr>
                <td colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" style="background-color:#ccc;font-size:12pt;font-weight:bold;">Order Information</td>
            </tr>
            <tr>
                <td>Transaction ID:</td>
                <td>

                    <% switch (TransID)
                       {
                           case "0":
                                Response.Write("Not Applicable.");
                                break;
                           default:
                                Response.Write(TransID);
                                break;
                       }
                    %>   
                </td>
            </tr>
            <tr>
                <td>Authorization Code:</td>
                <td>

                    <% switch (AuthCode)
                       {
                           case "000000":
                                Response.Write("Not Applicable.");
                                break;
                           default:
                                Response.Write(AuthCode);
                                break;
                       }
                    %>

                </td>
            </tr>            
            <tr>
                <td>Description:</td>
                <td><%= Description %></td>
            </tr>
            <tr>
                <td>Invoice #:</td>
                <td><%= InvoiceID %></td>
            </tr>
            <tr>    
                <td style="width:175px;">Amount:</td>
                <td>$<%= Amount %></td>
            </tr>            
            <tr>
                <td colspan="2" style="background-color:#ccc;font-size:12pt;font-weight:bold;">Billing Information</td>
            </tr>
            <tr>
                <td colspan="2"><%= BillingInfo %></td>
            </tr>           
            <tr>
                <td colspan="2" style="background-color:#ccc;font-size:12pt;font-weight:bold;">Verification Information</td>
            </tr>
            <tr>
                <td>Response Reason:</td>
                <td>(<%= ResponseReasonCode %>)&nbsp;<%= ResponseReasonText %></td>
            </tr>
            <tr>    
                <td>Address Verification:</td>
                <td>

                    <% // Turn the AVS code into the corresponding text string.
                        switch (AVS)
                        {
                            case "A":
                                Response.Write("Address (Street) matches, ZIP does not.");
                                break;
                            case "B":
                                Response.Write("Address Information Not Provided for AVS Check.");
                                break;
                            case "C":
                                Response.Write("Street address and Postal Code not verified for international transaction due to incompatible formats. (Acquirer sent both street address and Postal Code.)");
                                break;
                            case "D":
                                Response.Write("International Transaction:  Street address and Postal Code match.");
                                break;
                            case "E":
                                Response.Write("AVS Error.");
                                break;
                            case "G":
                                Response.Write("Non U.S. Card Issuing Bank.");
                                break;
                            case "N":
                                Response.Write("No Match on Address (Street) or ZIP.");
                                break;
                            case "P":
                                Response.Write("AVS not applicable for this transaction.");
                                break;                                
                            case "R":
                                Response.Write("Retry. System unavailable or timed out.");
                                break;
                            case "S":
                                Response.Write("Service not supported by issuer.");
                                break;
                            case "U":
                                Response.Write("Address information is unavailable.");
                                break;
                            case "W":
                                Response.Write("9 digit ZIP matches, Address (Street) does not.");
                                break;
                            case "X":
                                Response.Write("Address (Street) and 9 digit ZIP match.");
                                break;
                            case "Y":
                                Response.Write("Address (Street) and 5 digit ZIP match.");
                                break;
                            case "Z":
                                Response.Write("5 digit ZIP matches, Address (Street) does not.");
                                break;
                            default:
                                Response.Write("The address verification system returned an unknown value.");
                                break;
                        }
                    %>

                </td>
            </tr>
        </table>
    </body>
</html>