Пример #1
0
        public async Task <DataMessage> SaveControlNumberAsync(ControlNumberResp model)
        {
            ImisPayment payment             = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            var         controlNumberExists = payment.CheckControlNumber(model.internal_identifier, model.control_number);
            var         response            = await payment.SaveControlNumberAsync(model, controlNumberExists);

            if (model.error_occured)
            {
                response.ErrorOccured = true;
                response.MessageValue = model.error_message;
            }

            if (payment.PaymentId != 0 && payment.SmsRequired)
            {
                var ackResponse = payment.GetReqControlNumberAck(payment.PaymentId);

                if (!response.ErrorOccured && !controlNumberExists)
                {
                    ControlNumberAssignedSms(payment);
                }
                else
                {
                    ControlNumberNotassignedSms(payment, response.MessageValue);
                }
            }

            return(response);
        }
Пример #2
0
        public async void SendPaymentConfirmationSms(PaymentData pd, ImisPayment payment)
        {
            // Language lang = payment.Language.ToLower() == "en" || payment.Language.ToLower() == "english" || payment.Language.ToLower() == "primary" ? Language.Primary : Language.Secondary;
            ImisSms             sms     = new ImisSms(_configuration, _hostingEnvironment, payment.Language);
            List <SmsContainer> message = new List <SmsContainer>();

            var txtmsg = string.Format(
                sms.GetMessage("PaymentConfirmationSMS"),   // template
                payment.Location,                           // Product location
                pd.control_number,                          // invoice number
                pd.received_amount,                         // amount paid
                pd.receipt_identification,                  // receipt number
                DateTime.Parse(pd.payment_date).ToString(), // payment date
                pd.transaction_identification               // transaction number
                );


            message.Add(new SmsContainer()
            {
                Message = txtmsg, Recipient = pd.payer_phone_number
            });


            var fileName = "PaymentConfirmationSms_" + pd.payer_phone_number;

            string test = await sms.SendSMS(message, fileName);

            payment.UpdateLastSMSSentDateAsync();
        }
Пример #3
0
        public BulkControlNumbersForEO GetControlNumbersForEO(string officerCode, string productCode, int available)
        {
            var imisPayment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);

            var threshold = Convert.ToInt32(_configuration["PaymentGateWay:MaxControlNumberForEO"]);

            var requiredCNs = threshold - available;

            if (requiredCNs <= 0)
            {
                var response = new BulkControlNumbersForEO();
                var header   = new ControlNumbersForEOHeader
                {
                    Error        = (int)Errors.ControlNumbers.ThresholdReached,
                    ErrorMessage = Errors.ControlNumbers.ThresholdReached.ToString()
                };

                var controlNumebrs = new List <ControlNumbersForEO>();

                response.Header         = header;
                response.ControlNumbers = controlNumebrs;

                return(response);
            }

            return(imisPayment.GetControlNumbersForEO(officerCode, productCode, requiredCNs));
        }
Пример #4
0
        // Todo: make this method generic
        public async Task <DataMessage> CancelPayment(int payment_id)
        {
            ImisPayment payment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            DataMessage dt      = new DataMessage();

            if (payment_id > 0)
            {
                payment.GetPaymentInfo(payment_id);
                await payment.CancelPayment(payment_id);

                SendPaymentCancellationSms(payment);
            }
            else
            {
                //Todo: move hardcoded message to translation file
                DataMessage dm = new DataMessage
                {
                    Code         = 2,
                    ErrorOccured = true,
                    MessageValue = "CancelPayment:2:Control Number doesn't exists",
                };

                return(dm);
            }

            return(dt);
        }
