Beispiel #1
0
        public static string AddressVerificationRequest(AddressVerificationRequest AddressVerifReq)
        {
            var responseString = "";
            var fullUrl        = seamFixBaseUrl + "/sfx-verify/v2/address";
            var json           = JsonConvert.SerializeObject(AddressVerifReq);
            var requestTime    = DateTime.Now;

            try
            {
                using (var client = new HttpClient())
                {
                    Utils.AddCustomHeadersToHttpClient(client);
                    var data = new StringContent(json, Encoding.UTF8, "application/json");
                    requestTime = DateTime.Now;
                    var httpResponseMsg = client.PostAsync(fullUrl, data).Result;

                    if (httpResponseMsg.IsSuccessStatusCode)
                    {
                        responseString = httpResponseMsg.Content.ReadAsStringAsync().Result;
                    }
                }
                var responseTime = DateTime.Now;
                RequestResponseRepository.SaveRequestResponse("POST", json, requestTime, fullUrl, responseString, "", responseTime);
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(responseString);
        }
Beispiel #2
0
        //public AddressVerificationRequest GetAddressVerificationRequestConfirmation(AddressVerificationRequest avr)
        //{
        //    var avr2 = GetAddressVerificationRequest(avr.AddressId);
        //    avr2.MailServiceEnum = avr.MailServiceEnum;
        //    avr2.IsSure1 = avr.IsSure1;
        //    avr2.DateIsSure1 = DateTime.UtcNow;
        //    avr2.PaymentAmount = getVerificaionCost(avr2);

        //    return avr2;
        //}

        //double getVerificaionCost(AddressVerificationRequest avr)
        //{
        //    string error = "";
        //    double verificationCost = 0;

        //    switch (avr.MailServiceEnum)
        //    {
        //        case MailServiceENUM.Post:
        //            switch (CountryBiz.IsAddressInPakistan(avr.CountryId))
        //            {
        //                case true:
        //                    //is in Pakistan
        //                    verificationCost = VerificationConfig.Cost_Postal_Local;
        //                    break;
        //                case false:
        //                    //is foreign
        //                    verificationCost = VerificationConfig.Cost_Postal_International;
        //                    break;
        //                default:
        //                    error = string.Format("No such option");
        //                    throw new Exception(error);
        //            }
        //            break;
        //        case MailServiceENUM.Courier:
        //            switch (CountryBiz.IsAddressInPakistan(avr.CountryId))
        //            {
        //                case true:
        //                    //is in Pakistan
        //                    verificationCost = VerificationConfig.Cost_Courier_Local;
        //                    break;
        //                case false:
        //                    verificationCost = VerificationConfig.Cost_Courier_International;
        //                    //is foreign
        //                    break;
        //                default:
        //                    error = string.Format("No such option");
        //                    throw new Exception(error);
        //            }
        //            break;
        //        default:
        //            error = string.Format("No such option: {0}", avr.MailServiceEnum);
        //            throw new Exception(error);
        //    }

        //    return verificationCost;
        //}


        public void IssueAddressVerificationRequest(AddressVerificationRequest avr, GlobalObject globalObject)
        {
            avr.AddressId.IsNullOrWhiteSpaceThrowArgumentException("id");

            if (avr.MailServiceEnum == MailServiceENUM.Unknown)
            {
                throw new Exception("Mail Service is unknown");
            }

            if (avr.IsSure1 == false)
            {
                throw new Exception("Not Sure 1");
            }

            if (avr.IsSure2 == false)
            {
                throw new Exception("Not Sure 2");
            }

            if (avr.PaymentAmount == 0)
            {
                throw new Exception("No payment amount.");
            }


            AddressMain address = Find(avr.AddressId);

            address.IsNullThrowException("Address Not found");

            AddressVerificationTrx addyVerfTrx = fixAddressVerificationTrx(avr, address);

            //this is where we give the verification number
            long verificationNumber = GenerateRandomVerificationNumber;

            addyVerfTrx.Verification.VerificationNumber = verificationNumber;



            if (address.AddressVerificationTrxs.IsNull())
            {
                address.AddressVerificationTrxs = new List <AddressVerificationTrx>();
            }

            address.AddressVerificationTrxs.Add(addyVerfTrx);
            address.Verification.VerificaionStatusEnum = VerificaionStatusENUM.Requested;

            AddressVerificationTrxBiz.Create(addyVerfTrx);

            ControllerCreateEditParameter param = new ControllerCreateEditParameter();

            param.Entity       = address as ICommonWithId;
            param.GlobalObject = globalObject;


            UpdateAndSave(param);

            //UpdateAndSave(address);
        }
Beispiel #3
0
        public double getVerificaionCost(AddressVerificationRequest avr)
        {
            string error            = "";
            double verificationCost = 0;

            switch (avr.MailServiceEnum)
            {
            case MailServiceENUM.Post:
                switch (CountryBiz.IsAddressInPakistan(avr.CountryId))
                {
                case true:
                    //is in Pakistan
                    verificationCost = VerificationConfig.Sale_Postal_Local;
                    break;

                case false:
                    //is foreign
                    verificationCost = VerificationConfig.Sale_Postal_International;
                    break;

                default:
                    error = string.Format("No such option");
                    throw new Exception(error);
                }
                break;

            case MailServiceENUM.Courier:
                switch (CountryBiz.IsAddressInPakistan(avr.CountryId))
                {
                case true:
                    //is in Pakistan
                    verificationCost = VerificationConfig.Sale_Courier_Local;
                    break;

                case false:
                    verificationCost = VerificationConfig.Sale_Courier_International;
                    //is foreign
                    break;

                default:
                    error = string.Format("No such option");
                    throw new Exception(error);
                }
                break;

            default:
                error = string.Format("No such option: {0}", avr.MailServiceEnum);
                throw new Exception(error);
            }

            return(verificationCost);
        }
Beispiel #4
0
        AddressVerificationTrx fixAddressVerificationTrx(AddressVerificationRequest avr, AddressMain address)
        {
            address.Verification.SetTo(EnumLibrary.EnumNS.VerificaionStatusENUM.Requested);

            //create a Verification Request
            AddressVerificationTrx addyVerfTrx = AddressVerificationTrxBiz.Factory() as AddressVerificationTrx;

            //addyVerfTrx.Address = address;
            addyVerfTrx.AddressId       = avr.AddressId;
            addyVerfTrx.MailServiceEnum = avr.MailServiceEnum;
            //todo
            //addyVerfTrx.MailLocalOrForiegnEnum = GetMailLocalOrForiegnEnum(address.CountryId);

            //Accept payment here?
            addyVerfTrx.DateVerifcationPaymentAccepted = DateTime.UtcNow;

            addyVerfTrx.Verification.SetTo(VerificaionStatusENUM.Requested);
            addyVerfTrx.Name = string.Format("{0}-{1}", UserName, address.Name);

            return(addyVerfTrx);
        }
        private AddressVerificationRequest load_AddressVerificationRequestModel(string addressId, AddressMain address)
        {
            addressId.IsNullOrWhiteSpaceThrowArgumentException("addressId");
            AddressVerificationRequest avr = new AddressVerificationRequest();

            avr.AddressMailForm = address.ToPostalHTML();

            avr.AddressId = addressId;
            //tod
            //avr.CountryId = address.CountryId;
            //avr.CourierInternationalPayment = VerificationConfig.Sale_Courier_International.ToString();
            //avr.CourierLocalPayment = VerificationConfig.Sale_Courier_Local.ToString();
            //avr.PostalInternationalPayment = VerificationConfig.Sale_Postal_International.ToString();
            //avr.PostalLocalPayment = VerificationConfig.Sale_Postal_Local.ToString();

            avr.CourierBtnCaption = "";
            MailLocalOrForiegnENUM mailLocalOrForiegnEnum = IsAddressInPakistan(addressId) ? MailLocalOrForiegnENUM.InPakistan : MailLocalOrForiegnENUM.OutOfPakistan;

            string postBtnCaption;

            getVerificaionCharges(MailServiceENUM.Post, mailLocalOrForiegnEnum, out postBtnCaption);
            avr.PostalBtnCaption = postBtnCaption;

            string courierBtnCaption;

            getVerificaionCharges(MailServiceENUM.Courier, mailLocalOrForiegnEnum, out courierBtnCaption);
            avr.CourierBtnCaption = courierBtnCaption;



            avr.MailLocalOrForeignEnum = IsAddressInPakistan(addressId) ?
                                         MailLocalOrForiegnENUM.InPakistan :
                                         MailLocalOrForiegnENUM.OutOfPakistan;

            return(avr);
        }
Beispiel #6
0
        public static AddressVerificationResponse AddressVerificationResponseProcessor(AddressVerificationRequest AddressVerifReq)
        {
            var resp = new AddressVerificationResponse();

            try
            {
                string jsonResponse = KycService.AddressVerificationRequest(AddressVerifReq);
                resp = JsonConvert.DeserializeObject <AddressVerificationResponse>(jsonResponse);
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(resp);
        }
Beispiel #7
0
        private double getVerificaionCharges(AddressVerificationRequest avr, out string btnCaption)
        {
            double charges = getVerificaionCharges(avr.MailServiceEnum, avr.MailLocalOrForeignEnum, out btnCaption);

            return(charges);
        }
Beispiel #8
0
 public AddressVerificationResponse DoAddressVerifReq(AddressVerificationRequest AddressVerifReq)
 {
     return(KycLogic.AddressVerificationResponseProcessor(AddressVerifReq));
 }