Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:18:27+00:00 2026-06-07T12:18:27+00:00

After playing around with the Authorize.Net CIM XML API C# sample code , I

  • 0

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'.

enter image description here

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

Update:

Proof that CIM can store bank account information:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:18:29+00:00Added an answer on June 7, 2026 at 12:18 pm

    The following is tested, but only so far as what the original question brought up (Test it more for me?), I wrote it using the provided XML example and by copying the code for the AddCreditCard code.

    When you are all done updating the following code will work:

            var cg = new CustomerGateway("login", "transkey", ServiceMode.Test);
            var c = cg.CreateCustomer("peter@example.com", "test customer");
            //just to show that we didn't break CC
            cg.AddCreditCard(c.ProfileID, "cc#", 07, 2011);
            cg.AddBankAccount(c.ProfileID, "Peter", "bankaccoung#", "routing#");
            //tostring doesn't actually do much... but if you break on it you can see the details for both the CC and the bank info.
            foreach (PaymentProfile pp in cg.GetCustomer(c.ProfileID).PaymentProfiles)
            {
                Console.WriteLine(pp.ToString());
            }
    

    First, download the C# source code for the API from http://developer.authorize.net/downloads/.

    In reviewing the code I can see 4 files that use “creditCardType”, these are SubscriptionRequest.cs, CustomerGateway.cs, PaymentProfile.cs and AnetApiSchema.cs (this last one we don’t have to touch). We also need to watch out for ‘creditCardMaskedType’, which is used in PaymentProfile.cs, Transaction.cs and AnetApiSchema.cs. Any place these files show up we need to make sure we support the bankAccount equivelants as well.

    Open the AuthorizeNET solution. We’ll be jumping around a bit through the files listed above.

    In CustomerGateway.cs add the following block of code:

        /// <summary>
        /// Adds a bank account profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddBankAccount(string profileID, string nameOnAccount, string accountNumber, string routingNumber)
        {
            var req = new createCustomerPaymentProfileRequest();
            req.customerProfileId = profileID;
            req.paymentProfile = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();
    
            bankAccountType new_bank = new bankAccountType();
            new_bank.nameOnAccount = nameOnAccount;
            new_bank.accountNumber = accountNumber;
            new_bank.routingNumber = routingNumber;
    
            req.paymentProfile.payment.Item = new_bank;
    
            var response = (createCustomerPaymentProfileResponse)_gateway.Send(req);
    
            return response.customerPaymentProfileId;
        }
    

    In PaymentProfile.cs add some public properties

        public string BankNameOnAccount {get; set; }
        public string BankAccountNumber { get; set; }
        public string BankRoutingNumber { get; set; }
    

    Modify the the following block of the PaymentProfile(customerPaymentProfileMaskedType apiType) constructor:

            if (apiType.payment != null) {
                if(apiType.payment.Item is bankAccountMaskedType) {
                    var bankAccount = (bankAccountMaskedType)apiType.payment.Item;
                    this.BankNameOnAccount = bankAccount.nameOnAccount;
                    this.BankAccountNumber = bankAccount.accountNumber;
                    this.BankRoutingNumber = bankAccount.routingNumber;
                }
                else if (apiType.payment.Item is creditCardMaskedType)
                {
                    var card = (creditCardMaskedType)apiType.payment.Item;
                    this.CardType = card.cardType;
                    this.CardNumber = card.cardNumber;
                    this.CardExpiration = card.expirationDate;
                }
            }
    

    Add this block to the PaymentProfile.ToAPI() method:

            if (!string.IsNullOrEmpty(this.BankAccountNumber))
            {
                bankAccountType new_bank = new bankAccountType();
                new_bank.nameOnAccount = BankNameOnAccount;
                new_bank.accountNumber = BankAccountNumber;
                new_bank.routingNumber = BankRoutingNumber;
    
                result.payment.Item = new_bank;
            }
    

    Add the following public properties to SubscriptionRequest.cs > SubscriptionRequest class (around line 187)

        public string BankNameOnAccount {get; set; }
        public string BankAccountNumber { get; set; }
        public string BankRoutingNumber { get; set; }
    

    Add the following else if block TWICE to SubscriptionRequest. The first time is in the ToAPI method, the second is in the ToUpdateableAPI method, in both cases it goes after the CC number null check.

            else if (!String.IsNullOrEmpty(this.BankAccountNumber))
            {
                bankAccountType new_bank = new bankAccountType();
                new_bank.nameOnAccount = BankNameOnAccount;
                new_bank.accountNumber = BankAccountNumber;
                new_bank.routingNumber = BankRoutingNumber;
    
                sub.payment = new paymentType();
                sub.payment.Item = new_bank;
            }
    

    Add the following public properties to Transaction.cs

        public string BankNameOnAccount { get; set; }
        public string BankAccountNumber { get; set; }
        public string BankRoutingNumber { get; set; }
    

    In Transaction.cs in the static NewFromResponse(transactionDetailsType trans) method, find the block that checks for trans.payment != null and tweak as shown:

            if (trans.payment != null) {
                if (trans.payment.Item.GetType() == typeof(creditCardMaskedType))
                {
                    var cc = (creditCardMaskedType)trans.payment.Item;
                    result.CardNumber = cc.cardNumber;
                    result.CardExpiration = cc.expirationDate;
                    result.CardType = cc.cardType;
                } 
                else if (trans.payment.Item.GetType() == typeof(bankAccountMaskedType))
                {
                    var bankAccount = (bankAccountMaskedType)trans.payment.Item;
                    result.BankNameOnAccount = bankAccount.nameOnAccount;
                    result.BankAccountNumber = bankAccount.accountNumber;
                    result.BankRoutingNumber = bankAccount.routingNumber;
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT - After playing around with a bunch of potential solutions (using backgroundworker and
i am going to be coding an api, and after playing around with the
I just started playing around with MASM styled assembly and after playing around long
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>
Update: After playing around with this for a few hours, went with a multi-query
I am in the process of creating a synthesiser for iOS. After playing around
After installing Monobjc and playing around with the Monobjc Application Project under C# in
Alright, so after a few hours of me playing around to no avail, I
I'm still learning python and after playing around with pygame I noticed I'm re-importing
I'm new with AppFabric Server caching but after playing around with it everything has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.