cancel
Showing results for 
Search instead for 
Did you mean: 

Add Bank Account Payment Profile Using C# SDK

After playing around with the Authorize.Net CIM XML API C# sample code, I started using the Authorize.Net C# SDK. I am able to add credit cards and bank accounts to customer profiles using the CIM XML API sample code. I don't see how to add bank accounts using the SDK though.

Adding bank account with CIM XML API:

...
customerPaymentProfileType new_payment_profile = new customerPaymentProfileType();
paymentType new_payment = new paymentType();

bankAccountType new_bank = new bankAccountType();
new_bank.nameOnAccount = "xyz";
new_bank.accountNumber = "4111111";
new_bank.routingNumber = "325070760";
new_payment.Item = new_bank;

new_payment_profile.payment = new_payment;

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

request.customerProfileId = profile_id.ToString();
request.paymentProfile = new_payment_profile;
request.validationMode = validationModeEnum.testMode;
...

Using the SDK I only see a `.AddCreditCard()` method, but no way to add a bank account. When I loop through all my `PaymentProfiles` It throws an exception when it comes across a bank account too:

CustomerGateway cg = new CustomerGateway("xxx", "yyy");

foreach (string cid in cg.GetCustomerIDs())
{
Customer c = cg.GetCustomer(cid);
foreach (PaymentProfile pp in c.PaymentProfiles)
{
Console.WriteLine(pp.ToString());
}
}

Exception:

Unable to cast object of type 'AuthorizeNet.APICore.bankAccountMaskedType' to type 'AuthorizeNet.APICore.creditCardMaskedType'.

 

 

How do I add a bank account to a CIM profile using the Authorize.Net C# SDK?

ghartsho
Member
5 REPLIES 5

Hi ghartsho,

 

Thanks for bringing this up. It looks like there may be an issue with the SDK. I'm forwarding this on to our development teams.

 

Thanks,

 

Michelle

Developer Community Manager

Michelle
All Star

I wrote up a little walk through on adding bank account support, it involves downloading the source code and modifying a number of files.  If you are interested check out http://stackoverflow.com/a/11475815/328968


@patricker1 wrote:

I wrote up a little walk through on adding bank account support, it involves downloading the source code and modifying a number of files.  If you are interested check out http://stackoverflow.com/a/11475815/328968


Thanks for the walkthrough on this.  Is there going to be a new version of the SDK released to reflect this change?  I have linked several SDK classes in my project and I try to avoid modifying these types of libraries as best practice.  

 

I'm using the version from Anet's download section.  anet_dotnet_sdk-1.7.1.zip - C#

Is this issue fixed? Im facing a similar problem while fetching the customer details using CIM api.

Hello @nik_0811 

 

Are you using the latest SDK from GitHub?

 

https://github.com/AuthorizeNet/sdk-dotnet

 

Richard