> ## Documentation Index
> Fetch the complete documentation index at: https://docs.killb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 银行账户

> 设置用于法币转账的银行账户

## 概览

银行账户用作 off-ramp 交易（加密货币 → 法币）的目的地。KillB 支持拉丁美洲和美国的多个银行系统。

## 支持的银行账户类型

<CardGroup cols={2}>
  <Card title="PSE（哥伦比亚）" icon="building-columns">
    通过 PSE 系统的哥伦比亚银行账户
  </Card>

  <Card title="SPEI（墨西哥）" icon="bolt">
    基于 CLABE 的墨西哥账户
  </Card>

  <Card title="ACH（美国）" icon="landmark">
    通过 ACH 的美国银行账户
  </Card>

  <Card title="Wire（国际）" icon="globe">
    电汇账户
  </Card>
</CardGroup>

## 哥伦比亚 - PSE 账户

```json theme={null}
{
  "type": "PSE",
  "userId": "user-id",
  "externalId": "pse-account-1",
  "data": {
    "firstName": "Juan",
    "lastName": "García",
    "email": "juan@example.com",
    "phone": "+573001234567",
    "accountNumber": "1234567890",
    "bankCode": "0001",
    "type": "savings",
    "countryCode": "CO",
    "document": {
      "type": "NUIP",
      "number": "1234567890",
      "issuedCountryCode": "CO"
    }
  }
}
```

**账户类型：**

* `savings` - 储蓄账户（Cuenta de Ahorros）
* `checking` - 支票账户（Cuenta Corriente）

### 获取哥伦比亚银行

```bash theme={null}
GET /api/v2/banks?countryCode=CO
```

```json 响应 theme={null}
[
  {
    "code": "0001",
    "companyName": "Bancolombia",
    "accountTypes": ["savings", "checking"]
  },
  {
    "code": "0002",
    "companyName": "Banco de Bogotá",
    "accountTypes": ["savings", "checking"]
  }
]
```

## 墨西哥 - SPEI 账户

```json theme={null}
{
  "type": "SPEI",
  "userId": "user-id",
  "externalId": "spei-account-1",
  "data": {
    "firstName": "María",
    "lastName": "López",
    "email": "maria@example.com",
    "phone": "+525512345678",
    "clabe": "012345678901234567",
    "clabeType": "CLABE",
    "countryCode": "MX",
    "document": {
      "type": "RFC",
      "number": "LOMM920310ABC",
      "issuedCountryCode": "MX"
    }
  }
}
```

### CLABE 类型

<Tabs>
  <Tab title="标准 CLABE">
    18 位银行账户号码

    ```json theme={null}
    {
      "clabe": "012345678901234567",
      "clabeType": "CLABE"
    }
    ```

    银行转账最常见的格式。
  </Tab>

  <Tab title="借记卡">
    16 位卡号

    ```json theme={null}
    {
      "clabe": "1234567890123456",
      "clabeType": "DEBIT_CARD",
      "bankCode": "012"
    }
    ```

    需要 `bankCode` 字段。
  </Tab>

  <Tab title="电话号码">
    10 位手机号码用于手机银行

    ```json theme={null}
    {
      "clabe": "5512345678",
      "clabeType": "PHONE_NUMBER",
      "bankCode": "014"
    }
    ```

    需要 `bankCode` 字段。
  </Tab>
</Tabs>

### 获取墨西哥银行

```bash theme={null}
GET /api/v2/banks?countryCode=MX
```

## 美国 - ACH 账户

```json theme={null}
{
  "type": "ACH",
  "userId": "user-id",
  "externalId": "ach-account-1",
  "data": {
    "firstName": "John",
    "lastName": "Smith",
    "email": "john@example.com",
    "phone": "+12125551234",
    "bankName": "Chase Bank",
    "routingNumber": "021000021",
    "accountNumber": "123456789",
    "type": "checking",
    "countryCode": "US",
    "document": {
      "type": "SSN",
      "number": "123-45-6789",
      "issuedCountryCode": "US"
    }
  }
}
```

