Hi,
I have developed an application which needs payment gateway. I have already worked on "Paypal". It was successful and now i need to integrate another payment gateway that is "ccavenue". Can anybody help me how to integrate that one?
Thanks.
-
DO you have the documentation from CCAvenue and what is the exact help you needed on this? – nprd May 21 '14 at 17:19
-
I did not have any document from ccavenue.Please share me if any documents or any example on ccavenue..This is my mailId: kmadhu1423@gmail.com – Madhu May 26 '14 at 04:56
6 Answers
I was searching for the SDK as they have mentioned here that IOS/Android/Windows SDKs are available. But did not find anything. Finally I drafted an email to CCAvenue tech. support team.
Then had call with them and this is what they said:
- We need to have actual merchant account to get the login credentials to download the SDKs.
- They do not provide any sandbox testing environment.
- The process is, they will verify the merchant account by merchant's website and other entered details.
- Once they are done with verification, they send an activation email to merchant's registered email address.
- Once merchant activates his account, he will get the login credentials to download the SDK.
- There are two types of subscription: Free and privileged.(Refer their website to know more)
- With SDK, if merchant has free plan then only INR and USD currencies are supported. If merchant wants to add support for any other currency then he will have to request CCAvenue for the same. CCAvenue team will verify with the concerned banks for it, if banks allow the transactions then new currency can be activated by paying Rs. 5000 for each.
- If merchant has privileged plan, then along with INR, merchant can select any 4 currencies from the supported 27 currencies. If merchant wants more, then he can purchase currency by paying Rs. 5000 for each.

- 603
- 1
- 8
- 18
-
@hello BHumi, does it working perfect ? i have to implement in my app, can you please provide me demo of this Payment Gateway ? – Mehul Oct 16 '15 at 10:06
-
5Hi, I got the registered account details from my client who is the actual merchant for CCAvenue. I got the SDK link after login in the CCAvenue dashboard... but I still have to integrate the SDK and study more. I will post the demo as soon as I integrate it. But if you have the login detail of merchant then you can find the SDK links from your M.A.R.S. account under the Resources > Web Integration Kit section. – Bhumi Goklani Oct 17 '15 at 12:13
-
Thank you very much. yes i am integrating it. whenever i need support/help i will surely contact you. – Mehul Oct 19 '15 at 06:49
-
Hi @Mehul can you explain the integration part of ccavanue.. i am not getting clear idea about that – Mahe Dec 11 '15 at 06:50
-
@Mahe, Now,Payment integration is done from server side, so i have not used this.And i did not implemented CCAvenue, i just tried to integrate it,but then after my client refuse it as it complicated and complex. – Mehul Dec 16 '15 at 12:03
-
@Mahe have you integrated ccAvenue in iOS please provide steps or demo . I cant not integrated it..thanks – user100 Jun 13 '16 at 07:09
-
4Hi Everyone I am preparing a document for whole process of CCAvenue integration including what you need to do on your server and what kind of server you will need. I will share a demo project soon. CCAvenue has not created any clearly understandable document but I have gathered information by calling them over support team. – Bhumi Goklani Jul 08 '16 at 04:38
-
2Hi All Here is the sample code for Non-seamless SDK for CCAvenue: https://www.dropbox.com/s/20x77jffyh6ydyo/Non-Seamless.zip?dl=0 When you will run this code, you will see a form. Those details will be dynamic and merchantID you will get from CCAVenue. – Bhumi Goklani Aug 03 '16 at 09:03
-
@BhumiGoklani dropbox.com/s/20x77jffyh6ydyo/Non-Seamless.zip?dl=0 Dropbox Link is not Working Now Plz check It, i need help – Avinash Vaghasiya Nov 18 '16 at 06:33
-
2New link: https://www.dropbox.com/s/blxvvxvtkamgneq/Non-Seamless.zip?dl=0 Note: Code update might be required while running in new xcode versions – Bhumi Goklani Feb 09 '18 at 08:40
-
Hello @BhumiGoklani,i am getting  ,added to RSA key.how to remove that – Krutarth Patel Oct 13 '18 at 13:19
Since the CCAvenue shows server side options we need to connect to web view and load the ccavenue gateway which is compatable with iphone screens. Here in Our application we need to do small things as follows
First create the html file and parameters related to your ccavenue gateway
<html>
<body>
<form name='form2' method='post' action='UR URL HERE'>
<input type="text" name='Merchant_Id'><br>
<input type="text" name='Amount'><br>
<input type="text" name='Order_Id'><br>
<input type="text" name='Redirect_Url'><br>
<input type="text" name='Checksum'><br>
<input type="text" name='billing_cust_name'><br>
<input type="text" name='billing_cust_address'><br>
<input type="text" name='billing_cust_address'><br>
<input type="text" name='billing_cust_tel'><br>
<input type="text" name='billing_cust_email'><br>
<input type="text" name='delivery_cust_name'><br>
<input type="text" name='delivery_cust_address'><br>
<input type="text" name='delivery_cust_tel'><br>
<input type="text" name='delivery_cust_notes'><br>
<input type="text" name='Merchant_Param'><br>
</form>
</body>
After that load the web view on your screen
NSURL *url = [NSURL URLWithString: @"https://www.ccavenue.com/shopzone/cc_details.jsp"];
webView.delegate = self;
webView.scalesPageToFit = YES;
NSString *strUsername = [[NSUserDefaults standardUserDefaults] objectForKey:@"userName"];
NSString *body = [NSString stringWithFormat: @"Merchant_Id=%@&Amount=%@&Order_Id=%@&Redirect_Url=%@&Checksum=%@&billing_cust_name=%@&billing_cust_address=%@&billing_cust_country=%@&billing_cust_tel=%@&billing_cust_email=%@&delivery_cust_name=%@&delivery_cust_address=%@&delivery_cust_tel=%@&delivery_cust_notes=%@&Merchant_Param=%@",@"XXXXX",@"10",@"123456",@"http://us2guntur.com/us2guntur/CCAvenueredirecturl.jsp",@"1234567890",@"Test",@"Hyderabad",@"India",@"1357896437",@"Test1000",@"Guntur",@"234567896",@"",@""];
NSLog(@"%@",body);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];
[webView loadRequest: request];

- 2,565
- 2
- 25
- 32
-
Have you done the same in android, if then how i can test the implementation in android , i would like to implement the payment gateway in android , why we need the html file , what is url should be passed in this action – Sankar Ganesh PMP Dec 09 '14 at 08:50
-
@Madhu.. What is the use of the HTML file, is it on the Device or the server.? – Bonnie Apr 10 '15 at 12:47
-
CCAvenue Payment Gateway Integration in Swift 3
First check this link "https://www.ccavenue.com/inapp_payments.jsp" for integration, what CCAvenue provides.
Kindly follow the below steps for implementing the Payment Gateway on your Mobile Application by Non Seamless Method :
1. Kindly make sure that your Public/Outgoing IP has been whitlisted on CCAvenue's end.
2. Place GetRSA and ccavResponseHandler files on your server.
3. In your App, mention the path of GetRSA file kept on your server
4. Call GetRSA from your app which is kept on your server for fetching the RSA public key.
5. Using the fetched public key merchant will encrypt parameters(amount,currency). To encrypt the RSA key, do following steps (From Step1 to Step8).
Step1: You have to download CCAvenue SDK from CCAvenue website and to download you must have to login using merchant account credential.
Step2: After login, to download SDK go to Resources->Mobile Integration Kit. See following screen shot.
Step3: To download, click on Download Integration Kits as shown in following screen shot. Before downloading choose Seamless or Non-Seamless. (Check details about this in document provided by CCAvenue)
Seamless: If a merchant is configured as seamless, then all the billing/shipping details including the payment options are accepted on the merchant page.
Non-Seamless: If a merchant is configured as non-seamless, then the Billing/Shipping details including the payment options are accepted on the CCAvenue's mobile page.
Step4: After downloading SDK kit, you have to copy folder "OpenSSL" to your project or else you can install "openssl" using pods also.
Step5: You will find 2 folders include and lib under Openssl/openssl-1.0.1i-iOS folder. Also under Build Settings of project go for Search Paths->Library, Search Paths, remove what is provided Users/test/desktop/.... and drag & drop include/ and lib/ this two folder. Also you have to do same thing for Paths->User Header Search Paths.
Stop6: Copy this two files (Files available in you downloaded SDK`s) to you project "CCTOOL & BASE64.
Step7: Using bridging header import "CCTool.h".
Step8: Finally encrypt your RSA key using the method which is present in "CCTool" file.
6. After encrypting the parameters you will post the encrypted value along with the other billing shipping details(if any) to the CCAvenue server via a browser(embedded webview) post. (If you didn`t able to convert all code from objective-c to swift, use objective-c file CCWEBVIEWCONTROLER)
7. The user will be redirected to the CCAvenue's billing shipping page where he will fill in the required details including the payment option.
8. After filling the required details he will be redirected to the bank page wherein he will authorize himself.
9. After authorization he will be redirected to CCAvenue and a response i.e. Success or failure will be sent to the merchant page which was configured as return url during registration.
10. You should then decrypt the response, which can then be parsed to get transaction status.
Note :
Access code and order ID should be the same as passed during the RSA call.
Order ID should always be unique
The transaction should hit the CCAvenue server within 60 seconds after receiving the RSA key.
Working key posted in ccavResponseHandler file should be corresponding to the Accesscode being posted to CCAvenue.

- 1,361
- 12
- 23
-
hi @Sagar Sukode im getting problem with CCTool.h how to convert it in swift please help me – Nandkishor mewara Apr 18 '18 at 12:29
CCAvenue's integration page shows only server side options.
So, you will have to implement this yourself. You can integrate CCAvenue's payment gateway on your server and open the payment page in a web view on the device. Since the server side implementation is in your control, you can send payment confirmation details via cookies the ways its done in OAuth.

- 10,385
- 2
- 35
- 58
I have followed all the steps of Sagar Sukode and integrated CCAvenue SUCCESSFULLY.
If anyone need CCWEBVIEWCONTROLER in swift 2.3 :-
In ViewDidLoad :
let rsaKey = getRsaKeyForCCAvenue()
//Encrypting Card Details
let myRequestString = "amount=\(AMOUNT)¤cy=\(CURRENCY)"
let ccTool = CCTool()
var encVal = ccTool .encryptRSA(myRequestString, key: rsaKey)
let charset = NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]").invertedSet
encVal = encVal.stringByAddingPercentEncodingWithAllowedCharacters(charset)
//Preparing for a webview call
let urlAsString = TRANS_URL
let encryptedStr = "\(KEY_MERCHANT_ID)=\(MERCHANT_ID)&\(KEY_ORDER_ID)=\(ORDER_ID)&\(KEY_REDIRECT_URL)=\(REDIRECT_URL)&\(KEY_CANCEL_URL)=\(CANCEL_URL)&\(KEY_ENC_VAL)=\(encVal)&\(KEY_CC_ACCESS_CODE)=\(CC_ACCESS_CODE)&\(KEY_BILLING_NAME)=""&\(KEY_BILLING_ADDRESS)=""&\(KEY_BILLING_ZIP)=""&\(KEY_BILLING_CITY)=""&\(KEY_BILLING_STATE)=""&\(KEY_BILLING_COUNTRY)=""&\(KEY_BILLING_TEL)=""&\(KEY_BILLING_EMAIL)="""
let myRequestData = encryptedStr.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
let request = NSMutableURLRequest(URL: NSURL(string: urlAsString)!)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
request.setValue("https://secure.ccavenue.com/", forHTTPHeaderField: "Referer")
request.HTTPMethod = "POST"
request.HTTPBody = myRequestData
ccWebView .loadRequest(request)
Method To get rsaKey :
func getRsaKeyForCCAvenue() -> String {
//Getting RSA Key
let rsaKeyDataStr = "\(KEY_CC_ACCESS_CODE)=\(CC_ACCESS_CODE)&\(KEY_ORDER_ID)=\(ORDER_ID)"
let requestData = rsaKeyDataStr.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
let rsaRequest = NSMutableURLRequest(URL: NSURL(string: RSA_KEY_URL)!)
rsaRequest .setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
rsaRequest.HTTPMethod = "POST"
rsaRequest.HTTPBody = requestData
let rsaKeyData: NSData? = try? NSURLConnection.sendSynchronousRequest(rsaRequest, returningResponse: nil)
var rsaKey = NSString(data: rsaKeyData!, encoding: NSASCIIStringEncoding)
let strNewRSA = rsaKey as! String
let range: Range<String.Index> = strNewRSA.rangeOfString("<")!
let index: Int = strNewRSA.startIndex.distanceTo(range.startIndex)
rsaKey = strNewRSA.substringToIndex(range.startIndex)
rsaKey = rsaKey?.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet())
rsaKey = "-----BEGIN PUBLIC KEY-----\n\(rsaKey!)\n-----END PUBLIC KEY-----\n"
return rsaKey as! String
}
Web View Delegate method to read the response :
func webViewDidFinishLoad(webView: UIWebView) {
let webString = webView.request?.URL?.absoluteString
if (webString! as NSString).containsString("PaymentCCAvenue/ReturnAPI") {
let html = webView .stringByEvaluatingJavaScriptFromString("document.documentElement.outerHTML")
if (html! as NSString).containsString("Success") {
}
else if (html! as NSString).containsString("Failure") {
}
else {
}
}
}
Just check for the response strings from the back end developers to add conditions in webViewDidFinishLoad.

- 4,837
- 5
- 31
- 46
-
-
-
My loop is not going inside this check if (webString! as NSString).containsString("PaymentCCAvenue/ReturnAPI"). Can you please help me out in this. What can be the error ?? – Hakikat Singh Jan 25 '18 at 05:55
For anyone who needs an answer for Swift 3.2 here is the code. Took me a while to convert to it. But here you go. Before that let me explain in case things are still unclear.
(1) you place your GetRSA file on the server and then copy and paste that link in your app as "rsaKeyUrl".
(2) The "getRsaKeyForCCAvenue()" function makes a call to that file placed on the server, the IP of which has to be whitelisted beforehand.
(3) The "getRSA" file makes a request to CCavenue on the link that is already in it.(This is important as CCAvenue only accepts requests from whitelisted IP's and this enables all the requests to be routed from just one IP.
(4) CCAvenue checks the details and processes the request and sends the response and redirects to the payment page if everything checks.
(5) The redirection URL shall be the link of the "ccavResponseHandler" file which has your access code and translates the response.
THE CODE IN SWIFT 3.2
1) Get RSA Key
func getRsaKeyForCCAvenue() -> String {
//Getting RSA Key
let rsaKeyDataStr = "access_code=\(accessCode)&order_id=\(orderId)"
let requestData = rsaKeyDataStr.data(using: String.Encoding.utf8, allowLossyConversion: false)
var request = URLRequest(url: URL(string: rsaKeyUrl)!)
let rsaRequest = NSMutableURLRequest(url: URL(string: rsaKeyUrl)!)
rsaRequest .setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
rsaRequest.httpMethod = "POST"
rsaRequest.httpBody = requestData
let rsaKeyData: NSData? = try? NSURLConnection.sendSynchronousRequest(rsaRequest as URLRequest, returning: nil) as NSData
var rsaKey = NSString(data: rsaKeyData! as Data, encoding: String.Encoding.ascii.rawValue)
rsaKey = rsaKey?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) as NSString?
// rsaKey = rsaKey?.trimmingCharacters(in: NSCharacterSet.newlines) as? NSString
rsaKey = "-----BEGIN PUBLIC KEY-----\n\(rsaKey!)\n-----END PUBLIC KEY-----\n" as NSString
print(rsaKey)
return rsaKey! as String
}
2) Code after super.viewDidLoad()
let rsaKey = getRsaKeyForCCAvenue()
//Encrypting Card Details
let myRequestString = "amount=\(VQ_MOUNT)¤cy=\(currency)"
let ccTool = CCTool()
var encVal :NSString = ccTool.encryptRSA(myRequestString, key: (rsaKey as NSString) as String!) as NSString
let charset : String = "!*'();:@&=+$,/?%#[]"
encVal = CFURLCreateStringByAddingPercentEscapes(nil, encVal as CFString, nil, (charset as CFString), CFStringBuiltInEncodings.UTF8.rawValue) as String as NSString
//Preparing for a webview call
let urlAsString = TRANS_URL
var encryptedStr = "merchant_id=\(merchantId)&order_id=\(orderId)&redirect_url=\(redirectUrl)&cancel_url=\(cancelUrl)&enc_val=\(encVal)&access_code=\(accessCode)"
let myRequestData = NSData.init(bytes: encryptedStr.cString(using: .utf8), length: encryptedStr.characters.count) as Data
let request = NSMutableURLRequest(url: URL(string: urlAsString)!)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
request.setValue(TRANS_URL, forHTTPHeaderField: "Referer")
request.httpMethod = "POST"
request.httpBody = myRequestData
viewWeb.loadRequest(request as URLRequest)
3) Finally the webViewDidFinishLoad() implementation
func webViewDidFinishLoad(_ webView: UIWebView) {
let webString = webView.request?.url?.absoluteString
if ((webString as NSString?)?.range(of: "/ccavResponseHandler.jsp"))?.location != NSNotFound {
let html: String? = webView.stringByEvaluatingJavaScript(from: "document.documentElement.outerHTML")
var transStatus = "Not Known"
if (((html as NSString?)?.range(of: "Aborted"))?.location != NSNotFound) || (((html as NSString?)?.range(of: "Cancel"))?.location != NSNotFound) {
transStatus = "Transaction Cancelled"
}
else if (((html as NSString?)?.range(of: "Success"))?.location != NSNotFound) {
transStatus = "Transaction Successful"
}
else if (((html as NSString?)?.range(of: "Fail"))?.location != NSNotFound) {
transStatus = "Transaction Failed"
}
var controller = storyboard?.instantiateViewController(withIdentifier: "CCResultViewController") as? CCResultViewController
controller?.transStatus = transStatus
controller?.modalTransitionStyle = .crossDissolve
present(controller ?? UIViewController(), animated: true)
}else {
print("Something went wrong...")
}
}

- 486
- 1
- 6
- 16
-
I am trying this code everything works fine all the transactions occurs but in func webViewDidFinishLoad(_ webView: UIWebView) loop always goes in else and prints "Something went wrong...". Do you have any idea ?? – Hakikat Singh Jan 25 '18 at 05:53
-
@HakikatSingh Let me check and I'll get back to you in a day or two. – The Doctor Jan 25 '18 at 16:15
-
-