2016-10-21 41 views
-1

我是新來的CCAvenue集成,我想通過所有的客戶數據到webview,但我不知道如何通過它。誰能幫我解決?如何在iOS中的CCAvenue集成中將數據傳遞給webview?

+0

請先閱讀[我如何問一個很好的問題(http://stackoverflow.com/help/how-to-ask)和[如何創建一個最小的,完整的,並且可驗證的示例]( http://stackoverflow.com/help/mcve)來改善你的問題。這不是「浪費時間」。 –

回答

2

請嘗試以下代碼viewDidLoadCCAvenue webview控制器,在這裏您還可以通過帳單地址,如果您需要在您的應用程序。

//Getting RSA Key 
     NSString *rsaKeyDataStr = [NSString stringWithFormat:@"access_code=%@&order_id=%@",accessCode,orderId]; 
     NSData *requestData = [NSData dataWithBytes: [rsaKeyDataStr UTF8String] length: [rsaKeyDataStr length]]; 
     NSMutableURLRequest *rsaRequest = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: rsaKeyUrl]]; 
     [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]; 
     NSLog(@"%@",rsaKey); 

     //Encrypting Card Details 
     NSString *myRequestString = [NSString stringWithFormat:@"amount=%@&currency=%@",amount,currency]; 
     CCTool *ccTool = [[CCTool alloc] init]; 
     NSString *encVal = [ccTool encryptRSA:myRequestString key:rsaKey]; 
     encVal = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, 
                         (CFStringRef)encVal, 
                         NULL, 
                         (CFStringRef)@"!*'();:@&=+$,/?%#[]", 
                         kCFStringEncodingUTF8)); 

     //Preparing for a webview call 
     NSString *urlAsString = [NSString stringWithFormat:@"https://secure.ccavenue.com/transaction/initTrans"]; 
     NSString *Name=[NSString stringWithFormat:@"%@ %@",billing_Fname,billing_Lname]; 
     NSString *encryptedStr = [NSString stringWithFormat:@"merchant_id=%@&order_id=%@&redirect_url=%@&cancel_url=%@&enc_val=%@&access_code=%@&billing_name=%@&billing_address=%@&billing_city=%@&billing_state=%@&billing_zip=%@&billing_country=India&billing_tel=%@&billing_email=%@&delivery_name=%@&delivery_address=%@&delivery_city=%@&delivery_state=%@&delivery_zip=%@&delivery_country=India&delivery_tel=%@",merchantId,orderId,redirectUrl,cancelUrl,encVal,accessCode,Name,billing_address,billing_city,billing_state,billing_zip,billing_tel,billing_email,Name,billing_address,billing_city,billing_state,billing_zip,billing_tel]; 

     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]; 
     [_viewWeb loadRequest:request]; 
+0

我這樣做,但它給我錯誤 – NilamPari

+0

什麼是錯誤? –

+0

明白了......我已經完成了這個 – NilamPari

相關問題