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

# B2B 付款

> 在 B2B 结账过程中收集 Tax ID 和企业名称。验证 Tax ID，并根据客户所在国家/地区应用正确的税务处理方式。

B2B 支付允许您在结账过程中收集 Tax ID 和企业名称、验证 Tax ID，并根据客户所在国家/地区及相关法规应用正确的税务处理方式。

## B2B 交易的 Tax ID 验证

在结账过程中提供有效的 Tax ID 后：

* 发票中会包含客户的 Tax ID。
* 根据客户所在国家/地区适用的法规确定税收减免。
* 发票中会包含 Dodo Payments 的税务详情以及应用于该交易的税费。

## 为 B2B 发票收集企业名称

对于 B2B 购买，您可以让客户的法定企业名称显示在发票上，而不是买方的个人姓名。该信息会与 Tax ID 一起通过 `customer_business_name` 字段收集。

当客户在结账时选择 **以企业身份购买** 后，系统会提示其填写 **企业名称** 和 **Tax ID Number**。

客户输入时会实时验证 Tax ID。对于欧盟成员国、Great Britain 和澳大利亚，结账流程会同时执行格式验证、校验和验证，以及实时注册信息查询（分别使用 VIES、HMRC 和 ABR）；如果找到匹配项，还会自动填充注册的法定企业名称。对于其他所有国家/地区，仅执行格式验证和校验和验证。

![已启用“以企业身份购买”切换开关的结账页面，显示企业名称和 Tax ID Number 字段](https://mintcdn.com/dodopayments/OBU18S2UplPD5yUr/images/b2b-payments-business-name.png?fit=max\&auto=format\&n=OBU18S2UplPD5yUr\&q=85\&s=8874862394939cf83551c9a499448ab3)

仅当以下三个条件全部满足时，企业名称才会显示在发票上：

1. 交易属于 B2B（`b2b = true`）。
2. 存在 `tax_id`。
3. 提供了非空的 `customer_business_name`。

如果任一条件不满足，则使用客户的个人姓名。

### 在结账时设置

直接传入 `customer_business_name`，和/或启用 `allow_customer_editing_business_name`，以允许客户在结账页面中 Tax ID 旁边输入或编辑该信息：

```typescript theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'pdt_abc', quantity: 1 }],
  customer: { email: 'buyer@acme.com' },
  tax_id: 'GB123456789',
  customer_business_name: 'Acme Corp Ltd',
  feature_flags: {
    allow_tax_id: true,
    allow_customer_editing_business_name: true // optional: let the customer edit it
  },
  return_url: 'https://yoursite.com/return'
});
```

| 界面 | 字段 | 备注 |
| - | - | - |
| Checkout Sessions | `customer_business_name`、`feature_flags.allow_customer_editing_business_name` | 最多 250 个字符；标志默认为 `false` |
| Payments | `customer_business_name` | 最多 250 个字符 |
| Subscriptions | `customer_business_name` | 通过 `PATCH /subscriptions/{subscription_id}` 设置或清除 |

> [!WARNING]
>
> 如果没有 `tax_id`，则无法设置 `customer_business_name` — 请求会被拒绝。清除 `tax_id` 也会清除企业名称，因为这两个字段在发票中相互关联。系统会去除首尾空格，仅包含空格的值会被视为明确清除该字段。

## 将 Tax ID 设为必填项

默认情况下，Tax ID 为可选项——客户可以自行决定是否以企业身份购买。如果您只向注册企业销售，请在 checkout session 上设置 `require_tax_id` feature flag，将其设为必填：

```typescript theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'pdt_abc', quantity: 1 }],
  customer: { email: 'buyer@acme.com' },
  billing_address: { country: 'IN' },
  feature_flags: {
    allow_tax_id: true,   // default; must be true
    require_tax_id: true
  },
  return_url: 'https://yoursite.com/return'
});
```

### 结账时的变化

* **以企业身份购买**会被预先选中，且无法取消选择。这些 session 不提供个人买家路径。
* **企业名称**和 **Tax ID Number** 均会标记为必填，必须填写。
* 当任一字段为空，或输入的 Tax ID 未通过验证时，**Continue to Payment** 会保持灰色不可用状态。

Tax ID 验证仍采用 fail-open 方式——查询服务中断或国家/地区不受支持时，永远不会阻止客户，因此即使按钮显示为灰色，仍可点击。

> [!NOTE]
>
> 在 session 上传入 `tax_id` 和 `customer_business_name` 会预填充这两个字段，因此在客户操作表单之前就满足必填要求。如果希望客户自行填写，请省略这两个字段。

### 规则和限制

| 规则 | 行为 |
| - | - |
| `require_tax_id: true` 与 `allow_tax_id: false` 同时使用 | 返回 `400` 而被拒绝——该标志要求填写一个 checkout 根本不会显示的字段 |
| `require_tax_id: true` 与 `confirm: true` 同时使用 | 返回 `422` 而被拒绝，除非请求包含非空的 `tax_id`，因为 `confirm` 会跳过结账页面 |
| 未提供标志 | 默认为 `false`；现有 session 和集成不受影响 |

> [!NOTE]
>
> 空白或仅包含空格的 `tax_id` 会被视为缺失，无论是在 `confirm: true` 守卫中，还是在 hosted-page session 确认时，均是如此。

> [!WARNING]
>
> 在 hosted checkout page（`confirm: false`）上，该要求会在浏览器中强制执行。API 会在确认时拒绝空白 Tax ID，但无法区分未填写该字段的个人买家和企业买家。因此，对于 hosted session，应将 `require_tax_id` 视为结账体验控制，而不是确保每笔支付都携带 Tax ID 的保证。`confirm: true` session 的要求更严格：它始终被视为企业购买，没有 Tax ID 时会直接被拒绝。

## B2C 交易的税务处理

未提供有效 Tax ID 的交易会被视为 B2C 交易，并根据客户所在国家/地区适用的税务法规扣除税费。发票中会包含 Dodo Payments 的税务详情以及应用于该交易的税费。

## Reverse Charge 机制

通常情况下，商品或服务的供应商负责缴纳 VAT、Service Tax 或 GST。但是，在进口及其他规定的供应情形下，根据 Reverse Charge 机制，纳税义务由收款方（客户）承担。Reverse Charge 是指，对于规定类别的供应，商品或服务的收款方而非供应商负责缴纳税费。

## Reverse Charge 的适用性

在法律适用的某些情况下，结账时不会扣除税费，交易将适用 Reverse Charge 机制。根据监管要求，当 Reverse Charge 适用时，发票会明确标示这一点。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.