CCAvenue Android Mobile
CCAvenue Android Mobile
For Android
Version 1.0
Statement of Confidentiality
This document contains information that is proprietary and confidential to Avenues India
Private Limited which shall not be disclosed, transmitted, or duplicated, used in whole or in
part for any purpose other than its intended purpose. Any use or disclosure in whole or in
part of this information without express written permission of Avenues India Private Ltd is
prohibited. Any other company and product names mentioned are used for identification
purposes only, and may be trademarks of their respective owners.
The CCAvenue mobile integration is designed to enable you to process payments through
mobile applications with protection from payment frauds and complexities related to
various regulations.
Steps:
1) Seamless:
If a merchant is configured as seamless then all the billing shipping details including the
payment option are accepted on the merchant page. A sample flow for the same is as
follows:
a) Merchant will design a screen from which he will accept all the required fields (billing
& shipping details) including the payment options and card details.
b) The required payment options can be fetched by making a JSON call to the CCAvenue
Server by passing required parameters.
c) Once the user enters the required billing and shipping values and the payment option,
a server to server call to the JSP(GetRSA) will be initiated which is kept on the
merchant server for fetching the rsa public key.
d) Availing the fetched public key, merchant will encrypt parameters: Amount, Currency,
Card Number, Expiry Year, Expiry Month and CVV.
e) After encrypting the parameters, merchant will post the billing/shipping details and
the encrypted value to the CCAvenue server via a browser(embedded webview) post.
The user will then be redirected to the selected gateway without displaying
CCAvenue's Billing/Shipping screen.
f) Once the user authenticates himself on the bank page, the response will be sent by
the CCAvenue server to the merchant server on the return URL that was configured
at the time of registration or the URL that was sent in the request.
g) Merchant should then decrypt the response, which can then be parsed to get the
transaction status.
2) Non-Seamless:
a) Merchant will call JSP(GetRSA) which is kept on the merchant server for fetching the
rsa public key.
b) Availing the fetched public key, merchant will encrypt parameters: Amount, Currency.
c) After encrypting the parameters, merchant will post the encrypted value along with
the other billing shipping details, if any, to the CCAvenue server via a
browser(embedded webview) post.
d) The user will be redirected to the CCAvenue's billing shipping page where he will fill
in the required details including the payment option.
e) After filling the required details, the user will be redirected to the bank page on
Android Mobile Integration Document Page 5
which he will authorize himself.
f) After authorization, the user will be redirected to CCAvenue and a response i.e.
Success or failure will be sent to the merchant page which was configured as the
return URL during registration.
g) Merchant should then decrypt the response, which can then be parsed to get the
transaction status.
Pre-requisites:
URLs:
To load payment options and cards, merchant will initiate a JSON call to the server with the
below specified parameters:
1) access_code
2) currency
3) amount
The below code does a server to server call for fetching JSON data. After fetching the
required data, it is then converted into list objects. The resulting list objects are used to
populate values in the spinner object as shown below.
Note: The parameters such as accessCode, amount, currency are fetched from previous
After populating the list, the values can be populated in the spinner object using the
following code
Now when a user selects an item from the payment option dropdown, a corresponding list
needs to be populated in the card type dropdown. The following listener is to be added for
the same.
Once the user enters the required billing shipping details and selects a payment option as
well as the related card type, he needs to click on the Pay button. The onclick event of the
pay button will pass the values to the next activity in the following way.
The first thing to do in the web view activity is to fetch RSA public key by requesting the page
that is kept on merchant server. To fetch RSA public key in app, parameters(accessCode and
orderId) are to be sent to the JSP(GetRSA). The GetRSA JSP will then initiate a server to
server call to the CCAvenue server with those parameters and will get an RSA public key in
response, which will be forwarded to the app. Using the RSA key, the following parameters
are to be encrypted:
1) Card Number(Only in case of credit/debit cards)
2) Card Expiry Month(Only in case of credit/debit cards)
3) Card Expiry Year(Only in case of credit/debit cards)
4) Card CVV(Only in case of credit/debit cards)
String vResponse =
sh.makeServiceCall(mainIntent.getStringExtra(AvenuesParams.RSA_KEY_URL),ServiceHandle
r.POST, params);
if(!ServiceUtility.chkNull(vResponse).equals("")
&& ServiceUtility.chkNull(vResponse).toString().indexOf("ERROR")==-
1){
// form a string including all the above specified parameters as given in the
integration kit
encVal = RSAUtility.encrypt(vEncVal.substring(0,vEncVal.length()-1), vResponse);
}
Once the details are encrypted those are sent in the request while opening up a web view.
After forming the parameter string, it needs to be posted to the url using the postUrl
method of the webview as shown above.
Once the webview is successfully opened, the user will be redirected to the bank page. After
completing the authorization process, the bank will send the response to the CCAvenue
Server. The response will then be parsed to determine the status and the same will be
posted to the return URL. To read the response, merchant needs to decrypt the parameters
using the provided AesCryptUtil class. To monitor the flow and read the html source of the
page, a listener must be added in the app.
@SuppressWarnings("unused")
class MyJavaScriptInterface{
@JavascriptInterface
public void processHTML(String html){
// process the html as needed by the app
}
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String
failingUrl) {
// raise error
}
});
The above specified listener is to be invoked only on the merchant page. In order to achieve
that, an anonymous class WebViewClient is to be set using the setWebViewClient method of
the webview. The method onPageFinished should be overridden to specify our
implementation, which will check for the URL and will then invoke the javascript method to
get the html of that page as shown above.
After determining the status of the transaction, an acknowledgement page can be displayed
to the user by sending these parameters to another activity as shown below.