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.
Note
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.
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.Define the version of the Google Pay API when creating your configuration function.
const baseRequest = {
apiVersion: 2,
apiVersionMinor: 0
};
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.const allowedCardNetworks = ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"];
const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
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.const tokenizationSpecification = {
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'wepay',
'gatewayMerchantId': 'WePay_Merchant_Id'
}
};
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
3.0.rc.2.1
or 3.2
in the Version header parameter for your requests to this endpoint.POST /payment_methods
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
{
"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"
}
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.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"
}
}
There are two final steps before your platform is fully approved for production.
- Click "Integrations" in the left-hand navigation.
- Click "Integrate with your website."
- Click "Add a new website" and insert the production website URL of your Platform.
- For "Integration type" choose "Gateway."
- 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.
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.