Am trying to add a subscription to a previously created transaction using the C# API. The customer profile was created as part of the transaction. Confirmed that the transaction and customer profile were created as expected.
Before I can make an API call to create a subscription from a customer profile, I need to retrieve the customer profile ID and the payment profile ID from the transaction detail. However, when I call getTransactionDetailsController with the transaction ID, it returns a null profile object.
I'm new to the Auth.Net so I think I'm missing something simple. Here's the code:
static void GetTransactionCustomerProfileID(string transactionID,
out string customerProfileID,
out string customerPaymentProfileID)
{
customerProfileID = null;
customerPaymentProfileID = null;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
var request = new getTransactionDetailsRequest();
request.transId = transactionID;
// instantiate the controller that will call the service
var controller = new getTransactionDetailsController(request);
controller.Execute();
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transaction != null)
{
Console.WriteLine("Transaction Id: {0}", response.transaction.transId);
Console.WriteLine("Transaction type: {0}", response.transaction.transactionType);
Console.WriteLine("Transaction status: {0}", response.transaction.transactionStatus);
Console.WriteLine("Transaction auth amount: {0}", response.transaction.authAmount);
Console.WriteLine("Transaction settle amount: {0}", response.transaction.settleAmount);
// ==================== profile is NULL! =============================
customerProfileID = response.transaction.profile.customerProfileId; // profile is NULL!
customerPaymentProfileID = response.transaction.profile.customerPaymentProfileId;
}
}
else if (response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
return;
}