---
# System prepended metadata

title: Golden F 單一錢包介接 Guideline
tags: [單一錢包介接]

---

<style>
code {
  font-size: 0.8rem;
}
h4 {
  line-height: 2.5;
  border-bottom: 1px solid #eee;
}

.nodes {
    color: white;
}
</style>
# Golden F 單一錢包介接 Guideline
---
##### 修改歷程
```
20210727 修正各接口 request response example
20201211 修正 "/sw/query-translog" response field (trans_id -> trace_id)
20200814 產品代碼列表更改為支持的產品
20200618 新增產品代碼 "TFG"
20200507
    查詢交易單據 /sw/query-translog
    請求參數新增 "member_account"
20200423 
    1. "捨棄" wallet_code 錢包代碼
    2. "捨棄接口" 領出玩家錢包餘額、歸還玩家錢包餘額
    3. "新增" vendor_code 產品代碼、bet_id 注單號、trans_type 交易類別
20200406 "查詢交易單據" 中 "trans_at" 補充說明
20200319 新增 "錯誤代碼" (7000 請求參數錯誤)
20200116 修正“查詢交易單據”說明
20191015 新增錯誤代碼、查詢交易單據API
20190923 新增新增錢包（LBKENO）、Response說明
20190905 新增新增錢包（AG真人、SBO錢包、GPK棋牌）
20190502 新增流程說明、 API清單
20190429 release v1.0
```
---
### 錯誤代碼
|代碼|說明|對應欄位|
|---|---|---|
|0|正常
|7000|請求參數錯誤
|7101|認證碼錯誤|wtoken
|7102|產品代碼不存在|vendor_code
|7103|玩家代碼不存在|member_account
|7104|交易序號重複|trace_id
|7105|查詢資料為空|
|7201|交易金額須為正數|amount
|7202|餘額不足||

### 產品代碼
|代碼|說明|備註|
|---|---|---|
|SBO|SBO 體育
|GPSSL|揪客嘉
### 交易類型
|代碼|說明|備註|
|---|---|---|
|Stake|下注
|Payoff|派彩
|cancelStake|取消下注
|cancelPayoff|取消派彩
|gameTransferOut|轉帳遊戲轉出|轉帳錢包遊戲
|gameTransferIn|轉帳遊戲轉入|轉帳錢包遊戲
### 流程說明
```mermaid
sequenceDiagram
    營運商->>Golden F:取得遊戲連結
    Golden F->>遊戲商: 取得遊戲連結
    Golden F->>營運商: 返回遊戲連結
    alt 單一錢包 
        遊戲商-->>Golden F:下注(Stake)
        Golden F-->>營運商:轉出(TransferOut)
        Golden F-->>遊戲商:完成下注(Stake)

        遊戲商-->>Golden F:派彩(Payoff)
        Golden F-->>營運商:轉入(Payoff)
        Golden F-->>遊戲商:完成派彩(Payoff)
    end
```