Пример #5
0
        public async Task <DataMessage> MatchPayment(MatchModel model)
        {
            ImisPayment payment  = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            var         response = payment.MatchPayment(model);

            if (model.internal_identifier == 0)
            {
                List <MatchSms> PaymentIds = new List <MatchSms>();

                PaymentIds = payment.GetPaymentIdsForSms();

                if (PaymentIds != null)
                {
                    // SendMatchSms(PaymentIds);
                }
            }
            else
            {
                // XML TO JSON
                var matchdata = JsonConvert.SerializeObject(response.Data);
                //
                var matchedPayments = JsonConvert.DeserializeObject <List <MatchedPayment> >(matchdata);

                if (matchedPayments.FirstOrDefault().PaymentMatched > 0)
                {
                    //SendPaymentSms(payment);
                }
            }

            return(await Task.FromResult(response));
        }
 public PaymentController(IConfiguration configuration, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory) : base(configuration, hostingEnvironment, loggerFactory)
 {
     env             = hostingEnvironment;
     imisPayment     = new ImisPayment(configuration, hostingEnvironment, loggerFactory);
     _gepgFileLogger = new GepgFileRequestLogger(hostingEnvironment, loggerFactory);
     _logger         = loggerFactory.CreateLogger <PaymentController>();
 }
        public async Task <IActionResult> CHFCancelOnePayment([FromBody] PaymentCancelModel model)
        {
            ImisPayment payment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            DataMessage dt      = new DataMessage();

            if (model.payment_id != 0 || model.control_number != null)
            {
                // if payment_id is in payload it will be used else it will be calculated from CN
                int paymentId = model.payment_id != 0 ? model.payment_id : payment.GetPaymentId(model.control_number);

                model.payment_id = paymentId;

                if (paymentId != 0)
                {
                    var ack = await payment.GePGPostCancelPayment(paymentId);

                    if (ack.GetType() == typeof(DataMessage))
                    {
                        return(Ok((DataMessage)ack));
                    }

                    GePGPaymentCancelResponse response = (GePGPaymentCancelResponse)ack;

                    if (response.gepgBillCanclResp.BillCanclTrxDt.Count() > 0 &&
                        response.gepgBillCanclResp.BillCanclTrxDt[0].TrxSts == TrxSts.Success)
                    {
                        return(await base.CancelPayment(model));
                    }
                    else
                    {
                        return(Ok(new DataMessage
                        {
                            Data = response,
                            Code = 3,
                            ErrorOccured = true,
                            MessageValue = "CancelPayment:3:Failed to cancel"
                        }));
                    }
                }
                else
                {
                    //Todo: move hardcoded message to translation file
                    return(Ok(new DataMessage
                    {
                        Code = 2,
                        ErrorOccured = true,
                        MessageValue = "CancelPayment:2:Control Number doesn't exists",
                    }));
                }
            }

            return(Ok(new DataMessage
            {
                Code = 1,
                ErrorOccured = true,
                MessageValue = "CancelPayment:1:Missing Control Number",
            }));
        }
Пример #8
0
        public async void SendPaymentSms(ImisPayment payment)
        {
            // Language lang = payment.Language.ToLower() == "en" || payment.Language.ToLower() == "english" || payment.Language.ToLower() == "primary" ? Language.Primary : Language.Secondary;
            ImisSms             sms     = new ImisSms(_configuration, _hostingEnvironment, payment.Language);
            List <SmsContainer> message = new List <SmsContainer>();
            var familyproduct           = payment.InsureeProducts.FirstOrDefault();

            if (familyproduct.PolicyActivated)
            {
                var txtmsg = string.Format(sms.GetMessage("PaidAndActivated"),
                                           payment.PaidAmount,
                                           DateTime.UtcNow.ToString("dd-MM-yyyy"),
                                           payment.ControlNum,
                                           familyproduct.InsureeNumber,
                                           familyproduct.InsureeName,
                                           familyproduct.ProductCode,
                                           familyproduct.ProductName,
                                           familyproduct.EffectiveDate.Value.ToShortDateString(),
                                           familyproduct.ExpiryDate.Value.ToShortDateString(),
                                           payment.PaidAmount);


                message.Add(new SmsContainer()
                {
                    Message = txtmsg, Recipient = payment.PhoneNumber
                });
            }
            else
            {
                decimal transferFee = 0;

                if (payment.typeOfPayment != null)
                {
                    transferFee = payment.determineTransferFee(payment.ExpectedAmount, (TypeOfPayment)payment.typeOfPayment);
                }

                var txtmsg = string.Format(sms.GetMessage("PaidAndNotActivated"),
                                           payment.PaidAmount,
                                           DateTime.UtcNow.ToString("dd-MM-yyyy"),
                                           payment.ControlNum,
                                           familyproduct.InsureeNumber,
                                           familyproduct.InsureeName,
                                           familyproduct.ProductCode,
                                           familyproduct.ProductName,
                                           payment.GetToBePaidAmount(payment.ExpectedAmount, transferFee),
                                           payment.OutStAmount);

                message.Add(new SmsContainer()
                {
                    Message = txtmsg, Recipient = payment.PhoneNumber
                });
            }
            var fileName = "PayStatSms_" + payment.PhoneNumber;

            string test = await sms.SendSMS(message, fileName);

            payment.UpdateLastSMSSentDateAsync();
        }
