public IGeneratePinOffsetResponse GeneratePVV(string encryptedPin, string accountNumber, string cardPan) { if (string.IsNullOrEmpty(encryptedPin)) { throw new ArgumentNullException("encryptedPin"); } if (string.IsNullOrEmpty(accountNumber)) { throw new ArgumentNullException("accountNumber"); } if (accountNumber.Length > 12) { throw new ArgumentException("accountNumber is longer than 12-digits"); } //string pinValidationData = cardPan.Substring(0, cardPan.Length - 6); //AHMED string pinValidationData = cardPan.Substring(0, 10); pinValidationData = string.Format("{0}N{1}", pinValidationData, cardPan.Last()); //configure Parameters var parameters = new List <string>() { PinConfigurationManager.HsmConfig.PinVerificationKeyPVV, encryptedPin, accountNumber.PadLeft(12, '0'), "0", //minPinLength.ToString().PadLeft(2,'0'), // PinConfigurationManager.HsmConfig.DecimalisationTable, // pinValidationData }; //configure Response Format var responseFormat = new MessageFields(); responseFormat.Fields.Add(new MessageField() { Name = "offset", Length = 4 }); var hsmResponse = _theHsm.Send("DG", parameters, responseFormat); IGeneratePinOffsetResponse response = new GeneratePinOffsetResponse(); response.Offset = hsmResponse.Item("offset"); return(response); }
public IGeneratePinOffsetResponse GeneratePinOffsetFromPinBlock(string encryptedPinBlock, string accountNumber, PinBlockFormats encryptedPinBlockFormat) { if (string.IsNullOrEmpty(encryptedPinBlock)) { throw new ArgumentNullException("encryptedPin"); } if (string.IsNullOrEmpty(accountNumber)) { throw new ArgumentNullException("accountNumber"); } if (accountNumber.Length > 12) { throw new ArgumentException("accountNumber is longer than 12-digits"); } //configure Parameters var parameters = new List <string>() { "001", PinConfigurationManager.HsmConfig.ZPK_LMK, PinConfigurationManager.HsmConfig.PinVerificationKey, encryptedPinBlock, ((int)encryptedPinBlockFormat).ToString().PadLeft(2, '0'), "04", accountNumber.PadLeft(12, '0'), PinConfigurationManager.HsmConfig.DecimalisationTable, PinConfigurationManager.HsmConfig.PinValidationData }; //5145851169N5 //configure Response Format var responseFormat = new MessageFields(); responseFormat.Fields.Add(new MessageField() { Name = "offset", Length = 12 }); var hsmResponse = _theHsm.Send("BK", parameters, responseFormat); IGeneratePinOffsetResponse response = new GeneratePinOffsetResponse(); response.Offset = hsmResponse.Item("offset"); return(response); }