- Home
- All APIs
- WPG guide
- The payment process
- Android Pay
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 legacy
Everything you need to take Android Pay payments via web or app:
How it works
You request the encrypted payload from your app or website
Android Pay returns the encrypted payload following shopper authentication
You send the encrypted payload to your server
You send an XML Direct request to Worldpay containing the encrypted Android Pay data
We send you the payment response
You inform the shopper of the outcome
Setup
Prerequisites
You need:
A
Direct integration to WorldpayA Google Account
Worldpay to enable Android Pay on your account
Get a public key
Contact the Worldpay Corporate Support team and give your Worldpay
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 need
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 this
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 the
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:
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();
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:
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='
}
}
}
}
];
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
:
PaymentMethodTokenizationParameters parameters =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.NETWORK_TOKEN) // Only use 'NETWORK_TOKEN' here
.addParameter("publicKey", publicKey)
.build();
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
:
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='
}
}
}
}
];
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
<?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 our
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
Useful links
Some links to Android Pay websites.