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
            //HDFC Track ID: 1000109173_1100065925-WEB

            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.ReferenceNo = long.Parse(refTokens[0]);
            tr.NYBookingID = refNo;
            //tr.AgentCode = refTokens[2];

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

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

            if (Request["paymentid"] != null)
            {
                try
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Receipt: " + Request["paymentid"].ToString());
                    tr.NYReceiptNo = 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 NYBookingID = tr.NYBookingID.ToString();
                    TransactionBOL.Get_NewYear_Detail(tr.NYBookingID, tr.NYReceiptNo);
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Going to Fetch Details of Booking Id from DB.Booking ID where" + NYBookingID);
                    DataTable dt = TransactionBOL.Select_NewYearTransaction_REFIDWISE(tr.NYBookingID.ToString());
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Fetched Details of Booking Id from DB.Booking ID where" + NYBookingID);
                    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.NYBookingID.ToString());
                            ReceiptUtils.NewYearSuccessPaymentResponse(dt.Rows[0], tr.NYReceiptNo.ToString(), tr.BookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId1"));
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Payment successful..." + tr.NYBookingID.ToString() + tr.NYReceiptNo.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.SuccessPaymentResponse(tr.NYBookingID.ToString(), tr.NYReceiptNo);
                            ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt.Rows[0], "");
                            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_Temptransaction_REFIDWISE(BookingID1);
                        ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt1.Rows[0], "");
                        //ReceiptUtils.SuccessPaymentResponse(tr.NYBookingID.ToString(), tr.NYReceiptNo);
                        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.NYBookingID.ToString();
                KoDTicketing.GTICKV.LogEntry(_refNo, "HDFC Payment Not Successful", "17", tr.NYBookingID.ToString());
                //GTICKBOL.ON_Session_out(_refNo);
                KoDTicketing.GTICKV.LogEntry(_refNo, "Seats Unlocked", "18", tr.NYBookingID.ToString());
                qstring.Append("err=pay");

                KoDTicketing.GTICKV.LogEntry(tr.NYReceiptNo.ToString(), "HDFC Error Occurred -- Payment Not Successful", "19", tr.NYBookingID.ToString());
                string BookingID = tr.NYBookingID.ToString();
                try
                {
                    DataTable dt = TransactionBOL.Select_NewYearTransaction_REFIDWISE(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 + "NewYearPackages/HDFC/FinalCall.aspx" + qstring.ToString(), false);
                #endregion
            }
            else
            {
                GTICKV.LogEntry(tr.NYReceiptNo.ToString(), "HDFC Payment Not Successful", "17", tr.NYBookingID.ToString());
                //GTICKBOL.ON_Session_out(tr.ReferenceNo.ToString());
                GTICKV.LogEntry(tr.NYReceiptNo.ToString(), "Seats Unlocked", "18", tr.NYBookingID.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");
            }
        }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblCouple.Visible     = false;
        lblCoupleQnty.Visible = false;
        lblKids.Visible       = false;
        lblKidsQnty.Visible   = false;
        lblSingle.Visible     = false;
        lblSingleQnty.Visible = false;
        lblTeens.Visible      = false;
        lblTeensQnty.Visible  = false;
        try
        {
            if (Request.QueryString["b"] != null)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("[B] Printing Receipt For  " + Request.QueryString["b"].ToString());
                dvDetails.Visible     = true;
                dvErrorDetail.Visible = false;
                string    NYBookingID = Request.QueryString["b"].ToString();
                DataTable dt          = TransactionBOL.Select_NewYearTransaction_REFIDWISE(NYBookingID);
                if (dt.Rows.Count > 0)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("[B] Printing Receipt with transaction details for  " + Request.QueryString["b"].ToString());
                    DataRow dr = dt.Rows[0];
                    lblBookingID.Text   = dr["BookingId"].ToString();
                    lblReceiptNo.Text   = dr["PGReceiptId"].ToString();
                    lbltotalamount.Text = dr["TotalAmount"].ToString();
                    lblPayMode.Text     = "Credit/Debit Card";
                    DateTime dob = Convert.ToDateTime(dr["DateOfBooking"].ToString()).ToLocalTime();
                    lblDOB.Text     = dob.ToString();
                    lblemailid.Text = dr["EmailId"].ToString();
                    if (Convert.ToInt16(dr["Qty_PackageTypeCouple"]) > 0)
                    {
                        lblCouple.Visible     = true;
                        lblCoupleQnty.Visible = true;
                        lblCoupleQnty.Text    = Convert.ToInt16(dr["Qty_PackageTypeCouple"]).ToString();
                    }
                    if (Convert.ToInt16(dr["Qty_PackageTypeSingle"]) > 0)
                    {
                        lblSingle.Visible     = true;
                        lblSingleQnty.Visible = true;
                        lblSingleQnty.Text    = Convert.ToInt16(dr["Qty_PackageTypeSingle"]).ToString();
                    }
                    if (Convert.ToInt16(dr["Qty_PackageTypeTeen"]) > 0)
                    {
                        lblTeens.Visible     = true;
                        lblTeensQnty.Visible = true;
                        lblTeensQnty.Text    = Convert.ToInt16(dr["Qty_PackageTypeTeen"]).ToString();
                    }
                    if (Convert.ToInt16(dr["Qty_PackageTypeKid"]) > 0)
                    {
                        lblKids.Visible     = true;
                        lblKidsQnty.Visible = true;
                        lblKidsQnty.Text    = Convert.ToInt16(dr["Qty_PackageTypeKid"]).ToString();
                    }
                    //lblpackagetype.Text = dr["PackageType"].ToString();
                    //lblquantity.Text = dr["PackageQty"].ToString();
                    lblcontactNo.Text = dr["ContactNumber"].ToString();
                    lnlname.Text      = dr["Name"].ToString();
                    bool isSuccessfull = Convert.ToBoolean(dr["PGIsPaymentSuccess"]);
                    if (isSuccessfull)
                    {
                        lbltrnsresponse.Text = "Transaction Successful";
                    }

                    else
                    {
                        lbltrnsresponse.Text = "Transaction Not Successful";
                    }
                }
            }
            else if (Request.QueryString["err"] != null)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Received Print Receipt with err value..." + Request.QueryString["err"].ToString());
                string err = Request.QueryString["err"].ToString();
                if (err == "pay")
                {
                    lblFinalMess.Text = "Your transaction was not successful. Please try later.";
                    if (Request["ErrorText"] != null)
                    {
                        lblFinalMess.Text += Environment.NewLine + "Transaction failed because" + Request["ErrorText"].ToString();
                    }
                }
                else if (err == "seat")
                {
                    lblFinalMess.Text = "Your payment transaction was successful, but your seats were not booked due to technical glitch, please contact (0124)4528000 for Seat Confirmation. Sorry for inconvenience.";
                }
                dvDetails.Visible     = false;
                dvErrorDetail.Visible = true;
                lblDate.Text          = System.DateTime.Now.ToString();
            }
            else
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Received Print Receipt without parameter...");
                dvErrorDetail.Visible = true;
                dvDetails.Visible     = false;
                lblFinalMess.Text     = "Sorry your payment transaction was not successful, please try again after some time.";
            }
            lblDate.Text = "Date : " + System.DateTime.Now.ToString();
        }

        catch (Exception ex)
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Error Printing Receipt For " + ex.Message);
        }
        Session.Clear();
    }