在CCAIOS中解密应用程序请求时出现问题

在CCAIOS中解密应用程序请求时出现问题,ios,swift,ccavenue,Ios,Swift,Ccavenue,我正在尝试在我的应用程序中实现支付网关。我遵循此答案,但得到以下错误: 我尝试过以下代码: private func encyptCardDetails(data: Data){ guard let rsaKeytemp = String(bytes: data, encoding: String.Encoding.ascii) else{ print("No value for rsaKeyTemp") return } rsaKey = rsaKeytemp rsaKey

我正在尝试在我的应用程序中实现支付网关。我遵循此答案,但得到以下错误:

我尝试过以下代码:

private func encyptCardDetails(data: Data){

guard let rsaKeytemp = String(bytes: data, encoding: String.Encoding.ascii) else{
    print("No value for rsaKeyTemp")
    return
}
rsaKey = rsaKeytemp
rsaKey = self.rsaKey.trimmingCharacters(in: CharacterSet.newlines)
rsaKey =  "-----BEGIN PUBLIC KEY-----\n\(self.rsaKey)\n-----END PUBLIC KEY-----\n"
print("rsaKey :: ",rsaKey)

let myRequestString = "amount=\(amount)&currency=\(getCurrency())"
let ccTool = CCTool()
var encVal = ccTool.encryptRSA(myRequestString, key: rsaKey)

encVal = CFURLCreateStringByAddingPercentEscapes(
    nil,
    encVal! as CFString,
    nil,
    "!*'();:@&=+$,/?%#[]" as CFString,
    CFStringBuiltInEncodings.UTF8.rawValue) as String?

let urlAsString = "https://secure.ccavenue.com/transaction/initTrans"
let encryptedStr = String(format:"merchant_id=%@&order_id=%@&redirect_url=%@&cancel_url=%@&enc_val=%@&access_code=%@", CC_AVENUE_MERCHANTID, self.orderId, CC_AVENUE_REDIRECTURL, CC_AVENUE_REDIRECTURL, encVal!,CC_AVENUE_ACCESSKEY)
print("access_code=\(CC_AVENUE_ACCESSKEY)")
print("order_id=\(self.orderId)")

let myRequestData = encryptedStr.data(using: String.Encoding.utf8)

request  = NSMutableURLRequest(url: URL(string: urlAsString)! as URL, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringCacheData, timeoutInterval: 30)
request?.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
request?.setValue(urlAsString, forHTTPHeaderField: "Referer")
request?.httpMethod = "POST"
request?.httpBody = myRequestData

print("\n\n\nwebview :: ",request?.url as Any)
print("\n\n\nwebview :: ",request?.description as Any)
print("\n\n\nwebview :: ",request?.httpBody?.description as Any)
print("\n\n\nwebview :: ",request?.allHTTPHeaderFields! as Any)

let session = URLSession(configuration: URLSessionConfiguration.default)
print("session",session)

session.dataTask(with: request! as URLRequest) {
    (data, response, error) -> Void in

    if let response = response as? HTTPURLResponse, 200...299 ~= response.statusCode{

        guard let data = data else{
            print("No value for data")
            return
        }

        // Create the delay here
        DispatchQueue.main.asyncAfter(deadline: .now()+1.0, execute: {
            self.viewWeb.loadRequest(self.request! as URLRequest)
        }
        print("data :: ",data)
    }else{
        print("into else")
        showAlertWithTitleWithMessage(message: "Unable to load webpage currently, Please try again later.")
    }
    }.resume()
}

任何帮助都将不胜感激。

此错误可能是由于访问代码不匹配造成的。请用您正在使用的访问代码交叉检查您的传出IP。正如我看到的,您正在使用旧版本的代码。向CCAVENCE索取Swift中更新版本的集成工具包。