Ejemplo n.º 1
0
        /// <summary>
        /// Method to load the common transaction details from Payment Central to Payment Tool
        /// </summary>
        /// <param name="PaymentIDPProxyInputRequest"></param>
        /// <returns></returns>
        public string InsertPaymentItem(PaymentIDPProxyInputRequest PaymentIDPProxyInputRequest)
        {
            try
            {
                if (PaymentIDPProxyInputRequest.branchHubNumber == null)
                {
                    PaymentIDPProxyInputRequest.branchHubNumber = string.Empty;
                }
                using (SqlConnection conn = new SqlConnection(connstring))
                {
                    conn.Open();
                    SqlCommand comm = new SqlCommand();

                    comm.Connection  = conn;
                    comm.CommandType = System.Data.CommandType.StoredProcedure;
                    //Calls PC_Pay_InsertPayment Stored Procedure
                    comm.CommandText = Constant.SP_INSERT_PAYMENT;
                    //Parameters
                    comm.Parameters.AddWithValue("@applicationID", PaymentIDPProxyInputRequest.applicationContext.application);
                    comm.Parameters.AddWithValue("@merchantRefNumber", PaymentIDPProxyInputRequest.externalReferenceNumber);
                    comm.Parameters.AddWithValue("@paymentTypeID", PaymentIDPProxyInputRequest.paymentMethod);
                    comm.Parameters.AddWithValue("@userID", PaymentIDPProxyInputRequest.userId);
                    comm.Parameters.AddWithValue("@receiptNumber", PaymentIDPProxyInputRequest.receiptNumber);
                    comm.Parameters.AddWithValue("@physicalLocation", PaymentIDPProxyInputRequest.districtOffice);
                    comm.Parameters.AddWithValue("@amount", PaymentIDPProxyInputRequest.totalAmount);
                    comm.Parameters.AddWithValue("@financialLocation", PaymentIDPProxyInputRequest.branchHubNumber);
                    comm.Parameters.AddWithValue("@pc_status", Constant.RESPONSE_SUCCESS);
                    comm.Parameters.AddWithValue("@crossSequenceNumber", "");
                    //MAIG - CH1 - BEGIN - Added the below code to support the extra parameter for Auto approval
                    comm.Parameters.AddWithValue("@IsAutoApproved", false);
                    //MAIG - CH1 - END - Added the below code to support the extra parameter for Auto approval
                    SqlParameter Paymentid = new SqlParameter("@PaymentId", System.Data.SqlDbType.Int);
                    Paymentid.Direction = ParameterDirection.Output;
                    comm.Parameters.Add(Paymentid);
                    comm.ExecuteScalar();
                    return(Paymentid.Value.ToString());//returns Payment id as  output
                }
            }
            catch (FaultException ex)
            {
                log.WriteLog(ex.Message.ToString());
            }
            catch (CommunicationException exp)
            {
                log.WriteLog(exp.Message.ToString());
            }
            catch (Exception e)
            {
                string Error = e.Message.ToString() + e.StackTrace.ToString();
                log.WriteLog(Error.ToString());
            }

            return(string.Empty);
        }
