Esempio n. 1
0
    protected string UpdateResponseByTranId()
    {
        try
        {
            TransactionRecord tr = new TransactionRecord();
            tr.BookingID   = tr.VoucherBookingID;
            tr.ReceiptNo   = "''";
            tr.ReferenceNo = long.Parse(PayDetailsTemp[1].Split('_')[0]);
            tr.AgentCode   = PayDetailsTemp[1].Split('_')[1].Split('~')[1];
            //****** Promo code usecase start here ************
            KODHelper objKODHelper = new KODHelper();
            tr = objKODHelper.GetPromotionDetails(tr);
            //****** Promo code usecase END here ************
            DataTable dt = TransactionBOL.Get_Transaction_Detail(tr);
            if (dt.Rows.Count > 0)
            {
                DataRow dr               = dt.Rows[0];
                bool    seatsBooked      = (dt.Rows[0]["SeatBooked"].ToString() == "1");
                bool    alreadyProcessed = (dt.Rows[0]["AlreadyProcessed"].ToString() == "1");
                if (seatsBooked)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Voucher Transaction : Seats Booked for " + tr.BookingID.ToString());
                }
                if (!alreadyProcessed)
                {
                    ReceiptUtils.SuccessPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, "");
                }
            }
        }
        catch (Exception ex)
        {
            if (qstring == "")
            {
                qstring += "?err=seat";
            }
            else
            {
                qstring += "&err=seat";
            }
            GTICKV.LogEntry(merchantReferenceNo, "Error Occured --" + ex.Message.Replace("'", ""), "19", MainBookingID);
        }
        Session["bookid"] = qstring;


        return(qstring);
    }
Esempio n. 2
0
    protected void HandleSuccess(ref TransactionRecord tr, ref System.Text.StringBuilder qstring)
    {
        qstring.Clear();

        #region handlesuccess
        GTICKV.LogEntry(tr.ReferenceNo.ToString(), "IDBI Payment successful...", "16", tr.BookingID.ToString(), tr.ReceiptNo.ToString());

        #region parsereceipt
        if (Request.QueryString["rec"] != null)
        {
            try
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Receipt: " + Request.QueryString["rec"]);
                tr.ReceiptNo = Request.QueryString["rec"].ToString();
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Response: Error parsing receipt.");
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ex.Message);
            }
        }
        #endregion parsereceipt

        try
        {
            //****** Promo code usecase start here ************
            KODHelper objKODHelper = new KODHelper();
            tr = objKODHelper.GetPromotionDetails(tr);
            tr.PaymentGateway = "IDBI";
            //****** Promo code usecase END here ************
            TransactionBOL.Update_PaymentStatus(tr);     //Update payment status in temp transection table
            DataTable dt = TransactionBOL.Get_Transaction_Detail(tr);


            if (dt != null && dt.Rows.Count > 0)
            {
                bool seatsBooked      = (dt.Rows[0]["SeatBooked"].ToString() == "1");
                bool alreadyProcessed = (dt.Rows[0]["AlreadyProcessed"].ToString() == "1");
                if (seatsBooked)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Transaction : Seats Booked for " + tr.BookingID.ToString());
                }
                if (!alreadyProcessed)
                {
                    if (dt.Rows[0]["PromotionCode"].ToString() == "MMT")
                    {
                        DataTable dt1 = TransactionBOL.Select_MMTTransaction_REFIDWISE(tr.BookingID.ToString());
                        ReceiptUtils.MMTPaymentResponse(dt.Rows[0], dt1.Rows[0], tr.ReceiptNo.ToString(), tr.BookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId2"), ConfigurationManager.AppSettings.Get("ConcertRefMailId3"), dt.Rows[0]["ShowTime"].ToString(), dt.Rows[0]["ShowDate"].ToString());
                    }
                    else if (dt.Rows[0]["PromotionCode"].ToString() == "MANA")
                    {
                        DataTable dt2 = TransactionBOL.Select_MANATransaction_REFIDWISE(tr.BookingID.ToString());
                        ReceiptUtils.MANAPaymentResponse(dt.Rows[0], dt2.Rows[0], tr.ReceiptNo.ToString(), tr.BookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId2"), ConfigurationManager.AppSettings.Get("ConcertRefMailId3"), dt.Rows[0]["ShowTime"].ToString(), dt.Rows[0]["ShowDate"].ToString());
                    }
                    else if (dt.Rows[0]["PromotionCode"].ToString() == "MCOTHERS" || dt.Rows[0]["PromotionCode"].ToString() == "MCWORLD")
                    {
                        DataTable dt3 = TransactionBOL.Select_MCTransaction_REFIDWISE(tr.ReferenceNo.ToString());
                        ReceiptUtils.MCPaymentResponse(dt.Rows[0], dt3.Rows[0], tr.ReceiptNo.ToString(), tr.BookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId2"), ConfigurationManager.AppSettings.Get("ConcertRefMailId3"), dt.Rows[0]["ShowTime"].ToString(), dt.Rows[0]["ShowDate"].ToString());
                    }
                    else if (dt.Rows[0]["PromotionCode"].ToString() == "JHUMROOOFFER")
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Enter into jhumroo offer mail content");
                        ReceiptUtils.JHUMROOOFFERPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, "");
                    }
                    else
                    {
                        ReceiptUtils.SuccessPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, "");
                    }
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Mail send through normal flow");
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Values are " + dt.Rows[0] + " , " + tr.ReferenceNo.ToString() + "," + tr.BookingID.ToString() + "," + tr.PromotionCode.ToString());
                    SendNotificationMailForHotels(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, tr.PromotionCode.ToString());
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Mail send through Hotel flow");
                }
                qstring.Clear();
                qstring.Append("?b=");
                qstring.Append((seatsBooked) ? dt.Rows[0]["BookingID"].ToString() : dt.Rows[0]["ID"].ToString());
            }
            else
            {
                long      BookingID1 = long.Parse(tr.ReferenceNo.ToString());
                DataTable dt2        = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID1);
                if (dt2 != null && dt2.Rows.Count > 0 && (Convert.ToDateTime(dt2.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.ToShortDateString()) || Convert.ToDateTime(dt2.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.AddDays(-1).ToShortDateString())))
                {
                    ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt2.Rows[0], "");
                }
                //ReceiptUtils.SuccessPaymentResponse(tr.BookingID.ToString(), tr.ReceiptNo);
                qstring.Append("?err=seat");
            }
        }
        catch (Exception ex)
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Receipt: error getting transaction details - " + ex.Message);
            HandleFailure(tr);
            long      BookingID1 = long.Parse(tr.ReferenceNo.ToString());
            DataTable dt1        = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID1);
            if (dt1 != null && dt1.Rows.Count > 0 && (Convert.ToDateTime(dt1.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.ToShortDateString()) || Convert.ToDateTime(dt1.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.AddDays(-1).ToShortDateString())))
            {
                ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt1.Rows[0], "");
            }
            qstring.Append("?err=seat");
        }
        #endregion handlesuccess
    }
