Domanda

Modifica che avevo frainteso quello che stava succedendo qui .. c'è un invio POST, quindi riceverà indietro di un risultato, quindi la stringa URL che sto vedendo qui è parte della stringa di query ... quindi non mi può decodificare ciò che questo è davvero, in quanto è codificato dal popolo gateway di pagamento e non a me.

Mi piacerebbe decodificare una stringa URL

Ecco il codice:

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();

Questa è l'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>

Ecco l'URL

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

Problema: Come faccio a decodificare la richiesta URL = back blahblah in XML

Lo sto facendo per cercare di dimostrare ciò che è contenuto nella stringa URL (che dovrebbe essere proprio come la XML qui sopra!)

È stato utile?

Soluzione

non ha avuto alcuna fortuna decodifica così l'URL potrebbe essere sbagliato, ma ho usato questo codice:

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

EDIT:. Nei loro documenti dicono è criptata

Altri suggerimenti

È possibile utilizzare una regex, qualcosa come

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

e catturare il valore di richiesta del gruppo denominato. Da lì, si spera si sarebbe in grado di decifrare il valore catturato.

Non ci sono garanzie che quanto sopra regex è corretta - non l'ho testato. Si dovrebbe almeno punto nella giusta direzione voi!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top