以下是我整合CCAvnenue的代码,我搜索过但没有得到任何有关如何在交易失败,取消交易和成功交易等操作后恢复应用程序的工作答案。
//Getting RSA Key
NSString *rsaKeyDataStr = [NSString stringWithFormat:@"access_code=%@&order_id=%@",access_code,order_id];
NSData *requestData = [NSData dataWithBytes: [rsaKeyDataStr UTF8String] length: [rsaKeyDataStr length]];
NSMutableURLRequest *rsaRequest = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:rsa_key_url]];
[rsaRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[rsaRequest setHTTPMethod: @"POST"];
[rsaRequest setHTTPBody: requestData];
NSData *rsaKeyData = [NSURLConnection sendSynchronousRequest: rsaRequest returningResponse: nil error: nil];
NSString *rsaKey = [[NSString alloc] initWithData:rsaKeyData encoding:NSASCIIStringEncoding];
rsaKey = [rsaKey stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
rsaKey = [NSString stringWithFormat:@"-----BEGIN PUBLIC KEY-----\n%@\n-----END PUBLIC KEY-----\n",rsaKey];
//Encrypting Card Details
NSString *myRequestString = [NSString stringWithFormat:@"amount=%@¤cy=%@",PayText.text,currency];
CCTool *ccTool = [[CCTool alloc] init];
NSString *encVal = [ccTool encryptRSA:myRequestString key:rsaKey];
encVal = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)encVal,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 ));
[ProgressHUD show:@"Please wait..."];
//Preparing for a webview call
NSString *urlAsString = [NSString stringWithFormat:@"https://secure.ccavenue.com/transaction/initTrans"];
NSString *encryptedStr = [NSString stringWithFormat:@"merchant_id=%@&order_id=%@&redirect_url=%@&cancel_url=%@&enc_val=%@&access_code=%@&billing_name=%@&billing_address=%@&billing_country=India&billing_tel=%@&billing_email=%@&billing_zip=110092&billing_state=Delhi&billing_city=New Delhi",merchant_id,order_id,redirect_url,cancel_url,encVal,access_code,billing_name,billing_address,billing_tel,billing_email];
NSData *myRequestData = [NSData dataWithBytes: [encryptedStr UTF8String] length: [encryptedStr length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: urlAsString]];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setValue:urlAsString forHTTPHeaderField:@"Referer"];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: myRequestData];
[_Web loadRequest:request];
}
答案 0 :(得分:0)
NSString *string = webView.request.URL.absoluteString;
if ([string rangeOfString:@"/ccavResponseHandler.php"].location != NSNotFound) {
NSString *html = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"];
NSString *transStatus = @"Not Known";
if (([html rangeOfString:@"Aborted"].location != NSNotFound) ||
([html rangeOfString:@"Cancel"].location != NSNotFound)) {
transStatus = @"Transaction Cancelled";
}
else if (([html rangeOfString:@"Success"].location != NSNotFound)) {
transStatus = @"Transaction Successful";
}
else if (([html rangeOfString:@"Fail"].location != NSNotFound)) {
transStatus = @"Transaction Failed";
}
}