Esempio n. 3
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.EvtBookingID = refNo;

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

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

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

                KoDTicketing.GTICKV.LogEntry(tr.EvtReceiptNo.ToString(), "HDFC Error Occurred -- Payment Not Successful", "19", tr.EvtBookingID.ToString());
                string BookingID = tr.EvtBookingID.ToString();
                try
                {
                    DataTable dt = TransactionBOL.Select_EventTransaction(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 + "EventTransaction/HDFC/FinalCall.aspx" + qstring.ToString(), false);
                #endregion
            }
            else
            {
                GTICKV.LogEntry(tr.EvtReceiptNo.ToString(), "HDFC Payment Not Successful", "17", tr.EvtBookingID.ToString());
                //GTICKBOL.ON_Session_out(tr.ReferenceNo.ToString());
                GTICKV.LogEntry(tr.EvtReceiptNo.ToString(), "Seats Unlocked", "18", tr.EvtBookingID.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");
            }
        }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Text.StringBuilder qstring = new System.Text.StringBuilder();
        int qsCount = Request.QueryString.Count;

        #region processreceipt
        if (qsCount > 0 && Request.QueryString["sta"] != null && Request.QueryString["tid"] != null)
        {
            TransactionRecord tr = new TransactionRecord();
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(string.Format("IDBI Web payment transaction response [{0}]", Request.QueryString["sta"]));
            tr.Status = Request.QueryString["sta"].ToString().Equals("50020");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Web payment transaction complete. Status: " + (tr.Status ? "Success" : "Failure"));

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

            String   refNo     = Request.QueryString["tid"].ToString();
            string[] refTokens = refNo.Split('_');
            KoDTicketing.GTICKV.LogEntry(refTokens[0], "Payment Getaway Response: " + (tr.Status ? "Success" : "Failure"), "14", "");
            if (refTokens.Length < 2)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Payment Response: Tokenization of reference string did not result in enough tokens. --> " + refNo);
                return;
            }

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Transaction reference: " + refTokens[0].ToString());
            tr.ReferenceNo = long.Parse(refTokens[0].ToString());

            string[] refSubTokens = refTokens[1].Split('~');

            if (refSubTokens.Length < 2)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Payment Response: Tokenization of reference substring did not result in enough sub tokens. --> " + refTokens[1].ToString());
                return;
            }

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Booking ID: " + refSubTokens[0]);
            tr.BookingID = long.Parse(refSubTokens[0]);

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Agent Code: " + refSubTokens[1]);
            tr.AgentCode = refSubTokens[1];
            #endregion parsereference
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Amount: " + Request.QueryString["amt"].ToString());
            tr.TotalAmount = decimal.Parse(Request.QueryString["amt"].ToString());
            try
            {
                if (true == tr.Status)
                {
                    HandleSuccess(ref tr, ref qstring);
                }
                else //failure
                {
                    GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Payment Not Successful", "25", tr.BookingID.ToString());
                    GTICKBOL.ON_Session_out(tr.ReferenceNo.ToString());
                    GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Seats Unlocked", "26", tr.BookingID.ToString());
                    long BookingID = long.Parse(tr.ReferenceNo.ToString());
                    GTICKV.LogEntry(tr.ReferenceNo.ToString(), "User Press Cancel Button", "15", tr.BookingID.ToString());
                    DataTable dt = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID);
                    if (dt != null && dt.Rows.Count > 0 && (Convert.ToDateTime(dt.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.ToShortDateString()) || Convert.ToDateTime(dt.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.AddDays(-1).ToShortDateString())))
                    {
                        ReceiptUtils.PaymentNotCaptureResponse(tr.ReceiptNo.ToString(), dt.Rows[0], "");
                    }
                    qstring.Append("?err=pay");
                }
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ex.Message);
                HandleFailure(tr);
                qstring.Append("?err=seat");
            }
        }

        #endregion processreceipt

        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Transaction Complete. " + Request.QueryString["rec"]);
        Response.Redirect("../Print-Receipt.aspx" + qstring.ToString(), false);
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        long transid         = 0;
        TransactionRecord tr = new TransactionRecord();

        try
        {
            #region Session based
            if (Session["seat_Val"] != null && Session["Seat_TransactionID"] != null)
            {
                try
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(string.Format("Transaction [{0}]  Seats [{1}]", Session["Seat_TransactionID"].ToString(), Session["seat_Val"].ToString()));
                    tr.BookingID = long.Parse(Session["Seat_TransactionID"].ToString());
                    string[] strarr = Session["seat_Val"].ToString().Split(',');
                    if (Session["AgentCode"] != null)
                    {
                        tr.AgentCode = Session["AgentCode"].ToString();
                        tr.Source    = "MSAGENT";
                    }
                    else
                    {
                        tr.AgentCode = "WEB";
                        tr.Source    = "WEB";
                    }
                    tr.BookingType = "INDIVIDUAL";
                    //tr.VoucherType = rblVoucher.SelectedValue;
                    //tr.VoucherNo = "";
                    //tr.VoucherBookingID = 0;
                    tr.CardType       = rbl_CardType.SelectedItem.Text;
                    tr.PaymentGateway = rbl_CardType.SelectedValue;
                    tr.CardNo         = "1111222233334444";
                    tr.MobileNo       = txtContactNo.Text;
                    tr.Name           = Session["FirstName"].ToString() + Session["LastName"].ToString();
                    tr.PaymentType    = ddlPaymentMode.SelectedItem.Text;
                    tr.DateOfBooking  = DateTime.Now.Date.ToShortDateString();

                    bool istrue = emailsnd.Checked;
                    Session["Istrue"] = istrue;
                    tr.IsChecked      = istrue;
                    tr.EmailID        = txtEmailAddress.Text;

                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IsChecked" + istrue);

                    tr.PlaceOfPick           = "";
                    tr.TimeOfPick            = "";
                    Session["Complimentary"] = "false";
                    tr.WantComplimentary     = false;

                    tr.Status        = false;
                    tr.TimeOfBooking = DateTime.Now.ToShortTimeString();

                    tr.TotalSeats = int.Parse(strarr[5].ToString());
                    tr.Category   = strarr[8];
                    tr.Location   = strarr[6];
                    tr.Play       = strarr[1];
                    //replace "-"with "/"
                    //string[] datarr = strarr[2].ToString().Split('/'); // for live server
                    string[] datarr = strarr[2].ToString().Split('-'); // for dev/local
                    //replace datarr[0] to datarr[1]
                    //tr.ShowDate = datarr[1] + "/" + datarr[0] + "/" + datarr[2]; // for live server
                    tr.ShowDate = datarr[0] + "/" + datarr[1] + "/" + datarr[2];  // for dev/local

                    tr.ShowTime = strarr[7];
                    tr.Day      = Convert.ToDateTime(tr.ShowDate).DayOfWeek.ToString();
                    // for dev/local, swap month & date above after day has been calculated above
                    //comment below two lines
                    //tr.ShowDate = tr.ShowDate.Replace(datarr[1], datarr[0]);
                    //tr.ShowDate = tr.ShowDate.Replace("30", datarr[1]);
                    tr.Remark              = "";
                    tr.TotalAmount         = GTICKBOL.Get_SeatPrice_SeatKeyNoWise(tr.BookingID);
                    Session["TotalAmount"] = tr.TotalAmount;
                    tr.SeatInfo            = Session["Seat_info"].ToString();
                    tr.Address             = Session["Address"].ToString().Trim();
                    //+ Session["Address2"].ToString()
                    tr.IP = GetIP();

                    //******Promotion code related changes START*****

                    if (Session["PromotionCode"] != null)
                    {
                        KoDTicketingLibrary.DTO.Promotion PromoSession = (KoDTicketingLibrary.DTO.Promotion)Session["PromotionCode"];
                        tr.PromotionCode      = PromoSession.PromotionCode;
                        tr.DiscountPercentage = PromoSession.DiscountPercentage;
                        tr.WebPromotionId     = PromoSession.WebPromotionId;
                        tr.DiscountedAmount   = (GTICKBOL.Get_SeatPrice_SeatKeyNoWise(tr.BookingID) - (GTICKBOL.Get_SeatPrice_SeatKeyNoWise(tr.BookingID) * PromoSession.DiscountPercentage / 100));
                    }
                    //******Promotion code related changes END*****



                    //******RoyalCard related changes START*****

                    tr.RegId         = Session["Regid"].ToString();
                    tr.AvailedAmount = Convert.ToDecimal(Session["RedeemBalance"]);
                    tr.AvailedPoints = Convert.ToDecimal(Session["RedeemPoints"]);
                    tr.TopUpAmount   = tr.TotalAmount - (Convert.ToDecimal(Session["RedeemPoints"]) + Convert.ToDecimal(Session["RedeemBalance"]));
                    if (tr.TopUpAmount != 0)
                    {
                        tr.TopUpTransactionId = TransactionBOL.Card_Transaction(tr.RegId, tr.TopUpAmount, DateTime.Now, tr.RegId, 0);
                    }
                    tr.OptionalEmail   = txtEmail.Text;
                    tr.OptionalContact = txtmobileno.Text;
                    //******RoyalCard related changes END*****



                    transid = TransactionBOL.Transaction_Temp_Insert(tr);
                }
                catch (Exception ex)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Transaction Preparation Error: " + ex.Message);
                }
                GTICKV.LogEntry(tr.BookingID.ToString(), "Category : " + tr.Category + " ,Seat Info : " + tr.SeatInfo +
                                ", Total Amt : " + tr.TotalAmount, "6", "");

                //******Promotion code send discounted AMOUNT to payment gateway changes START*****
                if (Session["PromotionCode"] != null)
                {
                    KoDTicketingLibrary.DTO.Promotion ObjPromoSession = (KoDTicketingLibrary.DTO.Promotion)Session["PromotionCode"];
                    tr.TotalAmount = 0;
                    DataTable prices = GTICKBOL.Get_AllSeatPrice_SeatKeyNoWise(tr.BookingID);
                    if (prices != null)
                    {
                        foreach (DataRow dr in prices.Rows)
                        {
                            decimal SinglePrice     = decimal.Parse(dr[0].ToString());
                            decimal DiscountedPrice = SinglePrice - (SinglePrice * ObjPromoSession.DiscountPercentage / 100);
                            DiscountedPrice = decimal.Truncate(DiscountedPrice);
                            if (DiscountedPrice == 1274)
                            {
                                DiscountedPrice = DiscountedPrice + 1;
                            }
                            else if (DiscountedPrice == 2124)
                            {
                                DiscountedPrice = DiscountedPrice + 1;
                            }
                            else if (DiscountedPrice == 2974)
                            {
                                DiscountedPrice = DiscountedPrice + 1;
                            }
                            else if (DiscountedPrice == 4249)
                            {
                                DiscountedPrice = DiscountedPrice + 1;
                            }
                            tr.TotalAmount += DiscountedPrice;
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Discounted Price For a Ticket" + DiscountedPrice.ToString());
                        }
                    }
                }
                //*******Promotion code send discounted AMOUNT to payment gateway changes END here **********


                tr.TotalAmount = (tr.TotalAmount) - (tr.AvailedPoints + tr.AvailedAmount);

                if (transid > 0)
                {
                    Session["AgentCode"] = null;
                    GTICKV.LogEntry(tr.BookingID.ToString(), "Data Successfully Written to Temp Transaction Table", "7", transid.ToString());
                    if (Session["PayableAmount"].ToString() == "0")
                    {
                        Session["BookingID"] = tr.BookingID;
                        Session["ID"]        = transid.ToString();
                        Response.Redirect("Payment/Print-Receipt.aspx");
                    }
                    else
                    {
                        string URL = "";
                        //Pay Details , Sent To Loyalty Card Page --  CardType,TransID,Amt,ShowName
                        //Session["PayDetailsTemp"] = rblVoucher.SelectedValue + "|" + tr.BookingID.ToString() + "_" + transid + "~" + tr.AgentCode + "|" + tr.TotalAmount + "|" + tr.Play;
                        Session["PayDetailsTemp"] = tr.BookingID.ToString() + "_" + transid + "~" + tr.AgentCode + "|" + tr.TotalAmount + "|" + tr.Play;

                        if (ddlPaymentMode.SelectedValue == "CREDIT")
                        {
                            if (rbl_CardType.SelectedValue == "IDBI")
                            {
                                GTICKV.LogEntry(tr.BookingID.ToString(), "Sending to IDBI Payment Gateway", "8", transid.ToString());
                                URL = "../../Payment/Idbi/Default.aspx?type=idbi&transid=" + tr.BookingID.ToString() + "_" + transid + "~" + tr.AgentCode + "~royal_card_payment_idbi" + "&amt=" + tr.TotalAmount
                                      + "&show=" + tr.Play;
                            }
                            else if (rbl_CardType.SelectedValue == "AMEX")
                            {
                                GTICKV.LogEntry(tr.BookingID.ToString(), "Sending to AMEX Payment Gateway", "8", transid.ToString());
                                URL = "Payment/Web/Default.aspx?type=amex&transid=" + tr.BookingID.ToString() + "_" + transid + "~" + tr.AgentCode + "&amt=" + tr.TotalAmount
                                      + "&show=" + tr.Play;
                            }
                            else if (rbl_CardType.SelectedValue == "HDFC")
                            {
                                //string check = gb.HDFCLogCheck(transid.ToString()).Rows[0]["Amount"].ToString();
                                GTICKV.LogEntry(tr.BookingID.ToString(), "Sending to HDFC Payment Gateway", "8", transid.ToString());
                                string trackId, amount;
                                //Random Rnd = new Random();
                                //trackId = Rnd.Next().ToString();		//Merchant Track ID, this is as per merchant logic
                                trackId            = tr.BookingID.ToString() + "_" + transid + "-" + tr.AgentCode;
                                Session["trackId"] = trackId;
                                amount             = tr.TotalAmount.ToString();
                                Session["amount"]  = amount;

                                String ErrorUrl    = KoDTicketingIPAddress + "RoyalCard/Account/Payment/HDFC/Error.aspx";
                                String ResponseUrl = KoDTicketingIPAddress + "RoyalCard/Account/Payment/HDFC/ReturnReceipt.aspx";

                                //string qrystr = "id=" + HDFCTransPortalID + "&password="******"&action=1&langid=USA&currencycode=356&amt=" + Server.UrlEncode(amount)
                                //    + "&responseURL=" + Server.UrlEncode(ResponseUrl) + "&errorURL=" + Server.UrlEncode(ErrorUrl)
                                //    + "&trackid=" + trackId
                                //    + "&udf1=TicketBooking&udf2=" + Server.UrlEncode(txtEmailAddress.Text.Trim())
                                //    + "&udf3=" + Server.UrlEncode(txtISDCode.Text + txtContactNo.Text) + "&udf4=" + Server.UrlEncode(txtAddress.Text.Trim()) + "&udf5=" + tr.BookingID;

                                string qrystr = "id=" + HDFCTransPortalID + "&password="******"&action=1&langid=USA&currencycode=356&amt=" + amount
                                                + "&responseURL=" + Server.UrlEncode(ResponseUrl) + "&errorURL=" + Server.UrlEncode(ErrorUrl)
                                                + "&trackid=" + trackId
                                                + "&udf1=TicketBooking&udf2=" + txtEmailAddress.Text.Trim()
                                                + "&udf3=" + Server.UrlEncode(txtISDCode.Text.TrimStart('+') + txtContactNo.Text) + "&udf4=" + Server.UrlEncode(tr.Address.ToString()) + "&udf5=" + tr.BookingID.ToString();

                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Preparing for HDFC Payment..." + qrystr);

                                //Writefile_new("\n***************Initial Request********************", Server.MapPath("~"));
                                //Writefile_new("\n\nDateTime:" + DateTime.Now.ToString("dd/MM/yy HH:mm:ss") + " Reference No:" + trackId + "Request XML:" + qrystr, Server.MapPath("~"));

                                System.IO.StreamWriter requestWriter = null;
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Redirecting for HDFC Payment..." + HDFCTransUrl);
                                System.Net.HttpWebRequest objRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(HDFCTransUrl);   //create a SSL connection object server-to-server
                                objRequest.Method          = "POST";
                                objRequest.ContentLength   = qrystr.Length;
                                objRequest.ContentType     = "application/x-www-form-urlencoded";
                                objRequest.CookieContainer = new System.Net.CookieContainer();
                                try
                                {
                                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Processing request for HDFC Payment...");
                                    requestWriter = new System.IO.StreamWriter(objRequest.GetRequestStream());  // here the request is sent to payment gateway
                                    requestWriter.Write(qrystr);
                                }
                                catch (Exception ex)
                                {
                                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Excetion while processing HDFC payment: " + trackId + ex.Message);
                                }

                                if (requestWriter != null)
                                {
                                    requestWriter.Close();
                                }

                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Review validation response from HDFC Payment Gateway...");
                                System.Net.HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse();

                                //System.Net.CookieContainer responseCookiesContainer = new System.Net.CookieContainer();
                                //foreach (System.Net.Cookie cook in objResponse.Cookies)
                                //{
                                //    responseCookiesContainer.Add(cook);
                                //}

                                using (System.IO.StreamReader sr =
                                           new System.IO.StreamReader(objResponse.GetResponseStream()))
                                {
                                    String NSDLval = sr.ReadToEnd();
                                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Response: " + NSDLval);
                                    if (NSDLval.Contains("Invalid User Defined Field"))
                                    {
                                        lblMess.Text = "The information submitted contains some invalid character, please avoid using [+,-,#] etc.";
                                        return;
                                    }

                                    //Writefile_new("\n***************Initial Response********************", Server.MapPath("~"));
                                    //Writefile_new("\n\nDateTime:" + DateTime.Now.ToString("dd/MM/yy HH:mm:ss") + " Reference No:" + trackId + "Request XML:" + NSDLval, Server.MapPath("~"));
                                    if (NSDLval.IndexOf("http") == -1)
                                    {
                                        lblMess.Text = "Payment cannot be processed with information provided.";
                                        return;
                                    }

                                    // gb.HDFCLog(transid.ToString(), "", trackId, "***Initial Response*** : " + NSDLval);
                                    string strPmtId  = NSDLval.Substring(0, NSDLval.IndexOf(":http"));  // Merchant MUST map (update) the Payment ID received with the merchant Track Id in his database at this place.
                                    string strPmtUrl = NSDLval.Substring(NSDLval.IndexOf("http"));
                                    if (strPmtId != String.Empty && strPmtUrl != String.Empty)
                                    {
                                        URL = strPmtUrl.ToString() + "?PaymentID=" + strPmtId;
                                    }
                                    else
                                    {
                                        lblMess.Text = "Invalid Response!";
                                    }
                                    sr.Close();
                                }
                            }//HDFC
                        }
                        //else if (ddlPaymentMode.SelectedValue == "VOUCHER")
                        //{
                        //    Session["PayDetailsTemp"] = rblVoucher.SelectedValue + "|" + tr.BookingID.ToString() + "_" + transid + "~" + tr.AgentCode + "|" + tr.TotalSeats;
                        //    URL = "~/Payment/Voucher/Voucher.aspx";
                        //}
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Payment Redirection: " + URL);
                        Response.Redirect(URL, false);
                    }
                }
                else
                {
                    lblMess.Text = "Session Timeout. Please start the transaction again by clicking \"Back\" button";
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Session Timeout. Need to restart transaction");
                }
            }
            else //no Session[seat_val]
            {
                ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='TicketBooking.aspx';</script>");
            }
            #endregion
        }
        catch (Exception ex)
        {
            GTICKV.LogEntry(tr.BookingID.ToString(), "Error Occurred - " + ex.Message.Replace("'", ""), "8", transid.ToString());
        }
    }
