I recently discovered that the ReasonCode was not properly exposed on in the C# SDK's version of a transaction response. The fix ended up being a palm to forehead moment for me. Here it is!
Let's take an overly simplified transaction request...
private void GetResponse(string profileID, string paymentProfileID, string shippingAddressID)
{
Order order = new Order(profileID, paymentProfileID, shippingAddressID);
//Build the order
var response = AuthAndCapture(order);
string reasonCode = response.ReasonCode; << IMPOSSIBLE! :(
}
private IGatewayResponse AuthAndCapture(Order order)
{
var req = new createCustomerProfileTransactionRequest();
var trans = new profileTransAuthCaptureType();
//Build the request
var response = (createCustomerProfileTransactionResponse)_gateway.Send(req);
return new GatewayResponse(response.directResponse.Split(','));
}
The response in GetResponse() will not contain contain the result code and result text, but not the reason code. This works just fine if the transaction is successful, but quite a hassle if it is not.
Open the GatewayResponse.cs class in the AIM > Responses directory of the SDK and insert the follwing property into the existing list:
public string ReasonCode {
get {
return ParseResponse(2);
}
}
Next open the IGatewayResponse.cs interface in the same directory and add the following property:
string ReasonCode { get; }
Now the GetResponse() method has access to the ReasonCode! Huzzah!
private void GetResponse(string profileID, string paymentProfileID, string shippingAddressID)
{
Order order = new Order(profileID, paymentProfileID, shippingAddressID);
//Build the order
var response = AuthAndCapture(order);
string reasonCode = response.ReasonCode;
}
08-24-2012 12:14 PM