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

# Tango Card

本文件提供將 Fluz Gift Card Vendor API Adapter 與 TangoCard 作為供應商時的特定使用細節。

## 原生 TangoCard API 與 Fluz API Adapter 比較

### 基本 URL

* 原生 TangoCard API：[https://integration-api.tangocard.com/rass](https://integration-api.tangocard.com/rass)
* Fluz API Adapter：
  * Staging：[https://api-adapter.staging.fluzapp.com/tangocard](https://api-adapter.staging.fluzapp.com/tangocard)

## 認證

### 原生 TangoCard

* 使用 Basic Authentication（使用者名稱與密碼）。

```text theme={null}
Username: QAPlatform2
Password: apYPfT6HNONpDRUj3CLGWYt7gvIHONpDRUYPfT6Hj
```

### Fluz API Adapter

* 使用 `Authorization` 標頭的 Basic Authentication（與所有供應商整合相同）。

```text theme={null}
Authorization: Basic <FLUZ-API-Key>
```

## API 端點比較

| Operation                  | TangoCard Endpoint                 | Fluz Endpoint                      | Notes              |
| :------------------------- | :--------------------------------- | :--------------------------------- | :----------------- |
| Get Order                  | `GET /v2/orders/:referenceOrderID` | `GET /v2/orders/:referenceOrderID` | 取得特定訂單的詳細資訊        |
| Get All Orders             | `GET /v2/orders/`                  | `GET /v2/orders`                   | 取得所有訂單             |
| Create Order               | `GET /v2/orders/`                  | `POST /v2/orders/`                 | 建立新的禮品卡訂單（以背景作業處理） |
| Get Balance (All Accounts) | `GET /v2/accounts`                 | `GET /v2/accounts`                 | 取得所有帳戶的餘額資訊        |
| Get Balance (By Account)   | `GET /v2/accounts/:accountId`      | `GET /v2/accounts/:id`             | 取得特定帳戶的餘額          |

# 請求範例

## 建立訂單

### 原生 TangoCard 請求：

```text theme={null}
{
  "sendEmail": false,
  "accountIdentifier": "testing1234account",
  "customerIdentifier": "johnr002",
  "utid": "U561593",
  "amount": 50
}
```

### Fluz API Adapter 請求：

```text theme={null}
{
  "sendEmail": false,
  "accountIdentifier": "testing1234account",
  "customerIdentifier": "johnr002",
  "utid": "1800FL-US",
  "amount": 40,
  "externalRefID": "d8e118ab-732b-4884-8e8a-70746b5f359e"
}
```

## TangoCard 訂單的背景處理

透過 TangoCard 整合進行的所有購買操作都會以背景作業的方式處理。然而，為了與 TangoCard 的 API 行為相容，Fluz API Adapter 可能會預設同步回傳完整結果。

<Callout icon="📘">
  **注意：** 即使結果看似同步，所有購買仍會在內部排程並追蹤為背景作業，以提升可靠性並更好地處理重試。
</Callout>

## 使用 cURL 的範例

### 範例 1：取得特定訂單

```text theme={null}
# Get a specific order with TangoCard via Fluz API Adapter
curl -X GET "https://api-adapter.staging.fluzapp.com/tangocard/v2/orders/72991f5a-b389-404e-98b0-ac5444839ca9" \
  -H "Authorization: Basic <FLUZ-API-Key>"
```

### 範例 2：取得所有訂單

```text theme={null}
# Get all orders with TangoCard via Fluz API Adapter
curl -X GET "https://api-adapter.staging.fluzapp.com/tangocard/v2/orders" \
  -H "Authorization: Basic <FLUZ-API-Key>"
```

### 範例 3：取得所有帳戶餘額

```text theme={null}
# Get Balance for all accounts with TangoCard via Fluz API Adapter
curl -X GET "https://api-adapter.staging.fluzapp.com/tangocard/v2/accounts" \
  -H "Authorization: Basic <FLUZ-API-Key>"
```

### 範例 4：取得特定帳戶餘額

```text theme={null}
# Get Balance for a specific account with TangoCard via Fluz API Adapter
curl -X GET "https://api-adapter.staging.fluzapp.com/tangocard/v2/accounts/testing1234account" \
  -H "Authorization: Basic <FLUZ-API-Key>"
```

### 範例 5：建立新訂單

```text theme={null}
# Create Order with TangoCard via Fluz API Adapter
# Note: This operation runs as a background process but may return complete results
curl -X POST "https://api-adapter.staging.fluzapp.com/tangocard/v2/orders" \
  -H "Authorization: Basic <FLUZ-API-Key>" \
  -H "Content-Type: application/json" \
  -d '{
    "sendEmail": false,
    "accountIdentifier": "testing1234account",
    "customerIdentifier": "johnr002",
    "utid": "1800FL-US",
    "amount": 40,
    "externalRefID": "d8e118ab-732b-4884-8e8a-70746b5f359e"
  }'
```
