【问题标题】:Revert back to app after CCAvenue actionCCAvenue 操作后恢复到应用程序
【发布时间】:2017-03-09 07:52:26
【问题描述】:

下面是我的代码集成 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=%@&currency=%@",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];

}

【问题讨论】:

    标签: ios objective-c ccavenue


    【解决方案1】:
    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";
    
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-14
      • 1970-01-01
      相关资源
      最近更新 更多