Last active
August 30, 2021 03:38
-
-
Save ansonliam/518891e017b4e2916daa35d0f5a5d5a2 to your computer and use it in GitHub Desktop.
Shopify Hmac generation In Postman.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This script is placed in the Pre-request Script. | |
// Setup two environment variables: "secret" and "hmac" | |
// replace the secret key from Shopify. and use {{hmac}} as the value in the header. | |
var secret = pm.environment.get('secret'); | |
var body = request.data; | |
var hmac = CryptoJS.HmacSHA256(body, secret); | |
hmac = CryptoJS.enc.Base64.stringify(hmac); | |
console.log("body: " + body); | |
console.log("secret: " + secret); | |
console.log("hmac: " + hmac); | |
postman.setEnvironmentVariable("hmac", hmac); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment