Google Pay

Google Pay is a mobile payment and digital wallet service. With Google Pay, consumers can enjoy a seamless checkout experience, eliminating the need to enter payment and shipping information manually.

Introduction

Google Pay is a widely used mobile payment solution that offers a convenient and secure way for customers to pay for goods and services. Integrating Google Pay with Payrails allows you to provide a fast, easy-to-use payment option for your customers while leveraging our platform to route the payment to any Payment Service Provider (PSP). This guide will explain the process of integrating Google Pay into your app or website using Payrails.

Pre-requisites

In order to start using Google Pay with Payrails, you must:

  1. Integrate with Payrails using one of our SDKs or our API
  2. Enable Google Pay for your PSP(s) of choice (guide here)
  3. Follow the setup steps in the Google Pay documentation below:

Google Pay on Android Devices

Google Pay on the Web

Ways to integrate

Payrails SDK

The simplest way to use Google Pay with Payrails is to use our drop-in in your checkout flow. With this integration type, no additional work is required to accept payments with Google Pay.

For a more flexible implementation using our SDK, you can use our Google Pay element. See special instructions here for your client-side implementation.

Server-to-server integration

You also have the option to completely manage your own client-side implementation, and use Payrails APIs with a server-to-server integration to process payments with Google Pay. With this approach, follow the Google documentation linked above to build Google Pay into your applications.

Pass Google Pay configuration in lookup response to Google Pay SDK

With a server-to-server integration, you can call our lookup payment options endpoint to get available payment options and relevant configurations for each payment method. You can get allowedAuthMethods and allowedCardNetworks from the response here and pass it to the Google Pay SDK. Please contact your Payrails representative during the onboarding phase in order to set these configurations before going live.

{
  "name": "lookup",
  "actionId": "bd879370-6935-4ff2-872e-fdb0c5ce3024",
  "executedAt": "2023-06-12T07:53:09.360484718Z",
  "data": {
    "paymentCompositionOptions": [
      {
        "integrationType": "api",
        "paymentMethodCode": "googlePay",
        "description": "GooglePay",
        "config": {
          "parameters": {
            "allowedAuthMethods": [
              "PAN_ONLY",
              "CRYPTOGRAM_3DS"
            ],
            "allowedCardNetworks": [
              "MASTERCARD",
              "VISA",
              "AMEX",
              "DISCOVER"
            ]
          },
          "tokenizationSpecification": {
            "parameters": {
              "gateway": "payrails",
              "gatewayMerchantId": "EXAMPLE_MERCHANT_ID"
            },
            "type": "PAYMENT_GATEWAY"
          },
          "type": "CARD"
        }
      }
    ]
  },
  "links": {
    "execution": "https://payrails-api.staging.payrails.io/merchant/workflows/payment-acceptance/executions/2ef29a74-d1ae-4fa5-a1d9-84e2cd710c23",
    "authorize": {
      "method": "POST",
      "href": "https://payrails-api.staging.payrails.io/merchant/workflows/payment-acceptance/executions/2ef29a74-d1ae-4fa5-a1d9-84e2cd710c23/authorize"
    }
  }
}

Pass Google Pay payment token in request to authorize payment with Payrails

When you initiate a transaction with the Google Pay SDK, a Payment Token (paymentMethodData.tokenizationData.token) containing a JSON-formatted string is sent to the merchant app. Pass the paymentMethodData.tokenizationData.token in your call to our authorize a payment endpoint. It will look something like this:

{
  "signature": "MEYCIQDTe92wpG6OUgxJ/8Qnr36XzSgjGGCM7R3LwxjgwPYMTAIhAJDrjHG9wEm1BxVM6MMMB+jGTGpi3VScEMVbHIUsObFi",
  "protocolVersion": "ECv1",
  "signedMessage": "{\"encryptedMessage\":\"FY8w/U3IbdsZQovX8ufNGFDOePgc/genRiMjHyvuIBqLY4a6uPz7wI0ra31K6YbFJlAnCjFhTwSvDxAYXw6hlmI8sESO5eM1eZlzfP3+NoKV80OXKvOM/xI/qOQEqpEQEVXx6Bw2EpMMFW8yBaA8XPUNee3EJlUk+/f8lRdRcNmI65QKPLAzUnySo75HzBkSc5It/8/oXdYwR93/K6HRKGZuD+bIaxy3SUvC9ehQqhBoP+A34yQX1knfJ1qjBMhhVVcPZHi+Bg6LXA4ms/lfDdim6D1Epr6XQhc2h4RZ/dT+6Enn81s/8ym+jMMs8kqsW9ib8vkdTARv9AbUu7zeGPrKTCAxwc1n6joRR72dSnNCI9j9sxd9tkuC9wuRyDmjbWT+hRZgLc1v/xzzNImo3NxdKdaPzKBE3t9XQZY5fp3lZELaoXAuxAZYtZ7bX64Mz9c28wD8EM+krvfbmGMiBjIt8EfeH48/SjeaUKfDu+yQnjPJAKbDZPhKJ1jqlY/ChP0Om7spQacT86QUVK/DwfzukwvwwRJkWydNEac5fgfS2T6ToZ+PW4VHbxkDnY/h+B0uwdlNQIL2a3Ar5Q\\u003d\\u003d\",\"ephemeralPublicKey\":\"BGkK4bSvob+e7ZgaNV/4vSJYYa10OJzd3aUk9yPEP6iNBRcfHiD/NTvhKjN4P24l0tEzH3L8TrySl6AczPJpCkw\\u003d\",\"tag\":\"xGEhEfJESIyBSfq2fExWiZxNWelnm3m4i8P7cgsarqg\\u003d\"}"
}
       

You can then make a request to our authorize a payment endpoint with googlePay as the paymentMethodCode and including the Google Pay token in the paymentToken field. See an example below.

{
  "amount": {
    "value": "12.50",
    "currency": "EUR"
  },
  "meta": {
    "shippingType": "Delivery"
  },
  "returnInfo": {
    "success": "https://mysuccessurl.com"
  },
  "paymentComposition": [
    {
      "integrationType": "api",
      "amount": {
        "value": "12.50",
        "currency": "EUR"
      },
      "paymentInstrumentData": {
        "paymentToken": "{\"signature\":\"MEUCIQCjP8Zv1M0Vzc02uwVuOhAOIfdr7..."
      },
      "storeInstrument": false,
      "paymentMethodCode": "googlePay"
    }
  ]
}