Пример #1
0
        public void LogTritonReversalRequest(ReversalModel atm, DateTime atmConnected, DateTime takenByCore, string atmId, string atmIp)
        {
            _transactionAmount = ((atm.AuthorizationTranAmount + atm.AuthorizationSurAmount) - atm.AuthorizationDispensedAmount) / 100m;

            TritonNode_Transaction logModel = new TritonNode_Transaction
            {
                req_type  = "Reversal",
                tran_type = "Request",
                communications_identifier = atm.CommunicationIdentifier,
                terminal_identifier       = atm.TerminalIdentifier,
                software_version_number   = atm.SoftwareVerionNo,
                encryption_mode_flag      = atm.EncryptionModeFlag,
                information_header        = atm.InformationHeader,
                terminal_id        = atm.TerminalId,
                transaction_code   = atm.TransactionCode,
                transaction_seq_no = atm.TranSeqNo,
                transaction_amount = _transactionAmount,
                miscellaneous_1    = atm.Miscellaneous1,
                miscellaneous_2    = atm.Miscellaneous2,
                status_monitoring  = atm.StatusMonitoringField,
                miscellaneous_X    = atm.MiscellaneousX,
                dtTakenByCore      = takenByCore.ToString("yyyy-MM-dd HH:mm:ss"),
                dtconnected        = atmConnected.ToString("yyyy-MM-dd HH:mm:ss"),
                tran_gid           = atmId,
                track2             = ReplaceTrack2(atm.Track2),
                tran_date          = takenByCore.ToString("yyyy-MM-dd"),
                tran_time          = takenByCore.ToString("HH:mm:ss"),
                switch_no          = 1,
                tran_ip            = atmIp,
                text = atm.Text,
                terminal_tran_seq = atm.AtmSeqNo
            };

            Log(logModel);
        }
Пример #2
0
        public byte[] ReversalResponse(ReversalModel model)
        {
            // Example Reversal response message
            //

            string InformationHeader = "            ";

            string builder = "";

            builder += InformationHeader;
            builder += "\x1C" + model.TerminalId;
            builder += "\x1C" + model.TransactionCode;
            builder += "\x1C" + model.AtmSeqNo.ToString("D4");           // Sequence Number  4 Numeric Copied from request message.
            builder += "\x1C" + model.AuthorizationCode.PadLeft(3, '0'); // Response Code  3 Numeric Result of request. Approved = 000. Non-0000 = declined. See Authorization Codes for list of decline codes.
            builder += "\x1C" + model.MiscellaneousX;                    // Miscellaneous X**  Variable Alphanumeric  V  X**  Miscellaneous data. Refer to Miscellaneous Field ID codes for possible uses for this field.
            builder += "\x1C";
            builder += "\x03";
            //builder  = "\x02" + builder + HexStringToString(CalculateChecksum(builder));
            builder = "\x02" + builder + CalcLRC(builder);


            byte[] result = Build(builder);
            string encode = _helper.AsciiOctets2String(result);

            _log.Debug("Message sent to ATM: " + encode);
            model.Text = encode;
            return(result);
        }
Пример #3
0
        public byte[] ReversalAdviceRequest(ReversalModel msg)
        {
            if (string.IsNullOrEmpty(msg.Mti) || msg.Mti != "0420")
            {
                throw new ArgumentException("Mti is not valid for ReversalAdviceRequest(0420)");
            }
            var model = new AS2805Model(msg.Mti);

            model.SetField(3, msg.ProcessingCode);
            model.SetField(4, msg.AmountTran);
            model.SetField(7, msg.TranDate);
            model.SetField(11, msg.Stan);
            model.SetField(12, msg.TimeLocalTran);
            model.SetField(13, msg.DateLocalTran);
            model.SetField(15, msg.DateSettlement);
            model.SetField(22, msg.MiscellaneousX);
            model.SetField(25, msg.PosConditionCode);
            model.SetField(28, msg.AmtTranFee);
            model.SetField(32, msg.AcqInstIdCode);
            model.SetField(35, msg.Track2);
            model.SetField(37, msg.TranSeqNo);
            model.SetField(41, msg.TerminalId);
            model.SetField(42, msg.CardAcptIdCode);
            model.SetField(43, msg.NameLocation);
            model.SetField(47, msg.AddtlDataNat);
            model.SetField(53, msg.SecControlInfo);
            model.SetField(55, msg.MiscellaneousX);
            model.SetField(57, msg.AmountCash);
            model.SetField(90, msg.Stan, msg.TranDate, msg.AcqInstIdCode, msg.FwdInstIdCode);
            model.SetField(128, msg.Mac128);

            return(model.ToBytes());
        }
