Verve Android SDK

The Verve Payment SDK for Android lets you easily add payment capability into your Android application.

To download the SDK, visit the github repository here [Android SDK Download] URL. The steps below describe how you can go about integrating the SDK into your application.

Registering your application on the Developer Console

To begin integration with the Verve SDK, you have to register your application on the Developer Console. To do this, follow the steps below:

  1. Go to the Developer Console, sign-up if you haven’t. After signing-up a confirmation e-mail would be sent to you and you would have to click the link in it to confirm your e-mail. For security reasons, your application would be vetted and an e-mail would be sent to you when your application is approved.
  2. If you already have an approved login details, log-in to gain access to your console.
  3. To begin, click on “Dashboard” at the top of the page and click the “Create your first App” button.devConHome
  4. The “New App” form comes up. Fill in the details correctly. Remember to choose “Mobile Application” for the “Application Type” field.NewApp
  5. After submitting the form, you would immediately get a sandbox Client ID. You should use this for test purposes.
  6. To expose services to the Client ID, click on the App name on the left hand side of the screen, to select it. Then click on the “Manage” button on the top right-hand side of the screen. This would display the app management page, for setting the configuration of the application.AppDashboard
  7. Scroll down to the “Services” section of the app management page and change the status of any service that you intend to use, from “OFF” to “ON”. Make sure you turn on Verve Wallet Services and Verve Services SwitchServices.
  8. Now you have the keys and access to the services, you can go ahead and create your application as you please.

Downloading and Installing the SDK

Using the SDK in your project

  1. Dependencies:
    You can specify the dependencies as shown below or simply follow the link to download the jar file
    Using Android Studio, add the following to build.gradle file

     
                   compile 'com.google.code.gson:gson:2.2.4'
                   compile 'com.madgag:sc-light-jdk15on:1.47.0.3'
                   compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
                   compile 'org.springframework.android:spring-android-auth:1.0.1.RELEASE'
                   compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'

    As a Maven project, add the following to pom.xml file

                   <dependency>
    	               <groupId>com.google.code.gson</groupId>
    	               <artifactId>gson</artifactId>
    	               <version>2.2.4</version>
                   </dependency>
                   <dependency>
    	          <groupId>com.madgag</groupId>
    	          <artifactId>sc-light-jdk15on</artifactId>
    	          <version>1.47.0.3</version>
                   </dependency>
                   <dependency>
    	           <groupId>org.springframework.android</groupId>
    	           <artifactId>spring-android-core</artifactId>
    	           <version>1.0.1.RELEASE</version>
                   </dependency>
                   <dependency>
    	           <groupId>org.springframework.android</groupId>
    	           <artifactId>spring-android-auth</artifactId>
    	           <version>1.0.1.RELEASE</version>
                   </dependency>
                   <dependency>
    	           <groupId>org.springframework.android</groupId>
    	           <artifactId>spring-android-rest-template</artifactId>
    	           <version>1.0.1.RELEASE</version>
                   </dependency>

    Or you could just download the jars files here
    Google Gson library
    The Bouncy Castle Crypto package
    Spring for Android Core
    Spring for Android Auth
    Spring for Android Rest Template

  2. Add the following lines of codes to your AndroidManifest.xml file to request for network access
                        <uses-permission android:name="android.permission.INTERNET" />
                        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    These lines request for permission to access the internet access and network state of the phone respectively

  3. Add the following lines of code to your AndroidManifest.xml file to register the activities used by the SDK
             <activity
                android:name="com.interswitchng.techquest.vervepayment.VervePayment"
                android:label="" >
            </activity>
            <activity
                android:name="com.interswitchng.techquest.vervepayment.LoginActivity"
                android:label=""
              >
            </activity>
            <activity
                android:name="com.interswitchng.techquest.vervepayment.VerifyPhoneActivity"
                android:label="" >
            </activity>
            <activity
                android:name="com.interswitchng.techquest.vervepayment.VerifyTokenActivity"
                android:label="" >
            </activity>
            <activity
                android:name="com.interswitchng.techquest.vervepayment.AddCardActivity"
                android:label="" >
            </activity>
            <activity
                android:name="com.interswitchng.techquest.vervepayment.ListCardsActivity"
                android:label="" >
            </activity>
            <activity
                android:name="com.interswitchng.techquest.vervepayment.base.BaseActivity"
                android:label="" >
            </activity>
            <activity
                android:name="com.interswitchng.techquest.vervepayment.PayWithExistingCardActivity"
                android:label="" >
            </activity>
  4. To initiate payment, simply create a new intent and pass VervePayment as a class reference. For example
     Intent intent = new Intent(MainActivity.this,VervePayment.class);
  5. Supply required parameters to the intent as shown below
                    intent.putExtra("clientId", “Your client id”);
    		intent.putExtra("clientSecret", “Your client secret”);
    		intent.putExtra("customerId", “Customer Id”);
    		intent.putExtra("paymentCode", “Payment Item Code”);
    		intent.putExtra("amount", “Transaction amount”); 
                    intent.putExtra("isTestPayment", true);

    The meanings of the parameters are:

    Type Field

    Description

    string paymentCode This refers to the payment code for the item which you want to pay for. To get a payment code, go to your Developer Console and register a new item. You’ll automatically get a payment code for the item.
    long amount This refers to the cost of the item you want to pay for. It should be in kobo (i.e. 1 NGN = 100 kobo).
    string customerId This refers to the id of the customer who is trying to perform the payment on your application. It is usually issued by you and it can be anything.
    string clientId This refers to the client ID you got from Developer Console for the particular application that you are developing.
    string clientSecret This refers to your application secret key. The value is on the same page where you got the client id. You will have to click on “Show Secret” link to see it.
    boolean isTestPayment This is an optional parameter that is set when switching from test implementation to production environment. It is true by default which means that you are running in the test implementation. NOTE: it’s very important to set the value to false in a live distribution.
  6. Call startActivityForResult method passing the intent as a parameter and a resultCode to detect when the intent returns after execution.
    For example:

     startActivityForResult(intent, 400);
  7. Implement onActivityResult method of your Activity class. This is where you will receive the return value after execution. Sample code is shown below:
            @Override
    	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    		if (resultCode == RESULT_OK && requestCode == 400) {
    			// get data from intent
    			int txnStatus = data.getIntExtra("qtTransactionStatus", 0);
                            //txnStatus is either 0 if transaction failed or 1 if transaction was successful
     
    		}
    	}
  8. Go ahead and implement your application as you please.

