type SymetricSignaturePayload struct {
Method string `json:"method"`
Url string `json:"url"`
AccessToken string `json:"accessToken"`
TimeStamp string `json:"timeStamp"`
ClientSecretKey string `json:"clientSecretKey"`
}
func SnapSymmetricSignature() {
body := `
{
"partnerReferenceNo":"2020102900000000000001",
"bankCardToken":"6d7963617264746f6b656e",
"accountNo":"7382382957893840",
"balanceTypes":[
"Cash",
"Coins"
],
"additionalInfo":{
"deviceId":"12345679237",
"channel":"mobilephone"
}
}
`
sha256 := crypto.SHA256.New()
sha256.Write([]byte(body))
sha256SecretKey := hex.EncodeToString(sha256.Sum(nil))
headers := SymetricSignaturePayload{}
headers.Method = http.MethodPost
headers.Url = "/v1.0/balance-inquiry"
headers.TimeStamp = time.Now().Add(time.Duration(time.Second * 15)).Format(time.RFC3339)
headers.ClientSecretKey = "82150823919040624621823174737537"
payload :=
headers.Method + ":" + headers.Url + ":" + headers.AccessToken + ":" + strings.ToLower(sha256SecretKey) + ":" + headers.TimeStamp
hmac512 := hmac.New(crypto.SHA512.New, []byte(headers.ClientSecretKey))
hmac512.Write([]byte(payload))
hmac512SecretKey := base64.StdEncoding.EncodeToString(hmac512.Sum(nil))
fmt.Println(hmac512SecretKey)
}