I get the response as follow:
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
How can I get original text string? This is my code for Parsing the 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"
开发者_如何学JAVA "&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");
}
It is not encrypted, it is URL Encoded, that is troublesome characters are replaced with their hex values. Ex: '%2d' is '-'.
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 output:
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
精彩评论