function processPayload(payload, globalAttributes = {}, stringify = true) {
    if (stringify) {
        const maskedStr = maskSensitiveData(payload);
        const processed = Object.assign({}, JSON.parse(maskedStr), globalAttributes);
        return JSON.stringify(processed);
    } else {
        const processed = Object.assign({}, payload, globalAttributes);
        const maskedStr = maskSensitiveData(processed);
        return JSON.parse(maskedStr);
    }
}
Process a payload with sensitive data masked

@param {Object} payload - The original payload 
@param {Object} globalAttributes - Additional attributes to add
@param {boolean} stringify - Whether to return a string or object
@returns {string|Object} Processed payload