# Update 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 is used to update the payment source details of a customer. Information related to bank account payment source such as email, first name, and last name can be updated.

-   For GoCardless, Chargebee supports (ACH,BACS,SEPA,AUTOGIRO,BECS,BECS\_NZ,PAD).
-   For Stripe, Chargebee only supports SEPA.

The API is only supported for the `payment_method` of type `direct_debit`.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/payment_sources/pm___test__KyVnPbSerKGB5d/update_bank_account \
     -u {site_api_key}:\
     -d "bank_account[email]"="johndoe@example.com" \
     -d "bank_account[first_name]"="John" \
     -d "bank_account[last_name]"="Doe"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = PaymentSource.UpdateBankAccount("pm___test__KyVnPbSerKGB5d")
		.BankAccountEmail("johndoe@example.com")
		.BankAccountFirstName("John")
		.BankAccountLastName("Doe")
		.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"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := paymentsourceAction.UpdateBankAccount("pm___test__KyVnPbSerKGB5d", &paymentsource.UpdateBankAccountRequestParams{
        BankAccount : &paymentsource.UpdateBankAccountBankAccountParams{
            Email : "johndoe@example.com",
            FirstName : "John",
            LastName : "Doe",
        },
    }).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.PaymentSourceUpdateBankAccountRequest{
    BankAccount : &chargebee.PaymentSourceUpdateBankAccountBankAccount{
        Email : "johndoe@example.com",
        FirstName : "John",
        LastName : "Doe",
    },
}
  res, err := client.PaymentSource.UpdateBankAccount("pm___test__KyVnPbSerKGB5d", 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.updateBankAccount("pm___test__KyVnPbSerKGB5d")
            .bankAccountEmail("johndoe@example.com")
            .bankAccountFirstName("John")
            .bankAccountLastName("Doe")
            .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.PaymentSourceUpdateBankAccountParams;
import com.chargebee.v4.models.paymentSource.responses.PaymentSourceUpdateBankAccountResponse;

public class PaymentSourceUpdateBankAccount {

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

        PaymentSourceUpdateBankAccountParams.BankAccountParams bankAccountParams =
            PaymentSourceUpdateBankAccountParams.BankAccountParams.builder()
                .email("johndoe@example.com")
                .firstName("John")
                .lastName("Doe")
                .build();

        PaymentSourceUpdateBankAccountParams params = PaymentSourceUpdateBankAccountParams.builder()
            .bankAccount(bankAccountParams)
            .build();

        PaymentSourceUpdateBankAccountResponse response = client
            .paymentSources()
            .updateBankAccount("pm___test__KyVnPbSerKGB5d", 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.updateBankAccount("pm___test__KyVnPbSerKGB5d", {
        bank_account: {
            email: "johndoe@example.com",
            first_name: "John",
            last_name: "Doe"
        }
    });

    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()->updateBankAccount("pm___test__KyVnPbSerKGB5d", [
    "bank_account" => [
        "email" => "johndoe@example.com",
        "first_name" => "John",
        "last_name" => "Doe"
    ]
]);
$customer = $result->customer;
$paymentSource = $result->payment_source;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.PaymentSource.update_bank_account("pm___test__KyVnPbSerKGB5d",
    cb_client.PaymentSource.UpdateBankAccountParams(
        bank_account=cb_client.PaymentSource.UpdateBankAccountBankAccountParams(
            email="johndoe@example.com",
            first_name="John",
            last_name="Doe"
        )
    )
)
customer = response.customer
payment_source = response.payment_source
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::PaymentSource.update_bank_account("pm___test__KyVnPbSerKGB5d",{
  :bank_account => {
    :email => "johndoe@example.com",
    :first_name => "John",
    :last_name => "Doe"
  }
})

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

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": true,
    "auto_collection": "on",
    "channel": "web",
    "created_at": 1517507082,
    "deleted": false,
    "email": "markhenry@example.com",
    "excess_payments": 0,
    "first_name": "Mark",
    "id": "__test__KyVnPbSerKFjFY",
    "last_name": "Henry",
    "net_term_days": 0,
    "object": "customer",
    "payment_method": {
      "gateway": "stripe",
      "gateway_account_id": "gw___test__KyVnGoSerKFdA2t",
      "object": "payment_method",
      "reference_id": "cus_Jxe0kGs9uZuKX3/src_1JJiiNJv9j0DyntJXYkqBHE8",
      "status": "valid",
      "type": "direct_debit"
    },
    "pii_cleared": "active",
    "preferred_currency_code": "EUR",
    "primary_payment_source_id": "pm___test__KyVnPbSerKGB5d",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517507084711,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517507084
  },
  "payment_source": {
    "bank_account": {
      "email": "johndoe@example.com",
      "last4": "3000",
      "mandate_id": "OI1M52OFAXGFQZRR",
      "name_on_account": "John Doe",
      "object": "bank_account"
    },
    "created_at": 1517507084,
    "customer_id": "__test__KyVnPbSerKFjFY",
    "deleted": false,
    "gateway": "stripe",
    "gateway_account_id": "gw___test__KyVnGoSerKFdA2t",
    "id": "pm___test__KyVnPbSerKGB5d",
    "issuing_country": "DE",
    "object": "payment_source",
    "reference_id": "cus_Jxe0kGs9uZuKX3/src_1JJiiNJv9j0DyntJXYkqBHE8",
    "resource_version": 1517507084712,
    "status": "valid",
    "type": "direct_debit",
    "updated_at": 1517507084
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/payment_sources/{cust-payment-source-id}/update_bank_account

## Input Parameters

- `bank_account` (optional, string)
  Parameters for bank\_account
  - `first_name` (optional, string, max chars=150)
    Account holder's first name as per bank account.
  - `last_name` (optional, string, max chars=150)
    Account holder's last name as per bank account.
  - `email` (optional, string, max chars=70)
    Account holder's email address. All Direct Debit compliant emails will be sent to this email address.

## Returns

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

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