Exemplo n.º 1
0
    protected String UpdateResponse(String trackid, String reference, String result, String postdate, String auth)
    {
        System.Text.StringBuilder qstring = new System.Text.StringBuilder();
        try
        {
            TransactionRecord tr = new TransactionRecord();

            string IpAddress = System.Configuration.ConfigurationManager.AppSettings["KoDTicketingIPAddress"];

            #region parsereference

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Transaction reference: " + trackid);
            string refNo = trackid;

            if (refNo.Length < 1)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Payment Response: Tokenization of reference string did not result in enough sub tokens. --> " + refNo);
                return("?err=pay");
            }

            tr.VLBookingID = refNo;

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(string.Format("HDFC Payment Response: Reference[{0}], Booking ID [{1}], Agent Code [{2}] ", tr.ReferenceNo.ToString(), tr.VLBookingID.ToString(), tr.AgentCode));
            #endregion parsereference

            if (Request["amt"] != null)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Amount: " + Request["amt"].ToString());
                tr.VLTotalAmount = decimal.Parse(Request["amt"].ToString());
            }

            if (Request["paymentid"] != null)
            {
                try
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Receipt: " + Request["paymentid"].ToString());
                    tr.VLReceiptNo = Request["paymentid"].ToString();
                }
                catch (Exception ex)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Response: Error parsing receipt.");
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ex.Message);
                }
            }


            if (result == "CAPTURED")
            {
                # region CAPTURED
                //string retURL = UpdateResponseByTranId(status, amount, transactionId);
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC payment captured.");
                try
                {
                    string VLBookingID = tr.VLBookingID.ToString();
                    TransactionBOL.Get_Dandiya_Details(tr.VLBookingID, tr.VLReceiptNo);
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Going to Fetch Details of Booking Id from DB.Booking ID where" + VLBookingID);
                    DataTable dt = TransactionBOL.Select_DandiyaTransaction(tr.VLBookingID.ToString());
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Fetched Details of Booking Id from DB.Booking ID where" + VLBookingID);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Fetched Details of Booking Id from DB.Booking ID where" + dt.Rows[0]);
                        try
                        {
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Seats booked against HDFC payment.");
                            qstring.Append("?b=");
                            qstring.Append(tr.VLBookingID.ToString());
                            ReceiptUtils.DandiyaPaymentSuccess(dt.Rows[0], tr.VLReceiptNo.ToString(), tr.BookingID.ToString());
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Payment successful..." + tr.VLBookingID.ToString() + tr.VLReceiptNo.ToString());
                            GTICKV.LogEntry("HDFC Payment successful...", "10", tr.BookingID.ToString(), tr.ReceiptNo.ToString());
                        }

                        catch (Exception ex)
                        {
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Error processing receipt post booking. " + ex.Message);
                            ReceiptUtils.DSuccessPaymentResponse(tr.VLReceiptNo.ToString(), dt.Rows[0], "");
                            //ReceiptUtils.SuccessPaymentResponse(tr.VLBookingID.ToString(), tr.VLReceiptNo);
                            qstring.Append((qstring.Length == 0) ? "?err=seat" : "&err=seat");
                        }
                        return(qstring.ToString());
                    }
                    else
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC successful booking but ask customer to call");;
                        long      BookingID1 = long.Parse(tr.ReferenceNo.ToString());
                        DataTable dt1        = TransactionBOL.Select_DandiyaTransaction(tr.VLBookingID.ToString());
                        ReceiptUtils.DSuccessPaymentResponse(tr.VLReceiptNo.ToString(), dt1.Rows[0], "");
                        //ReceiptUtils.SuccessPaymentResponse(tr.VLBookingID.ToString(), tr.VLReceiptNo);
                        qstring.Append((qstring.Length == 0) ? "?err=seat" : "&err=seat");
                    }
                }
                catch (Exception ex)

                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Receipt: error getting transaction details - " + ex.Message); qstring.Append((qstring.Length == 0) ? "?err=seat" : "&err=seat");
                }
                //if you reach here problem occurred

                String _refNo = tr.VLBookingID.ToString();
                KoDTicketing.GTICKV.LogEntry(_refNo, "HDFC Payment Not Successful", "17", tr.VLBookingID.ToString());
                //GTICKBOL.ON_Session_out(_refNo);
                KoDTicketing.GTICKV.LogEntry(_refNo, "Seats Unlocked", "18", tr.VLBookingID.ToString());
                qstring.Append("err=pay");

                KoDTicketing.GTICKV.LogEntry(tr.VLReceiptNo.ToString(), "HDFC Error Occurred -- Payment Not Successful", "19", tr.VLBookingID.ToString());
                string BookingID = tr.VLBookingID.ToString();
                try
                {
                    DataTable dt = TransactionBOL.Select_DandiyaTransaction(BookingID);

                    if (dt.Rows.Count == 0)
                    {
                        ReceiptUtils.FailurePaymentResponse();
                    }
                    else
                    {
                        ReceiptUtils.FailurePaymentResponse(dt.Rows[0]);
                    }
                    qstring.Append((qstring.Length == 1) ? "err=seat" : "&err=seat");
                    return(qstring.ToString());
                }

                catch (Exception ex)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Error occurred processing unsuccessful payment..." + ex.Message);
                }
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Final Call");
                Response.Redirect(IpAddress + "DandiyaRaas/HDFC/FinalCall.aspx" + qstring.ToString(), false);
                #endregion
            }
            else
            {
                GTICKV.LogEntry(tr.VLReceiptNo.ToString(), "HDFC Payment Not Successful", "17", tr.VLBookingID.ToString());
                //GTICKBOL.ON_Session_out(tr.ReferenceNo.ToString());
                GTICKV.LogEntry(tr.VLReceiptNo.ToString(), "Seats Unlocked", "18", tr.VLBookingID.ToString());
                long BookingID = long.Parse(tr.ReferenceNo.ToString());
                //DataTable dt = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID);
                //ReceiptUtils.PaymentNotCaptureResponse(tr.ReceiptNo.ToString(), dt.Rows[0], "");
                qstring.Append("?err=pay");
            }
        }