Esempio n. 6
0
    protected void HandleSuccess(ref TransactionRecord tr, ref System.Text.StringBuilder qstring)
    {
        qstring.Clear();

        #region handlesuccess
        GTICKV.LogEntry(tr.ReferenceNo.ToString(), "IDBI Payment successful...", "10", tr.BookingID.ToString(), tr.ReceiptNo.ToString());

        #region parsereceipt
        if (Request.QueryString["rec"] != null)
        {
            try
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Receipt: " + Request.QueryString["rec"]);
                tr.ReceiptNo = Request.QueryString["rec"].ToString();
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Response: Error parsing receipt.");
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ex.Message);
            }
        }
        #endregion parsereceipt

        try
        {
            //****** Promo code/RoyalCard usecase start here ************
            KODHelper objKODHelper = new KODHelper();
            tr = objKODHelper.GetRoyalCardDetails(tr);
            tr = objKODHelper.GetPromotionDetails(tr);
            //****** Promo code/RoyalCard usecase END here ************


            if (tr.TopUpAmount != 0)
            {
                TransactionBOL.Top_UP(tr.TopUpTransactionId);
            }
            tr.AvailedAmount += tr.TopUpAmount;
            if (tr.AvailedAmount != 0 || tr.AvailedPoints != 0)
            {
                TransactionBOL.Redeem_Points(tr.RegId, tr.AvailedAmount, tr.AvailedPoints, tr.TotalAmount, tr.Play, tr.MobileNo, tr.ReferenceNo.ToString(), tr.TotalSeats);
            }

            DataTable dt = TransactionBOL.Get_Transaction_Detail(tr);
            if (dt != null && dt.Rows.Count > 0)
            {
                bool seatsBooked      = (dt.Rows[0]["SeatBooked"].ToString() == "1");
                bool alreadyProcessed = (dt.Rows[0]["AlreadyProcessed"].ToString() == "1");
                if (seatsBooked)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Transaction : Seats Booked for " + tr.BookingID.ToString());
                }
                if (!alreadyProcessed)
                {
                    ReceiptUtils.SuccessPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, System.Configuration.ConfigurationManager.AppSettings["RoyalCardAdminID"]);
                }
                qstring.Clear();
                qstring.Append("?b=");
                qstring.Append((seatsBooked) ? dt.Rows[0]["BookingID"].ToString() : dt.Rows[0]["ID"].ToString());
            }
            else
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI 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.BookingID.ToString(), tr.ReceiptNo);
                qstring.Append("?err=seat");
            }
        }
        catch (Exception ex)
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Receipt: error getting transaction details - " + ex.Message);
            HandleFailure(tr);
            long      BookingID1 = long.Parse(tr.ReferenceNo.ToString());
            DataTable dt1        = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID1);
            ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt1.Rows[0], "");
            qstring.Append("?err=seat");
        }
        #endregion handlesuccess
    }