Пример #4
0
        public void DisConnect()
        {
            if (_pState.CurrentState == AtmStates.ST_SEND_ACK && _atmBaseModel is TransactionModel)
            {
                TransactionModel autReverse = _atmBaseModel as TransactionModel;
                if (autReverse.AuthorizationCode == "00")
                {
                    _log.Warn("Triton process reversal message to bank");
                    // sent reversal to bank

                    ReversalModel reversal = new ReversalModel().Create(autReverse);
                    // logging request into database
                    _conLogger.LogTritonRequest(reversal, DateTime.Now);
                    //
                    var response = _coreComm.ReversalRequest(reversal);
                    // logging request into database
                    _conLogger.LogTritonResponse(response, DateTime.Now, DateTime.Now);  // logging into database
                    //
                }
                else
                {
                    // Wait to confirm
                }
            }
            _pState.CurrentState = AtmStates.ST_DISCONNECT;
        }
Пример #5
0
        public ReversalModel ReversalRequest(ReversalModel atm)
        {
            using (var proxy = _proxyClient)
            {
                proxy.Connect();
                ReversalTritonNodeRequestDto req = new ReversalTritonNodeRequestDto
                                                   (
                    atm.TerminalId,
                    atm.TransactionCode,
                    atm.AuthorizationTranAmount,
                    atm.AuthorizationSurAmount,
                    atm.AuthorizationDispensedAmount,
                    atm.Track2,
                    atm.TranSeqNo,
                    atm.MiscellaneousX,
                    atm.PosCondCode,
                    atm.AuthorizationNum
                                                   );

                ReversalCoreNodeResponseDto responseDto = proxy.ServiceProxy.RequestReversal(req);

                atm.AuthorizationCode   = responseDto.ResponseCode;
                atm.AuthorizationDesc   = responseDto.ResponseDescription;
                atm.AuthorizationAction = responseDto.ResponseAction;

                atm.AuthorizationNum = responseDto.Stan;
                atm.TranSeqNo        = responseDto.TranSeqNo;
                return(atm);
            }
        }
