public string GetPaymentAuthorization([FromBody] string xmlData) { string response; // creating object of CultureInfo CultureInfo cultures = new CultureInfo("en-US"); try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlData); #region data fetched from xml string senderVirtualIdString, senderInstitutionIdString, receiverVirtualIdString, referenceNumberString, amountString, otherInfo; senderVirtualIdString = doc.GetElementsByTagName("SenderVID").Item(0).Attributes["value"].Value; senderInstitutionIdString = doc.GetElementsByTagName("SenderInstID").Item(0).Attributes["value"].Value; receiverVirtualIdString = doc.GetElementsByTagName("ReceiverVID").Item(0).Attributes["value"].Value; referenceNumberString = doc.GetElementsByTagName("ReferenceNo").Item(0).Attributes["value"].Value; amountString = doc.GetElementsByTagName("TxnAmount").Item(0).Attributes["value"].Value; otherInfo = doc.GetElementsByTagName("OtherInfo").Item(0).Attributes["value"].Value; #endregion double amount = 0; amount = System.Convert.ToDouble(amountString, cultures); IDTPUserEntity iDTPUserEntitySender = _businessLayer.GetAllIDTPUserEntities().Where(x => x.VirtualId == senderVirtualIdString).FirstOrDefault(); IDTPUserEntity iDTPUserEntityReceiver = _businessLayer.GetAllIDTPUserEntities().Where(x => x.VirtualId == receiverVirtualIdString).FirstOrDefault(); bool status = false; // TODO: we will add payment authorization rules validation here if (iDTPUserEntitySender != null && iDTPUserEntityReceiver != null) { response = IDTPXmlParser.PrepareSuccessResponse("PaymentAuthorizationResponse", "ReferenceNumber", referenceNumberString); status = true; } else { response = IDTPXmlParser.PrepareFailResponse("PaymentAuthorizationResponse"); status = false; } PaymentAuthorization paymentAuthorization = new PaymentAuthorization { SenderId = iDTPUserEntitySender.Id, ReceiverId = iDTPUserEntityReceiver.Id, Amount = amount, Status = status, OtherInfo = otherInfo, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, EntityState = EntityState.Added }; _businessLayer.AddPaymentAuthorization(paymentAuthorization); return(response); } catch (Exception) { response = IDTPXmlParser.PrepareFailResponse("PaymentAuthorizationResponse"); return(response); } }
public string RegisterUser([FromBody] string xmlData) { string response; try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlData); #region data fetched from xml string identityTypeIdString, entityTypeIdString, institutionIdString, accountNoString, virtualIdString, identifyingId, secret; identityTypeIdString = doc.GetElementsByTagName("Identity").Item(0).Attributes["type"].Value; identifyingId = doc.GetElementsByTagName("Identity").Item(0).Attributes["id"].Value; entityTypeIdString = doc.GetElementsByTagName("Entity").Item(0).Attributes["type"].Value; institutionIdString = doc.GetElementsByTagName("InsitutionID").Item(0).Attributes["value"].Value; accountNoString = doc.GetElementsByTagName("AccountNo").Item(0).Attributes["value"].Value; virtualIdString = doc.GetElementsByTagName("RequestedVirtualID").Item(0).Attributes["value"].Value; secret = doc.GetElementsByTagName("Data").Item(0).InnerText; #endregion int deviceLocationInfoId = ParseDeviceLocationInfo.SaveInfo(doc); int identityTypeId = 0, entityTypeId = 0; identityTypeId = _businessLayer.GetAllIdentityTypes().Where(x => x.Type == identityTypeIdString).FirstOrDefault().Id; entityTypeId = _businessLayer.GetAllEntityTypes().Where(x => x.Type == entityTypeIdString).FirstOrDefault().Id; Cryptography.Services.IDTPCryptography cryptography = new Cryptography.Services.IDTPCryptography(); IDTPUserEntity newUser = new IDTPUserEntity(); string passSalt = cryptography.GetSecretSalt(); newUser.SecretSalt = passSalt; newUser.Secret = cryptography.EncryptSecret(passSalt, secret); newUser.IdentityTypeId = identityTypeId; newUser.EntityTypeId = entityTypeId; newUser.AccountNo = accountNoString; newUser.VirtualId = virtualIdString; newUser.InstitutionId = institutionIdString; newUser.NidTinBin = identifyingId; newUser.EntityState = EntityState.Added; newUser.DeviceLocationInfoId = deviceLocationInfoId; _businessLayer.AddIDTPUserEntity(newUser); response = IDTPXmlParser.PrepareSuccessResponse("RegisterUserResponse", "VirtualID", virtualIdString); return(response); } catch (WebException) { response = IDTPXmlParser.PrepareFailResponse("RegisterUserResponse"); return(response); } }
public string RecordPayment([FromBody] string xmlData) { // creating object of CultureInfo CultureInfo cultures = new CultureInfo("en-US"); try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlData); #region data fetched from xml string senderVirtialId, senderInstitution, receiverVirtialId, receiverInstitutionId, referenceNumber, amountString, otherInfo; senderVirtialId = doc.GetElementsByTagName("SenderVID").Item(0).Attributes["value"].Value; senderInstitution = doc.GetElementsByTagName("SenderInstID").Item(0).Attributes["value"].Value; receiverVirtialId = doc.GetElementsByTagName("ReceiverVID").Item(0).Attributes["value"].Value; receiverInstitutionId = doc.GetElementsByTagName("ReceiverInstID").Item(0).Attributes["value"].Value; amountString = doc.GetElementsByTagName("TxnAmount").Item(0).Attributes["value"].Value; referenceNumber = doc.GetElementsByTagName("ReferenceNo").Item(0).Attributes["value"].Value; otherInfo = doc.GetElementsByTagName("OtherInfo").Item(0).Attributes["value"].Value; #endregion int deviceLocationInfoId = ParseDeviceLocationInfo.SaveInfo(doc); IDTPUserEntity iDTPUserEntitySender = _businessLayer.GetAllIDTPUserEntities().Where(x => x.VirtualId == senderVirtialId).FirstOrDefault(); IDTPUserEntity iDTPUserEntityReceiver = _businessLayer.GetAllIDTPUserEntities().Where(x => x.VirtualId == receiverVirtialId).FirstOrDefault(); double amount = 0; amount = System.Convert.ToDouble(amountString, cultures); PaymentRecord paymentRecord = new PaymentRecord { SenderId = iDTPUserEntitySender.Id, ReceiverId = iDTPUserEntityReceiver.Id, Amount = amount, ReferenceNumber = referenceNumber, OtherInfo = otherInfo, DeviceLocationInfoId = deviceLocationInfoId, EntityState = EntityState.Added }; _businessLayer.AddPaymentRecord(paymentRecord); response = IDTPXmlParser.PrepareSuccessResponse("PaymentRecordResponse", "ReferenceNumber", referenceNumber); return(response); } catch (Exception) { response = IDTPXmlParser.PrepareFailResponse("PaymentRecordResponse"); return(response); } }