/*
         * updated by Shahbaz Akhtar on 27-12-2016 for view and grid        */
        public DirectPayment GetDirectPaymentRecord(int recordID, string UserID)
        {
            string proc = string.Empty;

            try
            {
                DirectPayment  dp         = new DirectPayment();
                SqlParameter[] Parameters = { new SqlParameter("@SNo",    Convert.ToInt32(recordID)),
                                              new SqlParameter("@UserID", Convert.ToInt32(UserID)) };

                if (System.Web.HttpContext.Current.Request.QueryString.ToString().Split('=')[4] == "O")
                {
                    proc = "GetRecordDirectPayment_Office";
                }
                else
                {
                    proc = "GetRecordDirectPayment";
                }

                SqlDataReader dr = SqlHelper.ExecuteReader(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, proc, Parameters);
                if (dr.Read())

                // SqlDataReader dr = SqlHelper.ExecuteReader(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordDirectPayment", Parameters);
                //  if (dr.Read())
                {
                    dp.SNo                     = Convert.ToString(dr["SNo"]);
                    dp.AccountSNo              = Convert.ToInt32(dr["SNo"]);
                    dp.RefNo                   = dr["RefNo"].ToString();
                    dp.Office                  = dr["Office"].ToString().ToUpper();
                    dp.Agent                   = dr["Agent"].ToString().ToUpper();
                    dp.Amount                  = Convert.ToString(dr["Amount"]);
                    dp.Credit                  = Convert.ToString(dr["Credit"]);
                    dp.UpdateTypeText          = dr["UpdateType"].ToString();
                    dp.Transaction             = dr["Transaction"].ToString();
                    dp.CreatedUser             = dr["CreatedUser"].ToString();
                    dp.UpdatedUser             = dr["UpdatedUser"].ToString();
                    dp.AccountSNo              = Convert.ToInt32(dr["AccountSNo"]);
                    dp.CitySNo                 = Convert.ToInt32(dr["CitySNo"]);
                    dp.AirlineSNo              = Convert.ToInt32(dr["AirlineSno"]);
                    dp.OfficeSNo               = Convert.ToInt32(dr["officeSno"]);
                    dp.CurrencySNo             = Convert.ToInt32(dr["CurrencySNo"]);
                    dp.AirlineSNo              = Convert.ToInt32(dr["Airlinesno"]);
                    dp.Text_AirlineSNo         = dr["Airline"].ToString();
                    dp.Text_Agent              = dr["Agent"].ToString();
                    dp.Text_City               = dr["City"].ToString();
                    dp.Text_CurrencySNo        = dr["Currency"].ToString();
                    dp.Text_Office             = dr["Office"].ToString();
                    dp.PaymentBy               = dr["Office"].ToString() == "0" || dr["Office"].ToString() == "" ? 1 : 0;
                    dp.TransactionType         = dr["TransactionType"].ToString();
                    dp.CreditLimit             = dr["CreditLimit"].ToString();
                    dp.ExistingCreditLimit     = Convert.ToString(dr["ExistingCreditLimit"]);
                    dp.PaymentDate             = Convert.ToString(dr["PaymentDate"]);
                    dp.PaymentDateCal          = string.IsNullOrEmpty(dr["PaymentDate"].ToString()) == true ? (DateTime?)null : Convert.ToDateTime(dr["PaymentDate"].ToString());
                    dp.Remarks                 = Convert.ToString(dr["Remarks"]);
                    dp.TotalNtaAmount          = Convert.ToString(dr["TotalNtaAmount"]);
                    dp.TransectionModeSNo      = Convert.ToInt32(dr["TransectionModeSNo"]);
                    dp.Text_TransectionModeSNo = Convert.ToString(dr["Text_TransectionModeSNo"]);
                    dp.Text_UpdateType         = Convert.ToString(dr["Text_UpdateType"]);
                    dp.BankAccountNo           = Convert.ToString(dr["BankAccountNo"]);
                    dp.BankName                = Convert.ToString(dr["BankName"]);
                    dp.BranchName              = Convert.ToString(dr["BranchName"]);
                    dp.ChequeAccountName       = Convert.ToString(dr["ChequeAccountName"]);
                    dp.ChequeDate              = string.IsNullOrEmpty(dr["ChequeDate"].ToString()) == true ? (DateTime?)null : Convert.ToDateTime(dr["ChequeDate"].ToString());
                    dp.ValidFrom               = string.IsNullOrEmpty(dr["ValidFrom"].ToString()) == true ? (DateTime?)null : Convert.ToDateTime(dr["ValidFrom"].ToString());
                    dp.ValidTo                 = string.IsNullOrEmpty(dr["ValidTo"].ToString()) == true ? (DateTime?)null : Convert.ToDateTime(dr["ValidTo"].ToString());
                    dp.ReferenceNo             = Convert.ToString(dr["ReferenceNo"]);
                    dp.Text_AWBSNo             = dr["AwbNumber"].ToString();
                    dp.ChequeNo                = Convert.ToString(dr["ChequeNo"]);
                    dp.Description             = Convert.ToString(dr["Description"]).ToUpper();
                }
                dr.Close();
                return(dp);
            }
            catch (Exception ex)// (Exception ex)
            {
                throw ex;
            }
        }
        static void Main(string[] args)
        {
            //Create voguepay merchant instance
            Merchant merchantinfo = new Merchant();

            merchantinfo.MerchantID      = "6359-0000000";
            merchantinfo.Username        = "******";
            merchantinfo.Email           = "*****@*****.**";
            merchantinfo.CommandAPIToken = "ZnHzcbxKVbvF5d3J5JvZqZe587Rna";
            merchantinfo.PublicKeyFile   = @"C:\Users\Rock\public.txt"; //URL path to saved public key

            //Create voguepay instance (Parameters "live" or "demo", default is demo)
            Voguepay voguepay = new Voguepay("live");

            voguepay.Init(merchantinfo);

            //Create customer instance
            Customerinfo customer = new Customerinfo();

            customer.Name    = "Sam Great";
            customer.Phone   = "20339922";
            customer.Email   = "*****@*****.**";
            customer.City    = "Allen";
            customer.Country = "NGA";
            customer.State   = "Ikeja";
            customer.ZipCode = "23401";
            customer.Address = "3 Drive view estate";


            DirectPayment directpayment = new DirectPayment();

            directpayment.version     = 2;
            directpayment.Amount      = 100.22;
            directpayment.Currency    = "USD";
            directpayment.Reference   = "MY_UNIQUE_REF";
            directpayment.Memo        = "Sample payment";
            directpayment.RedirectURL = "https://sample.com/redirect";
            directpayment.ReferralURL = "https://sample.com/referral";
            directpayment.ResponseURL = "https://sample.com/notify/";
            directpayment.StoreID     = "5a33c3933ca"; //optional

            directpayment.CardName        = "Steve";
            directpayment.CardPan         = "5389830123937029";
            directpayment.CardExpiryMonth = 5;
            directpayment.CardExpiryYear  = 21;
            directpayment.CardCVV         = 170;


            directpayment.ServerPublicIP           = "192.333.44.33";
            directpayment.ServerWebsiteURL         = "www.google.com";
            directpayment.CustomerReferringIP      = "10.22.333.33";
            directpayment.CustomerReferringWebsite = "www.shades.com";

            directpayment.DescriptorCompanyName    = "Sparks";
            directpayment.DescriptorCountryAddress = "Sparks Street";
            directpayment.DescriptorCityAddress    = "Califonia";
            directpayment.DescriptorCountryAddress = "USA"; //country or 3 letter ISO

            // directpayment.CardToken = "5a344439203";
            //  directpayment.CardTokenize =true;

            string jsonResult = voguepay.Pay(directpayment, customer);

            Console.WriteLine(jsonResult);
            Console.ReadKey();
        }