Tutorial

  • This tutorial provides a step-by-step guide for integrating Google Pay into Android applications for accepting card payments.

  • Developers can configure payment settings, including supported card networks and payment providers.

  • The tutorial includes code examples in Kotlin and Java to demonstrate the integration process.

  • The example gateway is for testing purposes only; replace it with your provider's details for live transactions.

  • Developers should ensure to review the Google Pay API documentation and best practices for a successful integration.

Follow the steps in this tutorial to add Google Pay to your Android application and configure it to accept payment cards.

Step 1: Define your payment configuration

Configure your Google Pay API version

Declare the version of the Google Pay API that your application uses. The major and minor versions affect the fields expected in each passed object and are included in the response.

Create a base request object that contains properties that are present in all other request objects.

Kotlin

private val baseRequest = JSONObject()
    .put("apiVersion", 2)
    .put("apiVersionMinor", 0)
    

Java

private static JSONObject getBaseRequest() throws JSONException {
  return new JSONObject()
      .put("apiVersion", 2)
      .put("apiVersionMinor", 0);
}
    

Request a payment token for your payment provider

Google encrypts information about a payer's selected card for secure processing by a payment provider.

Kotlin

private fun gatewayTokenizationSpecification(): JSONObject {
    return JSONObject().apply {
        put("type", "PAYMENT_GATEWAY")
        put("parameters", JSONObject(mapOf(
                "gateway" to "example",
                "gatewayMerchantId" to "exampleGatewayMerchantId")))
    }
}
    

Java

private static JSONObject getGatewayTokenizationSpecification() throws JSONException {
  return new JSONObject()
      .put("type", "PAYMENT_GATEWAY")
      .put("parameters", new JSONObject()
          .put("gateway", "example")
          .put("gatewayMerchantId", "exampleGatewayMerchantId")
      );
}
    

Replace example and exampleGatewayMerchantId with the appropriate values for your payment provider. Use the following table to find the specific gateway and gatewayMerchantId values for your payment provider:

Gateway Parameters and documents
9Pay
  "gateway": "ninepay"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

91APP PAYMENTS
  "gateway": "payments91app"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

A-IT
  "gateway": "aitecomm"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

ABA PayWay
  "gateway": "ababank"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

accept.blue
  "gateway": "acceptblue"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

ACI
  "gateway": "aciworldwide"
  "gatewayMerchantId": "YOUR_ENTITY_ID"

Developer docs

ACpay
  "gateway": "acpay"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

Acquired.com
  "gateway": "acquired"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

Adyen
  "gateway": "adyen"
  "gatewayMerchantId": "YOUR_MERCHANT_ACCOUNT_NAME"

Developer docs

African Payment Solution (PTY) Ltd t/a LekkaPay
  "gateway": "lekkapay"
  "gatewayMerchantId": "YOUR_MERCHANT_ACCOUNT_NAME"

Developer docs

AI Fintech
  "gateway": "aifintech"
  "gatewayMerchantId": "YOUR_MERCHANT_ACCOUNT_NAME"

Developer docs

Airba Pay
  "gateway": "airbapay""
  "gatewayMerchantId": "YOUR_MERCHANT_ACCOUNT_NAME"

Developer docs

Airvend
  "gateway": "airvend"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

Airwallex
  "gateway": "airwallex"
  "gatewayMerchantId": "YOUR_MERCHANT_ACCOUNT_NAME"

Developer docs

Akua
  "gateway": "akua"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

Akurateco
  "gateway": "akuratecolab"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs

Alfa-Bank
  "gateway": "alfabank"
  "gatewayMerchantId": "YOUR_GATEWAY_MERCHANT_ID"

Developer docs