public void GetLoyaltyPoints()
        {
            EPayuLoyaltyItem item = new EPayuLoyaltyItem
            {
                SecretKey = "yourkey",
                CardNumber = "yourcardnumber",
                CardOwner = "cardowner",
                Currency = "currency",
                Cvv = "cvv",
                ExpireMonth = "month",
                ExpireYear = "year",
                MerchantId = "merchantid"
            };

            PayuIntegration integration = new PayuIntegration();
            var result = integration.GetLoyaltyPoints(item);

            Assert.AreEqual("SUCCESS",result.Status);
        }
        public EPayment GetLoyaltyPoints(EPayuLoyaltyItem model)
        {
            ELoyaltyPoint loyaltyPoint = new ELoyaltyPoint
            {
                Merchant = model.MerchantId,
                Date = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
                CVV = model.Cvv,
                CardNumber = model.CardNumber,
                ExpiryMonth = model.ExpireMonth,
                ExpiryYear = string.Format("20{0}", model.ExpireYear),
                Currency = model.Currency,
                SecretKey = model.SecretKey,
                CardOwnerName = model.CardOwner
            };

            Dictionary<string, string> parameters = new Dictionary<string, string>
            {
                {"CC_CVV", loyaltyPoint.CVV},
                {"CC_NUMBER", loyaltyPoint.CardNumber},
                {"CC_OWNER", loyaltyPoint.CardOwnerName},
                {"CURRENCY", loyaltyPoint.Currency},
                {"DATE", loyaltyPoint.Date},
                {"EXP_MONTH", loyaltyPoint.ExpiryMonth},
                {"EXP_YEAR", loyaltyPoint.ExpiryYear},
                {"MERCHANT", loyaltyPoint.Merchant}
            };

            var message = parameters.Select(kvp => kvp.Value)
                .Aggregate(string.Empty, (current, v) => current + (v.Length + v));

            var hash = Helper.Hash(loyaltyPoint.SecretKey, message);

            parameters.Add("HASH", hash);

            string postString = Helper.DictionaryToPostString(parameters);

            postString = postString.Remove(postString.Length - 1);

            byte[] postBytes = Encoding.UTF8.GetBytes(postString);

            HttpWebRequest webRequest =
                (HttpWebRequest) WebRequest.Create("https://secure.payu.com.tr/api/loyalty-points/check");
            webRequest.Method = "POST";
            webRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            webRequest.ContentLength = postBytes.Length;

            Stream postStream = webRequest.GetRequestStream();
            postStream.Write(postBytes, 0, postBytes.Length);
            postStream.Close();

            HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();

            if (webResponse.StatusCode == HttpStatusCode.OK)
            {
                Stream responseStream = webResponse.GetResponseStream();
                StreamReader responseStreamReader = new StreamReader(responseStream);

                var res = responseStreamReader.ReadToEnd();

                System.Xml.Serialization.XmlSerializer ser =
                    new System.Xml.Serialization.XmlSerializer(typeof (EPayment));

                using (StringReader sr = new StringReader(res))
                {
                    return (EPayment) ser.Deserialize(sr);
                }

            }
            else
            {
                return new EPayment();
            }
        }