cancel
Showing results for 
Search instead for 
Did you mean: 

C# code works in test but not live

I've got the following:

 

<div id="AuthorizeDiv" style="visibility:collapse" runat="server">
                                        <%=AuthorizeNet.Helpers.CheckoutFormBuilders.CreditCardForm(false) %>
                                    </div>

    IGateway OpenGateway()
        {
            //we used the form builder so we can now just load it up
            //using the form reader
            var login = ConfigurationManager.AppSettings["ApiLogin"];
            var transactionKey = ConfigurationManager.AppSettings["TransactionKey"];

            var gate = new Gateway(login, transactionKey, false);
            return gate;
        }

var gate = OpenGateway();

                //build the request from the Form post
                var apiRequest = CheckoutFormReaders.BuildAuthAndCaptureFromPost();

                apiRequest.Queue(ApiFields.Amount, OrderTotal.ToString());

                //send to Auth.NET
                var response = gate.Send(apiRequest);

                string code = response.ResponseCode;

                if (code.Length > 0 && code != "1")
                {
                    throw new Exception("Error processing Authorize.net transaction. Error code: " + code + " - " + response.Message);
                }
                else
                {
                    if (!response.Approved)
                    {
                        throw new Exception("Authorize.net transaction not approved. Error code: " + code + " - " + response.Message);
                    }
                }

 Am I just missing something or misunderstanding something about how this works?

Machaira
Member
7 REPLIES 7

error compiling? response code 3?

RaynorC1emen7
Expert

No compilation errors and no response codes when calling the code. It never shows on the list of transactions that have gone through though.

 

Is there some way to test live code that I'm not aware of? None of the testing tools help.

If the live account is in testmode. Transaction will not get save.

so code is blank?

string code = response.ResponseCode;

 

 

 

It's not in test mode. No exceptions are thrown so the code is blank.

 

This shouldn't be this difficult IMO. I would think it would just work. :(

var response = gate.Send(apiRequest);

response is blank too?

The object is not null and the response.Approved property is true. 

That default to true.

I would said it erroring trying to connect to https://secure.authorize.net/gateway/transact.dll

but debug the code to be sure.