Ejemplo n.º 1
0
        public ChangePINResponse DoBalanceEnquiry(CardDetails theCard, Account acct, string seq_nr)
        {
            ChangePINResponse response = null;

            lock (this)
            {
                if (_clientPeer.IsConnected)
                {
                    BalanceEnquiryISO cpMsg = new BalanceEnquiryISO(acct, theCard, _transactionID, seq_nr);

                    Trx.Messaging.Message responseMessage = ProcessRequest(cpMsg);
                    response = new ChangePINResponse(responseMessage);
                    response.TransactionID = _transactionID;
                }
            }
            return(response);
        }
Ejemplo n.º 2
0
        public ChangePINResponse DoChangePIN(CardDetails theCard, Account acct, string seq_nr)
        {
            ChangePINResponse response = null;

            lock (this)
            {
                if (_clientPeer.IsConnected)
                {
                    ChangePIN cpMsg = new ChangePIN(_terminal, acct, theCard, _transactionID, seq_nr);
                    new PANE.ERRORLOG.Error().LogInfo("Pin Change Request: " + cpMsg.ToString());

                    Trx.Messaging.Message responseMessage = ProcessRequest(cpMsg);
                    new PANE.ERRORLOG.Error().LogInfo("Pin Change Response: " + responseMessage.ToString());
                    response = new ChangePINResponse(responseMessage);
                    response.TransactionID = _transactionID;
                }
            }
            return(response);
        }
Ejemplo n.º 3
0
        protected string DoPinChange(PinIssuanceRequest request, Card theCard)
        {
            if (request.Pin != request.ConfirmPin)
            {
                throw new ApplicationException("New Pin and Confirm New Pin are not the same");
            }

            string            response   = string.Empty;
            ThalesHsm         hsm        = new ThalesHsm();
            ChangePINResponse cpResponse = null;

            // obatin the account number
            string accountNo = "";

            try
            {
                accountNo = theCard.pan.Substring(theCard.pan.Length - 13, 12);
            }
            catch (Exception ex)
            {
                new PANE.ERRORLOG.Error().LogToFile(ex);
                throw new ApplicationException("Unable to derive account number from card PAN. Ensure that card PAN is minimum of 16 digits");
            }

            // Step 4: Do PinChange with random pin as oldpin and translated pin as newpin
            try
            {
                Engine theFepEngine = new PinIssuance.Net.Bridge.PostBridge.Client.Engine(
                    PinConfigurationManager.FepConfig.BridgeHostIp,
                    PinConfigurationManager.FepConfig.InternalServerPort,
                    new CardAcceptor(request.TerminalId, request.TerminalId)
                {
                },
                    "trx"
                    );

                theFepEngine.Connect();

                cpResponse = theFepEngine.DoChangePIN
                             (
                    new CardDetails()
                {
                    ExpiryDate  = DateTime.ParseExact(theCard.expiry_date, "yyMM", DateTimeFormatInfo.InvariantInfo),
                    PAN         = theCard.pan,
                    PIN         = GetPinBlockToPopulateIn52IsoInPinChange(accountNo, request.OldPin), //pinbytearr,
                    NewPINBlock = GetPinBlockToPopulateIn53ISO(accountNo, request.ConfirmPin),        //newEncryptedPinBlock
                    IccData     = request.IccData,
                    Track2      = request.Track2
                },
                    new Bridge.PostBridge.Client.DTO.Account(accountNo, ""), theCard.seq_nr
                             );
            }
            catch (Exception ex)
            {
                new PANE.ERRORLOG.Error().LogToFile(ex);
                Exception ex2 = new ApplicationException("Unable to Do PinChange with random pin as oldpin and translated pin as newpin");
                throw ex2;
            }

            // Step 8: Obtain the isser script from PinChange response and return to the Pos
            if (cpResponse == null || string.IsNullOrEmpty(cpResponse.IssuerScript))
            {
                throw new ApplicationException("Invalid pin change response");
            }
            if (cpResponse.ResponseCode == "00")
            {
                // response = string.Format("C:1|APPROVED|{0}|{1}|", cpResponse.IssuerAuthenticationData, cpResponse.IssuerScript);
                response = string.Format("true|{0}", cpResponse.IccData);
            }
            else
            {
                //response = string.Format("C:2|DECLINED|{0}", cpResponse.ResponseCode);
                response = string.Format("false|{0}", cpResponse.ResponseDescription);
            }
            return(response);
        }