Sample codes and application can be found here: https://github.com/techquest/paywith-quickteller-sample-wp8

Migrating your application to Production environment

Now that you have finished developing your application and your payment process is working fine locally, you want to publish your application to the stores so that your customers can download and use it. The keys which you currently use for development won’t work in production. To acquire new keys for production, please follow the steps below:

  1. Log in to the developer console. If your application is not selected, click on your application on the left-hand side of the page to select it, then click on the “Manage” button at the top right-hand side of the screen. This takes you to the app management page.
  2. At the “status” section of the app management page, click on the switch next to “Are you ready to migrate this app to production environment?” to change it from “NO” to “YES”.
    SwichToProduction
  3. You would get an e-mail which confirms that you have requested to migrate to Production. After this, your application would be reviewed and migrated to Production, and you would get an e-mail to this regards.
  4. If approved, you would be issued a new set of keys, which you should replace the old ones in your app with.DevConProductionMode
    PLEASE NOTE: Apart from replacing the client ID and secret key, you would have to set the last optional parameter on the VervePayment constructor in your code to false. This is important, because if you don’t, requests from your application would be treated as sandbox requests.

                     ...
                     //set isTestPayment to false
                    intent.putExtra("clientId", “Your client id”);
    		intent.putExtra("clientSecret", “Your client secret”);
    		intent.putExtra("customerId", “Customer Id”);
    		intent.putExtra("paymentCode", “Payment Item Code”);
    		intent.putExtra("amount", “Transaction amount”); 
                    intent.putExtra("isTestPayment", false);
                    ...
  5. After you are done with this, you can go ahead and test your app in production mode and publish your app to the store when you are done.

2 Comments

  1. Olaseni Odebiyi

    Hello,

    Please how do I activate the Payment Code without using EditText? I tried this:

    String strPaymentCode = “1234″;
    int paymentCode = Integer.parseInt(strPaymentCode);

    But the paymentCode is not used.

    I will appreciate your help on this.

Leave A Comment?

Ask Questions With: