Skip to content

Instantly share code, notes, and snippets.

@norbornen
Last active February 27, 2022 15:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save norbornen/4c47e50bc6e7c9f3756a0b9556efa670 to your computer and use it in GitHub Desktop.
Save norbornen/4c47e50bc6e7c9f3756a0b9556efa670 to your computer and use it in GitHub Desktop.
Пример использования в node.js сбербанковской библиотеки для работы с банковскими терминалами sbrf.dll
const winax = require('winax');
const sbrf = new winax.Object('SBRFSRV.Server');
let opResultCode;
const opPinpadCheckResultCode = sbrf.NFun(7003);
console.log(opPinpadCheckResultCode, opPinpadCheckResultCode === 0 ? 'пинпад есть' : 'пинпада нет');
sbrf.clear();
// контрольная лента
console.info('[контрольная лента]');
opResultCode = sbrf.NFun(7000);
console.log(opResultCode, sbrf.GParamString('Cheque'), sbrf.GParamString('Cheque1251'));
sbrf.clear();
// короткая контрольная лента
console.info('[короткая контрольная лента]');
opResultCode = sbrf.NFun(7004);
console.log(opResultCode, sbrf.GParamString('Cheque'), sbrf.GParamString('Cheque1251'));
sbrf.clear();
// сверка итогов ("итоги дня по картам")
console.info('[сверка итогов]');
opResultCode = sbrf.NFun(6000);
console.log(opResultCode);
sbrf.clear();
// // x-отчёт по картам
// console.info('[x-отчёт по картам]');
// opResultCode = sbrf.NFun(6002);
// console.log(opResultCode);
// sbrf.clear();
// console.info('[получить номер терминала и мерчанта]');
// opResultCode = sbrf.NFun(7007);
// console.log(opResultCode, sbrf.GParamString('TermNum'), sbrf.GParamString('MerchNum'));
// sbrf.clear();
// оплата
sbrf.SParam('Amount', 300*100);
opResultCode = sbrf.NFun(4000);
console.log(opResultCode);
const e = [
'AmountClear',
'Amount',
'CardName',
'CardType',
'TrxDate',
'TrxTime',
'TermNum',
'MerchNum',
'AuthCode',
'RRN',
'MerchantTSN',
'MerchantBatchNum',
'ClientCard',
'ClientExpiryDate',
'Hash',
'OwnCard'
].reduce((acc, key) => {
acc[key] = sbrf.GParamString(key);
return acc;
}, {});
console.log(e);
sbrf.clear();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment