Integrate ccavenue payment gateway in rails app

Pramodkumar
3 min readSep 18, 2020

Things you need to setup first.

  1. Create a rails app
  2. Create a ccavenue account
    Get the MerchentID, Access Code and Working key from ccavenue account
    To get this login into ccavenue account and go to settings > Api keys section
  3. Save these keys in some notepad

Lets start

Step 1:
After setting up the account go to the resources > Web Integration Kits

Then go to “Download Integration Kits” tab and download the ruby on rails kit

Extract the file you will see four files in the folder
1. ccavRequestHandler.html.erb
2. ccavResponseHandler.html.er
3. crypto.rb
4. dataFrom.html.erb

Step 2:
Create folder “services” in <project_folder>/app/services
Add the crypto.rb file there

Step 3:
Add Routes with resources as “transactions” and a individual route inside it as “response_handler”

Step 4:
Now create a controller “TransactionsController” and add three methods
“new”, “create” and “response_handler” and save as “transactions_controller.rb”

Step 5 :
Create a new folder “transactions” in views and add three new views with name “new.html.erb”, “create.html.erb” and “response_handler.html.erb”

Step 6:
Copy the form data from the integration kit dataFrom.html.erb (this was downloaded in step 1) and add it in new.html.erb file.

Now Replace the <MERCHENT_ID> with the id you got from ccavenue
(For testing purpose keep the rest data same)

And replace the Redirect URL and Cancel url with the response handler routes created in step 3

Step 7:
Copy the data from ccavRequestHandler.html.erb (this was downloaded in step 1) and add it in the create.html.erb file
Replace the “working_key” and the “access_code” from the key which you received from ccavenue
Note: Don’t add anything in merchentData

Step 8:
Copy the data from ccavResponseHandler.html.erb (this was downloaded in step 1) and add it in the response_handler.html.erb file

That’s it
Now hit the form url in browser to load the form
URL: “<domain_url>/transactions/new”

You will load payment page something like this.

Click on checkout at the bottom of the page to initiate the payment

Your payment page will load

Few things to note
1. Use the domain url which is registered in ccavenue as there is domain url check.
2. Minimum amount is Rs 1.
3. If you want to access payment gateway from you local you will need test account which you will get by requesting to customer care.

--

--