Пример #9
0
        public async void SendMatchSms(List <MatchSms> Ids)
        {
            List <SmsContainer> message = new List <SmsContainer>();

            foreach (var m in Ids)
            {
                bool shoulSendSms = LocalDefault.ShouldSendSms(_configuration, m.DateLastSms, m.MatchedDate);

                if (shoulSendSms)
                {
                    var    txtmsgTemplate = string.Empty;
                    string othersCount    = string.Empty;

                    ImisPayment _pay = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
                    _pay.GetPaymentInfo(m.PaymentId);

                    //Language lang = _pay.Language.ToLower() == "en" || _pay.Language.ToLower() == "english" || _pay.Language.ToLower() == "primary" ? Language.Primary : Language.Secondary;
                    ImisSms sms = new ImisSms(_configuration, _hostingEnvironment, _pay.Language);

                    if (_pay.PaymentId != 0)
                    {
                        if (_pay.InsureeProducts.Count > 1)
                        {
                            txtmsgTemplate = sms.GetMessage("PaidAndNotMatchedV2");
                            othersCount    = Convert.ToString(_pay.InsureeProducts.Count - 1);
                        }
                        else
                        {
                            txtmsgTemplate = sms.GetMessage("PaidAndNotMatched");
                        }
                        var familyproduct = _pay.InsureeProducts.FirstOrDefault();
                        var txtmsg        = string.Format(txtmsgTemplate,
                                                          _pay.PaidAmount,
                                                          DateTime.UtcNow.ToString("dd-MM-yyyy"),
                                                          _pay.ControlNum,
                                                          familyproduct.InsureeNumber,
                                                          familyproduct.InsureeName,
                                                          familyproduct.ProductCode,
                                                          familyproduct.ProductName,
                                                          othersCount);


                        message.Add(new SmsContainer()
                        {
                            Message = txtmsg, Recipient = _pay.PhoneNumber
                        });
                        _pay.UpdateLastSMSSentDateAsync();
                    }
                    else
                    {
                        throw new Exception();
                    }

                    var    fileName = "PayNotMatched_";
                    string test     = await sms.SendSMS(message, fileName);
                }
            }
        }
Пример #10
0
        public async Task <DataMessage> SaveAcknowledgementAsync(Acknowledgement model)
        {
            ImisPayment payment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory)
            {
                PaymentId = model.internal_identifier
            };
            var response = await payment.SaveControlNumberAknAsync(model.error_occured, model.error_message);

            return(response);
        }
Пример #11
0
        public async Task <DataMessage> GetControlNumbers(PaymentRequest requests)
        {
            ImisPayment payment    = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            var         PaymentIds = requests.requests.Select(x => x.internal_identifier).ToArray();

            var PaymentIds_string = string.Join(",", PaymentIds);

            var response = await payment.GetControlNumbers(PaymentIds_string);

            return(response);
        }
Пример #12
0
        public void CreatePremium(PolicyRenewalModel renewal)
        {
            ImisPayment payment      = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            var         paymentLogic = new PaymentLogic(_configuration, _hostingEnvironment, _loggerFactory);

            if (_configuration.GetValue <bool>("PaymentGateWay:CreatePremiumOnPaymentReceived"))
            {
                int paymentId = payment.GetPaymentId(renewal.ControlNumber);
                _ = paymentLogic.CreatePremium(paymentId);
            }
        }
