ios - CCAvenue“遇到错误。错误

标签 ios objective-c

我已经将 CCAvenue 集成到我的应用程序中,但问题是当代码被命中时

https://secure.ccavenue.com/transaction/initTrans

下面是代码:

NSString *encryptedStr = [NSString stringWithFormat:@"Merchant_Id=%@&Order_Id=%@&redirect_url=%@&cancel_url=%@&enc_val=%@&access_code=AVSB00EA86CN75BSNC&billing_name=%@&billing_address =%@&billing_city=%@&billing_state=%@&billing_zip=%@&billing_country=%@&billing_email=%@&billing_tel=%@",MerchantID,_order_id,redirectUrl,cancelUrl,encVal,self.billing_name,self.billing_address,self.billing_city,self.billing_state,self.billing_zip,self.billing_country,self.billing_email,self.billing_tel];
NSData *myRequestData = [NSData dataWithBytes: [encryptedStr UTF8String] length: [encryptedStr length]];
NSMutableURLRequest *requestN = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: urlAsString]];
[requestN setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[requestN setValue:urlAsString forHTTPHeaderField:@"Referer"];
[requestN setHTTPMethod: @"POST"];
[requestN setHTTPBody: myRequestData];
[self.webView loadRequest:requestN];

每次它回来

Error Encountered.ERROR!! Problem in decrypting application request

最佳答案

this is the solution for non-shameless ... I think only difference is regarding the payment details(non-shameless and shameless) ... only . this is working for me I hope it will resolve ur issue ... and check that are u hitting the ccavenue server through ur mobile with in 120 sec or not after u getting the rsa key.u need to hit the ccavenue server(with in 120 sec) for billing page otherwise it will expire.

试试这个:

来自服务器:

once u hit the ccavenue sever for RSA key with ur accesscode and orderID

u will get : rsa key for ur transaction.

u need to encrypt the key with base64 and AES-256 format.

before u encrypt u need to remove some unnecessary data in a key

1.double quotes in a key

  1. \n in the key
  2. \ in a key
   // removing double quates
            NSString * newReplacedString2 = [rsaKey stringByReplacingOccurrencesOfString:@"\"" withString:@""];

            NSLog(@"%@",rsaKey);

            //removing \n in the key
            NSString * newReplacedString = [newReplacedString2 stringByReplacingOccurrencesOfString:@"\\n" withString:@""];

            NSLog(@"%@",rsaKey);
        //removing \ in the key
        NSString * newReplacedString1 = [newReplacedString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
        NSLog(@"%@",newReplacedString1);

//and u need to divide the key for every 64 bits 

    NSString * abc = [NSString stringWithFormat:@"%@", newReplacedString1];
    NSMutableString *sss=[NSMutableString new];
    int j=(int)([abc length]/63);
    for (int i=0; i<=j; i++) {
        int k= i*63;
        NSString * newString;
        if (i != j) {
            newString = [abc substringWithRange:NSMakeRange(k,63)];
            NSLog(@"%lu",(unsigned long)newString.length);
            newString=[NSString stringWithFormat:@"%@",newString];
        }else{
            newString = [abc substringWithRange:NSMakeRange(k,[abc length]-k)];
            NSLog(@"%lu",(unsigned long)newString.length);
            if (newString.length !=0)
                newString=[NSString stringWithFormat:@"%@",newString];
        }
        if (newString.length !=0)
            [sss appendString:[NSString stringWithFormat:@"%@\n",newString]];
    }
    NSLog(@"%@",sss);

     //as per the documentation u can follow the process 
    rsaKey = [NSString stringWithFormat:@"-----BEGIN PUBLIC KEY-----\n%@-----END PUBLIC KEY-----\n",sss];
    NSLog(@"%@",rsaKey);

    //Encrypting Card Details
        NSString *myRequestString = [NSString stringWithFormat:@"amount=%@&currency=%@",amount,currency];
        CCTool *ccTool = [[CCTool alloc] init];


    NSLog(@"emcrpted data %@",[ccTool encryptRSA:myRequestString key:rsaKey]);

关于ios - CCAvenue“遇到错误。错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43929323/

相关文章:

android - ionic 框架拍摄实时视频

objective-c - 弹出式按钮单元使用 Cocoa Binding 返回 bool 值

ios - 在具有不同像素格式的 Metal 纹理之间复制

iphone - 在核心数据后台填充期间处理应用程序终止

objective-c - Objective C - 数据绑定(bind)?

ios - 'filter' 与嵌套过滤器的使用不明确

ios - 视频不再在 iOS 8 WebbApp 独立模式下播放,有人找到解决方案吗?

ios - 有没有其他方法来转换矩形的坐标?

ios - Swift 每隔一个项目追加到数组

iphone - iPhone 上的长双倍