Google Pay API

 
Note

Google Pay is currently a closed Beta feature and does not support CAD at this time.

We support the use of Google Pay on your platform through an API integration. Using Google Pay allows your Merchants to simplify the checkout flow, making checkouts faster, and impacting the conversion performance of your platform.

Payments are encrypted by Google and decrypted by us, protecting payment information even in the event of a compromised application. Follow this guide to learn how to integrate Google Pay in to your platform.

See the image below for a graphic of the entire integration flow.

PartnerGoogle PayWePay1. Request Payment Data2. Receive Encrypted Payload3. Send Payload via POST/payment_Mehod API to Create a Payment Method4. Use POST/Payments with the Payment Method ID from Step 3 to Create the Payment5. Provide Partner with the responsePartnerGoogle PayWePay
Note
Looking for step-by-step code? Use our sample Google Pay App for a quicker integration.

Setup your Google Merchant Account

Onboard your account to Google

Sign in using your business email address and register your business for a Google account on the Google Pay Business console page, where you will start off by providing your business name, location of operation, and agree to Google's Terms of Service.

Further details are outlined in Google's Integration checklist.

Once you've registered your account, navigate to the Business Profile within the console. This is where you will finish Google onboarding, which is a necessary step in submitting your application for approval. Additional application approval steps are outlined in the Submit your App for Production section below.

Access your Google Merchant ID

Once your website passes the initial Google on-boarding review, grab your Google Pay merchant identifier which can be found by clicking Dashboard in the left-hand navigation, located in the top right-hand corner.You will use your Google Merchant ID later on in your integration.An image showing where to find the Google Merchant ID.
An image showing where to find the Google Merchant ID.

Integrate the Google APIs

Follow Google's integration guide for step-by-step instruction on how to implement Google Pay within your application. The instructions below highlight key configuration settings you will need to include while integrating Google Pay. Alternatively, watch Google's tutorial video to integrate: All about integrating Google Pay online.

Configuration Information

Define the version of the Google Pay API when creating your configuration function.

Copy
Copied
const baseRequest = {
  apiVersion: 2,
  apiVersionMinor: 0
};
Define the card networks accepted by WePay through instantiating the allowedCardNetworks variable within your application.

The Google Pay API might return cards on file with Google (PAN_ONLY), and/or a device token on an Android device that's authenticated with a 3-D Secure cryptogram (CRYPTOGRAM_3DS). Instantiate this through the allowedCardAuthMethods parameter.
Copy
Copied
const allowedCardNetworks = ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"];

const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
We will decrypt the Google Pay token sent to our gateway, it's important to specify wepay within your tokenization specification variable by setting the gateway name to wepay and the gatewayMerchantId to your gateway merchant ID. You will receive your gatewayMerchantId from your WePay integration team.
Copy
Copied
const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    'gateway': 'wepay',
    'gatewayMerchantId': 'WePay_Merchant_Id'
  }
};

Create a Wepay Payment Method

Once your application is able to create Google Pay tokens, you will need to send a POST /payment_methods request to us, using the Google Pay token returned to your server.

See the sample request below, where the Google Pay token, payment method type, and cardholder information need to be provided. Insert the public_key value received from us during your application on-boarding. Use the https://stage-api.wepay.com url for staging and the https://api.wepay.com url for production.

See our Process Payments article for further information on processing payments.

Note
Be sure to use the Pre-Release version 3.0.rc.2.1 or 3.2 in the Version header parameter for your requests to this endpoint.
POST /payment_methods
Copy
Copied
  curl -X POST \
  --url 'https://stage-api.wepay.com/payment_methods' \
  -H 'Accept: application/json'\
  -H 'App-Id: {YOUR-APP-ID}'\
  -H 'App-Token: {YOUR-APP-TOKEN}'\
  -H 'Api-Version: '3.2'\
  -H 'Content-Type: application/json'\
  -H 'Unique-Key: {UNIQUE-KEY}
  --data-raw {
        "type": "google_pay",
        "google_pay": {
            "payment_method_data": "BASE_64_ENCODED_RESPONSE_FROM_GOOGLE",
            "card_holder": {
                "holder_name": "John Snow",
                "email": "example@wepay.com",
                "address": {
                    "country": "US",
                    "postal_code": "94025"
                }
            }
        }
    }

Below is a sample response payload where a WePay payment method ID will be returned (be sure to keep this handy - you'll need to use this to create and capture a payment later), as well as fill in other information.

POST /payment_method
Copy
Copied
{
  "id": "00000000-6363-0000-0000-00521ec2df84",
  "resource": "payment_methods",
  "path": "/payment_methods/00000000-6363-0000-0000-00521ec2df84",
  "owner": {
      "id": "27415",
      "resource": "applications",
      "path": null
  },
  "create_time": 1629930873,
  "type": "google_pay",
  "google_pay": {
      "card_holder": {
          "holder_name": "Tony Stark",
          "email": "example@wepay.com",
          "address": {
              "line1": null,
              "line2": null,
              "city": null,
              "region": null,
              "postal_code": "94025",
              "country": "US"
          },
          "phone": {
              "country_code": null,
              "phone_number": null,
              "type": null
          }
      },
      "expiration_month": 4,
      "expiration_year": 2030,
      "display_name": "MasterCard xxxxxx4769"
  },
  "custom_data": null,
  "api_version": "3.0"
}

Create a Wepay Payment

Use the WePay payment method ID returned above in the POST /payment_methods type parameter to "payment_method_id" when executing Google payments.See our Capture Authorized Payments guide to learn about how to execute manual, deferred, and partial captures of payments.
Copy
Copied
curl -X POST \
  --url 'https://stage-api.wepay.com/payments' \
  -H 'Accept: application/json'\
  -H 'App-Id: {YOUT-APP-ID}'\
  -H 'App-Token: {YOUR-APP-TOKEN}'\
  -H 'Api-Version: 3.0'\
  -H 'Content-Type: application/json'\
  -H 'Unique-Key: {UNIQUE-KEY}
  --data-raw '{
	"amount": AMOUNT_AS_INTEGER,
	"currency": "USD",
	"account_id": "{merchant's-account-id}",
	"payment_method": {
            "payment_method_id": "INSERT_PAYMENT_METHODS-ID",
            "type": "payment_method_id"
	}
}
Read through the Risk Certification guide to identify standard required payment-level rBits and Risk Headers which will allow you to send us risk information about the payment. A payment may be flagged for manual risk review in which it is subject to 1-2 business days hold. The inclusion of payment-level rBits reduces the frequency and duration of manually reviewed payments as well as allows our Risk team to accurately action a payment.

Submit your App for Production

There are two final steps before your platform is fully approved for production.

  1. Certify with Google
  2. Certify with WePay

Certify with Google

Before your platform can fully integrate with Google, the Google Pay team must clear your final integration for production. After you have completed each part of the integration checklist, which includes testing your integration, navigate to your Google Pay Business console to get started.
  1. Click "Integrations" in the left-hand navigation.
  2. Click "Integrate with your website."
  3. Click "Add a new website" and insert the production website URL of your Platform.
  4. For "Integration type" choose "Gateway."
  5. Upload required screenshots to show what the integration looks like.

After your platform has been approved for Production by Google, you will receive a confirmation email.

Certify with WePay

To ensure that we can decrypt your Google Pay Token, test the flow from creating the Google Pay Token to using that token to create a WePay Payment Method. No manual intervention from us is required for this certification, as successfully creating the WePay Payment Method inherently validates that we are able to decrypt the token.