### API清單
|名稱|API-Path|備註|
|-|-|-|
|[查詢玩家錢包餘額](#查詢玩家錢包餘額)|/sw/player-balance||
|[轉出/下注](#轉出-下注)|/sw/transfer-out|(單一錢包)|
|[轉入/派彩](#轉入-派彩)|/sw/transfer-in|(單一錢包)|
|[強制 轉出/下注](#強制-轉出-下注)|/sw/force-transfer-out|<span style="color:red;">※提供“交易金額”大於“帳戶餘額”的交易，此情況發生在比賽結果改派。</span>|
|[查詢交易單據](#查詢交易單據)|/sw/query-translog||

### API重點
>1. 我方呼叫貴司 API 時，會傳入 wtoken， 此資料由貴司提供，給貴司驗證是否為我方呼叫 API。
>2. trace_id 為唯一不重複的值，請貴方務必確認其唯一性
>3. 當貴司收到 vendor_code 請自行決定玩家交易的錢包。
>4. 執行交易時，請務必紀錄下交易前後的金額。
>5. API 回應的 Content-Type為 application/json
>6. 交易的紀錄格式如下

|參數名稱|說明|備註|
|-|-|-|
|`wtoken`|驗證用|
|`trans_type`|交易類型|[交易類型](#交易類型)
|`member_account`|玩家代碼|
|`vendor_code`|產品代碼|不同遊戲對應不同[產品代碼](#產品代碼)|
|`amount`|交易金額|須為 <span style="color:red;">正數</span>|
|`trace_id`|交易序號|唯一不重複<span style="color:red;">長度最多255字元</span>|
<pre>
#Example success
{
    "data": {
        "member_account": "testAccount",
        "vendor_code": "GPSSL"
        "balance": 100
    },
    "code": 0
}
</pre>
```json
#Example failed
{
    "data": null,
    "code": 7000
}
```

#### 查詢玩家錢包餘額
URL:`/sw/player-balance`
Method:`POST`
Headers:`Content-Type:application/x-www-form-urlencoded`
##### Request
|Parameter|Type|Require|Description|
|-|-|-|-|
|wtoken|string|Required|給貴司驗證是否為我方呼叫|
|member_account|string|Required|玩家代碼|
|vendor_code|string|Required|產品代碼|

<pre>
#Request Example
{
   "wtoken": "ca947da21f92447eadb43c76ee6bdda4",
   "member_account": "testAccount",
   "vendor_code": "GPSSL",
}
</pre>

##### Response
|Parameter|Type|Require|Description|
|-|-|-|-|
|data.member_account|string|Required|玩家代碼|
|data.vendor_code|string|Required|產品代码|
|data.balance|number|Required|餘額|
|code|int|Required|狀態碼|

<pre>
#Response Example
{
    "data": {
        "member_account": "testAccount",
        "vendor_code": "GPSSL",
        "balance": 100
    },
    "code": 0
}
</pre>

#### 轉出 / 下注
URL:`/sw/transfer-out`
Method:`POST`
Headers:`Content-Type:application/x-www-form-urlencoded`
##### Request
| Parameter      | Type   | Require  | Description              |
| -------------- | ------ | -------- | ------------------------ |
| wtoken         | string | Required | 給貴司驗證是否為我方呼叫 |
| member_account | string | Required | 玩家代碼                 |             |
| vendor_code    | string | Required | 產品代碼                 |
| trans_type | string | Required | 交易類型|
| amount         | number | Required | 交易金額                 |
| trace_id       | string | Required | 交易單號                 |
| bet_id| string | Required | 注單號 |
<pre>
#Request Example
{
   "wtoken": "ca947da21f92447eadb43c76ee6bdda4",
   "member_account": "testAccount",
   "vendor_code": "GPSSL",
   "trans_type": "Stake"
   "amount": 0.3,
   "trace_id": "testAccount-traceId-stake-1627376697",
   "bet_id":"test-1627376697"
}
</pre>

##### Response
|Parameter|Type|Require|Description|
|-|-|-|-|
|data.member_account|string|Required|玩家代碼|
|data.vendor_code|string|Required|產品代码|
|data.trans_type|string|Required|交易類型|
|data.before_balance|number|Required|交易前餘額|
|data.amount|number|Required|交易金額|
|data.balance|number|Required|交易後餘額|
|code|int|Required|狀態碼|

<pre>
#Response Example
{
    "data": {
        "member_account": "testAccount",
        "vendor_code": "GPSSL",
        "trans_type": "Stake"
        "before_balance": 100,
        "amount": 0.3,
        "balance": 99.7
    },
    "code": 0
}
</pre>

#### 轉入 / 派彩
URL:`/sw/transfer-in`
Method:`POST`
Headers:`Content-Type:application/x-www-form-urlencoded`
##### Request
|Parameter|Type|Require|Description|
|-|-|-|-|
|wtoken|string|Required|給貴司驗證是否為我方呼叫|
|member_account|string|Required|玩家代碼|
|vendor_code|string|Required|產品代碼|
|trans_type|string|Required|交易類型|
|amount|number|Required|交易金額|
|trace_id|string|Required|交易單號|
|bet_id|string|Required|注單號|

<pre>
#Request Example
{
   "wtoken": "ca947da21f92447eadb43c76ee6bdda4",
   "member_account": "testAccount",
   "vendor_code": "GPSSL"
   "trans_type": "Payoff"
   "amount": 1.3,
   "trace_id": "testAccount-traceId-payoff-1627376697",
   "bet_id":"test-1627376697"
}
</pre>

##### Response
|Parameter|Type|Require|Description|
|-|-|-|-|
|data.member_account|string|Required|玩家代碼|
|data.vendor_code|string|Required|產品代碼|
|data.trans_type|string|Required|交易類型|
|data.before_balance|number|Required|交易前餘額|
|data.amount|number|Required|交易金額|
|data.balance|number|Required|交易後餘額|
|code|int|Required|狀態碼|

<pre>
#Response Example
{
    "data": {
        "member_account": "testAccount",
        "vendor_code": "GPSSL"
        "trans_type": "Payoff"
        "before_balance": 99.7,
        "amount": 1.3,
        "balance": 101
    },
    "code": 0
}
</pre>

#### 強制 轉出 / 下注
<span style="color:red;">※提供“交易金額”大於“帳戶餘額”的交易，此情況發生在比賽結果改派。</span>
URL:`/sw/force-transfer-out`
Method:`POST`
Headers:`Content-Type:application/x-www-form-urlencoded`
##### Request
|Parameter|Type|Require|Description|
|-|-|-|-|
|wtoken|string|Required|給貴司驗證是否為我方呼叫|
|member_account|string|Required|玩家代碼|
|vendor_code|string|Required|產品代碼|
|trans_type|string|Required|交易類型|
|amount|number|Required|交易金額|
|trace_id|string|Required|交易單號|
|bet_id|string|Required|注單號|

<pre>
#Request Example
{
   "wtoken": "ca947da21f92447eadb43c76ee6bdda4",
   "member_account": "testAccount",
   "vendor_code": "GPSSL",
   "trans_type": "cancelPayoff",
   "amount": 1.3,
   "trace_id": "testAccount-traceId-cancelpayoff-1627376697",
   "bet_id":"test-1627376697"
}
</pre>

##### Response
|Parameter|Type|Require|Description|
|-|-|-|-|
|data.member_account|string|Required|玩家代碼|
|data.vendor_code|string|Required|產品代碼|
|data.trans_type|string|Required|交易類型|
|data.before_balance|number|Required|交易前餘額|
|data.amount|number|Required|交易金額|
|data.balance|number|Required|交易後餘額|
|code|int|Required|狀態碼|

<pre>
#Response Example
{
    "data": {
        "member_account": "testAccount",
        "vendor_code": "GPSSL"
        "trans_type": "cancelPayoff"
        "before_balance": 101,
        "amount": 1.3,
        "balance": 99.7
    },
    "code": 0
}
</pre>


#### 查詢交易單據
URL:`/sw/query-translog`
Method:`POST`
Headers:`Content-Type:application/x-www-form-urlencoded`
##### Request
|Parameter|Type|Require|Description|
|-|-|-|-|
|wtoken|string|Required|給貴司驗證是否為我方呼叫|
|trace_id|string|Required|交易單號|
|<span style="color:red">member_account</span>|string|Required|玩家代碼|

<pre>
#Request Example
{
   "wtoken": "ca947da21f92447eadb43c76ee6bdda4",
   "trace_id": "testAccount-traceId-cancelpayoff-1627376697",
   <span style="color:red">"member_account": "testAccount"</span>
}
</pre>

##### Response
|Parameter|Type|Require|Description|
|-|-|-|-|
|data.trans_at|integer|Required|交易時間戳記 (貴司收到我方請求產生交易的時間)|
|data.trace_id|string|Required|交易序號|
|data.member_account|string|Required|玩家代碼|
|data.vendor_code|string|Required|產品代碼|
|data.trans_type|string|Required|交易類型|
|data.before_balance|number|Required|交易前餘額|
|data.amount|number|Required|交易金額|
|data.after_balance|number|Required|交易後餘額|
|code|int|Required|狀態碼<span style="color:red;">（※若查詢資料為空時返回7105）</span>|

<pre>
#Response Example
{
    "data": {
        "trans_at": 1627376697231,
        "trace_id": "testAccount-traceId-cancelpayoff-1627376697",
        "member_account": "testAccount",
        "vendor_code": "GPSSL",
        "trans_type": "cancelPayoff",
        "before_balance": 101,
        "amount": 1.3,
        "balance": 99.7
    },
    "code": 0
}
</pre>


##### 查無資料時
```json
#Response Example
{
    "data": null,
    "code": 7105
}
```

###### tags: `單一錢包介接`