Hi guys, today we will learn about how to implement CCAvenue payment gateway in an iOS application.
Before starting to code first we need to know what a payment gateway is
A payment gateway is a merchant service provided by an e-commerce application service provider that authorizes credit card or direct payments processing for e-businesses, online retailers, bricks, and clicks, or traditional brick and mortar.
Thus, its enough for us now. Let’s start by following the instructions below.
STEPS TO INTEGRATE
->Download & Unzip
1. Please download the framework from below link.
https://ccavenue.ae/downloads_mcpg/mobile_sdk/CCAvenueSDK_iOS_V2.0.zip
2. Download CCAvenueSDKiOS.zip file for iOS. This contains the framework file, bundle
resources file, response handler file (ResponseHandler.jsp), RSA file (GetRSA.jsp) and
a demo app (Swift & Objective-C).
3. Unzip the downloaded CCAvenueSDKiOS.zip file anywhere on the file system.
->Upload GetRSA.jsp & ResponseHandler.jsp on Merchant Server
1. GetRSA.jsp kept on the merchant server for fetching the RSA Public Key and send the file
path URL with the request.
2. Also, ResponseHandler.jsp kept on the merchant server for the response will be sent by the
CCAvenue server to the merchant server on the return URL that was configured at the URL
that was sent in the request. Merchant should then decrypt the response, which can then be
parsed to get all transaction details and will send back to the merchant app.
->Include the SDK in Xcode Project
1. Drag the CCAvenueSDK.framework to Frameworks & CCAvenueSDK.bundle under
project in project navigator.
2. Create a new group Frameworks if it does not exist.
3. Choose to Create groups for any added folders. Make sure to select Copy files if
needed.
4. For Swift Projects add the following:
#import <CCAvenueSDK/InitialViewController.h> to the Bridging-Header.h
Note: Ensure linked once in the Linked Framework and Libraries or just drag the
CCAvenueSDK.framework to Embedded Binaries in the general tab in the project
settings.
->Please Insert the following XML source code snippet into the body of your Info.plist file just before the final.
</dict>element
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
->Now Add The Below Code In Your Payment Controller.
1. Import the CCAvenue Library
1 |
#import <CCAvenueSDK/InitialViewController> |
2. Initialize InitialViewController and pass values in Initializer for SDK.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
let initialVC = InitialViewController.init(OrderId:”1234” , merchantId:”79562” , accessCode:”ABHGH784GFDE”, amount:”10.00”, currency:”AED”, rsaKeyUrl:”www.abc.ae/RSA.jsp”, redirectUrl:”www.abc.ae/Redirect.jsp”, cancelUrl:”www.abc.ae/Cancel.jsp”, showAddress:”Y”, billingName:”ABC”, billingAddress:”Star City”, billingCity:”Dubai”, billingState:”Dubai”, billingCountry:”United Arab Emirates”, billingTel:”+971 1234567890”, billingEmail:”test@gmail.com” deliveryName:”XYZ”, deliveryAddress:”Internet City”, deliveryCity:”Dubai”, deliveryState:”Dubai”, deliveryCountry:”United Arab Emirates”, deliveryTel:”+971 9876543210” promoCode:”PROMO1270” merchant_param1:"Param 1” merchant_param2:"Param 2” merchant_param3:"Param 3” merchant_param4:"Param 4" merchant_param5:"Param 5” useCCPromo:“Y”) |
3. Initialize InitViewContollerDelegate for last class where you start SDK.
1 |
class ViewController: UIViewController, InitialViewControllerDelegate |
4. Assign an instance of the class that’s adopted the delegate protocol to its delegate property.
1 |
initialVC?.delegate = self; |
5. Present Initial controller of SDK to process payment.
1 |
self.present(initialVC!, animated: true, completion: nil); |
->Finish SDK and get Response from SDK.
1. Call delegate method of InitialViewConrollerDelegate.
1 2 3 4 5 6 7 |
self.present(initialVC!, animated: true, completion: nil); func getResponse(_ responseDict_: NSMutableDictionary!) { print("Response in merchant app :- \(responseDict_)”); // here SDK will closed and you get response in Dictionary and use for further process } |