public VakifBankResponse VakifOdemeYap()
        {
            byte[] b = new byte[1500];

            string provizyonMesaji = OdemeOlusutur();

            b.Initialize();

            b = Encoding.UTF8.GetBytes(provizyonMesaji);

            WebRequest h1 = (WebRequest)HttpWebRequest.Create(provizyonMesaji);

            h1.Method = "GET";

            Stream      dataStream;
            WebResponse response = h1.GetResponse();

            dataStream = response.GetResponseStream();
            StreamReader reader             = new StreamReader(dataStream, System.Text.Encoding.UTF8);
            string       responseFromServer = reader.ReadToEnd().Replace("\n", "").Replace("\"", @"#");

            responseFromServer = responseFromServer.Replace('#', '"');



            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(responseFromServer));

            DataSet dt = new DataSet();

            dt.ReadXml(stream);


            DataTable         dt1       = dt.Tables[0];
            VakifBankResponse _response = GetResponseFromCode(dt1.Rows[0]["Kod"].ToString(), dt1);

            reader.Close();
            dataStream.Close();
            response.Close();



            return(_response);
        }
        private VakifBankResponse GetResponseFromCode(string p, DataTable dt1)
        {
            VakifBankResponse _response = new VakifBankResponse();

            if (p == "00")
            {
                _response.BKMKod = dt1.Rows[0]["BKMKod"].ToString();
                _response.Mesaj  = BKMKoduDondur((PaymentEnums.VakifBankBkmCodes)Enum.Parse(typeof(PaymentEnums.VakifBankBkmCodes), "_" + dt1.Rows[0]["BKMKod"].ToString()));
                _response.Status = dt1.Rows[0]["Status"].ToString();
                _response.Tutar  = dt1.Rows[0]["Tutar"].ToString();
                _response.ProvNo = dt1.Rows[0]["ProvNo"].ToString();
                _response.VBRef  = dt1.Rows[0]["VBRef"].ToString();
                _response.Tarih  = dt1.Rows[0]["Tarih"].ToString();
            }
            else
            {
                _response.Kod   = dt1.Rows[0]["Kod"].ToString();
                _response.Mesaj = ResponseKoduDondur((PaymentEnums.VakifBankResponseCodes)Enum.Parse(typeof(PaymentEnums.VakifBankResponseCodes), "_" + dt1.Rows[0]["Kod"].ToString()));
                // _response.VBRef = dt1.Rows[0]["VBRef"].ToString();
            }


            return(_response);
        }
        public VakifBankResponse VakifBankOdemeYap(EravsePaymentParameters eravseParameter)
        {
            VakifBankResponse response = null;

            if (eravseParameter.Bank != PaymentEnums.Banks.DefaultBank)
            {
                if (eravseParameter.Bank == PaymentEnums.Banks.VakifBank)
                {
                    response = new VakifBankResponse();
                }


                using (Datasets.GatewayContextDataContext db = new Datasets.GatewayContextDataContext())
                {
                    var User = db.PaymentCustomers.Where(r => r.UserGuid == eravseParameter.CompanyCode && r.Password == eravseParameter.Password);
                    if (User.Count() > 0)
                    {
                        #region + + +  VAKIFBANK + + +


                        if (eravseParameter.Bank == PaymentEnums.Banks.VakifBank)
                        {
                            VakifBankParamterBuilder _builder = new VakifBankParamterBuilder();

                            Datasets.CustomerParameter customerParameter = db.CustomerParameters.First(r => r.CustomerRowId == User.First().UserGuid&& r.Bank == (int)eravseParameter.Bank);
                            byte[] b = customerParameter.Parameters;

                            _builder = (VakifBankParamterBuilder)SerializeProccess.Deserialize(b);

                            _builder.kkno    = eravseParameter.CardNo;
                            _builder.gectar  = eravseParameter.LastValidYear + eravseParameter.LastValidMount;
                            _builder.cvc     = eravseParameter.Cvc.ToString(CultureInfo.InvariantCulture);
                            _builder.tutar   = "000000000100";
                            _builder.khip    = eravseParameter.ClientIp;
                            _builder.taksits = "0" + eravseParameter.Installment.ToString();

                            using (VakifBankOdeme odeme = new VakifBankOdeme(_builder))
                            {
                                response = odeme.VakifOdemeYap();
                            }
                        }
                        #endregion
                    }
                }
            }
            else
            {
                response = new VakifBankResponse
                {
                    Kod   = PaymentEnums.EravseReturnCode.BankKodeNotValid.ToString(),
                    Mesaj = GetEravseResponseMessageFromReturnCode(PaymentEnums.EravseReturnCode.BankKodeNotValid)
                };
            }



            // LOGIN KONTROL
            // EGER DB BAGLANTISI YAPACAKSANIZ ORNEK OLARAK VERILMISTIR.


            //Classes.VakifBankParamterBuilder builerder = new VakifBankParamterBuilder{

            //kullanici ="0001",
            //sifre ="00000000",
            //islem = PaymentEnums.VakifBankIslem.PRO,
            //uyeno = "000000000",
            //posno="00000000",
            //provno="000000",
            //islemyeri = PaymentEnums.VakifBankIslemYeri.I,
            //uyeref="200501011234567890",
            //vbref ="6527BB1815F9AB1DE864A488E5198663002D0000",
            //xcip ="ABABABABAB",
            //ucaf=""
            //};


            //builerder.kkno = EravseParameter.CardNo.ToString();
            //builerder.gectar = EravseParameter.LastValidYear.ToString() + EravseParameter.LastValidMount.ToString();
            //builerder.cvc = EravseParameter.CVC.ToString();
            //builerder.tutar = "000000000100";
            //builerder.khip = EravseParameter.ClientIP;

            //using (Datasets.GatewayContextDataContext db  = new Datasets.GatewayContextDataContext())
            //{
            //    Datasets.CustomerParameter cp = new Datasets.CustomerParameter {
            //        Id = Guid.NewGuid(),
            //    CustomerRowId = Guid.Parse("46dd9004-39e2-4b15-aa55-3c85a4ce279a"),
            //    Bank = 1,
            //    Parameters =  Classes.SerializeProccess.Serialize(builerder)
            //    };

            //    db.CustomerParameters.InsertOnSubmit(cp);
            //    db.SubmitChanges();
            //}



            //using (Classes.VakifBankOdeme Odeme = new Classes.VakifBankOdeme(Param))
            //{
            //    return Odeme.VakifOdemeYap();

            //}


            return(response);
        }