Skip to content

Instantly share code, notes, and snippets.

@manuelfdo
manuelfdo / decode_ecwid_request.js
Last active August 23, 2023 07:35
Example of decoding Ecwid payment request using Web Cryptography API / SublteCrypto. https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto
var bodyData = 'ECWID PAYLOAD';
var clientId = 'YOUR CLIENT SECRET';
// Added required padding to make the payload a multiple of 4. We can do this using a repeat or a simple while.
// var paddingLength = 4 - (bodyData.length % 4);
// if (paddingLength !== 4) {
// bodyData + '='.repeat(paddingLength);
// }