**账户类型：**

* `checking` - 支票账户
* `savings` - 储蓄账户

**路由号码：** 9 位 ABA 路由号码

## 电汇账户

用于国际电汇：

```json theme={null}
{
  "type": "WIRE",
  "userId": "user-id",
  "externalId": "wire-account-1",
  "data": {
    "firstName": "Jane",
    "lastName": "Doe",
    "email": "jane@example.com",
    "phone": "+12125559876",
    "accountNumber": "987654321",
    "routingNumber": "021000021",
    "bankName": "Bank of America",
    "bankAddress": {
      "street1": "100 Main St",
      "city": "New York",
      "stateCode": "NY",
      "zipCode": "10001",
      "countryCode": "US"
    },
    "countryCode": "US",
    "document": {
      "type": "SSN",
      "number": "987-65-4321",
      "issuedCountryCode": "US"
    }
  }
}
```

<Note>
  电汇账户需要银行地址信息用于国际转账。
</Note>

## 验证

创建前验证账户详情：

<CodeGroup>
  ```javascript 验证 PSE theme={null}
  const validatePSEAccount = (data) => {
    const errors = [];
    
    // 账户号码（10-20 位数字）
    if (!/^\d{10,20}$/.test(data.accountNumber)) {
      errors.push('账户号码格式无效');
    }
    
    // 银行代码（4 位数字）
    if (!/^\d{4}$/.test(data.bankCode)) {
      errors.push('银行代码无效');
    }
    
    // 账户类型
    if (!['savings', 'checking'].includes(data.type)) {
      errors.push('账户类型必须是 savings 或 checking');
    }
    
    return errors;
  };
  ```

  ```javascript 验证 SPEI theme={null}
  const validateSPEIAccount = (data) => {
    const errors = [];
    
    if (data.clabeType === 'CLABE') {
      // 验证 18 位 CLABE
      if (!/^\d{18}$/.test(data.clabe)) {
        errors.push('CLABE 必须是 18 位数字');
      }
      
      // 验证 CLABE 校验和
      if (!isValidCLABEChecksum(data.clabe)) {
        errors.push('CLABE 校验和无效');
      }
    } else if (data.clabeType === 'PHONE_NUMBER') {
      // 验证 10 位电话号码
      if (!/^\d{10}$/.test(data.clabe)) {
        errors.push('电话号码必须是 10 位数字');
      }
      if (!data.bankCode) {
        errors.push('电话号码需要银行代码');
      }
    }
    
    return errors;
  };
  ```

  ```javascript 验证 ACH theme={null}
  const validateACHAccount = (data) => {
    const errors = [];
    
    // 路由号码（9 位数字）
    if (!/^\d{9}$/.test(data.routingNumber)) {
      errors.push('路由号码必须是 9 位数字');
    }
    
    // 账户号码（4-17 位数字）
    if (!/^\d{4,17}$/.test(data.accountNumber)) {
      errors.push('账户号码长度无效');
    }
    
    return errors;
  };
  ```
</CodeGroup>

## 测试银行账户

在沙盒中，使用这些测试银行代码：

**哥伦比亚：**

* `0001` - Bancolombia
* `0002` - Banco de Bogotá
* `0003` - Davivienda

**墨西哥：**

* `012` - BBVA
* `014` - Santander
* `072` - Banorte

<Tip>
  在沙盒中，任何账户号码格式都可以使用。使用真实的格式以获得更好的测试效果。
</Tip>

## 下一步

<CardGroup cols={2}>
  <Card title="加密货币钱包" icon="wallet" href="/zh/guides/accounts/crypto-wallets">
    设置加密货币钱包账户
  </Card>

  <Card title="创建 Off-Ramp" icon="arrow-down" href="/zh/guides/ramps/off-ramp">
    在 off-ramps 中使用银行账户
  </Card>
</CardGroup>