Пример #13
0
        public async Task <ReconciliationMessage> ProvideReconciliationData(ReconciliationRequest model)
        {
            ImisPayment payment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);

            var response = payment.ProvideReconciliationData(model);

            ReconciliationMessage return_message = new ReconciliationMessage
            {
                transactions   = response,
                error_occurred = false
            };

            return(await Task.FromResult(return_message));
        }
Пример #14
0
        public async void ControlNumberAssignedSms(ImisPayment payment)
        {
            //Language lang = payment.Language.ToLower() == "en" || payment.Language.ToLower() == "english" || payment.Language.ToLower() == "primary" ? Language.Primary : Language.Secondary;
            ImisSms sms            = new ImisSms(_configuration, _hostingEnvironment, payment.Language);
            var     txtmsgTemplate = string.Empty;
            string  othersCount    = string.Empty;

            if (payment.InsureeProducts.Count > 1)
            {
                txtmsgTemplate = sms.GetMessage("ControlNumberAssignedV2");
                othersCount    = Convert.ToString(payment.InsureeProducts.Count - 1);
            }
            else
            {
                txtmsgTemplate = sms.GetMessage("ControlNumberAssigned");
            }

            decimal transferFee = 0;

            if (payment.typeOfPayment != null)
            {
                transferFee = payment.determineTransferFee(payment.ExpectedAmount, (TypeOfPayment)payment.typeOfPayment);
            }

            var txtmsg = string.Format(txtmsgTemplate,
                                       payment.ControlNum,
                                       DateTime.UtcNow.ToString("dd-MM-yyyy"),
                                       DateTime.UtcNow.ToString("dd-MM-yyyy"),
                                       payment.InsureeProducts.FirstOrDefault().InsureeNumber,
                                       payment.InsureeProducts.FirstOrDefault().InsureeName,
                                       payment.InsureeProducts.FirstOrDefault().ProductCode,
                                       payment.InsureeProducts.FirstOrDefault().ProductName,
                                       payment.GetToBePaidAmount(payment.ExpectedAmount, transferFee),
                                       othersCount);

            List <SmsContainer> message = new List <SmsContainer>();

            message.Add(new SmsContainer()
            {
                Message = txtmsg, Recipient = payment.PhoneNumber
            });

            var fileName = "CnAssigned_" + payment.PhoneNumber;

            string test = await sms.SendSMS(message, fileName);
        }
Пример #15
0
        public void CreatePremium(EnrolFamilyModel model)
        {
            ImisPayment  payment      = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            PaymentLogic paymentLogic = new PaymentLogic(_configuration, _hostingEnvironment, _loggerFactory);

            if (_configuration.GetValue <bool>("PaymentGateWay:CreatePremiumOnPaymentReceived"))
            {
                foreach (var family in model.Family)
                {
                    foreach (var policy in family.Policies)
                    {
                        int paymentId = payment.GetPaymentId(policy.ControlNumber);
                        _ = paymentLogic.CreatePremium(paymentId);
                    }
                }
            }
        }
Пример #16
0
        public async Task <DataMessage> SaveIntent(IntentOfPay intent, int?errorNumber = 0, string errorMessage = null)
        {
            var payment        = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);
            var cnHandler      = new SingleControlNumberHandler(_configuration, _hostingEnvironment);
            var return_message = cnHandler.GetControlNumber(intent);
            var data           = new AssignedControlNumber();

            if (return_message.ErrorOccured == true)
            {
                data = (AssignedControlNumber)return_message.Data;
            }

            if (return_message.ErrorOccured == false)
            {
                var objstring = return_message.Data.ToString();
                data = (JsonConvert.DeserializeObject <List <AssignedControlNumber> >(objstring)).FirstOrDefault();
                return_message.Data = data;
            }


            if (data.control_number != null & data.internal_identifier != null && intent.SmsRequired & !return_message.ErrorOccured)
            {
                payment.GetPaymentInfo(Convert.ToInt32(data.internal_identifier));
                ControlNumberAssignedSms(payment);
            }
            else
            {
                payment.ControlNum      = null;
                payment.InsureeProducts = new List <InsureeProduct>();
                payment.InsureeProducts.Add(
                    new InsureeProduct {
                    InsureeNumber = intent.policies.FirstOrDefault().insurance_number,
                    ProductCode   = intent.policies.FirstOrDefault().insurance_product_code
                }
                    );
                payment.PhoneNumber = intent.phone_number;
                ControlNumberNotassignedSms(payment, return_message.MessageValue);
            }

            return(return_message);
        }
