示例#1
0
        public ActionResult ProcessSampathBankResponse(PaymentCompleteRequest paymentCompleteRequest)
        {
            if (TempData.ContainsKey("CloseWindows"))
            {
                ViewBag.CloseWindow = TempData["CloseWindows"].ToString();
            }
            int clientID = Convert.ToInt32(ConfigurationManager.AppSettings["CLIENTID"].ToString());

            paymentCompleteRequest.clientId = clientID;
            GatewayClient           gatewayClient           = new GatewayClient(make_ClientConfig_Sampath());
            PaymentCompleteResponse paymentCompleteResponse = gatewayClient.payment.complete(paymentCompleteRequest);
            PaymentModel            objPaymentModel         = new PaymentModel();

            objPaymentModel.UserName      = Username;
            objPaymentModel.ReqId         = paymentCompleteRequest.reqid;
            objPaymentModel.PayableAmount = Convert.ToString(Convert.ToInt32(paymentCompleteResponse.transactionAmount.paymentAmount / 100));
            objPaymentModel.PGResponse    = paymentCompleteResponse.responseCode + "|" + paymentCompleteResponse.responseText;
            objPaymentModel = objPaymentBusiness.UpdatePGTransaction(objPaymentModel);
            string msg = string.Empty;

            msg             = objPaymentModel.Error.ErrorMessage;
            ViewBag.Message = msg;
            if (string.IsNullOrEmpty(objPaymentModel.Error.ErrorMessage))
            {
                AIA.Life.Business.Policy.PolicyBusiness objPolicyBusiness = new AIA.Life.Business.Policy.PolicyBusiness();
                if (!string.IsNullOrEmpty(objPaymentModel.UWMessage))
                {
                    msg = objPaymentModel.UWMessage;
                }
                else if (objPaymentModel.Message == "Success")
                {
                    msg = "Your policy has been issued. Please refer policy number " + objPaymentModel.ProposalNo + " for future reference";
                    #region policy issuance triggers
                    if (!string.IsNullOrEmpty(objPaymentModel.Message) && objPaymentModel.Message == "Success")
                    {
                        objPaymentModel = objPaymentBusiness.FetchProposals(objPaymentModel);
                        ReportsController objReportController = new ReportsController();
                        List <byte[]>     lstBytes            = new List <byte[]>();
                        try
                        {
                            if (objPaymentModel.lstPaymentItems.Count > 0)
                            {
                                int prdID       = objPaymentModel.lstPaymentItems[0].ProductID;
                                var obj         = Context.tblMasProductPlans.Where(a => a.ProductId == prdID).FirstOrDefault();
                                var ProductCode = Context.tblProducts.Where(a => a.ProductId == prdID).Select(a => a.ProductCode).FirstOrDefault();
                                if (obj != null)
                                {
                                    byte[] quoteBytes = objReportController.ReportQuotation(objPaymentModel.QuoteNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                                    if (quoteBytes != null)
                                    {
                                        lstBytes.Add(quoteBytes);
                                    }
                                    byte[]        a  = objReportController.ReportForIllustrationPDF(objPaymentModel.QuoteNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage, objPaymentModel.ProposalNo);
                                    byte[]        b  = objReportController.ReportForPolicySchedule(objPaymentModel.ProposalNo, ProductCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                                    byte[]        c  = objReportController.ReportForCoveringLetter(objPaymentModel.ProposalNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                                    List <byte[]> vs = new List <byte[]>();
                                    if (c != null)
                                    {
                                        vs.Add(c);
                                    }
                                    if (b != null)
                                    {
                                        vs.Add(b);
                                    }
                                    if (a != null)
                                    {
                                        vs.Add(a);
                                    }
                                    objPaymentModel.ByteArray2 = concatAndAddContent(vs);
                                    objPaymentModel.ByteArray3 = objReportController.ProposalReport(objPaymentModel.QuoteNo, ProductCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                                    if (objPaymentModel.ByteArray2 != null)
                                    {
                                        lstBytes.Add(objPaymentModel.ByteArray2);
                                    }
                                    if (objPaymentModel.ByteArray3 != null)
                                    {
                                        lstBytes.Add(objPaymentModel.ByteArray3);
                                    }
                                }
                            }
                            objPolicyBusiness.PostPolicyIssuanceTriggers(objPaymentModel);
                        }
                        catch (Exception e)
                        {
                            log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                            Logger.Error(e);
                        }
                        try
                        {
                            for (int i = 0; i < lstBytes.Count; i++)
                            {
                                LdmsDocuments documents = new LdmsDocuments();
                                documents.SourcePath = ConfigurationManager.AppSettings["DocumentUploadPath"];
                                documents.DocCode    = i == 0 ? "PRD004" : (i == 1 ? "PRD009" : (i == 2 ? "PRD001" : ""));
                                documents.AgentCode  = Username;
                                documents.ProposalNo = objPaymentModel.ProposalNo;
                                documents.SourcePath = documents.SourcePath + @"\UW\" + documents.AgentCode + @"\" + documents.ProposalNo + @"\";
                                if (!Directory.Exists(documents.SourcePath))
                                {
                                    Directory.CreateDirectory(documents.SourcePath);
                                }
                                documents.SourcePath = documents.SourcePath + documents.DocCode + ".pdf";
                                System.IO.File.WriteAllBytes(documents.SourcePath, lstBytes[i]);
                                objPolicyBusiness.UploadDocumentsLDMS(documents);
                            }
                        }
                        catch (Exception ex)
                        {
                            log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                            Logger.Error(ex);
                        }
                    }
                    #endregion
                }
                else
                {
                    msg = objPaymentModel.Message;
                }

                ViewBag.Message = msg;
                return(View("~/Views/Payment/PaymentSuccess.cshtml"));
            }
            else
            {
                return(View("~/Views/Payment/PaymentFailure.cshtml"));
            }
        }
示例#2
0
        public JsonResult MCashPayment(PaymentModel objPaymentModel)
        {
            objPaymentModel.UserName = Username;
            objPaymentModel          = objPaymentBusiness.MCashPayment(objPaymentModel);
            #region policy issuance triggers
            if (!string.IsNullOrEmpty(objPaymentModel.Message) && objPaymentModel.Message == "Success")
            {
                objPaymentModel = objPaymentBusiness.FetchProposals(objPaymentModel);
                AIA.Life.Business.Policy.PolicyBusiness objPolicyBusiness = new AIA.Life.Business.Policy.PolicyBusiness();
                ReportsController objReportController = new ReportsController();
                List <byte[]>     lstBytes            = new List <byte[]>();
                try
                {
                    if (objPaymentModel.lstPaymentItems.Count > 0)
                    {
                        int prdID       = objPaymentModel.lstPaymentItems[0].ProductID;
                        var obj         = Context.tblMasProductPlans.Where(a => a.ProductId == prdID).FirstOrDefault();
                        var ProductCode = Context.tblProducts.Where(a => a.ProductId == prdID).Select(a => a.ProductCode).FirstOrDefault();
                        if (obj != null)
                        {
                            byte[] quoteBytes = objReportController.ReportQuotation(objPaymentModel.QuoteNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                            if (quoteBytes != null)
                            {
                                lstBytes.Add(quoteBytes);
                            }
                            byte[]        a  = objReportController.ReportForIllustrationPDF(objPaymentModel.QuoteNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage, objPaymentModel.ProposalNo);
                            byte[]        b  = objReportController.ReportForPolicySchedule(objPaymentModel.ProposalNo, ProductCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                            byte[]        c  = objReportController.ReportForCoveringLetter(objPaymentModel.ProposalNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                            List <byte[]> vs = new List <byte[]>();
                            if (c != null)
                            {
                                vs.Add(c);
                            }
                            if (b != null)
                            {
                                vs.Add(b);
                            }
                            if (a != null)
                            {
                                vs.Add(a);
                            }
                            objPaymentModel.ByteArray2 = concatAndAddContent(vs);
                            objPaymentModel.ByteArray3 = objReportController.ProposalReport(objPaymentModel.QuoteNo, ProductCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                            if (objPaymentModel.ByteArray2 != null)
                            {
                                lstBytes.Add(objPaymentModel.ByteArray2);
                            }
                            if (objPaymentModel.ByteArray3 != null)
                            {
                                lstBytes.Add(objPaymentModel.ByteArray3);
                            }
                        }
                    }

                    objPolicyBusiness.PostPolicyIssuanceTriggers(objPaymentModel);
                }
                catch (Exception e)
                {
                    log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                    Logger.Error(e);
                }
                try
                {
                    for (int i = 0; i < lstBytes.Count; i++)
                    {
                        LdmsDocuments documents = new LdmsDocuments();
                        documents.SourcePath = ConfigurationManager.AppSettings["DocumentUploadPath"];
                        documents.DocCode    = i == 0 ? "PRD004" : (i == 1 ? "PRD009" : (i == 2 ? "PRD001" : ""));
                        documents.AgentCode  = Username;
                        documents.ProposalNo = objPaymentModel.ProposalNo;
                        documents.SourcePath = documents.SourcePath + @"\UW\" + documents.AgentCode + @"\" + documents.ProposalNo + @"\";
                        if (!Directory.Exists(documents.SourcePath))
                        {
                            Directory.CreateDirectory(documents.SourcePath);
                        }
                        documents.SourcePath = documents.SourcePath + documents.DocCode + ".pdf";
                        System.IO.File.WriteAllBytes(documents.SourcePath, lstBytes[i]);
                        objPolicyBusiness.UploadDocumentsLDMS(documents);
                    }
                }
                catch (Exception ex)
                {
                    log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                    Logger.Error(ex);
                }
            }
            #endregion
            var ObjResponse = new { Message = objPaymentModel.Message, ProposalNo = objPaymentModel.ProposalNo, UWMessage = objPaymentModel.UWMessage, ErrorMessage = objPaymentModel.Error.ErrorMessage };
            return(Json(ObjResponse, JsonRequestBehavior.AllowGet));
        }