Esempio n. 7
0
    protected void GetResponse()
    {
        String URL = "";
        String vpc_TxnResponseCode = "";
        String txtRefCode          = "";
        String ShoWName            = "";
        String stramt             = "";
        String ReceiptNo          = "";
        String vpc_avsResultCode  = "";
        String TranSactNo         = "";
        String ResponseCode       = "";
        String Amount             = "";
        String vpc_3DSstatus      = "";
        String vpc_3DSenrolled    = "";
        String vpc_AcqAVSRespCode = "";

        try
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Prepare to transact wth AmEx...");

            // Create the VPCRequest object
            VPCRequest conn = new VPCRequest("https://vpos.amxvpos.com/vpcpay");
            //conn.setSecureSecret("C12DC6FE16681E9DD3211D2BB0C0BBA2");

            //Live
            conn.setSecureSecret("44DD98D32ECD3C1AA7F12A1D0F8B41EA");
            // Process the response
            conn.process3PartyResponse(Page.Request.QueryString);

            // Check if the transaction was successful or if there was an error
            vpc_TxnResponseCode = conn.getResultField("vpc_TxnResponseCode", "Unknown");

            // Set the display fields for the receipt with the result fields
            // Core Fields

            // Label_vpc_TxnResponseCode.Text = vpc_TxnResponseCode;

            txtRefCode = conn.getResultField("vpc_MerchTxnRef", "Unknown");
            ShoWName   = conn.getResultField("vpc_OrderInfo", "Unknown");

            Amount    = conn.getResultField("vpc_Amount", "Unknown");
            ReceiptNo = conn.getResultField("vpc_ReceiptNo", "Unknown");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx Receiot No. : " + ReceiptNo);

            //**************Safe Key and AAV Verification************//
            vpc_3DSenrolled = conn.getResultField("vpc_3DSenrolled", "Unknown");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("vpc_3DSenrolled : " + vpc_3DSenrolled);

            vpc_AcqAVSRespCode = conn.getResultField("vpc_AcqAVSRespCode", "Unknown");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("vpc_AcqAVSRespCode : " + vpc_AcqAVSRespCode);
            //***********************************************//

            // Address Verification / Advanced Address Verification
            vpc_avsResultCode = conn.getResultField("vpc_AVSResultCode", "Unknown");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Auth result code: " + vpc_avsResultCode);

            // Perform the Capture if the Authorization was successful
            TranSactNo = conn.getResultField("vpc_TransactionNo", "Unknown");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Auth response code: " + vpc_TxnResponseCode);
            string errtxnresponce   = PaymentCodesHelper.getTxnResponseCodeDescription(vpc_TxnResponseCode);
            string errAVSResultCode = PaymentCodesHelper.getAVSDescription(vpc_avsResultCode);

            if (vpc_3DSenrolled == "Y")
            {
                vpc_3DSstatus = conn.getResultField("vpc_3DSstatus", "Unknown");
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Auth safe key code vpc_3DSstatus: " + vpc_3DSstatus);
                if (vpc_TxnResponseCode == "0" && (vpc_3DSstatus == "Y" || vpc_3DSstatus == "A"))
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx authorization successful, starting capture...");
                    // Create a new VPCRequest Object and set the proxy details if required
                    conn = new VPCRequest("https://vpos.amxvpos.com/vpcdps");
                    conn.setProxyHost("");
                    conn.setProxyUser("");
                    conn.setProxyPassword("");
                    conn.setProxyDomain("");

                    //test server
                    // Add the Required Fields
                    //conn.addDigitialOrderField("vpc_Version", "1");
                    //conn.addDigitialOrderField("vpc_AccessCode", "D30639FF");
                    //conn.addDigitialOrderField("vpc_Merchant", "TEST9824533848");
                    //conn.addDigitialOrderField("vpc_User", "kingdomama");
                    //conn.addDigitialOrderField("vpc_Password", "0password");
                    //conn.addDigitialOrderField("vpc_Command", "capture");

                    //live server
                    conn.addDigitialOrderField("vpc_Version", "1");
                    conn.addDigitialOrderField("vpc_AccessCode", "0FE6FE77");
                    conn.addDigitialOrderField("vpc_Merchant", "9824533848");
                    conn.addDigitialOrderField("vpc_User", "kingdomama");
                    conn.addDigitialOrderField("vpc_Password", "0password");
                    conn.addDigitialOrderField("vpc_Command", "capture");

                    conn.addDigitialOrderField("vpc_MerchTxnRef", txtRefCode.Substring(0, txtRefCode.Length - 2) + "-C");
                    conn.addDigitialOrderField("vpc_TransNo", TranSactNo);
                    conn.addDigitialOrderField("vpc_Amount", Amount);
                    // Perform the transaction
                    conn.sendRequest();
                    // Check if the transaction was successful or if there was an error
                    ResponseCode = conn.getResultField("vpc_TxnResponseCode", "Unknown");
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Capture response code: " + ResponseCode);
                }
            }
            else
            {
                if (vpc_TxnResponseCode == "0" && vpc_AcqAVSRespCode == "M")
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx authorization successful, starting capture...");
                    // Create a new VPCRequest Object and set the proxy details if required
                    conn = new VPCRequest("https://vpos.amxvpos.com/vpcdps");
                    conn.setProxyHost("");
                    conn.setProxyUser("");
                    conn.setProxyPassword("");
                    conn.setProxyDomain("");

                    //test server
                    // Add the Required Fields
                    //conn.addDigitialOrderField("vpc_Version", "1");
                    //conn.addDigitialOrderField("vpc_AccessCode", "D30639FF");
                    //conn.addDigitialOrderField("vpc_Merchant", "TEST9824533848");
                    //conn.addDigitialOrderField("vpc_User", "kingdomama");
                    //conn.addDigitialOrderField("vpc_Password", "0password");
                    //conn.addDigitialOrderField("vpc_Command", "capture");

                    //live server
                    conn.addDigitialOrderField("vpc_Version", "1");
                    conn.addDigitialOrderField("vpc_AccessCode", "0FE6FE77");
                    conn.addDigitialOrderField("vpc_Merchant", "9824533848");
                    conn.addDigitialOrderField("vpc_User", "kingdomama");
                    conn.addDigitialOrderField("vpc_Password", "0password");
                    conn.addDigitialOrderField("vpc_Command", "capture");

                    conn.addDigitialOrderField("vpc_MerchTxnRef", txtRefCode.Substring(0, txtRefCode.Length - 2) + "-C");
                    conn.addDigitialOrderField("vpc_TransNo", TranSactNo);
                    conn.addDigitialOrderField("vpc_Amount", Amount);
                    // Perform the transaction
                    conn.sendRequest();
                    // Check if the transaction was successful or if there was an error
                    ResponseCode = conn.getResultField("vpc_TxnResponseCode", "Unknown");
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Capture response code: " + ResponseCode);
                }
            }
            /*******************Payement Gateway Error Value Code**********************/
            #region PG_DB
            if (vpc_TxnResponseCode != "0")
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB");
                string bookingid = txtRefCode.Split('_')[1].ToString().Split('~')[0].ToString();
                int    i         = GTICKBOL.Insert_Payment_DB(errtxnresponce, bookingid, "AMEX");
            }
            else if (vpc_avsResultCode != "X" && vpc_avsResultCode != "Y")
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB");
                string bookingid = txtRefCode.Split('_')[1].ToString().Split('~')[0].ToString();
                int    i         = GTICKBOL.Insert_Payment_DB(errAVSResultCode, bookingid, "AMEX");
            }
            #endregion PG_DB
            /*********************End******************************/
            //convert amt
            int amt = (Convert.ToInt32(Amount)) / 100;
            stramt = amt.ToString();
            GTICKBOL gb = new GTICKBOL();
            GTICKV.LogEntry(txtRefCode.Split('_')[0], "Return From AMEX Payment Gateway, amt : " + stramt + ",recieptNO : " + ReceiptNo, "13", txtRefCode.Split('_')[1].Split('~')[0]);
            //***********Url for address Verification*********//
            //URL = "ReturnReceipt.aspx?tid=" + txtRefCode + "&sta=" + vpc_TxnResponseCode + "&amt=" + stramt + "&rec=" + ReceiptNo + "&ResultCode=" + vpc_avsResultCode;
            //************************************************//
            URL = "ReturnReceipt.aspx?tid=" + txtRefCode + "&sta=" + vpc_TxnResponseCode + "&amt=" + stramt + "&rec=" + ReceiptNo + "&Safecode=" + vpc_3DSstatus + "&response=" + vpc_AcqAVSRespCode + "&enroll=" + vpc_3DSenrolled;
            Response.Redirect(URL, false);
        }
        catch (Exception ex)
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Error in AmEx Payment Response: " + ex.Message);
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Session["Name"]           = txtName.Text;
        Session["Email"]          = txtEmailAddress.Text;
        Session["ContactNo"]      = txtContactNo.Text;
        Session["Paymentgateway"] = rbl_CardType.SelectedValue;
        Decimal           TotalAmount   = Convert.ToDecimal(Session["TotalAmount"].ToString());
        Decimal           PayableAmount = Convert.ToDecimal(Session["PayableAmount"].ToString());
        DateTime          DateofBooking = DateTime.Now.Date;
        string            ISDCode       = "91";
        TransactionRecord tr            = new TransactionRecord();

        tr.MMTBookingID = GTICKBOL.MMTBooking_Max();
        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(tr.MMTBookingID.ToString() + "booking id");
        Session["BookingID"] = tr.MMTBookingID;
        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(tr.MMTBookingID.ToString() + "booking id");
        tr.MMTPayableAmount = Convert.ToDecimal(Session["PayableAmount"].ToString());
        DateTime day = Convert.ToDateTime(Session["day"]);

        MaxBookingId();
        GTICKBOL.MMTBooking_Details(Convert.ToInt16(Session["NoofPackages"]), Session["pnr"].ToString(), Session["promocode"].ToString(), Convert.ToDecimal(Session["TotalAmount"].ToString()), Convert.ToDecimal(Session["PayableAmount"].ToString()), DateofBooking, Session["BookingID"].ToString(), day, Session["Name"].ToString(), Session["Email"].ToString(), Session["ContactNo"].ToString(), Session["Paymentgateway"].ToString(), false, "", "");
        //Parameters for AMEX.........................
        string Street  = txt_street.Text;
        string Pin     = txt_pin.Text;
        string Country = ddl_country.SelectedValue;
        string tital   = Ddl_title.SelectedValue;
        string fname   = Txtfname.Text;
        string mname   = Txtmname.Text;
        string lname   = Txtlname.Text;
        string city    = Txtcity.Text;
        string state   = Txtstate.Text;
        string country = txt_country.SelectedValue;


        string trackId, amount;

        trackId            = Session["BookingID"].ToString();
        Session["trackId"] = trackId;
        amount             = Session["PayableAmount"].ToString();
        Session["amount"]  = amount;
        // Session["PayDetailsTemp"] = tr.BookingID.ToString() + "_" + trackId + "~" + "web" + "|" + tr.MMTPayableAmount + "|" + "Jhumroo";


        if (rbl_CardType.SelectedValue == "HDFC")
        {
            string URL = "";
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(Session["BookingID"].ToString() + "Sending to HDFC Payment Gateway");
            //GTICKV.LogEntry(tr.NYBookingID.ToString(), "Sending to HDFC Payment Gateway", "8", "");


            String ErrorUrl    = KoDTicketingIPAddress + "MMT/HDFC/Error.aspx";
            String ResponseUrl = KoDTicketingIPAddress + "MMT/HDFC/ReturnReceipt.aspx";

            //string qrystr = "id=" + HDFCTransPortalID + "&password="******"&action=1&langid=USA&currencycode=356&amt=" + Server.UrlEncode(amount)
            //    + "&responseURL=" + Server.UrlEncode(ResponseUrl) + "&errorURL=" + Server.UrlEncode(ErrorUrl)
            //    + "&trackid=" + trackId
            //    + "&udf1=TicketBooking&udf2=" + Server.UrlEncode(txtEmailAddress.Text.Trim())
            //    + "&udf3=" + Server.UrlEncode(txtISDCode.Text + txtContactNo.Text) + "&udf4=" + Server.UrlEncode(txtAddress.Text.Trim()) + "&udf5=" + tr.BookingID;

            string qrystr = "id=" + HDFCTransPortalID + "&password="******"&action=1&langid=USA&currencycode=356&amt=" + amount
                            + "&responseURL=" + Server.UrlEncode(ResponseUrl) + "&errorURL=" + Server.UrlEncode(ErrorUrl)
                            + "&trackid=" + trackId
                            + "&udf1=TicketBooking&udf2=" + txtEmailAddress.Text.Trim()
                            + "&udf3=" + Server.UrlEncode(ISDCode.ToString().TrimStart('+') + txtContactNo.Text) + "&udf4=" + Server.UrlEncode(txtName.Text.Trim()) + "&udf5=" + tr.MMTBookingID.ToString();

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Preparing for HDFC Payment..." + qrystr);

            //Writefile_new("\n***************Initial Request********************", Server.MapPath("~"));
            //Writefile_new("\n\nDateTime:" + DateTime.Now.ToString("dd/MM/yy HH:mm:ss") + " Reference No:" + trackId + "Request XML:" + qrystr, Server.MapPath("~"));

            System.IO.StreamWriter requestWriter = null;
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Redirecting for HDFC Payment..." + HDFCTransUrl);
            System.Net.HttpWebRequest objRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(HDFCTransUrl);       //create a SSL connection object server-to-server
            objRequest.Method          = "POST";
            objRequest.ContentLength   = qrystr.Length;
            objRequest.ContentType     = "application/x-www-form-urlencoded";
            objRequest.CookieContainer = new System.Net.CookieContainer();
            try
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Processing request for HDFC Payment...");
                requestWriter = new System.IO.StreamWriter(objRequest.GetRequestStream());      // here the request is sent to payment gateway
                requestWriter.Write(qrystr);
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Excetion while processing HDFC payment: " + trackId + ex.Message);
            }

            if (requestWriter != null)
            {
                requestWriter.Close();
            }

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Review validation response from HDFC Payment Gateway...");
            System.Net.HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse();

            //System.Net.CookieContainer responseCookiesContainer = new System.Net.CookieContainer();
            //foreach (System.Net.Cookie cook in objResponse.Cookies)
            //{
            //    responseCookiesContainer.Add(cook);
            //}

            using (System.IO.StreamReader sr =
                       new System.IO.StreamReader(objResponse.GetResponseStream()))
            {
                String NSDLval = sr.ReadToEnd();
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Response: " + NSDLval);
                if (NSDLval.Contains("Invalid User Defined Field"))
                {
                    lblMess.Text = "The information submitted contains some invalid character, please avoid using [+,-,#] etc.";
                    return;
                }

                //Writefile_new("\n***************Initial Response********************", Server.MapPath("~"));
                //Writefile_new("\n\nDateTime:" + DateTime.Now.ToString("dd/MM/yy HH:mm:ss") + " Reference No:" + trackId + "Request XML:" + NSDLval, Server.MapPath("~"));
                if (NSDLval.IndexOf("http") == -1)
                {
                    lblMess.Text = "Payment cannot be processed with information provided.";
                    return;
                }

                // gb.HDFCLog(transid.ToString(), "", trackId, "***Initial Response*** : " + NSDLval);
                string strPmtId  = NSDLval.Substring(0, NSDLval.IndexOf(":http"));      // Merchant MUST map (update) the Payment ID received with the merchant Track Id in his database at this place.
                string strPmtUrl = NSDLval.Substring(NSDLval.IndexOf("http"));
                if (strPmtId != String.Empty && strPmtUrl != String.Empty)
                {
                    URL = strPmtUrl.ToString() + "?PaymentID=" + strPmtId;
                }
                else
                {
                    lblMess.Text = "Invalid Response!";
                }
                sr.Close();
            }
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Payment Redirection: " + URL);
            Response.Redirect(URL, false);
        }
        else if (rbl_CardType.SelectedValue == "AMEX")
        {
            string URL = "";

            GTICKV.LogEntry(tr.BookingID.ToString(), "Sending to AMEX Payment Gateway", "8", trackId.ToString());
            if (ddl_country.SelectedValue == "india")
            {
                URL = "AMEX/Default.aspx?type=amex&transid=" + trackId + "&amt=" + tr.MMTPayableAmount
                      + "&show=" + "" + "&title=" + "" + "&fname=" + "" + "&mname=" + "" + "&lname=" + "" + "&street=" + "NA" + "&city=" + "NA" + "&state=" + "NA" + "&pin=" + "NA" + "&country=" + "";
            }
            else
            {
                URL = "AMEX/Default.aspx?type=amex&transid=" + trackId + "&amt=" + tr.MMTPayableAmount
                      + "&show=" + "" + "&title=" + tital + "&fname=" + fname + "&mname=" + mname + "&lname=" + lname + "&street=" + Street + "&city=" + city + "&state=" + state + "&pin=" + Pin + "&country=" + country;
            }
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Payment Redirection: " + URL);
            //Response.Redirect(URL, false);
            Response.Redirect(URL, false);
        }
    }
