加簽加密說明
規則說明
簽章產生規則:
- 除「簽章(sign)」欄位外,所有 Request 欄位序列化為 Json 字串, Json 字串需使用 Key
- 進行字母排序,且字串內除欄位值外 ,不可含空白及換行符號 (\r\n)
- 欄位型態若為字串,且該欄位未設定值,請塞入空字串
- 將 Json 字串加上 MerchantKey 以 UTF 8 編碼,使用 SHA 256 加密後再轉換為16進位字串
範例
第一步驟:
先與街口支付申請對應的 MerchantKey,範例值為 2AA6B9B6F9C64247ABB2677B6AF2C896,並組成 Payment Request
"MerchantID": "9999999"
"StoreID": "000000000000001"
"StoreName": "Welcome"
"GatewayTradeNo": ""
"MerchantTradeNo": "2343565453423421"
"PosID": "1"
"PosTradeTime": "2016/05/08 12:01:01"
"CardToken": "22J111111111111111"
"TradeAmount": 200
"UnRedeem": 0
"Remark": "remark"
"Extra1": "abc"
"Extra2": ""
"Extra3": ""
"SendTime": "20160805120103"
第二步驟:
將 Payment Request 內容進行序列化為 Json 字串,並於 Json 字串尾加上 MerchantKey,重新排序後,請勿加入空白以及換行
{"CardToken":"22J111111111111111","Extra1":"abc","Extra2":"","Extra3":"","GatewayTradeNo":"","MerchantID":"9999999","MerchantTradeNo":"2343565453423421","PosID":"1","PosTradeTime":"2016/05/08 12:01:01","Remark":"remark","SendTime":"20160805120103","StoreID":"000000000000001","StoreName":"Welcome","TradeAmount":200,"UnRedeem":0}2AA6B9B6F9C64247ABB2677B6AF2C896
第三步驟:
將上述內容進行 SHA-256 加密,再換為 16 進位字串表示:
e8cdee71be13a512e6dbfcc7e86541aa7a05078de0f6d584a1e442437e0dab9d