Пример #17
0
        public async void SendMatchSms(ImisPayment payment)
        {
            // Language lang = payment.Language.ToLower() == "en" || payment.Language.ToLower() == "english" || payment.Language.ToLower() == "primary" ? Language.Primary : Language.Secondary;
            ImisSms             sms     = new ImisSms(_configuration, _hostingEnvironment, payment.Language);
            List <SmsContainer> message = new List <SmsContainer>();

            var    txtmsgTemplate = string.Empty;
            string othersCount    = string.Empty;

            if (payment.InsureeProducts.Count > 1)
            {
                txtmsgTemplate = sms.GetMessage("PaidAndNotMatchedV2");
                othersCount    = Convert.ToString(payment.InsureeProducts.Count - 1);
            }
            else
            {
                txtmsgTemplate = sms.GetMessage("PaidAndNotMatched");
            }
            var familyproduct = payment.InsureeProducts.FirstOrDefault();
            var txtmsg        = string.Format(txtmsgTemplate,
                                              payment.PaidAmount,
                                              DateTime.UtcNow.ToString("dd-MM-yyyy"),
                                              payment.ControlNum,
                                              familyproduct.InsureeNumber,
                                              familyproduct.InsureeName,
                                              familyproduct.ProductCode,
                                              familyproduct.ProductName,
                                              othersCount);


            message.Add(new SmsContainer()
            {
                Message = txtmsg, Recipient = payment.PhoneNumber
            });

            var fileName = "PayNotMatched_" + payment.PhoneNumber;

            string test = await sms.SendSMS(message, fileName);
        }
Пример #18
0
        public async void SendPaymentCancellationSms(ImisPayment payment)
        {
            ImisSms             sms     = new ImisSms(_configuration, _hostingEnvironment, payment.Language);
            List <SmsContainer> message = new List <SmsContainer>();

            var txtmsg = string.Format(
                sms.GetMessage("CancellationSms"), // template
                payment.ControlNum,                // invoice number
                DateTime.Now.ToString()            // payment cancellation date
                );

            message.Add(new SmsContainer()
            {
                Message = txtmsg, Recipient = payment.PhoneNumber
            });

            var fileName = "PaymentCancellationSms_" + payment.PhoneNumber;

            string test = await sms.SendSMS(message, fileName);

            payment.UpdateLastSMSSentDateAsync();
        }
Пример #19
0
        private void SendSMS(ImisPayment payment)
        {
            var paymentLogic = new PaymentLogic(_configuration, _hostingEnvironment, _loggerFactory);

            paymentLogic.ControlNumberAssignedSms(payment);
        }
Пример #20
0
        public int CreatePremium(int paymentId)
        {
            var imisPayment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);

            return(imisPayment.CreatePremium(paymentId));
        }
Пример #21
0
        public async Task <int> ControlNumbersToBeRequested(string productCode)
        {
            var imisPayment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);

            return(await imisPayment.ControlNumbersToBeRequested(productCode));
        }