Ejemplo n.º 2
0
        public IDPProxyResponse CheckValidation(PaymentIDPProxyInputRequest PaymentIDPProxyInputRequest)
        {
            IDPProxyResponse message = null;

            Regex junk_Chars = new Regex(@"[\\\~!@#$%^*()_+{}|""?`;',/[\]]+");

            if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.checkNumber) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.checkNumber))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.checkNumber);
            }
            else
            {
                message = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, Constant.VALIDATION_SUCCESS + PaymentIDPProxyInputRequest.receiptNumber);
            }
            return(message);
        }
        //CHGXXXX.Ch2 : End

        // Added Code to Log the Service Request

        private void LogServiceRequest(PaymentIDPProxyInputRequest PaymentIDPProxyInputRequestobj)
        {
            try
            {
                if (PaymentIDPProxyInputRequestobj != null)
                {
                    System.Xml.Serialization.XmlSerializer serializerReq = new System.Xml.Serialization.XmlSerializer(PaymentIDPProxyInputRequestobj.GetType());
                    StringWriter writerReq = new StringWriter();
                    serializerReq.Serialize(writerReq, PaymentIDPProxyInputRequestobj);
                    log.WriteLog(" Payment IDP Proxy Service Request from Payment Central : \r\n " + writerReq);
                    writerReq.Close();
                }
            }
            catch (Exception Ex)
            {
                log.WriteLog("Error Occurred during logging of PaymentIDPProxy Service Request XML" + Ex.InnerException.ToString());
            }
        }
        public IDPProxyResponse insertIDPDetail(PaymentIDPProxyInputRequest PaymentIDPProxyInputRequest)
        {
            try
            {
                String            Error         = "";
                String            cardEncrypt   = String.Empty;
                int               lineItemCount = 0;
                string            paymentid     = string.Empty;
                InsertPaymentitem obj           = new InsertPaymentitem();
                if (ConfigurationSettings.AppSettings["LoggingEntry"].ToString() == "1")
                {
                    LogServiceRequest(PaymentIDPProxyInputRequest);
                }
                if (!string.IsNullOrEmpty(PaymentIDPProxyInputRequest.receiptNumber.ToString()))
                {
                    log.WriteLog("Input Request received for the receipt number: " + PaymentIDPProxyInputRequest.receiptNumber.ToString());
                }
                //Input Field validations
                message = (obj.Validation(PaymentIDPProxyInputRequest));
                if ((message.responseCode == Constant.RESPONSE_FAILURE))
                {
                    log.WriteLog(message.responseCode + '-' + message.responseMessage);
                    return(message);
                }
                if (PaymentIDPProxyInputRequest.paymentMethod.Equals("CRDC") || PaymentIDPProxyInputRequest.paymentMethod.Equals("EFT"))
                {
                    message = (obj.CardValidation(PaymentIDPProxyInputRequest));
                    if ((message.responseCode == Constant.RESPONSE_FAILURE))
                    {
                        log.WriteLog(message.responseCode + '-' + message.responseMessage);
                        return(message);
                    }
                }
                if (PaymentIDPProxyInputRequest.paymentMethod.Equals("CHCK"))
                {
                    message = (obj.CheckValidation(PaymentIDPProxyInputRequest));
                    if ((message.responseCode == Constant.RESPONSE_FAILURE))
                    {
                        log.WriteLog(message.responseCode + '-' + message.responseMessage);
                        return(message);
                    }
                }

                if (PaymentIDPProxyInputRequest.LineItem.Count >= 0)
                {
                    foreach (LineItem item in PaymentIDPProxyInputRequest.LineItem)
                    {
                        message = (obj.ValidationLineItem(item));
                        if (message != null)
                        {
                            if ((message.responseCode == Constant.RESPONSE_FAILURE))
                            {
                                log.WriteLog(message.responseCode + '-' + message.responseMessage);
                                return(message);
                            }
                        }
                        else
                        {
                            message = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, "");
                        }
                    }
                }

                if (message.responseCode == Constant.RESPONSE_SUCCESS)
                {
                    message = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, Constant.VALIDATION_SUCCESS + PaymentIDPProxyInputRequest.receiptNumber);

                    //Mapping the PC Data to PT Corresponding Fields

                    int[] ID_PNE = { 4, 5, 6, 13, 15, 16, 17, 18, 1, 3, 20 };


                    switch (PaymentIDPProxyInputRequest.applicationContext.application)
                    {
                    case "BILLIVR":
                        PaymentIDPProxyInputRequest.applicationContext.application = ID_PNE[2].ToString();
                        break;

                    case "HUON":
                        PaymentIDPProxyInputRequest.applicationContext.application = ID_PNE[3].ToString();
                        break;

                    case "NETPOS":
                        PaymentIDPProxyInputRequest.applicationContext.application = ID_PNE[4].ToString();
                        break;

                    case "PAS":
                        PaymentIDPProxyInputRequest.applicationContext.application = ID_PNE[5].ToString();
                        break;

                    case "AGNTINTRA":
                        PaymentIDPProxyInputRequest.applicationContext.application = ID_PNE[6].ToString();
                        break;

                    case "SIS":
                        PaymentIDPProxyInputRequest.applicationContext.application = ID_PNE[7].ToString();
                        break;

                    case "PCBCKOFF":
                        PaymentIDPProxyInputRequest.applicationContext.application = ID_PNE[10].ToString();
                        break;

                    default:
                        message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.application);
                        log.WriteLog(message.responseCode + '-' + message.responseMessage);
                        return(message);
                    }
                    //Payment Method Mapping

                    switch (PaymentIDPProxyInputRequest.paymentMethod)
                    {
                    case "CRDC":
                        PaymentIDPProxyInputRequest.paymentMethod = ID_PNE[8].ToString();
                        break;

                    case "CASH":
                        PaymentIDPProxyInputRequest.paymentMethod = ID_PNE[9].ToString();
                        break;

                    case "CHCK":
                        PaymentIDPProxyInputRequest.paymentMethod = ID_PNE[0].ToString();
                        break;

                    case "EFT":
                        PaymentIDPProxyInputRequest.paymentMethod = ID_PNE[1].ToString();
                        break;

                    default:
                        message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.paymentMethod);
                        log.WriteLog(message.responseCode + '-' + message.responseMessage);
                        return(message);
                    }
                    //Method Call to Insert Payment Details
                    paymentid = obj.InsertPaymentItem(PaymentIDPProxyInputRequest);

                    //Modified the below code to avoid duplicate receipt number enteries
                    if (!string.IsNullOrEmpty(paymentid))
                    {
                        if (paymentid.Trim() == "0")
                        {
                            message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.RECEIPT_DUPLICATE);
                            log.WriteLog(message.responseCode + '-' + message.responseMessage);
                            return(message);
                        }
                    }

                    //Changed the Flow for Insertion and removed the if structure for multi line item
                    foreach (LineItem Item in PaymentIDPProxyInputRequest.LineItem)
                    {
                        if (message.responseCode == Constant.RESPONSE_SUCCESS)
                        {
                            //Mapping for Product Code
                            message = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, Constant.VALIDATION_SUCCESS + PaymentIDPProxyInputRequest.receiptNumber);
                            //MAIG - CH1 - BEGIN - Modified the logic to get the Product code directly from External Interface

                            /*if ((Item.dataSource.Equals(Constant.PAS)) & (Item.policyNumber.Length.Equals(13)))
                             * {
                             *  if (Item.policyNumber.Substring(0, 2).Equals(Constant.CA_State))
                             *  {
                             *      Item.productCode = Constant.AUT;
                             *  }
                             *  else
                             *  {
                             *      Item.productCode = Constant.AAASS;
                             *  }
                             * }
                             * else if (((Item.dataSource.Equals(Constant.HUON)) & (Item.policyNumber.Length.Equals(9)) | ((Item.dataSource.Equals(Constant.POES))&&Item.productCode.Equals(Constant.ProductCode_PA)) | (Item.dataSource.Equals(Constant.ADES))))
                             * {
                             *  Item.productCode = Constant.POES_AUTO;
                             * }
                             * else if (Item.dataSource.Equals(Constant.HDES) | ((Item.dataSource.Equals(Constant.POES)) && Item.productCode.Equals(Constant.ProductCode_HO)))
                             * {
                             *  Item.productCode = Constant.HME;
                             * }
                             * else if (Item.dataSource.Equals(Constant.PUPSYS))
                             * {
                             *  Item.productCode = Constant.PUP;
                             * }
                             * else if ((Item.dataSource.Equals(Constant.SIS)))
                             * {
                             *  if ((Item.productCode.Equals(Constant.ProductCode_PA)))
                             *  {
                             *      Item.productCode = Constant.WUA;
                             *  }
                             *  else if (Item.productCode.Equals(Constant.ProductCode_HO))
                             *  {
                             *      Item.productCode = Constant.WUH;
                             *  }
                             *  else if ((Item.productCode.Equals(Constant.ProductCode_DF)))
                             *  {
                             *      Item.productCode = Constant.DF;
                             *  }
                             *  else if (Item.productCode.Equals(Constant.ProductCode_WC))
                             *  {
                             *      Item.productCode = Constant.WUW;
                             *  }
                             *  else if ((Item.productCode.Equals(Constant.ProductCode_MC)))
                             *  {
                             *      Item.productCode = Constant.WUM;
                             *  }
                             *  else
                             *  {
                             *      message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.productCode);
                             *      log.WriteLog(message.responseCode + '-' + message.responseMessage);
                             *      return message;
                             *  }
                             * }
                             * else if (Item.dataSource.Equals(Constant.HLSYS))
                             * {
                             *  Item.productCode = Constant.HL;
                             * }
                             * else
                             * {
                             *  message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.dataSource);
                             *  log.WriteLog(message.responseCode + '-' + message.responseMessage);
                             *  return message;
                             * }*/
                            //MAIG - CH1 - END - Modified the logic to get the Product code directly from External Interface
                            //Mapping for Revenue Type
                            if (Item.revenueType == Constant.revenuetype_ERND)
                            {
                                Item.revenueType = Constant.Revenue_Earned;
                            }
                            else if (Item.revenueType == Constant.revenuetype_INST)
                            {
                                Item.revenueType = Constant.Revenue_Installment;
                            }
                            else if (Item.revenueType == Constant.revenuetype_DOWN)
                            {
                                Item.revenueType = Constant.Revenue_Down;
                            }
                            else if (!string.IsNullOrEmpty(Item.revenueType))
                            {
                                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.revenueType);
                                log.WriteLog(message.responseCode + '-' + message.responseMessage);
                                return(message);
                            }

                            if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.checkNumber))
                            {
                                if (PaymentIDPProxyInputRequest.paymentMethod.ToUpper().Equals("CASH"))
                                {
                                    PaymentIDPProxyInputRequest.checkNumber = string.Empty;
                                }
                            }
                            Error = obj.InsertItem(Item, paymentid, PaymentIDPProxyInputRequest.checkNumber, PaymentIDPProxyInputRequest.paymentMethod, lineItemCount);
                            if ((Error == "") || (paymentid == ""))
                            {
                                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.VALIDATION_FAILURE);
                                log.WriteLog(message.responseCode + '-' + message.responseMessage);
                                return(message);
                            }
                            //Invoked the Echeck/Card Payment Method SP Call
                            if (PaymentIDPProxyInputRequest.paymentMethod.Equals("1") || PaymentIDPProxyInputRequest.paymentMethod.Equals("5"))
                            {
                                message     = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, Constant.VALIDATION_SUCCESS + PaymentIDPProxyInputRequest.receiptNumber);
                                cardEncrypt = PaymentIDPProxyInputRequest.card.cardEcheckNumber.ToString();
                                PaymentIDPProxyInputRequest.card.cardEcheckNumber = "XXXXXXXXXXXX" + cardEncrypt.Substring(11, 4).ToString();
                                obj.InsertCardCheck(paymentid, PaymentIDPProxyInputRequest.card);
                                message = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, Constant.VALIDATION_SUCCESS + PaymentIDPProxyInputRequest.receiptNumber);
                            }
                        }
                        else
                        {
                            log.WriteLog(message.responseCode + '-' + message.responseMessage);
                            return(message);
                        }
                        lineItemCount++;
                    }
                }
            }

            catch (FaultException ex)
            {
                log.WriteLog(ex.Message.ToString());
            }
            catch (CommunicationException exp)
            {
                log.WriteLog(exp.Message.ToString());
            }
            catch (Exception e)
            {
                String Err_Msg = e.ToString();
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Err_Msg);
                log.WriteLog(message.responseCode + '-' + message.responseMessage);
                return(message);
            }


            log.WriteLog(message.responseCode + '-' + message.responseMessage);
            message = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, Constant.VALIDATION_SUCCESS + PaymentIDPProxyInputRequest.receiptNumber);
            return(message);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Input Validation for Common Attributes
        /// </summary>
        /// <param name="PaymentIDPProxyInputRequest"></param>
        /// <returns></returns>
        public IDPProxyResponse Validation(PaymentIDPProxyInputRequest PaymentIDPProxyInputRequest)
        {
            IDPProxyResponse message = null;

            message = new IDPProxyResponse(Constant.RESPONSE_SUCCESS, Constant.VALIDATION_SUCCESS + PaymentIDPProxyInputRequest.receiptNumber);
            Regex   junk_Chars = new Regex(@"[\\\~!@#$%^*()_+{}|""?`;',/[\]]+");
            decimal amount     = 0.0M;
            decimal TotAmt     = 0.0M;

            if ((PaymentIDPProxyInputRequest.applicationContext.application == Constant.APP_SALESX) | (PaymentIDPProxyInputRequest.applicationContext.application == Constant.APP_PMTTOOL) | (PaymentIDPProxyInputRequest.applicationContext.application == Constant.APP_PAYMENTX))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.application);
            }
            else if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.applicationContext.application) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.applicationContext.application))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.application);
            }
            else if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.externalReferenceNumber) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.externalReferenceNumber))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.externalReferenceNumber);
            }
            else if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.districtOffice) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.districtOffice))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.districtOffice);
            }
            else if (!string.IsNullOrEmpty(PaymentIDPProxyInputRequest.branchHubNumber))
            {
                if (junk_Chars.IsMatch(PaymentIDPProxyInputRequest.branchHubNumber))
                {
                    message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.branchHubNumber);
                }
            }
            else if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.userId) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.userId))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.userId);
            }
            else if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.receiptNumber) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.receiptNumber))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.receiptNumber);
            }
            else if (PaymentIDPProxyInputRequest.createdDate.ToString() == "")
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.createdDate);
            }
            else if ((PaymentIDPProxyInputRequest.totalAmount == 0) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.totalAmount.ToString()))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.totalAmount);
            }

            else if (!((PaymentIDPProxyInputRequest.totalAmount == 0) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.totalAmount.ToString())))
            {
                if (PaymentIDPProxyInputRequest.LineItem.Count == 1)
                {
                    if (!(Decimal.Equals(PaymentIDPProxyInputRequest.totalAmount, PaymentIDPProxyInputRequest.LineItem[0].Amount)))
                    {
                        message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.totalAmount);
                    }
                }

                else if (PaymentIDPProxyInputRequest.LineItem.Count > 1)
                {
                    foreach (LineItem item in PaymentIDPProxyInputRequest.LineItem)
                    {
                        TotAmt = TotAmt + item.Amount;
                        amount = TotAmt;
                    }
                    if (Decimal.Equals(PaymentIDPProxyInputRequest.totalAmount, TotAmt))
                    {
                        PaymentIDPProxyInputRequest.totalAmount = TotAmt;
                    }
                    if (!(Decimal.Equals(PaymentIDPProxyInputRequest.totalAmount, amount)))
                    {
                        message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.totalAmount);
                    }
                }
            }

            if (string.IsNullOrEmpty(PaymentIDPProxyInputRequest.paymentMethod) | junk_Chars.IsMatch(PaymentIDPProxyInputRequest.paymentMethod))
            {
                message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.paymentMethod);
            }
            //
            else if (PaymentIDPProxyInputRequest.paymentMethod.ToUpper().Equals("CHCK"))
            {
                if ((string.IsNullOrEmpty(PaymentIDPProxyInputRequest.checkNumber)))
                {
                    message = new IDPProxyResponse(Constant.RESPONSE_FAILURE, Constant.ERR_VALIDATION + Constant.checkNumber);
                }
            }
            return(message);
        }