cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

CIM Transction Method Response Problem

Hi,
 
 
We are using CIM Transction method to invoice exist user using windows service.
Its failed to make the transaction and its does't return any error code in following code
 
 
 InsertSIMLog("LOG", "Message: " + ErrorResponse.messages.message[0].text, "Code: " + ErrorResponse.messages.message[0].code);
 
 
Error Message:: object reference not set to an instance

 

 

Thanks

Balaji

balajim
Member
3 REPLIES 3

What is the raw response?

object reference not set to an instance is as generic as anything.

RaynorC1emen7
Expert

Can i use this method in windows service ?

 

public static bool CreateTransaction(long profile_id, long payment_profile_id)
{
bool out_bool = false;

createCustomerProfileTransactionRequest request = new createCustomerProfileTransactionRequest();
XmlAPIUtilities.PopulateMerchantAuthentication((ANetApiRequest)request);

profileTransactionType new_trans = new profileTransactionType();

profileTransAuthOnlyType new_item = new profileTransAuthOnlyType();
new_item.customerProfileId = profile_id.ToString();
new_item.customerPaymentProfileId = payment_profile_id.ToString();
new_item.amount = 1.00m;

orderExType order = new orderExType();
order.invoiceNumber = "inv" + (DateTime.Now.Ticks % int.MaxValue).ToString();
order.description = "Example item";
new_item.order = order;

new_trans.Item = new_item;
request.transaction = new_trans;

System.Xml.XmlDocument response_xml = null;
bool bResult = XmlAPIUtilities.PostRequest(request, out response_xml);
object response = null;
createCustomerProfileTransactionResponse api_response = null;

if (bResult) bResult = XmlAPIUtilities.ProcessXmlResponse(response_xml, out response);
if (!(response is createCustomerProfileTransactionResponse))
{
ANetApiResponse ErrorResponse = (ANetApiResponse)response;
Console.WriteLine(String.Format("Created Transaction\n code: {0}\n msg: {1}", ErrorResponse.messages.message[0].code, ErrorResponse.messages.message[0].text));
return out_bool;
}
if (bResult) api_response = (createCustomerProfileTransactionResponse)response;
if (api_response != null)
{
out_bool = true;
Console.WriteLine("Created Transaction " + api_response.directResponse);
Console.WriteLine(String.Format(" code: {0}\n msg: {1}", api_response.messages.message[0].code, api_response.messages.message[0].text));
}
return out_bool;
}

 

 

output: out_bool =false

 

ErrorResponse.messages.message[0].text

above line  am getting object reference not set to an instance.

you can't assume ErrorResponse.messages.message[0] object exist.

run a debug and see what response is