cancel
Showing results for 
Search instead for 
Did you mean: 

Exception thrown using C# AIM dll on gateway request send

We are using the AIM C# dll provided with the following code:

 

                        request = new CardPresentAuthorizationRequest(pd.Amount, pd.Track1Data.StringNull(), pd.Track2Data.StringNull());
request.TestRequest = (pd.TestTransaction ? "1" : string.Empty);
                    request.AddMerchantValue("x_market_type", "2");
                    request.AddMerchantValue("x_device_type", "5");
                    var gateway = new Gateway(loginID, transactionKey, testGateway);
                    var response = gateway.Send(request);

Initially we were getting an "invalid market type" error which is why we added the two AddMerchantValue requests (after speaking with someone over the phone), then after we add them we get what looks like a valid post and response but an exception is thrown on the gateway.Send(request) method.  If the testrequest is not set to 1 then the transaction goes through, while an exception is still thrown.

 

Exception information:

[9/19/2013 2:40:39 PM]
Message: There was an error returned from AuthorizeNet: <?xml version="1.0" ?><response><ResponseCode>1</ResponseCode><Messages><Message><Code>1</Code><Description><![CDATA[This transaction has been approved.]]></Description></Message></Messages><AuthCode><![CDATA[000000]]></AuthCode><AVSResultCode>P</AVSResultCode><CVVResultCode></CVVResultCode><TransID>0</TransID><RefTransID></RefTransID><TransHash>[REMOVED FOR FORUM POST]</TransHash><TestMode>1</TestMode><UserRef></UserRef><AccountNumber>[REMOVED FOR FORUM POST]</AccountNumber><AccountType>American Express</AccountType></response>; this usually means your data sent along was incorrect. Please recheck that all dates and amounts are formatted correctly
Exception Type: System.IO.InvalidDataException
Source: AuthorizeNet
Stack Trace:    at AuthorizeNet.Gateway.DecideResponse(String[] rawResponse)
   at AuthorizeNet.Gateway.Send(IGatewayRequest request, String description)
   at AuthorizeNet.Gateway.Send(IGatewayRequest request)
   at Mitas.RCI.utils.RCIAuthorize.ProcessTransaction(PaymentDetails pd) in c:\mitas\sourcen\RCI\Projects\RCI3411\RCIAuthorize.cs:line 165
   at Mitas.IS.ScreenIO.IS549.BeforeInsertToDatabase() in C:\mitas\sourcen\IS\ScreenIO\IS549.cs:line 98
   at Mitas.Data.MitasDataObject.GenericInsert() in C:\mitas\sourcen\Framework\MitasData\MitasDataObject.cs:line 456

 

Using Fiddler we can see the raw request post data&colon;

x_delim_data=TRUE&x_delim_char=%7c&x_relay_response=FALSE&x_method=CC&x_type=AUTH_ONLY&x_track1=[REMOVED FOR FORUM POST]&x_track2=[REMOVED FOR FORUM POST]&x_amount=0.01&x_test_request=1&x_market_type=2&x_device_type=5&x_login=[REMOVED FOR FORUM POST]&x_tran_key=[REMOVED FOR FORUM POST]&x_description=

 

And the raw response:

<?xml version="1.0" ?><response><ResponseCode>1</ResponseCode><Messages><Message><Code>1</Code><Description><![CDATA[This transaction has been approved.]]></Description></Message></Messages><AuthCode><![CDATA[000000]]></AuthCode><AVSResultCode>P</AVSResultCode><CVVResultCode></CVVResultCode><TransID>0</TransID><RefTransID></RefTransID><TransHash>[REMOVED FOR FORUM POST]</TransHash><TestMode>1</TestMode><UserRef></UserRef><AccountNumber>[REMOVED FOR FORUM POST]</AccountNumber><AccountType>American Express</AccountType></response>

 

It's worth noting that on a test account sending a card not present AuthorizationRequest object, without the market/device type flags using the test credit card number provided in the setup email we are able to get a response object without the exception being thrown.

 

Thank you for your assistance.

Mitas
Member
2 REPLIES 2

Look like you are using the wrong gateway. There are CardPresentGateway

RaynorC1emen7
Expert

 

Exception throwing sample......How to throw exception

 

Rampt

rampatter
Member