Пример #22
0
        public async Task <DataMessage> CreateSelfRenewal(SelfRenewal renewal)
        {
            // Log the request for future reference
            GenerateRquestFile(renewal);

            var context     = new ImisDB();
            var dataMessage = Validate(renewal);

            // Send SMS for the previously created request
            if (dataMessage.Code == (int)Errors.Renewal.RenewalAlreadyRequested)
            {
                var payment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);

                var paymentId = GetPaymentId(renewal);
                if (paymentId > 0)
                {
                    payment.GetPaymentInfo(Convert.ToInt32(paymentId));

                    // Replace the phone number by the current recipient
                    payment.PhoneNumber = renewal.Msisdn;
                    SendSMS(payment);
                }
            }

            if (dataMessage.Code != 0)
            {
                return(dataMessage);
            }

            // All checks passed, continue creating a new policy in tblPolicy

            var insuree = context.TblInsuree
                          .Where(i => i.Chfid == renewal.InsuranceNumber && i.ValidityTo == null)
                          .Include(i => i.Family).ThenInclude(f => f.TblPolicy).ThenInclude(p => p.Prod).ThenInclude(pr => pr.ConversionProd)
                          .FirstOrDefault();

            var insurees = context.TblInsuree
                           .Where(i => i.FamilyId == insuree.FamilyId && i.ValidityTo == null).ToList();

            var product = context.TblProduct.Where(prod => prod.ProductCode.ToUpper() == renewal.ProductCode.ToUpper() && prod.ValidityTo == null).FirstOrDefault();

            var dtPolicyPeriod = GetPolicyPeriod(product.ProdId, DateTime.Now.Date);

            var prevPolicy = insuree.Family.TblPolicy.Where(p => p.Prod.ProductCode.ToUpper() == renewal.ProductCode.ToUpper() && p.ValidityTo == null).FirstOrDefault();

            var conProd = insuree.Family.TblPolicy.Any(p => p.Prod.ConversionProd != null);

            TblPolicy convPolicy = null;

            if (conProd == true)
            {
                convPolicy = insuree.Family.TblPolicy.Where(p => p.Prod.ConversionProd.ProductCode.ToUpper() == renewal.ProductCode.ToUpper() && p.ValidityTo == null).FirstOrDefault();
            }

            int officerId = 0;

            if (prevPolicy != null)
            {
                officerId = (int)prevPolicy.OfficerId;
            }
            else
            {
                officerId = (int)convPolicy.OfficerId;
            }


            // Prepare policy
            var policy = new TblPolicy
            {
                FamilyId     = insuree.FamilyId,
                EnrollDate   = DateTime.Now,
                StartDate    = (DateTime)dtPolicyPeriod.Rows[0]["StartDate"],
                ExpiryDate   = (DateTime?)dtPolicyPeriod.Rows[0]["ExpiryDate"],
                PolicyStatus = 1,
                PolicyValue  = product.LumpSum, // for now we are taking lumnpsum but in future we might have to consider other paramters like Grace period, discount preiod etc...
                ProdId       = product.ProdId,
                OfficerId    = officerId,
                ValidityFrom = DateTime.Now,
                AuditUserId  = -1,
                IsOffline    = false,
                PolicyStage  = "R",
                SelfRenewed  = true
            };

            // Prepare InsureePolicy
            var insureePolicy = new List <TblInsureePolicy>();

            foreach (var ins in insurees)
            {
                var insPol = new TblInsureePolicy
                {
                    InsureeId      = ins.InsureeId,
                    PolicyId       = policy.PolicyId,
                    EnrollmentDate = policy.EnrollDate,
                    StartDate      = policy.StartDate,
                    EffectiveDate  = policy.EffectiveDate,
                    ExpiryDate     = policy.ExpiryDate,
                    ValidityFrom   = DateTime.Now,
                    AuditUserId    = -1,
                    IsOffline      = false
                };

                insureePolicy.Add(insPol);
            }

            policy.TblInsureePolicy = insureePolicy;

            var controlNumberResponse = new GetControlNumberResp();

            // Begin transaction

            using (var dbContextTransaction = context.Database.BeginTransaction())
            {
                try
                {
                    context.TblPolicy.Add(policy);
                    context.SaveChanges();

                    // Request Control Number from the Pool, if we fail to get the control number delete the newly created entry

                    var officer = context.TblOfficer.Where(o => o.OfficerId == policy.OfficerId).FirstOrDefault();
                    var intent  = new IntentOfSinglePay
                    {
                        Msisdn        = renewal.Msisdn,
                        request_date  = DateTime.Now.Date.ToString(),
                        OfficerCode   = officer.Code,
                        InsureeNumber = renewal.InsuranceNumber,
                        ProductCode   = renewal.ProductCode,
                        EnrolmentType = ePayment.Models.EnrolmentType.Renewal,
                        language      = "en"
                    };

                    controlNumberResponse = await GetControlNumber(intent);

                    if (!String.IsNullOrEmpty(controlNumberResponse.control_number))
                    {
                        dbContextTransaction.Commit();
                        dataMessage.Data = context.TblPolicy.Where(p => p.PolicyId == policy.PolicyId).Select(p => new { p.PolicyId, p.EnrollDate, ControlNumber = controlNumberResponse.control_number }).FirstOrDefault();
                    }
                    else
                    {
                        dbContextTransaction.Rollback();
                        dataMessage.Data = controlNumberResponse.error_message;
                    }
                }
                catch (Exception)
                {
                    dbContextTransaction.Rollback();
                    throw;
                }
            }


            return(dataMessage);
        }
