# Create a bank account payment source

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

This API adds a Direct Debit payment source for a customer. The bank account details collected from your customer are passed as input to this API.

#### [Automated Clearing House (ACH) Network](https://www.chargebee.com/docs/direct-debit-payments.html#direct-debit-payments-in-the-united-states)[](#automated-clearing-house-ach-network)

ACH is an electronic network for passing financial transactions in the US. Chargebee currently supports ACH via [Stripe](https://www.chargebee.com/docs/ach-payments-stripe.html) , [Authorize.Net](https://www.chargebee.com/docs/ach-payments-authorize_net.html), and [GoCardless](https://www.chargebee.com/docs/2.0/gocardless.html).

**Note:**

-   For ACH via Stripe, it is mandatory to pass [user details](/docs/api/advanced-features) such as IP address(`chargebee-request-origin-ip`) and the device information(`chargebee-request-origin-device`).

##### Bank account verification[](#bank-account-verification)

Once the bank account has been added, it needs to be verified.

-   For Stripe, perform this verification using the [Verify bank account payment source API](/docs/api/payment_sources/verify-bank-account-payment-source).
-   For [Authorize.net](https://www.authorize.net/), the verification is done by them in 2-3 days after the account is added. No intervention is needed from your side or your customer.

#### Single Euro Payment Area (SEPA)[](#single-euro-payment-area-sepa)

SEPA is an initiative that integrates bank transfer payments denominated in euro. It is supported via [GoCardless](https://www.chargebee.com/docs/gocardless.html), [Stripe](https://www.chargebee.com/docs/sepa-stripe.html) and [Adyen](https://www.chargebee.com/docs/adyen-sepa.html).

**Note:**

-   For SEPA via Stripe, it is mandatory to pass [user details](/docs/api/advanced-features) such as IP address and device information.
-   For GoCardless, [local bank details](https://developer.gocardless.com/api-reference/#appendix-local-bank-details) can be passed instead of IBAN.

#### Bacs Payment Schemes Limited (BACS) and Bg Autogiro[](#bacs-payment-schemes-limited-bacs-and-bg-autogiro)

Bacs is an organization that manages the Direct Debit and Direct Credit payment methods in the UK. Bg Autogiro is a Direct Debit scheme for krona denominated payments in Sweden. Both Bacs and Bg Autogiro are supported via [GoCardless](https://www.chargebee.com/docs/gocardless.html).

**Note:**

-   For BACS via Stripe, it is mandatory to pass [user details](/docs/api/advanced-features) such as IP address(`chargebee-request-origin-ip`) and the device information(`chargebee-request-origin-device`).

#### Bulk Electronic Clearing System (BECS) and Pre-Authorized Debit (PAD)[](#bulk-electronic-clearing-system-becs-and-pre-authorized-debit-pad)

BECS is an automated payment method for Direct Debit in Australia and New Zealand while PAD does the same for Canada. [GoCardless](https://www.chargebee.com/docs/gocardless.html) supports both.

For Direct Debit, the customer needs to accept a mandate that allows the merchant to debit their bank account. This agreement PDF can be obtained using the [Retrieve direct debit agreement PDF API](/docs/api/hosted_pages/retrieve-direct-debit-agreement-pdf).

If the customer has already reached the payment source limit allowed for the site, pass `replace_primary_payment_source` as `true`. Alternatively, [delete](/docs/api/payment_sources/delete-a-payment-source) one of the payment sources first and then add the bank account payment source for the customer.

**Note:**

-   For BECS via Stripe, it is mandatory to pass [user details](/docs/api/advanced-features) such as IP address(`chargebee-request-origin-ip`) and the device information(`chargebee-request-origin-device`).

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/payment_sources/create_bank_account \
     -u {site_api_key}:\
     -d customer_id="__test__XpbTXGTSRp4Ly9Dj" \
     -d "bank_account[gateway_account_id]"="gw___test__5SK2lMpwSRp4Ljs2t" \
     -d "bank_account[account_number]"="000222222227" \
     -d "bank_account[routing_number]"="110000000" \
     -d "bank_account[bank_name]"="US Bank" \
     -d "bank_account[account_holder_type]"="INDIVIDUAL" \
     -d "bank_account[account_type]"="SAVINGS" \
     -d "bank_account[first_name]"="Shay" \
     -d "bank_account[last_name]"="Liam"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;
using ChargeBee.Models.Enums;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = PaymentSource.CreateBankAccount()
		.CustomerId("__test__XpbTXGTSRp4Ly9Dj")
		.BankAccountGatewayAccountId("gw___test__5SK2lMpwSRp4Ljs2t")
		.BankAccountAccountNumber("000222222227")
		.BankAccountRoutingNumber("110000000")
		.BankAccountBankName("US Bank")
		.BankAccountAccountHolderType(AccountHolderTypeEnum.Individual)
		.BankAccountAccountType(AccountTypeEnum.Savings)
		.BankAccountFirstName("Shay")
		.BankAccountLastName("Liam")
		.Request();

Customer customer = result.Customer;
PaymentSource paymentSource = result.PaymentSource;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    paymentsourceAction "github.com/chargebee/chargebee-go/v3/actions/paymentsource"
    "github.com/chargebee/chargebee-go/v3/models/paymentsource"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := paymentsourceAction.CreateBankAccount(&paymentsource.CreateBankAccountRequestParams{
        CustomerId : "__test__XpbTXGTSRp4Ly9Dj",
        BankAccount : &paymentsource.CreateBankAccountBankAccountParams{
            GatewayAccountId : "gw___test__5SK2lMpwSRp4Ljs2t",
            AccountNumber : "000222222227",
            RoutingNumber : "110000000",
            BankName : "US Bank",
            AccountHolderType : enum.AccountHolderTypeIndividual,
            AccountType : enum.AccountTypeSavings,
            FirstName : "Shay",
            LastName : "Liam",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
        PaymentSource := res.PaymentSource
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.PaymentSourceCreateBankAccountRequest{
    CustomerId : "__test__XpbTXGTSRp4Ly9Dj",
    BankAccount : &chargebee.PaymentSourceCreateBankAccountBankAccount{
        GatewayAccountId : "gw___test__5SK2lMpwSRp4Ljs2t",
        AccountNumber : "000222222227",
        RoutingNumber : "110000000",
        BankName : "US Bank",
        AccountHolderType : chargebee.AccountHolderTypeIndividual,
        AccountType : chargebee.AccountTypeSavings,
        FirstName : "Shay",
        LastName : "Liam",
    },
}
  res, err := client.PaymentSource.CreateBankAccount(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
        PaymentSource := res.PaymentSource
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = PaymentSource.createBankAccount()
            .customerId("__test__XpbTXGTSRp4Ly9Dj")
            .bankAccountGatewayAccountId("gw___test__5SK2lMpwSRp4Ljs2t")
            .bankAccountAccountNumber("000222222227")
            .bankAccountRoutingNumber("110000000")
            .bankAccountBankName("US Bank")
            .bankAccountAccountHolderType(AccountHolderType.INDIVIDUAL)
            .bankAccountAccountType(AccountType.SAVINGS)
            .bankAccountFirstName("Shay")
            .bankAccountLastName("Liam")
            .request();

        Customer customer = result.customer();
        PaymentSource paymentSource = result.paymentSource();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.paymentSource.PaymentSource;
import com.chargebee.v4.models.paymentSource.params.PaymentSourceCreateBankAccountParams;
import com.chargebee.v4.models.paymentSource.responses.PaymentSourceCreateBankAccountResponse;

public class PaymentSourceCreateBankAccount {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        PaymentSourceCreateBankAccountParams.BankAccountParams bankAccountParams =
            PaymentSourceCreateBankAccountParams.BankAccountParams.builder()
                .gatewayAccountId("gw___test__5SK2lMpwSRp4Ljs2t")
                .accountNumber("000222222227")
                .routingNumber("110000000")
                .bankName("US Bank")
                .accountHolderType(PaymentSourceCreateBankAccountParams.BankAccountParams.AccountHolderType.INDIVIDUAL)
                .accountType(PaymentSourceCreateBankAccountParams.BankAccountParams.AccountType.SAVINGS)
                .firstName("Shay")
                .lastName("Liam")
                .build();

        PaymentSourceCreateBankAccountParams params = PaymentSourceCreateBankAccountParams.builder()
            .customerId("__test__XpbTXGTSRp4Ly9Dj")
            .bankAccount(bankAccountParams)
            .build();

        PaymentSourceCreateBankAccountResponse response = client.paymentSources().createBankAccount(params);

        Customer customer = response.getCustomer();
        PaymentSource paymentSource = response.getPaymentSource();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.paymentSource.createBankAccount({
        customer_id: "__test__XpbTXGTSRp4Ly9Dj",
        bank_account: {
            gateway_account_id: "gw___test__5SK2lMpwSRp4Ljs2t",
            account_number: "000222222227",
            routing_number: 110000000,
            bank_name: "US Bank",
            account_holder_type: "individual",
            account_type: "savings",
            first_name: "Shay",
            last_name: "Liam"
        }
    });

    console.log(result);
    const customer = result.customer;
    const paymentSource = result.payment_source;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->paymentSource()->createBankAccount([
    "customer_id" => "__test__XpbTXGTSRp4Ly9Dj",
    "bank_account" => [
        "gateway_account_id" => "gw___test__5SK2lMpwSRp4Ljs2t",
        "account_number" => "000222222227",
        "routing_number" => "110000000",
        "bank_name" => "US Bank",
        "account_holder_type" => "individual",
        "account_type" => "savings",
        "first_name" => "Shay",
        "last_name" => "Liam"
    ]
]);
$customer = $result->customer;
$paymentSource = $result->payment_source;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.PaymentSource.create_bank_account(
    cb_client.PaymentSource.CreateBankAccountParams(
        customer_id="__test__XpbTXGTSRp4Ly9Dj",
        bank_account=cb_client.PaymentSource.CreateBankAccountBankAccountParams(
            gateway_account_id="gw___test__5SK2lMpwSRp4Ljs2t",
            account_number="000222222227",
            routing_number="110000000",
            bank_name="US Bank",
            account_holder_type=chargebee.AccountHolderType.INDIVIDUAL,
            account_type=chargebee.AccountType.SAVINGS,
            first_name="Shay",
            last_name="Liam"
        )
    )
)
customer = response.customer
payment_source = response.payment_source
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::PaymentSource.create_bank_account({
  :customer_id => "__test__XpbTXGTSRp4Ly9Dj",
  :bank_account => {
    :gateway_account_id => "gw___test__5SK2lMpwSRp4Ljs2t",
    :account_number => "000222222227",
    :routing_number => "110000000",
    :bank_name => "US Bank",
    :account_holder_type => "INDIVIDUAL",
    :account_type => "SAVINGS",
    :first_name => "Shay",
    :last_name => "Liam"
  }
})

customer = result.customer
payment_source = result.payment_source
```

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": true,
    "auto_collection": "on",
    "created_at": 1517487213,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "Mark",
    "id": "__test__XpbTXGTSRp4Ly9Dj",
    "last_name": "Henry",
    "net_term_days": 0,
    "object": "customer",
    "payment_method": {
      "gateway": "stripe",
      "gateway_account_id": "gw___test__5SK2lMpwSRp4Ljs2t",
      "object": "payment_method",
      "reference_id": "cus_J7rVKldNI2hKt0/ba_1IVbmEJv9j0DyntJTe5oRPZE",
      "status": "pending_verification",
      "type": "direct_debit"
    },
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "primary_payment_source_id": "pm___test__XpbTXGTSRp4MS7Dm",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517487215586,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517487215
  },
  "payment_source": {
    "bank_account": {
      "account_holder_type": "individual",
      "account_type": "not_applicable",
      "bank_name": "US Bank",
      "last4": "2227",
      "name_on_account": "Shay Liam",
      "object": "bank_account"
    },
    "created_at": 1517487215,
    "customer_id": "__test__XpbTXGTSRp4Ly9Dj",
    "deleted": false,
    "gateway": "stripe",
    "gateway_account_id": "gw___test__5SK2lMpwSRp4Ljs2t",
    "id": "pm___test__XpbTXGTSRp4MS7Dm",
    "issuing_country": "US",
    "object": "payment_source",
    "reference_id": "cus_J7rVKldNI2hKt0/ba_1IVbmEJv9j0DyntJTe5oRPZE",
    "resource_version": 1517487215582,
    "status": "pending_verification",
    "type": "direct_debit",
    "updated_at": 1517487215
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/payment_sources/create_bank_account

## Input Parameters

- `customer_id` (required, string, max chars=50)
  Identifier of the customer with whom this payment source is associated.

- `brand_id` (optional, string, max chars=50)
  The unique ID of the [brand](/docs/api/brands) this payment source should be linked to. Applicable only when multiple brands have been created for the site. This need not match the brand of the `customer_id`; when the two differ, the value provided here is used for the payment source. An alternative way of passing this parameter is by means of the `chargebee-brand-id` custom HTTP header; when both are provided, they must specify the same brand.
  
  **Default behavior**
  
  -   When not provided, the payment source is linked to the brand of the customer it is created for.

- `issuing_country` (optional, string, max chars=50)
  2-letter(alpha2) ISO country code. Required when local bank details are provided, and not IBAN.

- `replace_primary_payment_source` (optional, boolean, default=false)
  Indicates whether the primary payment source should be replaced with this payment source. In case of Create Subscription for Customer endpoint, the default value is True. Otherwise, the default value is False.

- `bank_account` (optional, string)
  Parameters for bank\_account
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.
  - `iban` (optional, string, min chars=10, max chars=50)
    Account holder's International Bank Account Number. For the [GoCardless](https://www.chargebee.com/docs/gocardless.html) platform, this can be the [local bank details](https://developer.gocardless.com/api-reference/#appendix-local-bank-details)
  - `first_name` (optional, string, max chars=150)
    Account holder's first name as per bank account. If not passed, details from customer details will be considered.
  - `last_name` (optional, string, max chars=150)
    Account holder's last name as per bank account. If not passed, details from customer details will be considered.
  - `company` (optional, string, max chars=250)
    Account holder's company name as per bank account. If not passed, details from customer details will be considered.
  - `email` (optional, string, max chars=70)
    Account holder's email address. If not passed, details from customer details will be considered. All Direct Debit compliant emails will be sent to this email address.
  - `phone` (optional, string, max chars=50)
    Phone number of the account holder that is linked to the bank account.
  - `bank_name` (optional, string, max chars=100)
    Name of account holder's bank.
  - `account_number` (optional, string, min chars=4, max chars=17)
    Account holder's bank account number.
  - `routing_number` (optional, string, min chars=3, max chars=9)
    Bank account routing number.
  - `bank_code` (optional, string, max chars=20)
    Indicates the bank code.
  - `account_type` (optional, enumerated string)
    Represents the account type used to create a payment source. Available for [Authorize.net](https://www.authorize.net/) ACH and Razorpay NetBanking users only. If not passed, account type is taken as null.
    Possible enum values:
      - `checking`
        Checking Account
      - `savings`
        Savings Account
      - `business_checking`
        Business Checking Account
      - `current`
        Current Account
  - `account_holder_type` (optional, enumerated string)
    For Stripe ACH users only. Indicates the account holder type.
    Possible enum values:
      - `individual`
        Individual Account.
      - `company`
        Company Account.
  - `echeck_type` (optional, enumerated string)
    For Authorize.net ACH users only. Indicates the type of eCheck.
    Possible enum values:
      - `web`
        Payment Authorization obtained from the customer via the internet.
      - `ppd`
        Payment Authorization is prearranged between the customer and the merchant.
      - `ccd`
        Payment Authorization agreement from the corporate customer is required. Applicable for business\_checking account\_type.
  - `swedish_identity_number` (optional, string, min chars=10, max chars=12)
    For GoCardless Autogiro users only. The civic/company number (personnummer, samordningsnummer, or organisationsnummer) of the customer. Must be supplied if the customer's bank account is denominated in Swedish krona (SEK). This field cannot be changed once it has been set.
  - `billing_address` (optional, jsonobject)
    The billing address associated with the bank account. The value is a JSON object with the following keys and their values:- `first_name`:(string, max chars=150) The first name of the contact.
    
    -   `last_name`:(string, max chars=150) The last name of the contact.
    -   `company_name`:(string, max chars=250) The company name for the address.
    -   `line1`:(string, max chars=180) The first line of the address.
    -   `line2`:(string, max chars=180) The second line of the address.
    -   `country`:(string) The name of the country for the address.
    -   `country_code`:(string, max chars=50) The two-letter, [ISO 3166 alpha-2](https://www.iso.org/iso-3166-country-codes.html) country code for the address.
    -   `state`:(string, max chars=50) The name of the state or province for the address. When not provided, this is set automatically for US, Canada, India, and UAE.
    -   `state_code`:(string, max chars=50) The [ISO 3166-2 state/province code](https://www.iso.org/obp/ui/#search/code/) without the country prefix. This is supported for USA, Canada, India, and UAE. For instance, for Arizona (USA), set state\_code as `AZ` (not `US-AZ`). For Tamil Nadu (India), set as `TN` (not `IN-TN`). For British Columbia (Canada), set as `BC` (not `CA-BC`). For Dubai (UAE), set as `DU` (not `AE-DU`).
    -   `city`:(string, max chars=50) The city name for the address.
    -   `postal_code`:(string, max chars=20) The postal or ZIP code for the address.
    -   `phone`:(string, max chars=50) The contact phone number for the address.
    -   `email`:(string, max chars=70) The contact email address for the address.

## Returns

- `customer` (Customer object)
  Resource object representing customer

- `payment_source` (Payment source object)
  Resource object representing payment\_source