Ejemplo n.º 4
0
        public string DoPinSelection(PinIssuanceRequest request, Card theCard)
        {
            new PANE.ERRORLOG.Error().LogInfo("Started Do PinSelection");
            if (request.Pin != request.ConfirmPin)
            {
                throw new ApplicationException("New Pin and Confirm New Pin are not the same");
            }

            string    response = string.Empty;
            ThalesHsm hsm      = new ThalesHsm();
            IGeneratePinOffsetResponse pinOffsset = null;
            ChangePINResponse          cpResponse = null;
            string clearRandomPin = null;

            // obatin the account number
            string accountNo = "";

            try
            {
                accountNo = theCard.pan.Substring(theCard.pan.Length - 13, 12);
            }
            catch (Exception ex)
            {
                new PANE.ERRORLOG.Error().LogToFile(ex);
                throw new ApplicationException("Unable to derive account number from card PAN. Ensure that card PAN is minimum of 16 digits");
            }

            // Step 1: Generate a new encrypted Random Pin
            string _encryptedPIN;

            try
            {
                clearRandomPin = new Random().Next(1111, 9999).ToString();
                _encryptedPIN  = hsm.PinGenerator().EncryptClearPin(clearRandomPin, accountNo).EncryptedPin;
                new PANE.ERRORLOG.Error().LogInfo("Generated Default Pin");
            }
            catch (Exception ex)
            {
                new PANE.ERRORLOG.Error().LogToFile(ex);
                Exception ex2 = new ApplicationException("Unable to Generate a new default Pin");
                throw ex2;
            }

            // Step 2: Generate the Pin offset for the random pin
            try
            {
                if (theCard.pan.StartsWith("4"))
                {
                    pinOffsset = hsm.PinGenerator().GenerateVISAPinOffset(_encryptedPIN, accountNo, theCard.pan);
                }
                else
                {
                    pinOffsset = hsm.PinGenerator().GeneratePinOffset(_encryptedPIN, accountNo, theCard.pan);

                    new PANE.ERRORLOG.Error().LogInfo("Generated Pin Offset");
                }
            }
            catch (Exception ex)
            {
                new PANE.ERRORLOG.Error().LogToFile(ex);
                Exception ex2 = new ApplicationException("Unable to Generate the Pin offset for the random pin");
                throw ex2;
            }

            // Step 3: Update PostCard with the generated pin offset
            try
            {
                CardUtilities.UpdateCardPinOffset(theCard, pinOffsset.Offset.Substring(0, 4));

                new PANE.ERRORLOG.Error().LogInfo("Updated Pin Offset");
            }
            catch (Exception ex)
            {
                new PANE.ERRORLOG.Error().LogToFile(ex);
                Exception ex2 = new ApplicationException("Unable to Update PostCard with the generated pin offset");
                throw ex;
            }

            // Step 4: Do PinChange with random pin as oldpin and translated pin as newpin
            try
            {
                new PANE.ERRORLOG.Error().LogInfo("Connecting To FEP");
                Engine theFepEngine = new PinIssuance.Net.Bridge.PostBridge.Client.Engine(
                    PinConfigurationManager.FepConfig.BridgeHostIp,
                    PinConfigurationManager.FepConfig.InternalServerPort,
                    new CardAcceptor(request.TerminalId, request.TerminalId)
                {
                },
                    "trx"
                    );
                bool isConnectedToFEP = theFepEngine.Connect();

                new PANE.ERRORLOG.Error().LogInfo(string.Format("Connected to FEP - {0}", isConnectedToFEP));
                cpResponse = theFepEngine.DoChangePIN
                             (
                    new CardDetails()
                {
                    ExpiryDate  = DateTime.ParseExact(theCard.expiry_date, "yyMM", DateTimeFormatInfo.InvariantInfo),
                    PAN         = theCard.pan,
                    PIN         = GetPinBlockToPopulateIn52ISO(accountNo, clearRandomPin),     //pinbytearr,
                    NewPINBlock = GetPinBlockToPopulateIn53ISO(accountNo, request.ConfirmPin), //newEncryptedPinBlock
                    IccData     = request.IccData,
                    Track2      = request.Track2
                },
                    new Bridge.PostBridge.Client.DTO.Account(accountNo, ""), theCard.seq_nr
                             );
            }
            catch (Exception ex)
            {
                new PANE.ERRORLOG.Error().LogToFile(ex);
                Exception ex2 = new ApplicationException("Unable to Do PinChange with random pin as oldpin and translated pin as newpin");
                throw ex2;
            }

            // Step 5: Obtain the isser script from PinChange response and return to the Pos
            if (cpResponse == null || string.IsNullOrEmpty(cpResponse.IssuerScript))
            {
                throw new ApplicationException("Invalid pin change response");
            }
            if (cpResponse.ResponseCode == "00")
            {
                //response = string.Format("C:1|APPROVED|{0}|{1}", cpResponse.IssuerAuthenticationData, cpResponse.IssuerScript);
                response = string.Format("true|{0}", cpResponse.IccData);
                new PANE.ERRORLOG.Error().LogInfo("Pin Change Response: " + response);
            }
            else
            {
                //  response = string.Format("C:2|DECLINED|{0}", cpResponse.ResponseCode);
                response = string.Format("false|{0}", cpResponse.ResponseDescription);
            }

            new PANE.ERRORLOG.Error().LogInfo("Ended PinSelection");
            return(response);
        }