@shanwker/auttar
Version:
Auttar WebSocket JS Class. An easy implementation of Auttar WebSocket Service.
1 lines • 28.6 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../src/Helpers.js","../src/Auttar.js"],"sourcesContent":["const LogLevelName = {\n Info: 'info',\n Warn: 'warn',\n Error: 'error',\n Method: 'method',\n All: 'all',\n None: 'none',\n};\n\nconst LogLevelStyle = {\n Info: 'background:#215ace ; padding: 2px; border-radius: 2px 0 0 2px; color: #fff;',\n Warn: 'background:#e8c82c ; padding: 2px; border-radius: 2px 0 0 2px; color: #000;',\n Error: 'background:#c92112 ; padding: 2px; border-radius: 2px 0 0 2px; color: #fff;',\n Method: 'background:#6d0cb2 ; padding: 2px; border-radius: 2px 0 0 2px; color: #fff;',\n};\n\nconst NAME = 'Auttar ';\nconst BACKGROUND = 'background:#bc0909 ; padding: 2px; border-radius: 0 2px 2px 0; color: #fff ';\n\nconst log = (name, style, className, classStyle, message) => {\n console.log(`%c ${name} %c ${className} %c ${message}`, style, classStyle, 'background: transparent;'); // eslint-disable-line no-console\n};\n\nconst showError = (name, style, className, classStyle, message) => {\n console.error(`%c ${name} %c ${className} %c ${message}`, style, classStyle, 'background: transparent;'); // eslint-disable-line no-console\n};\n\nexport function required(name, param) {\n if (param === undefined) {\n throw new Error(`Parâmetro obrigatório ${name} não declarado.`);\n }\n\n return param;\n}\n\nexport function logInfo(msg) {\n log(LogLevelName.Info, LogLevelStyle.Info, NAME, BACKGROUND, msg);\n}\n\nexport function logWarn(msg) {\n log(LogLevelName.Warn, LogLevelStyle.Warn, NAME, BACKGROUND, msg);\n}\n\nexport function logMethod(method, args, params) {\n log(LogLevelName.Method, LogLevelStyle.Method, NAME, BACKGROUND, `Call Method: ${method}(${args || ''}) ${(params) ? `=> ${JSON.stringify(params)}` : ''}`);\n}\n\nexport function logError(msg) {\n showError(LogLevelName.Warn, LogLevelStyle.Warn, NAME, BACKGROUND, msg);\n}\n\n/**\n * Add spaces to match the max screen length\n * @param {string} text\n * @param {number} maxChar\n * @returns {string}\n */\nexport function addSpaces(text, maxChar) {\n return text\n .split('')\n .concat(...Array(maxChar)\n .fill(' '))\n .slice(0, maxChar)\n .join('');\n}\n\nexport function sleep(ms) {\n return new Promise((res) => setTimeout(res, ms));\n}\n\nexport default {\n required,\n logInfo,\n logError,\n logWarn,\n logMethod,\n addSpaces,\n sleep,\n};\n","/* eslint-disable no-underscore-dangle */\nimport {\n logInfo, logError, logMethod, logWarn, sleep,\n} from './Helpers';\n\nconst privateVariables = {\n transactions: {\n credit: {\n base: 112,\n installment: 113,\n installmentWithInterest: 114,\n },\n debit: {\n base: 101,\n voucher: 106,\n },\n cancel: 128,\n confirm: 6,\n requestCancel: 191,\n },\n return: {\n success: 0,\n timeOut: 1,\n notAuthorizes: 5,\n internetError: 10,\n intertefError: 12,\n error: 20,\n ecommerceError: 30,\n },\n errorCodes: {\n 5300: 'Valor não informado',\n 5301: 'Cartão inválido',\n 5302: 'Cartão vencido',\n 5303: 'Data de vencimento inválido',\n 5304: 'Código de segurança inválido',\n 5305: 'Taxa de serviço excede limite',\n 5306: 'Operação não permitida',\n 5307: 'Dados inválidos',\n 5308: 'Valor mínimo da parcela inválido',\n 5309: 'Número de parcelas inválido',\n 5310: 'Número de parcelas excede limite',\n 5311: 'Valor da entrada maior ou igual ao valor da transação',\n 5312: 'Valor da parcela inválido',\n 5313: 'Data inválida',\n 5314: 'Prazo excede limite',\n 5316: 'NSU inválido',\n 5317: 'Operação cancelada pelo usuário',\n 5318: 'Documento inválido (CPF ou CNPJ)',\n 5319: 'Valor do documento inválido',\n 5328: 'Erro na captura de dados do Pin-Pad',\n 5329: 'Erro na captura do chip ou cartão removido antes da hora.',\n 5364: 'Data de emissão do cartão inválida',\n 5355: 'O tipo de financiamento informado não é coerente com o número de parcelas',\n },\n ws: null,\n timeout: null,\n close: true,\n timeoutConn: null,\n timeoutMs: 60000,\n debug: false,\n};\n\nfunction _disconnect() {\n if (privateVariables.debug) {\n logMethod('_disconnect');\n }\n\n privateVariables.ws.close();\n}\n\nfunction _clearTimeout() {\n if (privateVariables.debug) {\n logMethod('_clearTimeout');\n logInfo('Clearing WebSocket timeout.');\n }\n\n privateVariables.close = false;\n clearTimeout(privateVariables.timeoutConn);\n privateVariables.close = true;\n}\n\nfunction _timeout(time = 10000) {\n return new Promise((resolve, reject) => {\n if (privateVariables.debug) {\n logMethod('_timeout', 'time', time);\n logInfo('Starting WebSocket timeout.');\n }\n\n privateVariables.timeoutConn = setTimeout(() => {\n if (!privateVariables.close) {\n _clearTimeout();\n resolve(true);\n } else {\n privateVariables.ws.close();\n reject(new Error('Connection Timeout.'));\n }\n }, time);\n });\n}\n\nfunction _connect(host, payload) {\n if (privateVariables.debug) {\n logMethod('_connect', 'host', host);\n }\n\n return new Promise((resolve, reject) => {\n try {\n if (privateVariables.ws === null) {\n if (privateVariables.debug) {\n logInfo('Starting WebSocket Connection.');\n }\n\n privateVariables.ws = new WebSocket(host);\n } else if (privateVariables.ws.readyState === 2 || privateVariables.ws.readyState === 3) {\n if (privateVariables.debug) {\n logWarn('WebSocket is connected but not available. Closing connection to start a new one.');\n }\n\n _disconnect();\n privateVariables.ws = new WebSocket(host);\n }\n } catch (e) {\n reject(e);\n }\n\n if (privateVariables.ws) {\n _timeout();\n\n const sendRequest = () => {\n if (privateVariables.debug) {\n logInfo('Sending a message to the WebSocket.');\n logInfo(JSON.stringify(payload));\n }\n\n _clearTimeout();\n privateVariables.ws.send(JSON.stringify(payload));\n _timeout(privateVariables.timeoutMs)\n .catch(e => reject(e));\n };\n\n if (privateVariables.ws.readyState === 1) {\n sendRequest();\n } else {\n privateVariables.ws.onopen = () => {\n if (privateVariables.debug) {\n logInfo('WebSocket Connected.');\n }\n\n sendRequest();\n };\n }\n\n privateVariables.ws.onmessage = (evtMsg) => {\n if (privateVariables.debug) {\n logInfo('Received a message from the WebSocket.');\n logInfo(JSON.stringify(evtMsg.data));\n }\n\n _clearTimeout();\n resolve(JSON.parse(evtMsg.data));\n };\n\n privateVariables.ws.onerror = (evtError) => {\n if (privateVariables.debug) {\n logWarn('WebSocket has returned an error.');\n logError(JSON.stringify(evtError));\n }\n\n _clearTimeout();\n reject(evtError);\n };\n }\n });\n}\n\n/**\n * @typedef {Object} AuttarCupomLinha\n * @property {string} linha\n */\n\n/** @typedef {Object} AuttarSuccessResponse\n * @property {String} bandeira\n * @property {String} cartao\n * @property {String} codigoAprovacao\n * @property {String} codigoErro\n * @property {String} codigoRespAutorizadora\n * @property {Array} cupomCliente\n * @property {Array.<AuttarCupomLinha>} cupomEstabelecimento\n * @property {Array.<AuttarCupomLinha>} cupomReduzido\n * @property {Array} display\n * @property {Number} nsuAutorizadora\n * @property {Number} nsuCTF\n * @property {Number} operacao\n * @property {String} redeAdquirente\n * @property {Number} retorno\n * @property {String} valorTransacao\n */\n\n/**\n * @class Auttar WebSocket\n * @constructor {AuttarConstructor}\n */\n/**\n * @typedef {object} AuttarConstructor\n * @property {string} host - WebSocket Host URL\n * @property {boolean} debug - Método debug da classe\n * @property {string} orderId - Número de identificação da venda\n * @property {float} amount - Valor da venda\n * @property {number} webSocketTimeout - SocketTimeout\n * @property {number} sleepTimeout - sleepTimeout\n * @property {AuttarSuccessResponse} ctfTrasaction - Objecto de resposta do websocket\n */\n\nclass Auttar {\n /**\n * Construtor da classe\n * @param {AuttarConstructor} props\n */\n constructor(props) {\n this.__host = props.host || 'ws://localhost:2500';\n this.debug = props.debug || false;\n privateVariables.debug = props.debug || false;\n privateVariables.timeoutMs = props.webSocketTimeout || 60000;\n this.orderId = props.orderId || '';\n this.__amount = 0;\n this.__sleepTimeout = props.sleepTimeout || 1000;\n if (props.amount) this.amount = props.amount;\n this.__transactionDate = new Date()\n .toLocaleDateString(\n 'pt-BR',\n {\n year: '2-digit',\n month: '2-digit',\n day: '2-digit',\n timeZone: 'America/Sao_Paulo',\n },\n )\n .replace(/\\//g, '');\n this.ctfTransaction = {};\n this.__debugMessage = [];\n }\n\n debugLog(message) {\n if (this.debug) {\n logInfo(JSON.stringify(message));\n }\n }\n\n debugWarning(message) {\n if (this.debug) {\n logWarn(message);\n }\n }\n\n debugLogMethod(method, args, ...params) {\n if (this.debug) {\n logMethod(method, args, params);\n }\n }\n\n classError(message) {\n this.debugMessage = {\n message,\n logLevel: 'error',\n };\n\n if (this.debug) {\n logError(message);\n }\n\n return new Error(message);\n }\n\n get debugMessage() {\n return this.__debugMessage;\n }\n\n set debugMessage(value) {\n if (this.debug) {\n const debugLog = {\n logLevel: 'info',\n message: '',\n ...value,\n };\n\n if (debugLog.logLevel === 'log' && debugLog.message) {\n return this.debugLog(debugLog.message);\n }\n\n this.__debugMessage\n .push({\n ...debugLog,\n date: new Date().toISOString(),\n });\n\n return this.debugLog(debugLog.message);\n }\n }\n\n get amount() {\n return this.__amount;\n }\n\n /**\n * Define o valor em para a classe em centavos\n * @param value\n */\n set amount(value) {\n if (typeof value === 'number' && value <= 0) {\n throw new Error('Não é possível definir um valor menor ou igual a zero.');\n } else {\n this.__amount = parseFloat(value) * 100;\n }\n }\n\n /**\n * Pagamento com cartão de crédito, podendo ser declarado\n * com parcelamento e se o juro é da administradora.\n * @param {number} installments - número de parcelas\n * @param {boolean} withInterest - juros pela administradora\n * @returns {Promise<AuttarSuccessResponse>}\n */\n credit(installments = 1, withInterest = false) {\n return new Promise((resolve, reject) => {\n this.debugLogMethod('credi', 'installments, withInterest', installments, withInterest);\n const requisition = {\n valorTransacao: this.amount,\n documento: this.orderId,\n operacao: privateVariables.transactions.credit.base,\n dataTransacao: this.__transactionDate,\n };\n if (installments > 1) {\n requisition.operacao = privateVariables.transactions.credit.installment;\n requisition.numeroParcelas = installments;\n }\n\n if (installments > 1 && withInterest) {\n requisition.operacao = privateVariables.transactions.credit.installmentWithInterest;\n requisition.numeroParcelas = installments;\n }\n\n this.debugMessage = {\n message: `Pagamento com cartão de crédito. Operação: ${requisition.operacao}. Valor ${this.amount} centavos`,\n };\n sleep(this.__sleepTimeout)\n .then(() => {\n _connect(this.__host, requisition)\n .then((response) => {\n if (response.retorno > 0) {\n const errorMsg = privateVariables.errorCodes[response.codigoErro]\n || response.display.length\n ? response.display.map(m => m.mensagem)\n .join(' ')\n : ' ';\n\n reject(this.classError(`Transação não concluída ${response.codigoErro}: ${errorMsg}`));\n }\n\n this.ctfTransaction = {\n ...response,\n dataTransacao: this.__transactionDate,\n };\n\n this.debugMessage = {\n message: this.ctfTransaction,\n };\n\n resolve({\n documento: this.orderId,\n dataTransacao: this.__transactionDate,\n ...response,\n });\n })\n .catch(e => this.classError(e));\n });\n });\n }\n\n /**\n * Pagamento com cartão de crédito, podendo ser\n * declarado com parcelamento e se o juro é da administradora.\n * @param {boolean} isVoucher\n * @returns {Promise<AuttarSuccessResponse>}\n */\n debit(isVoucher = false) {\n return new Promise((resolve, reject) => {\n this.debugLogMethod('debit', 'isVoucher', isVoucher);\n const operacao = isVoucher\n ? privateVariables.transactions.debit.voucher\n : privateVariables.transactions.debit.base;\n\n this.debugMessage = {\n message: `Pagamento com cartão de débito. Operação: ${operacao}. Valor ${this.amount} centavos`,\n };\n sleep(this.__sleepTimeout)\n .then(() => {\n _connect(this.__host, {\n valorTransacao: this.amount,\n documento: this.orderId,\n dataTransacao: this.__transactionDate,\n operacao,\n })\n .then((response) => {\n if (response.retorno > 0) {\n const errorMsg = privateVariables.errorCodes[response.codigoErro]\n || response.display.length\n ? response.display.map(m => m.mensagem)\n .join(' ')\n : ' ';\n\n reject(this.classError(`Transação não concluída ${response.codigoErro}: ${errorMsg}`));\n }\n\n this.ctfTransaction = {\n ...response,\n dataTransacao: this.__transactionDate,\n };\n\n this.debugMessage = {\n message: this.ctfTransaction,\n };\n\n resolve({\n documento: this.orderId,\n dataTransacao: this.__transactionDate,\n ...response,\n });\n })\n .catch(e => this.classError(e));\n });\n });\n }\n\n /**\n * Confirma a operação com o CTF\n * @returns {Promise<void>}\n */\n confirm() {\n return new Promise((resolve, reject) => {\n this.debugLogMethod('confirm');\n const operacao = privateVariables.transactions.confirm;\n sleep(this.__sleepTimeout)\n .then(() => {\n _connect(this.__host, { operacao })\n .then((response) => {\n this.debugMessage = {\n message: `Confirmação de pagamento da operação realizada.\n Operação: ${this.ctfTransaction.operacao}\n Data: ${this.ctfTransaction.dataTransacao}\n Valor: ${this.amount}\n Bandeira: ${this.ctfTransaction.bandeira}\n Cartão: ${this.ctfTransaction.cartao}`,\n };\n if (response.retorno > 0) {\n const errorMsg = privateVariables.errorCodes[response.codigoErro]\n || response.display.length\n ? response.display.map(m => m.mensagem)\n .join(' ')\n : ' ';\n\n reject(this.classError(`Transação não concluída ${response.codigoErro}: ${errorMsg}`));\n }\n\n this.ctfTransaction = Object.assign(this.ctfTransaction, response);\n this.debugMessage = {\n message: this.ctfTransaction,\n };\n\n resolve({\n ...this.ctfTransaction,\n ...response,\n });\n })\n .catch(e => this.classError(e));\n });\n });\n }\n\n /**\n * Inicia o processo de cancelamento de compra.\n * @returns {Promise<void>}\n */\n requestCancellation() {\n return new Promise((resolve, reject) => {\n this.debugLogMethod('requestCancellation');\n const operacao = privateVariables.transactions.requestCancel;\n sleep(this.__sleepTimeout)\n .then(() => {\n _connect(this.__host, { operacao })\n .then((response) => {\n this.debugMessage = {\n message: `Requisição de cancelamento de compra.\n Operação: ${this.ctfTransaction.operacao}\n Data: ${this.ctfTransaction.dataTransacao}\n Valor: ${this.amount}\n NSU: ${this.ctfTransaction.nsuCTF}`,\n };\n if (response.retorno > 0) {\n const errorMsg = privateVariables.errorCodes[response.codigoErro]\n || response.display.length\n ? response.display.map(m => m.mensagem)\n .join(' ')\n : ' ';\n\n reject(this.classError(`Transação não concluída ${response.codigoErro}: ${errorMsg}`));\n }\n\n this.debugMessage = {\n message: response,\n };\n\n resolve({\n ...this.ctfTransaction,\n ...response,\n });\n })\n .catch(e => this.classError(e));\n });\n });\n }\n\n /**\n * Realiza o cancelamento da compra.\n * @param {string} prop.dataTransacao\n * @param {number} prop.amount\n * @param {string} prop.nsuCTF\n * @param {string} prop.operacao\n * @returns {Promise<any>}\n */\n cancel(prop = {}) {\n return new Promise((resolve, reject) => {\n this.debugLogMethod('cancel', 'prop', prop);\n const operacao = privateVariables.transactions.cancel;\n const tefOperacao = prop.operacao || this.ctfTransaction.operacao;\n const tefDataTransacao = prop.dataTransacao || this.ctfTransaction.dataTransacao;\n const tefAmount = prop.amount ? parseFloat(prop.amount) * 100 : this.ctfTransaction.valorTransacao;\n const tefNsuCTF = prop.nsuCTF || this.ctfTransaction.nsuCTF;\n sleep(this.__sleepTimeout)\n .then(() => {\n _connect(this.__host, {\n operacao,\n valorTransacao: tefAmount,\n dataTransacao: tefDataTransacao,\n nsuCTF: tefNsuCTF,\n })\n .then((response) => {\n this.debugMessage = {\n message: `Cancelamento de compra.\n Operação: ${tefOperacao}\n Data: ${tefDataTransacao}\n Valor: ${tefAmount}\n NSU: ${tefNsuCTF}`,\n };\n if (response.retorno > 0) {\n const errorMsg = privateVariables.errorCodes[response.codigoErro] || response.display[0].mensagem;\n\n reject(this.classError(`Transação não concluída ${response.codigoErro}: ${errorMsg}`));\n }\n\n this.debugMessage = {\n message: response,\n };\n\n resolve({\n ...this.ctfTransaction,\n ...response,\n });\n })\n .catch(e => this.classError(e));\n });\n });\n }\n}\n\nexport default Auttar;\n"],"names":["LogLevelName","Info","Warn","Error","Method","All","None","LogLevelStyle","NAME","BACKGROUND","log","name","style","className","classStyle","message","console","showError","error","logInfo","msg","logWarn","logMethod","method","args","params","JSON","stringify","logError","sleep","ms","Promise","res","setTimeout","privateVariables","transactions","credit","base","installment","installmentWithInterest","debit","voucher","cancel","confirm","requestCancel","return","success","timeOut","notAuthorizes","internetError","intertefError","ecommerceError","errorCodes","ws","timeout","close","timeoutConn","timeoutMs","debug","_clearTimeout","clearTimeout","_timeout","time","resolve","reject","_connect","host","payload","WebSocket","readyState","e","sendRequest","send","catch","onopen","onmessage","evtMsg","data","parse","onerror","evtError","props","__host","webSocketTimeout","orderId","__amount","__sleepTimeout","sleepTimeout","amount","this","__transactionDate","Date","toLocaleDateString","year","month","day","timeZone","replace","ctfTransaction","__debugMessage","debugMessage","logLevel","installments","withInterest","_this","debugLogMethod","requisition","valorTransacao","documento","operacao","dataTransacao","numeroParcelas","then","response","retorno","errorMsg","codigoErro","display","length","map","m","mensagem","join","classError","isVoucher","_this2","_this3","bandeira","cartao","Object","assign","_this4","nsuCTF","prop","_this5","tefOperacao","tefDataTransacao","tefAmount","parseFloat","tefNsuCTF","value","debugLog","push","date","toISOString"],"mappings":";;;;;sKAAA,IAAMA,EAAe,CACnBC,KAAM,OACNC,KAAM,OACNC,MAAO,QACPC,OAAQ,SACRC,IAAK,MACLC,KAAM,QAGFC,EAAgB,CACpBN,KAAM,+EACNC,KAAM,+EACNC,MAAO,+EACPC,OAAQ,gFAGJI,EAAO,UACPC,EAAa,+EAEbC,EAAM,SAACC,EAAMC,EAAOC,EAAWC,EAAYC,GAC/CC,QAAQN,iBAAUC,iBAAWE,iBAAgBE,GAAWH,EAAOE,EAAY,6BAGvEG,EAAY,SAACN,EAAMC,EAAOC,EAAWC,EAAYC,GACrDC,QAAQE,mBAAYP,iBAAWE,iBAAgBE,GAAWH,EAAOE,EAAY,6BAWxE,SAASK,EAAQC,GACtBV,EAAIV,EAAaC,KAAMM,EAAcN,KAAMO,EAAMC,EAAYW,GAGxD,SAASC,EAAQD,GACtBV,EAAIV,EAAaE,KAAMK,EAAcL,KAAMM,EAAMC,EAAYW,GAG/D,SAAgBE,EAAUC,EAAQC,EAAMC,GACtCf,EAAIV,EAAaI,OAAQG,EAAcH,OAAQI,EAAMC,yBAA4Bc,cAAUC,GAAQ,gBAAQC,eAAgBC,KAAKC,UAAUF,IAAY,KAGjJ,SAASG,EAASR,GACvBH,EAAUjB,EAAaE,KAAMK,EAAcL,KAAMM,EAAMC,EAAYW,GAkB9D,SAASS,EAAMC,UACb,IAAIC,QAAQ,SAACC,UAAQC,WAAWD,EAAKF,KC9D9C,IAAMI,EAAmB,CACvBC,aAAc,CACZC,OAAQ,CACNC,KAAM,IACNC,YAAa,IAC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