서명
HaloPay API는 AppId와 AppKey로 요청을 인증합니다. HaloPay 계정에 로그인한 후 앱 관리 페이지에서 AppId와 AppKey를 확인할 수 있습니다.
정보
AppId와 AppKey는 높은 권한을 가지므로 안전하게 보관하세요. GitHub, 클라이언트 코드 등 공개 영역에 공유하지 마세요.
서명 가이드
헤더
| 이름 | 타입 | 설명 |
|---|---|---|
| X-Sign | string | 서명 |
| X-Timestamp | int | 타임스탬프(초) |
| X-Appid | string | 가맹점 APPID |
| content-type | string | application/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
}