2011-09-22 84 views
1

我得到的迴應如下:響應加密問題

TIMESTAMP=2011%2d09%2d22T10%3a20%3a24Z&CORRELATIONID=fa0181684fd81&ACK=Success 
&VERSION=65%2e0&BUILD=2133933&AMT=0%2e12&CURRENCYCODE=USD&AVSCODE=X&CVV2MATCH=M 
&TRANSACTIONID=6PT23270XK626941N" in this encrypted format 

我怎樣才能得到原始文本字符串?這是我解析URL的代碼:

NSString *parameterString = [[NSString stringWithFormat:@"USER=mercha_1316582882_biz_api1.ifuturz.com" 
           "&PWD=1316582974" 
           "&SIGNATURE=Az-qrCDOk-pVcMVvJLOJY7DrGESBAgSH4RGOILESJSsYaBlWVZ3mNfJB" 
           "&METHOD=DoDirectPayment" 
           "&CREDITCARDTYPE=Visa" 
           "&ACCT=%@" 
           "&EXPDATE=092016 " 
           "&CVV2=111" 
           "&AMT=%@" 
           "&FIRSTNAME=%@" 
           "&LASTNAME=%@" 
           "&STREET=%@" 
           "&CITY=%@" 
           "&STATE=%@" 
           "&ZIP=%@" 
           "&COUNTRYCODE=IN" 
           "&CURRENCYCODE=USD" 
           "&PAYMENTACTION=Sale" 
           "&VERSION=65.0", 
           txtCreditCardNo.text, 
           strAmount, 
           txtName.text, 
           txtName.text, 
           txtAddress.text, 
           txtCity.text, 
           txtState.text, 
           txtZipCode.text 
           ] retain]; 

NSLog(@"Soap : %@",parameterString); 

NSURL *url = [NSURL URLWithString:@"https://api-3t.sandbox.paypal.com/nvp"]; 

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; 
NSString *msgLength = [NSString stringWithFormat:@"%d", [parameterString length]]; 
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
[theRequest setHTTPMethod:@"POST"]; 
[theRequest setHTTPBody: [parameterString dataUsingEncoding:NSUTF8StringEncoding]]; 


NSError *err; 
NSURLResponse *resp; 
NSData *response = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&resp error:&err]; 

if (resp != nil) { 



    NSString *stringResponse = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; 

    NSLog(@"---------------------- %@",stringResponse); 

    SBJSON *jsonParser = [SBJSON new]; 
    NSMutableDictionary *json = [[NSMutableDictionary alloc] init]; 
    json = [jsonParser objectWithString:stringResponse error:NULL]; 
    NSLog(@"\n \n JSN Dic : %@",[json description]); 

} else if (err != nil) { 

    NSLog(@"\n \n Nill"); 

} 
+0

你能解釋一下你想要做更準確的... – Nekto

+0

這種反應我得到什麼: TIMESTAMP = 2011%2d09%2d22T10%3A20%3a24Z 及的correlationID = fa0181684fd81 &ACK =成功 &VERSION = 65%2E0 &BUILD = 2133933 &AMT = 0%2E12 &CURRENCYCODE = USD &AVSCODE = X &CVV2MATCH = M &TRANSACTIONID = 6PT23270XK626941N」 ,我想,這種反應: TIMESTAMP = 2011-09-22:10:20:3 24Z &的correlationID = fa0181684fd81 &ACK =成功 &VERSION = 65.0 &BUILD = 2133933 &AMT = 0.12 &CURRENCYCODE = USD &AVSCODE = X &CVV2MATCH = M &TRANSACTIONID = 6PT23270XK626941N」 手段如何刪除字符,如 '%2' 等... – Sonu

回答

1

它沒有加密,它是URL編碼的,那是麻煩的字符被替換爲它們的十六進制值。例如:'%2d'是' - '。

NSString *stringToDecode = @"TIMESTAMP=2011%2d09%2d22T10%3a20%3a24Z&CORRELATIONID=fa0181684fd81&ACK=Success&VERSION=65%2e0&BUILD=2133933&AMT=0%2e12&CURRENCYCODE=USD&AVSCODE=X&CVV2MATCH=M&TRANSACTIONID=6PT23270XK626941N"; 

NSString *decodedString = [stringToDecode stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 

NSLog(@"decodedString: %@", decodedString); 

的NSLog輸出:

decodedString: TIMESTAMP=2011-09-22T10:20:24Z&CORRELATIONID=fa0181684fd81&ACK=Success&VERSION=65.0&BUILD=2133933&AMT=0.12&CURRENCYCODE=USD&AVSCODE=X&CVV2MATCH=M&TRANSACTIONID=6PT23270XK626941N