Exemplo n.º 1
0
        public string GenerateQRCode([FromBody] string xmlData)
        {
            string response;

            try
            {
                XmlDocument doc = new XmlDocument();
                //ISOComposer composer = new ISOComposer();
                doc.LoadXml(xmlData);
                ParseDeviceLocationInfo.SaveInfo(doc);

                string receiverVirtialId, amountString, pin;
                #region data fetched from xml
                receiverVirtialId = doc.GetElementsByTagName("ReceiverVID").Item(0).Attributes["value"].Value;
                amountString      = doc.GetElementsByTagName("TxnAmount").Item(0).Attributes["value"].Value;
                pin = doc.GetElementsByTagName("Data").Item(0).InnerText;
                #endregion

                string imageString = string.Empty, qrText = $"{receiverVirtialId} Amount: {amountString}";
                imageString = IDTPQRCodeGenerator.GenerateQRCode(qrText);

                response = IDTPXmlParser.PrepareSuccessResponse("GenerateQRCodeResponse", "QRCode", imageString);
                return(response);
            }

            catch (Exception ex)
            {
                response = IDTPXmlParser.PrepareFailResponse("GenerateQRCodeResponse");
                return(response);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
        string ProcessAndInsertDisbursment(XmlDocument doc, string criteria)
        {
            // creating object of CultureInfo
            CultureInfo cultures = new CultureInfo("en-US");

            string referenceNumber;

            try
            {
                int deviceLocationInfoId = ParseDeviceLocationInfo.SaveInfo(doc);

                #region data fetched from xml
                string senderVirtialId, amountString;

                senderVirtialId = doc.GetElementsByTagName("SenderVID").Item(0).Attributes["value"].Value;
                amountString    = doc.GetElementsByTagName("TxnAmount").Item(0).Attributes["value"].Value;
                referenceNumber = doc.GetElementsByTagName("ReferenceNo").Item(0).Attributes["value"].Value;
                var receiverList = doc.GetElementsByTagName("ReceiverVID");
                #endregion

                double amount;
                amount = 0;

                double.TryParse(amountString, NumberStyles.Any, cultures, out amount);

                Disbursement disbursment = new Disbursement
                {
                    SenderVID            = senderVirtialId,
                    Amount               = amount,
                    ReferenceNo          = referenceNumber,
                    DeviceLocationInfoId = deviceLocationInfoId,
                    Criteria             = criteria,
                    CreatedOn            = DateTime.Now,
                    EntityState          = EntityState.Added
                };
                _businessLayer.AddDisbursment(disbursment);

                List <DisbursementDetail> disbursementDetails = new List <DisbursementDetail>();
                for (int i = 0; i < receiverList.Count; i++)
                {
                    DisbursementDetail disbursementDetail = new DisbursementDetail();

                    amountString = receiverList.Item(i).Attributes["amount"].Value;
                    double.TryParse(amountString, NumberStyles.Any, cultures, out amount);
                    disbursementDetail.ReceiverVID    = receiverList.Item(i).Attributes["value"].Value;
                    disbursementDetail.Amount         = amount;
                    disbursementDetail.DisbursementId = disbursment.Id;
                    disbursementDetail.EntityState    = EntityState.Added;
                    disbursementDetails.Add(disbursementDetail);
                }
                _businessLayer.AddDisbursmentDetail(disbursementDetails.ToArray());

                return(referenceNumber);
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
                //return ex.Message;
            }
        }