Please note: The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please post in our forum, but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance.
colinskow on the FoxyCart forums has developed a Node.js version of the simple add to cart link and form validation, as detailed on this page.
var createHmac = require('crypto').createHmac; module.exports = function hmacValidate(secret, key, value, productCode, parentCode = '', encodeValue = false) { let hmac = createHmac('sha256', secret); let toEncode = escapeHtml(productCode + parentCode + key + value); let label = encodeValue ? value : key; hmac.update(toEncode); let result = label + '||' + hmac.digest('hex').toLowerCase(); if(value === '--OPEN--') { result += '||open'; } return result; }; function escapeHtml(text) { var map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return text.replace(/[&<>"']/g, function(m) { return map[m]; }); }