Android Pay

For legacy integrations only.

Warning: Android Pay is now a method within Pay with Google. Please use our [Pay with Google](../mobilewallets/googlepay.htm) page to take Android Pay payments. Google will no longer allow new integrations to the legacyAndroid Pay API. Instead please use the newGoogle Payments API.

Everything you need to take Android Pay payments via web or app:

How it works

../resources/images/androidpayflow_thumb_350_0.png

  1. You request the encrypted payload from your app or website

  2. Android Pay returns the encrypted payload following shopper authentication

  3. You send the encrypted payload to your server

  4. You send an XML Direct request to Worldpay containing the encrypted Android Pay data

  5. We send you the payment response

  6. You inform the shopper of the outcome

Setup

Prerequisites

You need:

  • ADirectintegration to Worldpay

  • A Google Account

  • Worldpay to enable Android Pay on your account

Get a public key

Contact the Worldpay Corporate Support team and give your WorldpayMerchant Code- we will generate and send your public key.

Set up Android Pay

Configure your project before integrating Android Pay into your app or website.

In-app

To use Android Pay within your app you needAndroid StudioIDE. You must also import the Google Play services library and add Android Pay metadata.

For detailed instructions, see https://developers.google.com/android-pay/setup

On web

To use Android Pay on the web you will need to register yourself via thisGoogle form, providing your:

  • Company Name

  • Company Description

  • Google Account (email address)

  • Site Origin(s)

  • Integration Type (we only support Network Token Integration)

  • Network Token Public Encryption Key (provided by Worldpay)

You'll then be given a Google Merchant ID.

For detailed instructions see https://developers.google.com/android-pay/mobile-web/setup

Integrate with Android Pay

Note: Worldpay only supports the **Network Token Integration**.

Integrate to Android Pay to obtain the encrypted payment credentials. While doing this, be aware of the below properties which relate to the Worldpay integration.

In-app

For detailed instructions on how to configure Android Pay for in-app payments, see: https://developers.google.com/android-pay/tutorial

On web

For detailed instructions on how to configure Android Pay for web payments, see theIntegrate using network tokenpart of: https://developers.google.com/android-pay/mobile-web/tutorial

Set the allowedCardNetworks property

Worldpay only supports Android Pay payments with Visa, Mastercard and American Express (Amex) cards.

In-app

In Android Studio, configure the addAllowedCardNetworks property of the request object to only receive card networks Worldpay support. See the supportedNetworks.add lines in the example:

Copied!
Collection<Integer> supportedNetworks = new ArrayList<Integer>();
supportedNetworks.add(WalletConstants.CardNetwork.AMEX);
supportedNetworks.add(WalletConstants.CardNetwork.MASTERCARD);
supportedNetworks.add(WalletConstants.CardNetwork.VISA); // Only use the cards listed here  

MaskedWalletRequest maskedRequest = MaskedWalletRequest.newBuilder()
  .setMerchantName(BuildConfig.MERCHANT_NAME)
  .setPhoneNumberRequired(false)
  .setShippingAddressRequired(false)
  .setCurrencyCode("USD")
  .setEstimatedTotalPrice(String.format(Locale.US, "%s", total))
  .setCart(cart)
  .setPaymentMethodTokenizationParameters(parameters)
  .addAllowedCardNetworks(supportedNetworks) // Add allowed cards here
  .build();

On web

Configure the allowedCardNetworks property of the request object to only accept the card networks Worldpay support. See the code example below:

Copied!
var supportedInstruments = [
{
  supportedMethods: ['https://android.com/pay'],
  data: {
    //merchant ID obtained from Google that maps to your origin
    merchantId: '02510116604241796260',
    environment: 'TEST',
    allowedCardNetworks: ['AMEX', 'MASTERCARD', 'VISA'], // Only use the cards listed here
    paymentMethodTokenizationParameters: {
      tokenizationType: 'NETWORK_TOKEN',
      parameters: {
        //public key to encrypt response from Android Pay
        'publicKey': 'BC9u7amr4kFD8qsdxnEfWV7RPDR9v4gLLkx3jfyaGOvxBoEuLZKE0Tt5O/2jMMxJ9axHpAZD2Jhi4E74nqxr944='
        }
      }
    }
  }
];

Set the tokenizationType property

In-app

In Android Studio, configure the PaymentMethodTokenizationType property of the PaymentMethodTokenizationParameters object to only accept NETWORK_TOKEN:

Copied!
PaymentMethodTokenizationParameters parameters =
  PaymentMethodTokenizationParameters.newBuilder()
    .setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN) // Only use 'NETWORK_TOKEN' here
    .addParameter("publicKey", publicKey)
      .build();

On web

Configure the tokenizationType property of the request object to only accept NETWORK_TOKEN:

Copied!
var supportedInstruments = [
{
  supportedMethods: ['https://android.com/pay'],
  data: {
    //merchant ID obtained from Google that maps to your origin
    merchantId: '02510116604241796260',
    environment: 'TEST',
    allowedCardNetworks: ['AMEX', 'MASTERCARD', 'VISA'],
    paymentMethodTokenizationParameters: {
      tokenizationType: 'NETWORK_TOKEN', // Only use 'NETWORK_TOKEN' here
      parameters: {
        //public key to encrypt response from Android Pay
        'publicKey': 'BC9u7amr4kFD8qsdxnEfWV7RPDR9v4gLLkx3jfyaGOvxBoEuLZKE0Tt5O/2jMMxJ9axHpAZD2Jhi4E74nqxr944='
        }
      }
    }
  }
];

Integrate with Worldpay

Prerequisite: You've successfully integrated Android Pay to your website or app, and can generate an encrypted payload.

When you've generated an encrypted payload, and have passed this to your server, send the payload to us within <ANDROIDPAY-SSL>.

Example XML request

Select

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//WorldPay/DTD WorldPay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="MYMERCHANT">
  <submit>
    <order orderCode="androidpayorder123" shopperLanguageCode="en">
      <description>AndroidPay test order</description>
      <amount value="100" currencyCode="EUR" exponent="2"/>
      <orderContent>
        <![CDATA[]]>
      </orderContent>
      <paymentDetails>
        <ANDROIDPAY-SSL>
          <ephemeralPublicKey>AAAAAA...</ephemeralPublicKey>
          <encryptedMessage>AAAAAA...</encryptedMessage>
          <tag>AAAAAA...</tag>
        </ANDROIDPAY-SSL>
      </paymentDetails>
      <shopper>
        <shopperEmailAddress>sp@worldpay.com</shopperEmailAddress>
      </shopper>
    </order>
  </submit>
</paymentService>

Response

The response message is the same as ourstandard XML responses.

Test

Android Pay supports both a TEST and PRODUCTION mode. The modes are controlled with the WalletConstants.ENVIRONMENT_TEST or WalletConstants.ENVIRONMENT_PRODUCTION values.

When set to WalletConstants.ENVIRONMENT_TEST, the Android Pay wallet returns a fixed, dummy token value for each of the schemes to prevent real payment data being used by mistake.

Worldpay’s TEST environment is set up to recognise these dummy details and process them as a successfully AUTHORISED transaction.

Google provide further testing details at: https://developers.google.com/android-pay/deployment

Some links to Android Pay websites.

Android Pay

Worldpay/Android Pay

Android Pay guides

Android Pay tutorial

Android Pay reference

Android Pay developers

Create a payment with a decrypted payload