0

我是 Windows 通用应用程序开发的新手。现在我正在开发一个应用程序,我必须在其中集成 PayU。我尝试了很多,但每次从服务器抛出事务错误。

string temp1 = "key=xxxxxx&txnid=xxxxxx&hash=hashValue&amount=xxx&firstname=abc" + 
  "&email=a@a.com&phone=80xxxxxxxx&productinfo=xxxxxxxxxxxx" + 
  "&surl=https://www.google.com&furl=https://www.twitter.com" + 
  "&udf1=a&udf2=b&udf3=c&udf4=d&udf5=e&pg=CC&bankcode=CC" + 
  "&ccardtype=CC&ccnum=1234xxxxxxxxx&ccname=xxx&ccvv=xxx" +
  "&ccexpmon=xx&ccexpyr=xxxx";

var httpClient = new Windows.Web.Http.HttpClient();
Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, theUri);
Windows.Web.Http.IHttpContent content = new Windows.Web.Http.HttpStringContent(temp1, Windows.Storage.Streams.UnicodeEncoding.Utf8);
httpRequestMessage.Content = content;
try
{
    webView.NavigateWithHttpRequestMessage(httpRequestMessage);
}
catch(Exception f)
{
    new MessageDialog(f.ToString()).ShowAsync();
}

我正在使用方法创建 hashValue:

 public String SampleHashMsg(String strMsg)
    {
        // Convert the message string to binary data.
        string strAlgName = HashAlgorithmNames.Sha512;
        IBuffer buffUtf8Msg = CryptographicBuffer.ConvertStringToBinary(strMsg, BinaryStringEncoding.Utf8);

        // Create a HashAlgorithmProvider object.
        HashAlgorithmProvider objAlgProv = HashAlgorithmProvider.OpenAlgorithm(strAlgName);

        // Demonstrate how to retrieve the name of the hashing algorithm.
        String strAlgNameUsed = objAlgProv.AlgorithmName;

        // Hash the message.
        IBuffer buffHash = objAlgProv.HashData(buffUtf8Msg);

        // Verify that the hash length equals the length specified for the algorithm.
        if (buffHash.Length != objAlgProv.HashLength)
        {
            throw new Exception("There was an error creating the hash");
        }

        // Convert the hash to a string (for display).
        //String strHashBase64 = CryptographicBuffer.EncodeToBase64String(buffHash);

        String strHashBase64 = CryptographicBuffer.EncodeToHexString(buffHash);
        // Return the encoded string

        return strHashBase64;
    }

我应该将请求加载到 webview。但我收到一个错误“交易错误”。

我收到交易错误,未提供 txnid。在 PayU 端,发送的哈希密钥将用于验证交易。可能是我的 txnid 和 hash 包含的 txnid 不匹配,payu 服务器拒绝说提供 txnid 的交易。

我正在使用 Microsoft Visual Studio 2013 通用应用程序进行应用程序开发。

但我仍然没有得到正确的结果。如果有人可以帮助我,请立即回复。提前致谢。

4

0 回答 0