0

编辑我误解了这里发生的事情..有一个 POST 发送,然后收到一个结果,然后我在这里看到的 URL 字符串是查询字符串的一部分......所以我无法解码什么这确实是,因为它是由支付网关的人而不是我编码的。

我想解码一个 URL 字符串

这是代码:

private string SubmitXml(string InputXml)
    {
        string result = InputXml.ToString();

        HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(_WebServiceUrl);
        webReq.Method = "POST";

        byte[] reqBytes;

        reqBytes = System.Text.Encoding.UTF8.GetBytes(InputXml);
        webReq.ContentType = "application/x-www-form-urlencoded";
        webReq.ContentLength = reqBytes.Length;
        webReq.Timeout = 5000;
        Stream requestStream = webReq.GetRequestStream();
        requestStream.Write(reqBytes, 0, reqBytes.Length);
        requestStream.Close();

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

这是 InputXml:

 - <GenerateRequest>
  <PxPayUserId>KoruCareCHCH_Dev</PxPayUserId> 
  <PxPayKey>47d99ccdcae54816ecd78c9a80f8878c466a7ed829480e59d421cc4c456cbd93</PxPayKey> 
  <AmountInput>345.00</AmountInput> 
  <BillingId /> 
  <CurrencyInput>NZD</CurrencyInput> 
  <DpsBillingId /> 
  <DpsTxnRef /> 
  <EmailAddress /> 
  <EnableAddBillCard /> 
  <MerchantReference>43</MerchantReference> 
  <TxnData1 /> 
  <TxnData2 /> 
  <TxnData3 /> 
  <TxnType>Purchase</TxnType> 
  <TxnId>43</TxnId> 
  <UrlFail>http://localhost:1527/Auction/PurchaseTickets.aspx</UrlFail> 
  <UrlSuccess>http://localhost:1527/Auction/PurchaseTickets.aspx</UrlSuccess> 
  <Opt /> 
  </GenerateRequest>

这是网址

https://sec2.paymentexpress.com/pxpay/pxpay.aspx?userid=KoruCareCHCH_Dev&request=v5lK0D7j3qnGqQVnj3WThhuS5PoWwKhdLUXfnL1hiSzYzxzkKVtTbLKC49e0qerYoTAofoBXfkWHjJdtOEV1MrnEBZ3p9b-G5fTsS-sLqc76RhHOb8HTxtwe0EQ1kz1iCf2ExIgKRod-FPQTKf6XoTLLlQ4jhcrO7yQczrq1Hft5pB98LMJCdBX0FDnA5NV0ZGApR0NaCMy-xbpsVSsyTbSdmp03aiHpGXI4up2RxrBFhbiEOZKtpKkjUpqJ90UuoXmFwqTC5Pj0g1mx3VRV2ee358Tnu1_kuEID_RaP8sZNTVlAMY5-8qjB-u0dgM4ya8Faxxyw5AhyE=

问题:如何将 URL request=blahblah 解码回 XML

我这样做是为了尝试证明 URL 字符串中包含的内容(它应该就像上面的 XML 一样!)

4

2 回答 2

2

没有运气解码它,所以 URL 可能是错误的,但我使用了这段代码:

Uri uri = new Uri(...);
NameValueCollection query = HttpUtility.ParseQueryString(uri.Query);
string value = query["request"].Replace('-', '+').Replace('_', '/');
Debug.WriteLine(Convert.FromBase64String(value));

编辑:在他们的文档中,他们说它是加密的。

于 2010-12-22T06:03:03.003 回答
0

您可以使用正则表达式,例如

var match = new Regex("request=(?<key>[^&]+)").Match(url);

并捕获命名组中的请求值。从那里,希望您能够解密捕获的值。

不能保证上述正则表达式是正确的——我没有测试过。它至少应该为您指明正确的方向!

于 2010-12-22T06:55:36.633 回答