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

# Debin（阿根廷）

Localpayment 使商家能够通过阿根廷的 Debin（Débito Inmediato）系统处理即时银行转账。本指南概述了通过 Localpayment 的 API 发起 Debin 付款的流程，详细说明了所需的参数、响应处理以及状态代码解读，从而实现与阿根廷即时借记网络的无缝集成。

> [!WARNING]
>
> **重要的**
>
> Debin 付款将在创建日期后 **2 天** 过期。

## 开始之前

请确保您已备好：

* 有效的 [API 凭证](https://docs.localpayment.com/zh/docs/api-keys-and-environments.md)（访问令牌）。

***

## 步骤 1. 创建 Debin 付款

要生成 Debin 付款请求，请使用 Debin 特定参数向[创建 Payin](https://docs.localpayment.com/zh/reference/payins.md) endpoint 发送 `POST` 请求。

> [!NOTE]
>
> 付款请求只能发送至 CBU 账户。这些账户的识别特征是前三位数字不以零开头。

### 关键请求参数

该请求需要几个与 Debin 支付相关的关键对象：

| 对象 | 描述 | 必需的 |
| - | - | - |
| `paymentMethod.type` | 必须是 `BankTransfer`。 | ✅ |
| `paymentMethod.code` | Debin 必须为 `1040`。 | ✅ |
| `payer` | 付款人银行账户信息。 | ✅ |
| `merchant` | 商家/企业详情 | ✅ |
| `amount` | 交易金额 | ✅ |
| `currency` | 交易货币代码 | ✅ |
| `country` | 必须是 `ARG` | ✅ |

查看请求中所有可用的[参数](https://docs.localpayment.com/zh/reference/payins.md)。

### 示例请求

以下是使用 `curl` 的示例：

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
     --url https://api.stage.localpayment.com/api/payin/ \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'Authorization: Bearer <your_access_token>' \
     --data '
{
  "paymentMethod": {
    "type": "BankTransfer",
    "code": "1040",
    "flow": "DIRECT"
  },
  "currency": "ARS",
  "merchant": {
    "type": "COMPANY",
    "name": "Company"
  },
  "payer": {
    "type": "INDIVIDUAL",
    "document": {
      "type": "CUIL",
      "id": "20963514871"
    },
    "bank": {
      "account": {
        "type": "C",
        "number": "0070055930004044931234"
      },
      "name": "Galicia",
      "code": "007"
    },
    "name": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com"
  },
  "externalId": "0fcd5d00-a734-46d9-95d7-246126989132",
  "country": "ARG",
  "amount": 1800,
  "accountNumber": "{{yourAccountNumber}}",
  "conceptCode": "0038",
  "comment": "",
  "transactionType": "PayIn",
  "clientCode": "0028",
  "requireAuth": false,
  "file": false
}
'
```

***

> [!NOTE]
>
> 只有当客户在其银行应用程序中确认接受付款后，付款才算完成。如果客户拒绝付款，则付款将被拒绝。否则，付款状态将变为已过期。

## 步骤 2：处理响应

### 成功响应

成功创建 Debin 付款包括付款请求详情和授权流程：

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "transactionType": "PayIn",
  "externalId": "bb905b2f-e412-493f-a0a0-c3c03444e0c8",
  "internalId": "d05dab30-485f-473d-844c-041ed5355fc4",
  "paymentMethod": {
    "type": "BankTransfer",
    "code": "1040",
    "flow": "DIRECT"
  },
  "country": "ARG",
  "currency": "ARS",
  "amount": 2355,
  "accountNumber": "{{yourAccountNumber}}",
  "confirmed": {
    "currency": "ARS",
    "fxQuote": 1,
    "amount": 1
  },
  "payment": {
    "currency": "ARS",
    "fxQuote": 1,
    "financingFee": 0,
    "amount": 1
  },
  "localTaxes": [],
  "withHoldings": [],
  "fees": {
    "description": "Fee",
    "currency": "ARS",
    "fxSource": 1,
    "fxQuote": 1,
    "amount": 0,
    "account": "{{yourAccountNumber}}"
  },
  "status": {
    "code": "100",
    "description": "INPROGRESS",
    "detail": "The payin is pending the confirmation"
  },
  "merchant": {
    "type": "INDIVIDUAL",
    "name": "Company"
  },
  "payer": {
    "type": "INDIVIDUAL",
    "name": "John",
    "lastName": "Doe",
    "document": {
      "type": "CUIL",
      "id": "20045113651"
    },
    "email": "john.doe@example.com",
    "bank": {
      "name": "QA TEST",
      "code": "322",
      "account": {
        "type": "S",
        "number": "3220001805117354710015"
      }
    }
  },
  "intermediaries": [],
  "date": {
    "creationDate": "2025-02-16T20:04:04.993",
    "processedDate": "2025-02-16T20:04:10.969",
    "expirationDate": "2025-02-23T20:04:05.553"
  },
  "errors": [],
  "redirectUrl": "https://web-checkout.stage.localpayment.com/redirect/L3ZlcmlmaWNhdGlvbi8wMTM5P2ludGVybmFsSWQ9MGRlNmI5MmQtYjY0Yi00YThhLThjNGEtYjczNDk3ZWRhZDQx"
}
```

### 关键响应字段

| 参数 | 描述 | 用例 |
| - | - | - |
| `redirectUrl` | 用于重定向付款人进行授权的 URL。 | 直接由客户完成 Debin 授权流程。 |
| `externalId` | 您的原始参考编号。 | 内部核对和订单匹配。 |
| `status.code` | 当前交易状态（`100` = `INPROGRESS`） | 确定付款流程的后续步骤。 |
| `date.creationDate` | 交易创建时。 | 分析和绩效跟踪。 |
| `date.expirationDate` | Debin 请求失效时的 ISO 时间戳。 | 显示倒计时器并处理过期逻辑。 |

#### 错误响应

Debin 请求创建失败时，您将收到详细的错误信息：

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "externalId": "ce0aaa1a-4532-43b9-930a-26e780aba99b",
  "status": {
    "code": "812",
    "description": "REJECTED"
  },
  "errors": [
    {
      "code": "812",
      "detail": "External Id already used - duplication"
    }
  ]
}
```

***

## 步骤 3. 处理授权流程

1. **支付发起**：您的应用程序向 Localpayment API 发送 DEBIN 请求。

2. **银行网络处理**：Localpayment 通过阿根廷银行系统进行支付。

3. **客户通知**：客户在其银行应用程序中收到实时提醒。

4. **付款授权**：客户直接在银行界面批准付款。

5. **确认和 Webhook**：Localpayment 会立即发送包含最终付款状态的 webhook。

6. **订单履行**：您的应用程序会根据付款结果更新订单状态。

***

## 第四步：跟踪交易状态

您可以通过以下方式监控 Debin 的付款进度：

> [card] [Webhooks（推荐）](https://docs.localpayment.com/zh/docs/webhooks.md)
>
> 交易状态变更时接收实时通知。最适用于生产环境。

> [card] [状态 API endpoint](https://docs.localpayment.com/zh/reference/get-transaction-status.md)
>
> 以编程方式查询事务状态。可用于轮询或恢复丢失的 webhook 通知。

> [card] [Business Portal 视图](https://docs.localpayment.com/zh/docs/dashboard-overview.md)
>
> 用于监控交易的可视化界面。非常适合人工监督和详细的交易分析。

### 常用状态码

Localpayment API 提供各种状态代码来指示 Debin 付款的进度和结果。

| 代码 | 状态 | 描述 |
| :- | :- | :- |
| `100` | `INPROGRESS` | 款项到账尚待确认。 |
| `825` | `REJECTED` | 系统出错，无法生成付款信息。 |

> [!NOTE]
>
> **完整参考**
>
> 请查看我们的[交易状态文档](https://docs.localpayment.com/zh/reference/transaction-status-error-codes)，了解所有状态代码。

***

## 测试您的集成

### 沙盒环境

使用测试环境：

```
https://api.stage.localpayment.com/api/payin/
```

### 测试 Debin 场景

请确认您的集成方案能够处理以下场景：

1. **授权成功**：Debin 授权流程完成。
2. **授权过期**：处理已过期的授权请求。
3. **状态更新**：Webhook 处理和状态轮询。

***

## 后续步骤

实施 Debin 支付后，请考虑以下附加功能：

> [card] [退款](https://docs.localpayment.com/zh/docs/refund-apm-payment.md)
>
> 如有必要，您可以将款项退还给客户。详情请参阅相关文档。

> [card] [查看交易详情](https://docs.localpayment.com/zh/reference/get-transaction-status.md)
>
> 您可以使用 Localpayment API 获取交易信息，以获得更详细的分析。


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