Пример #6
0
        public ReversalHostNodeResponseDto RequestReversal(ReversalHostNodeRequestDto req)
        {
            BaseModel           res;
            ITransactionService svc = new TransactionService();
            var model = svc.RequestAdviceReversal(req);

            byte[] rawBytes = _responseBuilder.ReversalAdviceRequest(model);

            try
            {
                res = _bank.Send(rawBytes, model.Stan);
            }
            catch (Exception ex)
            {
                if (ex is TimeoutException)
                {
                    model    = svc.RequestAdviceReversal(req, true);
                    rawBytes = _responseBuilder.ReversalAdviceRequest(model);
                    try
                    {
                        res = _bank.Send(rawBytes, model.Stan);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                else
                {
                    throw;
                }
            }

            if (!(res is ReversalModel))
            {
                throw new InvalidOperationException("incorrect responsed from Bank");
            }
            else
            {
                ReversalModel reversal = res as ReversalModel;
                ReversalHostNodeResponseDto responseDto = new ReversalHostNodeResponseDto
                {
                    Stan                = reversal.Stan,
                    ResponseCode        = reversal.RespCode,
                    ResponseDescription = reversal.RespDescription,
                    ResponseAction      = reversal.RespAction,
                    AmountTran          = reversal.AmountTran,
                    AmtTranFee          = reversal.AmtTranFee,
                    AmountCash          = reversal.AmountCash,
                    TranSeqNo           = model.TranSeqNo // set from request model
                };
                return(responseDto);
            }
        }
Пример #7
0
        public void LogTritonReversalResponse(ReversalModel atm, DateTime responseSent, DateTime responseFromCoreNode, DateTime atmConnected, DateTime takenByCore, string atmId, string atmIp)
        {
            TritonNode_Transaction logModel = new TritonNode_Transaction
            {
                req_type  = "Reversal",
                tran_type = "Response",
                communications_identifier = atm.CommunicationIdentifier,
                terminal_identifier       = atm.TerminalIdentifier,
                software_version_number   = atm.SoftwareVerionNo,
                encryption_mode_flag      = atm.EncryptionModeFlag,
                information_header        = atm.InformationHeader,
                terminal_id        = atm.TerminalId,
                transaction_code   = atm.TransactionCode,
                transaction_seq_no = atm.TranSeqNo,
                transaction_amount = _transactionAmount,
                //dispense_amount = _actualDispenseAmount,
                //surcharge_amount = _surchargeAmount,
                miscellaneous_1    = atm.Miscellaneous1,
                miscellaneous_2    = atm.Miscellaneous2,
                status_monitoring  = atm.StatusMonitoringField,
                miscellaneous_X    = atm.MiscellaneousX,
                response_code      = atm.AuthorizationCode,
                dtResponseSent     = responseSent.ToString("yyyy-MM-dd HH:mm:ss"),
                dtTakenByCore      = takenByCore.ToString("yyyy-MM-dd HH:mm:ss"),
                dtconnected        = atmConnected.ToString("yyyy-MM-dd HH:mm:ss"),
                dtResponseFromCore = responseFromCoreNode.ToString("yyyy-MM-dd HH:mm:ss"),
                tran_gid           = atmId,
                track2             = ReplaceTrack2(atm.Track2),
                tran_date          = takenByCore.ToString("yyyy-MM-dd"),
                tran_time          = takenByCore.ToString("HH:mm:ss"),
                switch_no          = 1,
                tran_ip            = atmIp,
                auth_no            = atm.AuthorizationNum,
                text = atm.Text,
                terminal_tran_seq = atm.AtmSeqNo
            };

            Log(logModel);

            //if (atm.AuthorizationCode == "00")
            {
                Transaction_Completed logCompleted = new Transaction_Completed
                {
                    tran_gid           = atmId,
                    tran_ip            = atmIp,
                    switch_no          = 1,
                    request_timestamp  = takenByCore.ToString("yyyy-MM-dd HH:mm:ss"),
                    request_type       = "Reversal",
                    terminal_id        = atm.TerminalId,
                    transaction_seq_no = atm.TranSeqNo,
                    card_no            = ReplaceCardNo(atm.Track2),
                    transaction_amount = _transactionAmount,
                    //surcharge_amount = _surchargeAmount,
                    //dispense_amount = _actualDispenseAmount,
                    response_code     = atm.AuthorizationCode,
                    tran_date         = takenByCore.ToString("yyyy-MM-dd"),
                    tran_time         = takenByCore.ToString("HH:mm:ss"),
                    transaction_code  = atm.TransactionCode,
                    transaction_speed = (responseFromCoreNode - takenByCore).ToString("g"),
                    auth_no           = atm.AuthorizationNum,
                    response_desc     = atm.AuthorizationDesc,
                    response_action   = atm.AuthorizationAction,
                    status_monitoring = atm.StatusMonitoringField,
                    terminal_tran_seq = atm.AtmSeqNo
                };

                Log(logCompleted);
            }
        }