跳到主要内容

簽章

HaloPay API 透過 AppId 和 AppKey 對請求進行鑑權。登入 HaloPay 帳戶,進入 應用管理,可在該頁查看 AppIdAppKey

信息

AppId 和 AppKey 權限較高,請妥善保管,切勿在 GitHub、客戶端程式碼等公開可存取處洩漏。

簽章說明

請求標頭

名稱類型說明
X-Signstring簽章
X-Timestampint時間戳(秒)
X-Appidstring商戶 APPID
content-typestringapplication/json

簽章演算法

// sign (golang)
func hmacSHA256Sign(appKey, timestamp string, body interface{}) (string, error) {
jsonStr, err := json.Marshal(body)
if err != nil {
return "", err
}
sha256Mac := hmac.New(sha256.New, []byte(appKey))
_, err = sha256Mac.Write(append(jsonStr, []byte(timestamp)...))
if err != nil {
return "", err
}
return hex.EncodeToString(sha256Mac.Sum(nil)), nil
}