Пример #23
0
        public async Task <string> RequestBulkControlNumbers(RequestBulkControlNumbersModel model)
        {
            var imisPayment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);

            return(await imisPayment.RequestBulkControlNumbers(model));
        }
Пример #24
0
        public async Task <DataMessage> SavePayment(PaymentData model)
        {
            ImisPayment payment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory);

            //var controlNumberExists = payment.CheckControlNumber(model.internal_identifier, model.control_number);

            if (model.control_number != null)
            {
                model.type_of_payment = null;

                int paymentId = payment.GetPaymentId(model.control_number);

                if (paymentId != 0)
                {
                    payment.GetPaymentInfo(paymentId);
                }
                else
                {
                    DataMessage dm = new DataMessage
                    {
                        Code         = 3,
                        ErrorOccured = true,
                        MessageValue = "3-Wrong control_number",
                    };

                    return(dm);
                }
            }

            if (model.type_of_payment == null && payment.typeOfPayment != null)
            {
                var transferFee = payment.determineTransferFeeReverse(Convert.ToDecimal(model.received_amount), (TypeOfPayment)payment.typeOfPayment);
                var success     = await payment.UpdatePaymentTransferFeeAsync(payment.PaymentId, transferFee, (TypeOfPayment)payment.typeOfPayment);

                model.received_amount = model.received_amount + Convert.ToDouble(transferFee);
            }
            else if (model.type_of_payment != null && payment.typeOfPayment == null)
            {
                var transferFee = payment.determineTransferFeeReverse(Convert.ToDecimal(model.received_amount), (TypeOfPayment)model.type_of_payment);
                var success     = await payment.UpdatePaymentTransferFeeAsync(payment.PaymentId, transferFee, (TypeOfPayment)model.type_of_payment);

                model.received_amount = model.received_amount + Convert.ToDouble(transferFee);
            }

            var response = await payment.SavePaymentAsync(model);

            if (payment.PaymentId != 0)
            {
                if (_configuration.GetValue <bool>("PaymentGateWay:CreatePremiumOnPaymentReceived") & response.Code == 0)
                {
                    CreatePremium(payment.PaymentId);
                }

                SendPaymentConfirmationSms(model, payment);
            }

            if (payment.PaymentId != 0 && !response.ErrorOccured)
            {
                var ackResponse = payment.GetPaymentDataAck(payment.PaymentId, payment.ControlNum);

                MatchModel matchModel = new MatchModel()
                {
                    internal_identifier = payment.PaymentId, audit_user_id = -3
                };

                var matchresponse = await MatchPayment(matchModel);

                /*
                 #if DEBUG
                 * var matchdata = JsonConvert.SerializeObject(matchresponse.Data);
                 * var matchedPayments = JsonConvert.DeserializeObject<List<MatchedPayment>>(matchdata);
                 *
                 * if (matchedPayments.Select(x => x.PaymentId).Contains(payment.PaymentId))
                 * {
                 *  SendPaymentSms(payment);
                 * }
                 #endif*/
            }

            return(response);
        }