:::info
> [time=Jul 11, 2023 ]
Document init
Get Vendor Transaction新增回傳UpdateTime
> [time=Feb 23, 2024 ]
新增<a href="#Get-Login-Url" title="Title">Get Login Url</a>
移除<a href="#Get-Login-Key" title="Title">Get Login Key</a>和<a href="#Player-Login" title="Title">Player Login</a>
> [time=Mar 26, 2024 ]
移除Get Vendor Transaction非必要欄位 (vendorTransId, platformTransId, krainStake, poolStake, krainPayout)
> [time=May 29, 2024 ]
新增欄位(exposureAmount、availableBetAmount)<a href="#Get-Credit-Balance" title="Title">Get Credit Balance</a>
> [time=May 31, 2024 ]
<a href="#Withdraw" title="Title">Withdraw </a>新增欄位(withdrawAmount) 支援部分提領, 增加response資訊
----
:::
<!--
markdown to html see -> https://hackmd.io
-->
# API 使用流程
1. 透過 <a href="#Get-Login-Url" title="Title">GetLoginUrl</a> 取得Login URL傳給玩家進行登入
2. 透過 <a href="#Deposit" title="Title">Deposit</a> 進行轉帳對玩家錢包做存入
# API for player
## Get Login Url
**URL** `http://{host}/vendor/api/getLoginUrl`
**Method** `POST`
**Request**
| Parameter | Type | Require | Description |
| ---------- | ------ | ------- | ------------------------------------- |
| certCode | string | Y | security code |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| userId | string | Y | 玩家帳號,長度限制15 |
| betLimit | string | Y | [player bet limit](#Player-Bet-limit) |
**Response**
| Parameter | Type | Description |
| --------- | ------ | ----------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
| data | string | Login Url |
```json
{
"code": "1",
"message": "SUCCESS",
"data": "https://a3b7d.kbook99.com/player/index.html?token=7230d64f66777a2388e2beb91488ce128b30de2b517e2e3bdf3bac6ae9511b"
}
```
</br>
## Player Logout
**URL** `http://{host}/vendor/api/logout`
**Method** `POST`
**Request**
| Parameter | Type | Require | Description |
| ---------- | ------ | ------- | --------------------------- |
| certCode | string | Y | security code |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| userId | string | Y | 玩家帳號,長度限制15 |
**Response**
| Parameter | Type | Description |
| --------- | ------ | --------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
```json
{
"code": "1",
"message": "SUCCESS"
}
```
</br>
## Update Bet Limit
**URL** `http://{host}/vendor/api/updateBetLimit`
**Method** `POST`
**Request**
| Parameter | Type | Require | Description |
| ---------- | ------ | ------- | ------------------------------------- |
| certCode | string | Y | security code |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| userId | string | Y | 玩家帳號,長度限制15 |
| betLimit | string | Y | [player bet limit](#Player-Bet-limit) |
**Response**
| Parameter | Type | Description |
| --------- | ------ | --------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
```json
{
"code": "1",
"message": "SUCCESS"
}
```
### Player Bet limit
| Parameter | Type | Description |
| --------- | ------ | ----------- |
| certCode | string |security code |
| minBet | number | 最小注 |
| maxBet | number | 最大注 |
| maxExposure | number | 每場下注上限|
下限 100, 上限 10000, 單場最大下注金額50000
```jsonld
{
"minBet": 100,
"maxBet": 10000,
"maxExposure":50000
}
```
</br>
## Deposit
**URL** `http://{host}/vendor/api/deposit`
**Method** `POST`
**Description**
玩家入金
**Request**
| Parameter | Type | Require | Description |
| ------------- | ------ | ------- | ---------------------------------- |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| certCode | string | Y | security code |
| userId | string | Y | 玩家帳號,長度限制15 |
| tsCode | string | Y | 屬於此交易的 uuid 字串,長度限制36 |
| depositAmount | number | Y | 入金額度 |
**Response**
| Parameter | Type | Description |
| --------- | ------ | --------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
| data | Object | |
| userId | string | 使用者ID |
| vendorType | string | [Vendor type](#Vendor-Type) |
| currencyType | string | [Currency type](#Currency-Type) |
| tsCode | string | 屬於此交易的uuid字串 |
| transferAmount | number | 轉帳金額 |
| accountProfitLoss | number | 轉帳前盈虧金額 |
| costExposure | number | 潛在輸贏 |
| currentCredit | number | 目前的金額 |
| afterCredit | number | 轉帳後金額 |
| createTime | number | 建立時間 |
```json
{
"code": "1",
"message": "SUCCESS",
"data": {
"userId": "willy001",
"vendorType": "CPS_USD",
"currencyType": "USD",
"tsCode": "0cf4fdf2-814a-494e-9348-7286dbee7695",
"transferAmount": 10000,
"accountProfitLoss": 0,
"costExposure": 0,
"currentCredit": 0,
"afterCredit": 10000,
"createTime": 1717482781704
}
}
```
</br>
## Withdraw
**URL** `http://{host}/vendor/api/withdraw`
**Method** `POST`
**Description**
玩家出金
**Request**
| Parameter | Type | Require | Description |
| -------------- | ------ | ------- | ---------------------------------- |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| certCode | string | Y | security code |
| userId | string | Y | 玩家帳號,長度限制15 |
| tsCode | string | Y | 屬於此交易的 uuid 字串,長度限制36 |
| withdrawAmount | number | N | 出金額度(空的話為全提) |
**Response**
| Parameter | Type | Description |
| --------- | ------ | --------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
| data | Object | |
| userId | string | 使用者ID |
| vendorType | string | [Vendor type](#Vendor-Type) |
| currencyType | string | [Currency type](#Currency-Type) |
| tsCode | string | 屬於此交易的uuid字串 |
| transferAmount | number | 轉帳金額 |
| accountProfitLoss | number | 轉帳前盈虧金額 |
| costExposure | number | 潛在輸贏 |
| currentCredit | number | 目前的金額 |
| afterCredit | number | 轉帳後金額 |
| createTime | number | 建立時間 |
```json
{
"code": "1",
"message": "SUCCESS",
"data": {
"userId": "test001",
"vendorType": "CPS_USD",
"currencyType": "USD",
"tsCode": "5f893349-fb0b-45e2-8113-01e4da448651",
"transferAmount": -10547.83,
"accountProfitLoss": -472.17,
"costExposure": 0,
"currentCredit": 11020,
"afterCredit": 0,
"createTime": 1717384610507
}
}
```
</br>
## Get Credit Balance
**URL** `http://{host}/vendor/api/getCreditBalance`
**Method** `POST`
**Description**
查詢此玩家可下注的額度
**Request**
| Parameter | Type | Require | Description |
| ---------- | ------ | ------- | --------------------------- |
| certCode | string | Y | security code |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| userId | string | Y | 玩家帳號,長度限制15 |
**Response**
| Parameter | Type | Description |
| -------------- | ------ | --------------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
| data | Object | |
| userId | string | 使用者ID |
| vendorType | string | [Vendor type](#Vendor-Type) |
| currentBalance | number | 目前可提領餘額 |
| availableBetAmount | number | 目前可下單餘額 |
| exposureAmount | number | 潛在輸贏 |
| queryTime | number | 查詢時間 |
```json
{
"code": "1",
"message": "SUCCESS",
"data": {
"userId": "willy003",
"vendorType": "CPS_USD",
"currentBalance": 92.0,
"withdrawableAmount": 0,
"queryTime": 1716952830103
}
}
```
</br>
## Get Wallet Transfer Log
**URL** `http://{host}/vendor/api/getWalletTransferLog`
**Method** `POST`
**Description**
查詢此交易碼對應的資訊
**Request**
| Parameter | Type | Require | Description |
| ---------- | ------ | ------- | ---------------------------------- |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| certCode | string | Y | security code |
| tsCode | string | Y | 屬於此交易的 uuid 字串,長度限制36 |
**Response**
| Parameter | Type | Description |
| ----------------- | ------ | ------------------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
| data | Object | |
| userId | string | 使用者ID |
| vendorType | string | [Vendor type](#Vendor-Type) |
| currencyType | string | [Currency type](#Currency-Type) |
| tsCode | string | 屬於此交易的uuid字串 |
| transferAmount | number | 轉帳金額 |
| accountProfitLoss | number | 盈虧金額 |
| costExposure | number | 目前的exposure |
| currentCredit | number | 目前的金額 |
| afterCredit | number | 轉帳後金額 |
| createTime | number | 建立時間 |
```json
{
"code": "1",
"message": "SUCCESS",
"data": {
"userId": "test001",
"vendorType": "CPS_USD",
"currencyType": "USD",
"tsCode": "50de38cf-48ea-412d-9a46-05dcab45a40c",
"transferAmount": -2463.7,
"accountProfitLoss": 63.7,
"costExposure": 0,
"currentCredit": 2400,
"afterCredit": 0,
"createTime": 1710907822687
}
}
```
</br>
## Get Vendor Transaction
**URL** `http://{host}/vendor/api/getVendorTransactionByUpdateTime`
**Method** `POST`
**Description**
搜尋傳入之updateTime之後的交易單(兩天內)
**Request**
| Parameter | Type | Require | Description |
| ---------- | ------ | ------- | ---------------------------------- |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| certCode | string | Y | security code |
| updateTime | number | Y | yyyyMMddHHmmssSSS |
**Response**
| Parameter | Type | Description |
| --------------- | ------ | --------------------------------------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
| data | array | |
| id | number | 投注方交易單號 |
| vendorType | string | [Vendor type](#Vendor-Type) |
| gameSessionId | number | 遊戲場次ID |
| gameDate | string | 遊戲日期 |
| userId | string | 玩家ID |
| currencyType | string | [Currency type](#Currency-Type) |
| originStake | number | 下注金額(KBook) |
| transactionStatus | string | [Transaction Status type](#Transaction-Status-Type) |
| betType | string | [Bet type](#Bet-Type) |
| betOdds | number | 下注賠率 |
| originPayout | number | 結算時的輸贏(KBook) |
| betTime | number | 下注時間 |
| summaryTime | number | 結算時間 ||
updateTime | number | 更新時間 |
| betSourceType | string | 目前無用 |
| gameSessionType | string | [Game Session type](#Game-Session-Type) |
```json
{
"code": "1",
"message": "SUCCESS",
"data": [
{
"id": 11,
"vendorType": "CPS_USD",
"gameSessionId": 24699,
"gameDate": "26-03-2024",
"userId": "test001",
"currencyType": "USD",
"originStake": 100,
"transactionStatus": "ACTIVE",
"betType": "NO_RAIN",
"betOdds": 49.0,
"originPayout": 0,
"betTime": 1711425673595,
"summaryTime": null,
"updateTime": 1711425673595,
"betSourceType": "PLAYER",
"gameSessionType": "MORNING"
},
{
"id": 12,
"vendorType": "CPS_USD",
"gameSessionId": 24699,
"gameDate": "26-03-2024",
"userId": "test001",
"currencyType": "USD",
"originStake": 100,
"transactionStatus": "ACTIVE",
"betType": "NO_RAIN",
"betOdds": 49.0,
"originPayout": 0,
"betTime": 1711425678806,
"summaryTime": null,
"updateTime": 1711425678806,
"betSourceType": "PLAYER",
"gameSessionType": "MORNING"
},
{
"id": 13,
"vendorType": "CPS_USD",
"gameSessionId": 24699,
"gameDate": "26-03-2024",
"userId": "test001",
"currencyType": "USD",
"originStake": 400,
"transactionStatus": "ACTIVE",
"betType": "NO_RAIN",
"betOdds": 49.0,
"originPayout": 0,
"betTime": 1711425682188,
"summaryTime": null,
"updateTime": 1711425682188,
"betSourceType": "PLAYER",
"gameSessionType": "MORNING"
}
]
}
```
</br>
<!-- ## Get Summary Transaction By Game Date
**URL** `http://{host}/vendor/api/getSummaryTxnByGameDate`
**Method** `POST`
**Description**
搜尋時間區間內的 summary transaction
**Request**
| Parameter | Type | Require | Description |
| ---------- | ------ | ------- | --------------------------- |
| vendorType | string | Y | [vendor type](#Vendor-Type) |
| certCode | string | Y | security code |
| startDate | string | Y | yyyyMMdd |
| endDate | string | Y | yyyyMMdd |
**Response**
| Parameter | Type | Description |
| --------- | ------ | --------------------- |
| code | string | [狀態代碼](#狀態代碼) |
| message | string | [狀態代碼](#狀態代碼) |
```json
{
"code": "1",
"message": "SUCCESS",
"data": [
{
"vendorType": "CPS_USD",
"gameSessionId": 22097,
"userId": "test003",
"currencyType": "USD",
"gameDate": "10-07-2023",
"stake": 100,
"payout": -100,
"betSourceType": "PLAYER"
},
{
"vendorType": "CPS_USD",
"gameSessionId": 22097,
"userId": "test001",
"currencyType": "USD",
"gameDate": "10-07-2023",
"stake": 100,
"payout": -50,
"betSourceType": "PLAYER"
}
]
}
``` -->
</br>
# Types / Status
### Vendor Type
| type | website | currency | min bet | max bet
| ----- | ------ | ------- | ------- | -------
| CPS_USD | CPS | USD | 10 | 5000
| CPS2_USD | CPS2 | USD | 10 | 5000
<!-- | CPS_HKD | CPS | HKD | 100 | 6000 -->
<!-- | MPS_USD | MPS | USD | 100 | 7000 -->
### Bet Type
| type |
| -----
| RAIN
| NO_RAIN
### Game Session Type
| type | 場次區間 |
| --------- | ----------- |
| MORNING | 06:00-12:00 |
| AFTERNOON | 06:00-12:00 |
| NIGHT | 18:00-06:00 |
| NOON | 06:00-18:00 |
### Transaction Status Type
| type | 描述 |
| ------- | ---------------- |
| TEMP | 玩家下單 |
| ACTIVE | 雨天戳和成功 |
| FAILED | 雨天戳和失敗 |
| SETTLED | 結算 |
| VOID | 無效 |
| CHECK | 與KRain同步時的狀態 |
### Game Status Type
| type | 描述 |
| --------- | -------------- |
| READY | 目前只有雨天用 |
| OPEN | 開場 |
| CLOSE | 關場 |
| SUSPEND | 暫停 |
| UNSETTLED | 未結算 |
| SETTLED | 已結算 |
| VOID | 無效 |
### Game Result Type
| type
| -----
| NOT_AVAILABLE
| NO_RAIN
| RAIN
| VOID
### Currency Type
目前系統僅支援 `USD 美金`
| type
| -----
| USD
### 狀態代碼
| code | message |
| ----- |-------------|
| 1 | SUCCESS
| 0 | FAIL
| 1001 | ILLEGAL ARGUMENT
| 1002 | SOURCE NOT FOUND
| 1003 | CODE INSUFFICIENT BALANCE
| 1004 | DATE FORMAT EXCEPTION
| 2001 | TOKEN EXPIRE
| 2002 | TOKEN IP MISMATCH
| 2003 | NOT AUTHORIZED
| 2004 | PASSWORD ERROR
| 2005 | IP MISMATCH
| 2006 | REFRESH TOKEN EXPIRED
| 2007 | REFRESH TOKEN INVALID
| 4001 | GAME STATUS INVALID
| 4002 | MARKET STATUS INVALID
| 4003 | ODDS INVALID
| 4004 | BET LIMIT INVALID
| 4005 | CREDIT INVALID
| 4006 | EXCEED MAX EXPOSURE
| 4007 | PLACE BET FAILED
| 4008 | BETTING POOL FAILED
| 5001 | NOT READABLE ERROR
| 5002 | DATA ACCESS ERROR
| 5003 | CONTENT TYPE ERROR
| 6001 | DB UPDATE ERROR
| 6002 | DB SAVE ERROR
| 8001 | FAILED TO CALL K-RAIN API
| 999 | UNKNOWN ERROR