1. Data payload
{
"data": {
"date": "2022-10-26T14:22:46+07:00",
"ref_code": "CR22509365559", // mã CR hoặc FD
"order_code": "347171821",
"status": "canceled",
"type" : "cr" // fd | cr
}
}
Description
- date: time to push data
- ref_code: CR or FD code
- order_code: Tiki order code
- status: status of CR or FD. List of FD status here | List of CR status here
- type: cr | fd
2. Authentication signature
Using HMAC-SHA1 signature. TikiNOW provided webhook secret for client and formula generate HMAC-SHA1 signature. Using this signature to compare with signature on header request (key on header: x-signature).
Example Golang code
func GenerateSignature(secretToken, payloadBody string) string {
mac := hmac.New(sha1.New, []byte(secretToken))
mac.Write([]byte(payloadBody))
expectedMAC := mac.Sum(nil)
return "sha1=" + hex.EncodeToString(expectedMAC)
}
Return HTTP status 2xx when received successfully and 5xx when failed
Example
curl --location 'https://your-domain/aftersale/webhooks' \
--header 'Content-Type: application/json' \
--header 'x-signature: sha1=d929b12836ce52528db1bc25797186c86b13b4ee' \
--data '{"data":{"date":"2022-10-26T14:22:46+07:00","ref_code":"CR22509365559","order_code":"347171821","status":"canceled","type":"cr"}}'
Data response
| HTTP Status Code | Description | Response |
| 2xx | Success | { “success”: true } |
| 4xx | Error | { “success”: false “error”: { “code”: “CLIENT_NOT_EXIST”, “message”: “Client doesn’t exist”, }, } |
| 5xx | Server error | { “success”: false “error”: { “code”: “BAD_GATEWAY”, “message”: “Bad gateway”, }, } |