Signature
L'API HaloPay authentifie vos requêtes via AppId et AppKey. Connectez-vous à votre compte HaloPay, allez sur la page AppManage pour trouver votre AppId et AppKey.
info
AppId et AppKey donnent des privilèges étendus : gardez-les en sécurité. Ne les partagez pas dans des zones accessibles au public (GitHub, code client, etc.).
Guide de signature
En-têtes
| Nom | Type | Description |
|---|---|---|
| X-Sign | string | Signature |
| X-Timestamp | int | Horodatage (sec) |
| X-Appid | string | APPID marchand |
| content-type | string | application/json |
Algorithme de signature
// 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
}