public PaymentResponse ParsePaymentChallenge(string input, string userName, string key)
        {
            char[] seps = { '/' };//For Epoche Time
            String[] values = input.Split(seps);//For Epoche Time

            AuthenticateChallenge ac = new AuthenticateChallenge();
            string op = ac.CalculateHMAC(input, userName, key);

            PaymentResponse pay = new PaymentResponse
            {
                EpochTime = Convert.ToInt64(values[1]),
                MerchantID=values[2],
                OrderID=Convert.ToInt64(values[3]),
                HMAC = op
            };
            return pay;
        }
 private void SendAuthResponse(string result)
 {
     try
     {
         string address = String.Format("{0}/{1}{2}{3}",new DataSaverHelper().GetUrlBase(),"api/Customer/",userName,"/Authenticate");
         var postData = new AuthenticateChallenge().ParseAuthChallenge(result,userName,secretKey);
         string jsonReq = JsonConvert.SerializeObject(postData);
         string response = Utility.HttpPost(address, jsonReq);
         if ("true".Equals(response))
         {
             Utility.ShowToastLong(this, "Successfull Authenticaton.");
         }
         else
         {
             Utility.ShowToastLong(this, "Failure");
         }
     }
     catch
     {
         Utility.ShowToastLong(this, "Network Failure");
     }
 }
示例#3
0
 public void TestingReturningMethodofHMACSHA1()
 {
     AuthenticateChallenge ac = new AuthenticateChallenge();
     var r=  ac.ParseAuthChallenge(@"00/5678/abc", "sharath", "pavan");
     Assert.AreEqual(r.HMAC, "5ZDWKFKIJ2PWLEXMTNZZHE5FIDJHKQH6");
 }