Android integration

This page explains the steps to integrate Client Side Encryption with your Android application using Gradle, or manually.

  1. Create your RSA key pair, and access your key

  2. Import the codeinto your project

  3. Import the WorldpayCSE package

  4. Create the WorldpayCSE object

  5. Set the public (RSA) key

  6. Set up the cardholder data

  7. Encrypt the cardholder data

Note: View our Android terms of usehere.


  • Maven Central Sonatype maven repositary binaries:

  • Online generated API documentation:

  • GitHub repository :

Create your RSA key pair

CSE works using a 2048 bit RSA key pair which is made up of a public key and a private key. The public key must be supplied to the CSE library, and is used to encrypt the sensitive card details.

The private key exists within a secure environment at Worldpay. It is never transmitted and is not visible to any member of staff at Worldpay.

To create a key pair:

  1. Log in to the Merchant Admin Interface (MAI) and click Client Side Encryption in the left panel.

  2. Enter the description of the key, and then click Generate key.

    The key pair has now been generated, and you'll be able to use the public key to encrypt card details.

Note: You can create more than one key. This is useful, for example, if you want to roll your keys to change them after a period of time. You can also disable a disused key. To learn more seeKey Rotation.

Access your key

To build the key into your payment page, you must view it:

  1. Click View key on the key you wish to view. You'll be taken to a page which shows the key in two different formats:

    1. Public key

      This is the whole key in its entirety.

    2. JavaScript formatted key

      This is your formatted key. It has been formatted to allow you to simply copy it into your payment page.

  2. Click the Client Side Encryption button at the bottom of the page to return to the main page.

Note: Although sensitive information is encrypted, there is no change in the way Worldpay processes a payment.


With Gradle

Gradle is the official build system for Android Studio and a dependency manager for Android projects.

To use Worldpay CSE SDK in a project, add it as a build dependancy and import it.

  1. After you create a new project, either:

    • open your_app | build.gradle and add this to Module-level /app/build.gradle before dependancies:

      repositories {
    • or if you use an internal SonaType Nexus repository:

      repositories {
          maven { url ' }
  2. Add the compile dependency with the latest version of the Worldpay CSE SDK in the build.gradle file:

    dependencies {
    compile 'com.worldpay:cse-android-sdk:1.0.2'

Alternative: Manual installation

You can instead add the library as a simple module in your project:

  1. In Android Studio, go to File > New > Import Module.

  2. Navigate to where the Worldpay CSE SDK jar file is located, select it and press Finish.

Note: You can also import the Worldpay CSE SDK library by copying it into the /app/libs/ folder of your project.


Import the WorldpayCSE package

import com.worldpay.cse.WorldpayCSE;

Create the WorldpayCSE object

WorldpayCSE worldpayCSE = new WorldpayCSE();

Set the public (RSA) key

The public key should be in Worldpay string format, and will be used for any future encryption calls. To set it (to identify you on our server):


Set up the cardholder data

WPCardData cardData = new WPCardData();
cardData.setCardNumber ("4444333322221111");
cardData.setCvc ("123");
cardData.setExpiryMonth ("11");
cardData.setExpiryYear ("2020");
cardData.setCardHolderName ("John Doe");

Encrypt the cardholder data

try {
    encryptedData = worldpayCSE.encrypt(cardData);
} catch (WPCSEInvalidCardData e) {
    //Alternatively to catching this exception, there is a convenient method
    //WorldpayCSE#validate(WPCardData) that can be used for a similar purpose
} catch (WPCSEException e)  {
    //show error message 

Terms of use

You can find the terms of use for Android inWorldpay Developer Terms Of Use for Android.