예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string paymentId, ErrorText, result, postdate, tranid, auth, amt, reference;
            string ErrorNo, udf1, udf2, udf3, udf4, udf5, trackid;

            paymentId = Request["paymentid"] ?? String.Empty;
            ErrorText = Request["ErrorText"] ?? String.Empty;
            ErrorNo   = Request["Error"] ?? String.Empty;

            udf1 = Request["udf1"] ?? String.Empty;
            udf2 = Request["udf2"] ?? String.Empty;
            udf3 = Request["udf3"] ?? String.Empty;
            udf4 = Request["udf4"] ?? String.Empty;
            udf5 = Request["udf5"] ?? String.Empty;

            if (ErrorNo == String.Empty)
            {
                result    = Request["result"] ?? String.Empty;
                postdate  = Request["postdate"] ?? String.Empty;
                tranid    = Request["tranid"] ?? String.Empty;
                auth      = Request["auth"] ?? String.Empty;
                trackid   = Request["trackid"] ?? String.Empty;
                reference = Request["ref"] ?? String.Empty;
                amt       = Request["amt"] ?? String.Empty;

                String responseDetails = string.Format("HDFC Response: paymentId[{0}], ErrorText[{1}], result[{2}], postdate[{3}], tranid[{4}], auth[{5}], amt[{6}], reference[{7}], ErrorNo[{8}], udf1[{9}], udf2[{10}], udf3[{11}], udf4[{12}], udf5[{13}], trackid[{14}]",
                                                       paymentId, ErrorText, result, postdate, tranid, auth, amt, reference, ErrorNo, udf1, udf2, udf3, udf4, udf5, trackid);
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(responseDetails);

                if (trackid != String.Empty)
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Track ID: " + trackid);
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Result: " + Request["result"].ToString());
                    KoDTicketing.GTICKV.LogEntry(trackid.Split('_')[0], "Payment Getaway Response: " + Request["result"].ToString(), "14", trackid.Split('_')[1].Split('-')[0]);
                    /*******************Payement Gateway Error Value Code**********************/
                    #region PG_DB for ReturnReceipt
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB");
                    string bookingid = Request["trackid"].Split('_')[1].ToString().Split('-')[0].ToString();
                    int    i         = GTICKBOL.Insert_Payment_DB(Request["result"].ToString(), bookingid, "HDFC");
                    #endregion PG_DB for ReturnReceipt
                    /*********************End******************************/
                    string qstring = UpdateResponse(trackid, reference, result, postdate, auth);
                    if (!string.IsNullOrEmpty(qstring))
                    {
                        string redirectURL = "REDIRECT=" + KoDTicketingIPAddress + "Payment/Print-Receipt.aspx" + qstring;
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC response redirection: " + redirectURL);
                        Response.Write(redirectURL);
                        return;
                    }
                    else
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC response processing failed and resulting in empty receipt.");
                    }
                }
                else
                {
                    Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Response contains NO track ID");
                }
                Response.Write("REDIRECT=" + KoDTicketingIPAddress + "Payment/Print-Receipt.aspx?err=pay");
            }
            else
            {
                String errorDetails = string.Format("paymentId[{0}], ErrorText[{1}], ErrorNo[{2}], udf1[{3}], udf2[{4}], udf3[{5}], udf4[{6}], udf5[{7}]",
                                                    paymentId, ErrorText, ErrorNo, udf1, udf2, udf3, udf4, udf5);
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Response: " + errorDetails);
                /*******************Payement Gateway Error Value Code**********************/
                #region PG_DB for ReturnReceipt
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB");
                string bookingid = Request["trackid"].Split('_')[1].ToString().Split('-')[0].ToString();
                int    i         = GTICKBOL.Insert_Payment_DB(ErrorText.ToString(), bookingid, "HDFC");
                #endregion PG_DB for ReturnReceipt
                /*********************End******************************/

                string err;
                if (Request["ErrorText"] != null)
                {
                    err = Request["ErrorText"].ToString();
                }
                else
                {
                    err = "Error occcured in processing payment through HDFC payment gateway.";
                }
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Error Response: " + err);
                Response.Write("REDIRECT=" + KoDTicketingIPAddress + "Payment/Print-Receipt.aspx?err=pay");
            }
        }//!postback
    }