Esempio n. 9
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;
            string[] refTokens = refNo.Split(new char[] { '_', '-' });
            if (refTokens.Length < 3)
            {
                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.BookingID   = long.Parse(refTokens[1]);
            tr.AgentCode   = refTokens[2];

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

            #endregion parsereference

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

            if (Request["paymentid"] != null)
            {
                try
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Receipt: " + Request["paymentid"].ToString());
                    tr.ReceiptNo = 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
                {
                    //****** Promo code usecase start here ************
                    KODHelper objKODHelper = new KODHelper();
                    tr = objKODHelper.GetPromotionDetails(tr);
                    tr.PaymentGateway = "HDFC";
                    //****** Promo code usecase END here ************
                    TransactionBOL.Update_PaymentStatus(tr);     //Update payment status in temp transection table
                    DataTable dt = TransactionBOL.Get_Transaction_Detail(tr);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        try
                        {
                            //String dbamount = dt.Rows[0]["TotalAmount"].ToString();
                            //String dbTrackID = dt.Rows[0]["BookingID"].ToString() + "_" + dt.Rows[0]["ReferenceNo"].ToString() + "-" + dt.Rows[0]["AgentCode"].ToString();
                            ////Validating the Booking Amount and Track ID
                            //if (Request.QueryString["amt"].ToString() == dbamount && Request.QueryString["trackid"].ToString() == dbTrackID)
                            //{
                            bool seatsBooked      = (int.Parse(dt.Rows[0]["SeatBooked"].ToString()) > 0);
                            bool alreadyProcessed = (dt.Rows[0]["AlreadyProcessed"].ToString() == "1");
                            if (seatsBooked)
                            {
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Seats booked against HDFC payment.");
                            }
                            if (!alreadyProcessed)
                            {
                                if (dt.Rows[0]["PromotionCode"].ToString() == "MMT")
                                {
                                    DataTable dt1 = TransactionBOL.Select_MMTTransaction_REFIDWISE(tr.BookingID.ToString());
                                    ReceiptUtils.MMTPaymentResponse(dt.Rows[0], dt1.Rows[0], tr.ReceiptNo.ToString(), tr.BookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId2"), ConfigurationManager.AppSettings.Get("ConcertRefMailId3"), dt.Rows[0]["ShowTime"].ToString(), dt.Rows[0]["ShowDate"].ToString());
                                }
                                else if (dt.Rows[0]["PromotionCode"].ToString() == "MANA")
                                {
                                    DataTable dt2 = TransactionBOL.Select_MANATransaction_REFIDWISE(tr.BookingID.ToString());
                                    ReceiptUtils.MANAPaymentResponse(dt.Rows[0], dt2.Rows[0], tr.ReceiptNo.ToString(), tr.BookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId2"), ConfigurationManager.AppSettings.Get("ConcertRefMailId3"), dt.Rows[0]["ShowTime"].ToString(), dt.Rows[0]["ShowDate"].ToString());
                                }
                                else if (dt.Rows[0]["PromotionCode"].ToString() == "MCOTHERS" || dt.Rows[0]["PromotionCode"].ToString() == "MCWORLD")
                                {
                                    DataTable dt3 = TransactionBOL.Select_MCTransaction_REFIDWISE(tr.ReferenceNo.ToString());
                                    ReceiptUtils.MCPaymentResponse(dt.Rows[0], dt3.Rows[0], tr.ReceiptNo.ToString(), tr.BookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId2"), ConfigurationManager.AppSettings.Get("ConcertRefMailId3"), dt.Rows[0]["ShowTime"].ToString(), dt.Rows[0]["ShowDate"].ToString());
                                }
                                else if (dt.Rows[0]["PromotionCode"].ToString() == "JHUMROOOFFER")
                                {
                                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Enter into jhumroo offer mail content");
                                    ReceiptUtils.JHUMROOOFFERPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, "");
                                }
                                else
                                {
                                    ReceiptUtils.SuccessPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, "");
                                }
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Mail send through normal flow");
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Values are " + dt.Rows[0] + " , " + tr.ReferenceNo.ToString() + "," + tr.BookingID.ToString() + "," + tr.PromotionCode.ToString());
                                SendNotificationMailForHotels(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, tr.PromotionCode.ToString());
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Mail send through Hotel flow");
                            }
                            qstring.Append("?b=");
                            qstring.Append((seatsBooked) ? dt.Rows[0]["BookingID"].ToString() : dt.Rows[0]["ID"].ToString());
                            GTICKV.LogEntry(tr.ReferenceNo.ToString(), "HDFC Payment successful...", "16", tr.BookingID.ToString(), tr.ReceiptNo.ToString());
                            //}
                            //else
                            //{
                            //    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Amounts mismatch customer asked to call to confirm transaction.");
                            //    ReceiptUtils.SuccessPaymentResponse(tr.BookingID.ToString(), tr.ReceiptNo);
                            //}
                        }
                        catch (Exception ex)
                        {
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Error processing receipt post booking. " + ex.Message);
                            if (dt != null && dt.Rows.Count > 0 && (Convert.ToDateTime(dt.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.ToShortDateString()) || Convert.ToDateTime(dt.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.AddDays(-1).ToShortDateString())))
                            {
                                ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt.Rows[0], "");
                            }
                            //ReceiptUtils.SuccessPaymentResponse(tr.BookingID.ToString(), tr.ReceiptNo);
                            qstring.Append((qstring.Length == 0) ? "?err=seat" : "&err=seat");
                        }
                    }
                    else
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC successful booking but ask customer to call");;
                        long      BookingID1 = long.Parse(tr.ReferenceNo.ToString());
                        DataTable dt2        = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID1);
                        if (dt2 != null && dt2.Rows.Count > 0 && (Convert.ToDateTime(dt2.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.ToShortDateString()) || Convert.ToDateTime(dt2.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.AddDays(-1).ToShortDateString())))
                        {
                            ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt2.Rows[0], "");
                        }
                        //ReceiptUtils.SuccessPaymentResponse(tr.BookingID.ToString(), tr.ReceiptNo);
                        qstring.Append((qstring.Length == 0) ? "?err=seat" : "&err=seat");
                    }

                    return(qstring.ToString());
                }
                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.ReferenceNo.ToString();
                KoDTicketing.GTICKV.LogEntry(_refNo, "HDFC Payment Not Successful", "25", tr.BookingID.ToString());
                GTICKBOL.ON_Session_out(_refNo);
                KoDTicketing.GTICKV.LogEntry(_refNo, "Seats Unlocked", "26", tr.BookingID.ToString());
                qstring.Append("err=pay");

                KoDTicketing.GTICKV.LogEntry(tr.ReferenceNo.ToString(), "HDFC Error Occurred -- Payment Not Successful", "27", tr.BookingID.ToString());
                long BookingID = long.Parse(tr.ReferenceNo.ToString());
                try
                {
                    DataTable dt = TransactionBOL.Select_Temptransaction_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 + "Payment/FinalCall.aspx" + qstring.ToString(), false);
                #endregion
            }
            else
            {
                GTICKV.LogEntry(tr.ReferenceNo.ToString(), "User Press Cancel Button", "15", tr.BookingID.ToString());
                GTICKV.LogEntry(tr.ReferenceNo.ToString(), "HDFC Payment Not Successful", "25", tr.BookingID.ToString());
                GTICKBOL.ON_Session_out(tr.ReferenceNo.ToString());
                GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Seats Unlocked", "26", tr.BookingID.ToString());
                long      BookingID = long.Parse(tr.ReferenceNo.ToString());
                DataTable dt        = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID);
                if (dt != null && dt.Rows.Count > 0 && (Convert.ToDateTime(dt.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.ToShortDateString()) || Convert.ToDateTime(dt.Rows[0]["DateOfBooking"].ToString()) == Convert.ToDateTime(DateTime.Now.Date.AddDays(-1).ToShortDateString())))
                {
                    ReceiptUtils.PaymentNotCaptureResponse(tr.ReceiptNo.ToString(), dt.Rows[0], "");
                }
                qstring.Append("?err=pay");
            }
        }
Esempio n. 10
0
    protected void HandleSuccess(ref TransactionRecord tr, ref System.Text.StringBuilder qstring)
    {
        qstring.Clear();

        #region handlesuccess
        GTICKV.LogEntry(tr.ReferenceNo.ToString(), "IDBI Payment successful...", "10", tr.BookingID.ToString(), tr.ReceiptNo.ToString());

        #region parsereceipt
        if (Request.QueryString["rec"] != null)
        {
            try
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Receipt: " + Request.QueryString["rec"]);
                tr.SummerReceiptNo = Request.QueryString["rec"].ToString();
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Response: Error parsing receipt.");
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ex.Message);
            }
        }
        #endregion parsereceipt

        try
        {
            ////****** Promo code usecase start here ************
            //KODHelper objKODHelper = new KODHelper();
            //tr = objKODHelper.GetPromotionDetails(tr);
            ////****** Promo code usecase END here ************
            TransactionBOL.Get_Summer_Detail(tr.SummerBookingID, tr.SummerReceiptNo);
            DataTable dt = TransactionBOL.Select_SummerTransaction_REFIDWISE(tr.SummerBookingID.ToString());
            if (dt != null && dt.Rows.Count > 0)
            {
                bool seatsBooked = (dt.Rows[0]["IsPaymentSuccess"].ToString() == "1");
                ReceiptUtils.SummerPaymentResponse(dt.Rows[0], tr.SummerReceiptNo.ToString(), tr.SummerBookingID.ToString(), ConfigurationManager.AppSettings.Get("ConcertRefMailId"), ConfigurationManager.AppSettings.Get("ConcertRefMailId1"));
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Mail send through normal flow");
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Values are " + dt.Rows[0] + " , " + tr.SummerReceiptNo.ToString() + "," + tr.SummerBookingID.ToString());
                //SendNotificationMailForHotels(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, tr.PromotionCode.ToString());
                //Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Mail send through Hotel flow");
                qstring.Clear();
                qstring.Append("?b=");
                qstring.Append((seatsBooked) ? dt.Rows[0]["BookingID"].ToString() : dt.Rows[0]["ID"].ToString());
            }
            else
            {
                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.SummerBookingID.ToString(), tr.SummerReceiptNo);
                qstring.Append("?err=seat");
            }
        }
        catch (Exception ex)
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Receipt: error getting transaction details - " + ex.Message);
            HandleFailure(tr);
            long      BookingID1 = long.Parse(tr.ReferenceNo.ToString());
            DataTable dt1        = TransactionBOL.Select_Temptransaction_REFIDWISE(BookingID1);
            ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt1.Rows[0], "");
            qstring.Append("?err=seat");
        }
        #endregion handlesuccess
    }
Esempio n. 11
0
 protected void btnBackHome_Click(object sender, EventArgs e)
 {
     GTICKV.LogEntry(sessionvalue[12].ToString(), "User Press Cancel Button On contact detail Page.", "6", "");
     Response.Redirect("Default.aspx", false);
 }
Esempio n. 12
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Decrypt(Request.QueryString["SessionId"]) == sessionvalue[12].ToString() && Session[Decrypt(Request.QueryString["SessionId"])] != "")
        {
            long transid         = 0;
            long refno           = 0;
            TransactionRecord tr = new TransactionRecord();
            try
            {
                #region Session based
                if (Session_value != "" && Request.QueryString["SessionId"] != null)
                {
                    try
                    {
                        string[] strarr;
                        strarr = Session_value.Split(',');
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(string.Format("Transaction [{0}]  ", strarr[12]));
                        tr.BookingID = long.Parse(strarr[12]);
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(string.Format("Seats  " + Session_value));
                        // tr.AgentCode = Session["AgentCode"].ToString();
                        tr.AgentCode   = "Agent-" + Session["Agent"].ToString();
                        tr.Source      = "Web-TicketingAgent";
                        tr.BookingType = "Web-TicketingAgent";
                        //tr.VoucherType = rblVoucher.SelectedValue;
                        //tr.VoucherNo = "";
                        //tr.VoucherBookingID = 0;

                        tr.CardType       = "";
                        tr.PaymentGateway = "Web-TicketingAgent";
                        tr.CardNo         = "1111222233334444";
                        tr.MobileNo       = txtContactNo.Text;
                        tr.Name           = txtName.Text;
                        tr.PaymentType    = "";
                        tr.DateOfBooking  = DateTime.Now.Date.ToShortDateString();
                        // tr.IsProcessed = ;
                        // tr.PaymentStatus = ;
                        tr.router                = "";
                        tr.WantComplimentary     = false;
                        tr.WantComplimentaryDrop = false;
                        tr.PlaceOfDrop           = "";
                        tr.PlaceOfPick           = "";
                        tr.TimeOfPick            = "";
                        tr.TimeOfDrop            = "";
                        tr.EmailID               = txtEmailAddress.Text;
                        tr.Status                = false;
                        tr.TimeOfBooking         = DateTime.Now.ToShortTimeString();
                        tr.TotalSeats            = int.Parse(strarr[5].ToString());
                        tr.Category              = strarr[8];
                        tr.Location              = strarr[6];
                        tr.Play = strarr[1];

                        string[] datarr = strarr[2].ToString().Split('/');//for live server
                        //string[] datarr = strarr[2].ToString().Split('-');// for dev/local

                        tr.ShowDate = datarr[1] + "/" + datarr[0] + "/" + datarr[2];//for live server
                        //tr.ShowDate = datarr[0] + "/" + datarr[1] + "/" + datarr[2]; // for dev/local


                        tr.ShowTime = strarr[7];
                        tr.Day      = Convert.ToDateTime(tr.ShowDate).DayOfWeek.ToString();
                        //tr.ShowDate = datarr[1] + "/" + datarr[0] + "/" + datarr[2];//for local
                        tr.Remark      = "";
                        tr.TotalAmount = GTICKBOL.Get_SeatPrice_SeatKeyNoWise(tr.BookingID);
                        tr.SeatInfo    = SeatVal;
                        tr.Address     = txtAddress.Text.Trim();
                        tr.IP          = GetIP();
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Date : " + tr.DateOfBooking);
                        transid        = TransactionBOL.Transaction_Temp_Insert(tr);
                        tr.ReferenceNo = tr.BookingID;
                        tr.BookingID   = transid;
                        refno          = GTICKBOL.InsertAgentBooking_Details(tr);
                        GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Starting to write Information to temp Session Table", "7", "");
                    }
                    catch (Exception ex)
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Transaction Preparation Error: " + ex.Message);
                        ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                    }
                    GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Category : " + tr.Category + " ,Seat Info : " + tr.SeatInfo +
                                    ", Total Amt : " + tr.TotalAmount, "8", "");

                    if (transid > 0 && refno > 0)
                    {
                        Session["AgentCode"] = null;
                        GTICKV.LogEntry(tr.BookingID.ToString(), "Data Successfully Written to Temp Transaction Table", "9", transid.ToString());
                        string    URL = "";
                        DataTable dt  = TransactionBOL.Get_Transaction_Detail(tr);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            GTICKBOL.Update_AgentBooking(tr.BookingID);
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Payment Redirection: " + URL);
                            Response.Redirect("Print-Receipt.aspx?b=" + tr.BookingID.ToString(), false);
                            Session[Decrypt(Request.QueryString["SessionId"])] = "";
                            bool seatsBooked = (int.Parse(dt.Rows[0]["SeatBooked"].ToString()) > 0);
                            ReceiptUtils.SuccessPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, "");
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Booking successfull" + tr.ReferenceNo);
                        }
                        else
                        {
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("booking failed" + tr.ReferenceNo);
                            DataTable dt1 = TransactionBOL.Select_Temptransaction_REFIDWISE(tr.ReferenceNo);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                ReceiptUtils.PaymentNotCaptureResponse(tr.ReceiptNo.ToString(), dt1.Rows[0], "");
                            }
                            if (sessionvalue[12] != null)
                            {
                                String KeyNo = Decrypt(sessionvalue[12]);
                                GTICKBOL.ON_Session_out(KeyNo);
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("seat releasefor:" + KeyNo);
                            }
                            Session.Clear();
                            ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                        }
                    }
                    else
                    {
                        lblMess.Text = "Session Timeout. Please start the transaction again by clicking \"Back\" button";
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Session Timeout. Need to restart transaction");
                        ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                    }
                }
                else //no Session[seat_val]
                {
                    ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                }
                #endregion
            }
            catch (Exception ex)
            {
                GTICKV.LogEntry(tr.BookingID.ToString(), "Error Occurred - " + ex.Message.Replace("'", ""), "8", transid.ToString());
                ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
            }
        }
        else
        {
            Session.Clear();
            ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
        }
    }
