Google Pay

Everything you need to take Google Pay payments via an app:

How it works

../resources/images/paywithgoogleflow_thumb_350_0.png

  1. You request the encrypted payload from your app

  2. Google 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 data

  5. We send you the payment response

  6. You inform the shopper of the outcome

Setup

Prerequisites

You need:

  • ADirector [HPP] (/docs/wpg/hostedintegration/quickstart) integration to Worldpay

  • A Google account

  • Worldpay to enable Google Pay on your account

  • To contact Google in order to add your app to their system for production use.

Merchant ID

When Google Pay is enabled on your Worldpay account, use the WorldpayMAIto generate your own Merchant ID.

Set up Google Pay

For detailed instructions on how to configure Google Pay for in-app payments, seehere.

Integrate with Google Pay

See the Google Payment API guide - https://developers.google.com/payments/mobile-web-tutorial

Set the allowedCardNetworks property

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

Copied!
private PaymentDataRequest createPaymentDataRequest() {
  PaymentDataRequest.Builder request =
    PaymentDataRequest.newBuilder()
      .setTransactionInfo(
        TransactionInfo.newBuilder()
          .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
          .setTotalPrice("10.00")
          .setCurrencyCode("USD")
          .build())
      .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_CARD)
      .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD)
      .setCardRequirements(
        CardRequirements.newBuilder()
          .addAllowedCardNetworks(
            Arrays.asList(
              WalletConstants.CARD_NETWORK_AMEX,
              WalletConstants.CARD_NETWORK_VISA,
              WalletConstants.CARD_NETWORK_MASTERCARD))
          .build());
  PaymentMethodTokenizationParameters params =
    PaymentMethodTokenizationParameters.newBuilder()
      .setPaymentMethodTokenizationType(
        WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY)
      .addParameter("gateway", "worldpay")
      .addParameter("gatewayMerchantId", "MerchantIdProvidedByWorldpay")
      .build();
  request.setPaymentMethodTokenizationParameters(params);
  return request.build();
}

Extract the payload data

Extract the data from the Android device payload using the following:

Copied!
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  switch (requestCode) {
    case LOAD_PAYMENT_DATA_REQUEST_CODE:
      switch (resultCode) {
        case Activity.RESULT_OK:
          PaymentData paymentData = PaymentData.getFromIntent(data);
          String token = paymentData.getPaymentMethodToken().getToken();
          JSONObject obj = new JSONObject(token);
          // Data below goes into the XML message
          String signature = obj.getString("signature");
          String protocolVersion = obj.getString("protocolVersion");
          String signedMessage = obj.getString("signedMessage");
...

Integrate with Worldpay

Prerequisite: You've successfully integrated withGoogle Payto your 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 <PAYWITHGOOGLE-SSL>.

Example XML request

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="YOUR_MERCHANT_CODE">
  <submit>
    <order orderCode="YOUR_ORDER_CODE" shopperLanguageCode="en">
      <description>GOOGLE_PAY_TEST_ORDER</description>
      <amount value="100" currencyCode="GBP" exponent="2"/>
      <orderContent>
        <![CDATA[]]>
      </orderContent>
      <paymentDetails>
        <PAYWITHGOOGLE-SSL>
          <protocolVersion>AAAAAA...</protocolVersion>
          <signature>AAAAAA...</signature>
          <signedMessage>AAAAAA...</signedMessage>
        </PAYWITHGOOGLE-SSL>
      </paymentDetails>
      <shopper>
        <shopperEmailAddress>shopper@worldpay.com</shopperEmailAddress>
      </shopper>
    </order>
  </submit>
</paymentService>

Example payload

Here's an example of the payload within <PAYWITHGOOGLE-SSL>:

Copied!
<PAYWITHGOOGLE-SSL>
  <protocolVersion>ECv1</protocolVersion>
  <signature>TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ</signature>
  <signedMessage>{"encryptedMessage":"qrnk5KIV1syX8xuaJYpjAxjvTmAfH4arrxK+5wT4XNsn+K/21QC5KyNyXVnaZsfz+FjYeZcZyTDsAXMGp01u9Psq3wp/9aJJyZ9PS9+G2sVJ+symppSvIHhPYxfcFLyvDxcU7J2ZUIU2o7ZAsHkc9eUL0zqcjTfRxxyladBQmP3mjy7OtIZbXodSr5vZZqKrRm0MqmPo/ISYor0gPmv+l+wRdLmCugdhBrg6mFGMuMBtnIjdtOZ+o4iSl4NqYo4BnI1py4GXG78FPHAlqU9Im+a9V6CtOsVG1eiLCn616fI8WorvPU46bDL7UApF/+vRF6lJviV9Ie9pUJHejO5Z17GPTfBuxO8ZAPWqcPY\u003d","ephemeralPublicKey":"BJ8xDzqkngvLUZcOAkqgkYpwGIHi2TzOXO6ZDJpKHPJCnJZ5WZOTO0HtNrTiOgiVc2gdZQ+TWmcy2Y1KnNsAGpg\u003d","tag":"5t5pipJgyhxJUg9XcymYcdcKmtBxQ71VvF2uhnempbs\u003d"}</signedMessage>
</PAYWITHGOOGLE-SSL>

Recurring payments

To take recurring payments you must create a token and follow thestored credentials integration.

Example payment request using tokenisation and stored credentials

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="YOUR_MERCHANT_CODE">
  <submit>
    <order orderCode="YOUR_ORDER_CODE">
      <description>test order</description>
      <amount value="100" currencyCode="EUR" exponent="2"/>
      <orderContent>
        <![CDATA[]]>
      </orderContent>
      <paymentDetails>
        <PAYWITHGOOGLE-SSL>
          <protocolVersion>ECv1</protocolVersion>
          <signature>Signature goes here.</signature>
          <signedMessage>Signed message goes here.</signedMessage>
        </PAYWITHGOOGLE-SSL>
        <session shopperIPAddress="127.0.0.1" id="ssn512311246"/>
      </paymentDetails>
      <shopper>
        <shopperEmailAddress>sp@worldpay.com</shopperEmailAddress>
        <authenticatedShopperID>shopperID</authenticatedShopperID>
        <browser>
          <acceptHeader>text/html</acceptHeader>
          <userAgentHeader>Mozilla/5.0 ...</userAgentHeader>
        </browser>
      </shopper>
      <createToken tokenScope="shopper">
        <tokenEventReference>eventReference</tokenEventReference>
        <tokenReason>reason</tokenReason>
      </createToken>
    </order>
  </submit>
</paymentService>

Response

The responses you receive are the same as a standard shopper, merchant or use tokenresponse. We manage the transactionIdentifier returned by the schemes for cases where there's only ever a single agreement with one cardholder. Store the transactionIdentifer being returned to you for cases where you must handle multiple agreements for one cardholder in a single token.

SCA and PSD2 compliance

To comply with SCA and PSD2 regulations you must send ‘CARD’ based Google Pay transactions through 3DS Secure.

If you are not decrypting the Google Pay payload (and asking Worldpay to handle decryption) then you do not have visibility of the underlying credential being ‘CARD’ or ‘TOKEN. Therefore you must send the additional 3DS Secure parameters in all of your Google Pay transactions.

If you are decrypting the Google Pay payload, you must only send the 3DS Secure parameters to the ‘CARD’ credential. You must submit the card information and 3DS in the same way as you do for non-google pay processing.

const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"]

PAN_ONLY = PAYWITHGOOGLE PAN-based card credentials that require 3DS. CRYPTOGRAM_3DS = Tokenised-card-based credentials stored on device that do not require 3D Secure.

You must pass the required 3DS parameters for the version of 3DS you are using. This is the same as for card transactions. Ensure you can handle the 3DS challenge, and display this information to your shopper.

Or refer to ourAuthenticationsection to review all of our authentication integration options.

Contact your Worldpay Relationship Manager or Support team for further assistance.

Test

Google Pay is supported in the Worldpay Sandbox. Please use the WalletConstants.ENVIRONMENT_TEST parameter for any test transactions and the WalletConstants.ENVIRONMENT_PRODUCTION parameter for production transactions.

Worldpay’s Sandbox environment is set up to recognise dummy details and simulate a successful AUTHORISED transaction.

Testing with 3DS Flex

For Magic Values and where to use them, see the3DS Flexguide.

Google provide further testing detailshere.

Disable Google Pay (HPP integrations only)

Current Worldpay integrations have Google Pay enabled as a default setting.

If you do not want to take payments from Google Pay, follow the instructions in the Merchant Admin Interface guide,MAIto disable it.

You must have an Admin user account to change the Google Pay settings in the MAI. Your Admin user account must also have the permissions for Google Pay management ticked in the user settings.

General

Google Payment API - Guides and Tutorials

Android Studio

Android Tutorial

Android Test and Deploy

Android Developer Support library

Google's GitHub sample

Create a payment with a decrypted payload