Esempio n. 13
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;
            string[] refTokens = refNo.Split(new char[] { '_', '-' });
            if (refTokens.Length < 3)
            {
                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.BookingID   = long.Parse(refTokens[1]);
            tr.AgentCode   = refTokens[2];

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

            #endregion parsereference

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

            if (Request["paymentid"] != null)
            {
                try
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Receipt: " + Request["paymentid"].ToString());
                    tr.ReceiptNo = 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
                {
                    //****** Promo code/RoyalCard usecase start here ************
                    KODHelper objKODHelper = new KODHelper();
                    tr = objKODHelper.GetRoyalCardDetails(tr);
                    tr = objKODHelper.GetPromotionDetails(tr);
                    //****** Promo code/RoyalCard usecase END here ************


                    if (tr.TopUpAmount != 0)
                    {
                        TransactionBOL.Top_UP(tr.TopUpTransactionId);
                    }
                    tr.AvailedAmount += tr.TopUpAmount;
                    if (tr.AvailedAmount != 0 || tr.AvailedPoints != 0)
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Return Receipt HDFC 1 redeem");
                        TransactionBOL.Redeem_Points(tr.RegId, tr.AvailedAmount, tr.AvailedPoints, tr.TotalAmount, tr.Play, tr.MobileNo, tr.ReferenceNo.ToString(), tr.TotalSeats);
                    }

                    DataTable dt = TransactionBOL.Get_Transaction_Detail(tr);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        try
                        {
                            //String dbamount = dt.Rows[0]["TotalAmount"].ToString();
                            //String dbTrackID = dt.Rows[0]["BookingID"].ToString() + "_" + dt.Rows[0]["ReferenceNo"].ToString() + "-" + dt.Rows[0]["AgentCode"].ToString();
                            ////Validating the Booking Amount and Track ID
                            //if (Request.QueryString["amt"].ToString() == dbamount && Request.QueryString["trackid"].ToString() == dbTrackID)
                            //{
                            bool seatsBooked      = (int.Parse(dt.Rows[0]["SeatBooked"].ToString()) > 0);
                            bool alreadyProcessed = (dt.Rows[0]["AlreadyProcessed"].ToString() == "1");
                            if (seatsBooked)
                            {
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Seats booked against HDFC payment.");
                            }
                            if (!alreadyProcessed)
                            {
                                ReceiptUtils.SuccessPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, System.Configuration.ConfigurationManager.AppSettings["RoyalCardAdminID"]);
                            }
                            qstring.Append("?b=");
                            qstring.Append((seatsBooked) ? dt.Rows[0]["BookingID"].ToString() : dt.Rows[0]["ID"].ToString());
                            GTICKV.LogEntry(tr.ReferenceNo.ToString(), "HDFC Payment successful...", "10", tr.BookingID.ToString(), tr.ReceiptNo.ToString());
                            //}
                            //else
                            //{
                            //    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Amounts mismatch customer asked to call to confirm transaction.");
                            //    ReceiptUtils.SuccessPaymentResponse(tr.BookingID.ToString(), tr.ReceiptNo);
                            //}
                        }
                        catch (Exception ex)
                        {
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Error processing receipt post booking. " + ex.Message);
                            ReceiptUtils.SuccessPaymentResponse(tr.ReceiptNo.ToString(), dt.Rows[0], "");
                            //ReceiptUtils.SuccessPaymentResponse(tr.BookingID.ToString(), tr.ReceiptNo);
                            qstring.Append((qstring.Length == 0) ? "?err=seat" : "&err=seat");
                        }
                    }
                    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.BookingID.ToString(), tr.ReceiptNo);
                        qstring.Append((qstring.Length == 0) ? "?err=seat" : "&err=seat");
                    }

                    return(qstring.ToString());
                }
                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.ReferenceNo.ToString();
                KoDTicketing.GTICKV.LogEntry(_refNo, "HDFC Payment Not Successful", "17", tr.BookingID.ToString());
                GTICKBOL.ON_Session_out(_refNo);
                KoDTicketing.GTICKV.LogEntry(_refNo, "Seats Unlocked", "18", tr.BookingID.ToString());
                qstring.Append("err=pay");

                KoDTicketing.GTICKV.LogEntry(tr.ReferenceNo.ToString(), "HDFC Error Occurred -- Payment Not Successful", "19", tr.BookingID.ToString());
                long BookingID = long.Parse(tr.ReferenceNo.ToString());
                try
                {
                    DataTable dt = TransactionBOL.Select_Temptransaction_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 + "RoyalCard/Account/Payment/FinalCall.aspx" + qstring.ToString(), false);
                #endregion
            }
            else
            {
                GTICKV.LogEntry(tr.ReferenceNo.ToString(), "HDFC Payment Not Successful", "17", tr.BookingID.ToString());
                GTICKBOL.ON_Session_out(tr.ReferenceNo.ToString());
                GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Seats Unlocked", "18", tr.BookingID.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");
            }
        }