# **Google Pay™**

#### Learn how to accept payments using Google Pay.

## **Overview**

Integrate Google Pay with xMoney to provide a seamless checkout experience for your customers. This guide will walk you through the steps needed to integrate Google Pay into your website using xMoney as the payment processor.

**Please note** that xMoney is fully licensed to provide payment services in the European
Economic Area (EEA) countries.

> Since September 2019, the Strong Customer Authentication (SCA) regulation has required businesses across Europe to implement additional authentication measures for online payments.


Google Pay fully complies with SCA, as its payment process already includes a built-in authentication layer, such as biometric verification (fingerprint or facial recognition) or password authentication.

By integrating Google Pay, you agree to Google’s [terms of service](https://payments.developers.google.com/terms/sellertos).

## **Prerequisites**

Before you begin, ensure you have the following:

1. **xMoney** merchant account.


With your account, you will be given a siteId and a secret unique key (aka apiKey). This key is used to authenticate and communicate with our servers securely. The apiKey can be found in the merchant account on the following url: [https://merchant.xmoney.com](https://merchant.xmoney.com/)

For **test accounts** use [https://merchant-stage.xmoney.com](https://merchant-stage.xmoney.com/).

Under the “Sites” menu – clicking the number found at column # will bring up a site details window. The apiKey is listed in the Website details view as “Private key”

***Note:***

* *The apiKey is unique for each website – if you had a test account, the apiKey used for tests is not the same as the one you will need to use for the live environment.*
* *Integrate Google Pay API with xMoney as your gateway.
Follow the procedure in the Google Pay documentation to integrate your [web](https://developers.google.com/pay/api/web/guides/setup)
or [Android](https://developers.google.com/pay/api/android/) application.*


1. A **website running on HTTPS** (Google Pay requires a secure connection).
2. A working xMoney working integration with our checkout secure page or directly with our API.


-  for checkout secure page you can find details on how to configure an order request  using our documentation found [here](/guides/checkout/hosted-checkout)

- for API ( server to server) integration details can be found [here](https://docs.xmoney.com/api/order/create-an-order)

**Note:** If you have a module integration( woocomerce, shopify)  requirement  3 is not required.

> Supported card networks are:
- Visa
- Mastercard



### Accept a payment using GooglePay in your Website

Below is the option best suited for your integration.
Please refer to Google’s [branding guidelines](https://developers.google.com/pay/api/web/guides/brand-guidelines)
to correctly incorporate the Google Play brand on your website.

Hosted checkout
The Google Pay digital wallet button will be displayed on our checkout payment page.
To enable this feature, we will activate the option in your account.
If you encounter any issues, please contact [support@xmoney.com](mailto:support@xmoney.com) to confirm that Google Pay has been activated.

> Merchants must adhere to the Google Pay APIs [Acceptable Use Policy](https://payments.developers.google.com/terms/aup)
and accept the terms defined in the [Google Pay API Terms of Service](https://payments.developers.google.com/terms/sellertos).


Checkout elements
To ensure a seamless and secure checkout experience on your store our checkout page can
be configured to display only the digital wallet (Google Pay) button, which
will be placed within an iframe (requires action from merchant side).
To enable this option, the merchant request must include 2 additional parameters
in the transaction options.

- Similar with Hosted Checkout, but secure hosted payment page will only display
google pay button (all card payment related fields will not be displayed)
- This option is suitable for embedding google pay button in the merchant site as an iframe
- To achieve this will need to send 2 additional paramethers besides order information:



```
"forceMethodType": "digitalWallet",
"forceMethodBrand": "googlePay", //"applePay"
```

- Please refer to [the documentation](/guides/checkout/hosted-checkout) on how to implement secure hosted page
- Here is an example of a request containing the 2 additional digital wallet parameters :



```
{
  "siteId": 1,
  "customer": {
    ...
  },
  "order": {
    ...
    "forceMethodType": "digitalWallet",
    "forceMethodBrand": "googlePay", //"applePay"
    ...
  },
  "cardTransactionMode": "authAndCapture",
  "transactionOption" : {
    ...
  }
}
```

> Merchants must adhere to the Google Pay APIs [Acceptable Use Policy](https://payments.developers.google.com/terms/aup)
and accept the terms defined in the [Google Pay API Terms of Service](https://payments.developers.google.com/terms/sellertos).


> Note: This option is not available for module integration ( woocomerce, shopify).


Native Google Pay button
Advanced API integration ( requires action from merchant side).
The merchant needs to setup in his  store  his own  Google pay button according to
Google [documentation](https://developers.google.com/pay/api/web/overview).
Once you setup the Google Pay button, Google servers will respond with an unique payment
token that will be used as shown in the flow below:

- The customer presses the Google Pay button and initialize the payment process!
- The user selects a payment method and Google Pay securely return a payment token, example below:



```
{"signature":"MEUCIQDPJHKAbu3Mq3gR/XRCj7VBcMSRke8Ei+s7wionxa0ELwIgOGx+dKFrgWgqn0QOwRsha8iA41WAmDnnr5CKA8QSPWE\u003d","intermediateSigningKey":{"signedKey":"{\"keyValue\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE4QEJygL7aVds0vYIgmFANsMI1XWYR585iEo/JGXK1koo17+DkQTUrNQychLAIgS6K2yABnlo0dlg3AqtdSiHzA\\u003d\\u003d\",\"keyExpiration\":\"1722508828750\"}","signatures":["MEUCIBdRGXWAhJsbK/qBL5ewVtHRLkMioYDY0vzbKr0UqMQVAiEAyHk7bg5gK+xQ7dn+W20Gsq2vwNNsvlJ0vqGe4+WrQ3U\u003d"]},"protocolVersion":"ECv2","signedMessage":"{\"encryptedMessage\":\"U056mK2s4b73NKRTcfU4hxqLnNlLe4NBF2tlzXyhL80l9yYzX3RM7GMygg7Fj12AnhZbAuok5wHfk9KEDQBFnT2H83FsZQ+8lTyPid+3zaezxJpVy+Z9NlNyrLEZZd70eb+LsXCKOatJYj6c6ylrEP7BQFCMGUeb8cGsr13VCpxicTZayBFQ5Uel3GWY6rpT/7EuZUyBXR4eWuUx4pJHJb45qUe9rTBFIbIfDMC94Wcyj/Jgnjz7YBIweD2uNb+ze5z12g3cWX6dcOLr68+PEDjD5AccNJtz/yddQCMbbHF6GwEfTFME7x4Q3gzE3DS8aHY3aWT5vneV+wIytzLPzkG1h+W6H8yf3VxxfwMmnWwhIHPz1yDfRrVsvOOr/3EpqN8+wzFhH7NrLuyVtzaDgFAEXH5rc6cG9d/ZkqV8fvjOn6MerLNUePFz1b0RIBLebh1kghDCbuZ29TC9Yf8yLebkK0Ff6aoiKwUEC5vpCo7m5Cyk9pUF1Ov7s4k7yA67SpWTXOOtOc99bQTtL42DO94ZIphw1pEKY+eHYA6sdoYyNkEL\",\"ephemeralPublicKey\":\"BG0yEmzzWX09fARDybC7/Pfyj1Y3M29NgpHDokieBUFlsuJSMev4urThys0oxMpNoRqvyif8bZuG5xetWJinwDI\\u003d\",\"tag\":\"reirglS5rrJMF7+ZNp/u/pmJmWjE2x9x6dv/YdRBAAw\\u003d\"}"}
```

- Then,  the merchant will send an API request to xMoney server  using the  POST/order route.
Make sure to include the token received from Google on the **transactionOptions** parameter,  as shown bellow:



```
{
  "digitalWallet":{
    "walletType":"googlePay",
    "data": "insert your received json from google pay here (Base64 encoded)"
  }
}
```

**You can validate your JSon  against the following schema:   [https://api-stage.xmoney.com/schema/transactionOption.schema.json](https://api-stage.xmoney.com/schema/transactionOption.schema.json)*

Below is an example of transaction Options parameter  JSon  containing valid digital wallet (token) data:


```
//transactionOption parameteres:
{
    "digitalWallet": {
      "walletType": "googlePay",
      "data": "{
        \"signature\":\"MEUCIHh7W6hmUJX1twpTH8pC0hEUQa37subPpfpnE41nAy0WAiEAsivyI4TUi7vfiLwZKNJH2C2RXzhJHIeRHmD/JGVYFFs\\u003d\",
        \"intermediateSigningKey\":{
          \"signedKey\":\"{
            \"keyValue\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEdBUEUp1AMdo5q8Wzlo8KKBWxxonMeXNVSHdRd20c6kMpgnX8Ezf2gPUkNee8uijVo370jZPfyxC/CBBI4wmQEg\\u003d\\u003d\",
            \"keyExpiration\":\"1738320754104\"
          }\",
          \"signatures\":[\"MEQCIB1R1gw9vZLiFoqJcLifdWl+739th67LBk4/0N4S7v5uAiBVmziIToEyDURCJ6CBGkaP3iruwzvMj5nvKzFi5zMb+g\\u003d\\u003d\"]
        },
        \"protocolVersion\":\"ECv2\",
        \"signedMessage\":\"{
          \"encryptedMessage\":\"j2b5dFklonXw8g7c0l6ZwuYtqK3MBuM9M5Kny/l8rHo3g5k7BcNqLg77/WrgPZPu4a7UbRkJLE+TU+nBszCb2CL1QjUAPBsvYKwNnv7geZ2PGCJCEYYhlt0uFibDIcNRb1UCU6IwDfTldCT+oPHmqPjRvS6nq9+bvts14ZpVNsqTJ/rxnaVem1J/U9laSg2fWYPyyoBWP0Hb0W5BmArv9XUU6G3btKDb/w03OHlrbqOS7JsTl2vUGrK99NNQu4gbRz0XsSlzVORJIiXfvEo3JxC9c7p5aS988ajxMd5+oF11thqvMyoapDhqRy1UJqz8y7jAduu8cTinwnS7QkJ8SaSe7b47jlktD47QwJySxPsoDvX/3WBuWxT2PChtio8gMBJxcvzXmIKRIeRXVnYLEN2QfVGS24YwQ2pgMU7ixERuQ60bn9GrO6GFRScZTlExvWWuvPm9mhApn7ZZ/FDjICqZkLCz/8lt3pYAzyQgiLMAo7CEKuwpdKpPhVPHqwikwSXhZz1f0KVNV360avd9OS9ICXHylT2f/rJ+W/LqFsYSCs3JgqiogKctQA4FC86zZds\\u003d\",
          \"ephemeralPublicKey\":\"BKPm7rTncCXEG/Wa10DtZCCuMnubQ0CuSbvIuIyfpqO00DF5rQwm9lR/VQYU3xoJUG1YJF0JQQ8WaseSYoaYQ9Y\\u003d\",
          \"tag\":\"9nN/y5HYUPf65YGHfPy1yxryqr0jmXEDVDn2Sycte9o\\u003d\"
          }\"
      }"
    }
}
```

- After posting your request, xMoney will send back a transaction status response!


Follow this [integration checklist](https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist) from Google
to validate that you've completed all the required steps in your web integration

### Accept a payment using GooglePay in your Android App

#### Prerequisites

You app must be:

- Distributed through the Google Play store
- Built using the following configuration:
  - A `minSdkVersion` of `21` or higher
  - A `compileSdkVersion` of `34` or higher
- Follow the [Google Pay Android Brand Guidelines](https://developers.google.com/pay/api/android/guides/brand-guidelines)


> If you wish to test with your own device, you need to [add a payment method to your Google Account](https://support.google.com/wallet/answer/12058983?visit_id=637947092743186187-653786796&rd=1).


More details about how to configure the app can be found on
the official [Google Pay API](https://developers.google.com/pay/api/android/overview) documentation.

#### 1. Setup your integration

To start the setup follow [this guide](https://developers.google.com/pay/api/android/guides/setup).

For requesting a payment token you will need to use the following configs:


```
gateway: "xmomeypay"
gatewayMerchantId: "googlePayID"
```

To fetch the googlePayId you need to go to [Google Pay & Wallet Console](https://pay.google.com/business/console?utm_source=devsite&utm_medium=devsite&utm_campaign=devsite). The ID is found on the top right corner of the Google Pay Console.

Supported card networks are:

- Visa
- Mastercard


Supported Authorization methods are:

- PAN_ONLY
- CRYPTOGRAM_3DS


When configuring the card parameters, we need the `billingAddressParameters` as follows:


```
{
  format: "MIN",
  phoneNumberRequired: true
}
```

See [BillingAddressParameters](https://developers.google.com/pay/api/web/reference/request-objects#BillingAddressParameters) for more information.

#### 2. Add the Google Pay button

Add the Google Pay button to your app by following [Google’s tutorial](https://developers.google.com/pay/api/android/guides/tutorial#add-button).
This ensures you’re using the correct assets.

#### 3. Handle the result

- Get the `token` from the [PaymentData](https://developers.google.com/pay/api/web/reference/response-objects#PaymentData) response from the Google Pay API.
- From you API make a POST /order request to xMoney API and include the token info in `transactionOption` as shown bellow:



```
{
  "digitalWallet":{
    "walletType":"googlePay",
    "data": "insert your received json from google pay here (Base64 encoded)"
  }
}
```

If the shoper used a card that requires 3D secure authentication, before the payment can be completed,
you receive a response with redirect instructions:


```
{
  "code": 201,
  "message": "Created",
  "data": {
    "orderId": 0,
    "transactionId": 0,
    "is3d": 1,
    "isRedirect": true,
    "redirect": {
      "url": "https://secure.xmoney.com/acs20...",
      "formMethod": "POST",
      "params": {
        "PaReq": "",
        "MD": "",
        "TermsUrl": ""
      }
    }
  }
}
```

Use the `redirect` information to redirect the shopper to another webview to complete the 3D secure authentication.

Otherwise proceed to presenting the payment result to your shopper.

Refer to our [3D Secure Overview](/guides/payments/3d-secure/3d-secure) for more on frictionless vs. challenge flows.

#### 4. Test your integration

Follow this [Integration Checkist](https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist) Google
and [Test Your Integration](https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist#testing-your-integration).

#### 5. Go live with Google Pay

Follow [Google's instructions](https://developers.google.com/pay/api/android/guides/test-and-deploy/publish-your-integration) to request production access for your app. Choose the integration type
**Gateway** when prompted, and provide screenshots of your app for review.

## **Testing and Going Live**

### **Test Your Integration**

* Use [https://merchant-stage.xmoney.com](https://merchant-stage.xmoney.com/) for testing or  API
* The secure URL for testing  is: [https://secure-stage.xmoney.com](https://secure-stage.xmoney.com/)


### **Go Live**.

* Ensure your **xMoney API keys** are correct for production.
* Test real transactions to confirm proper payment processing.


## **Additional Resources**

* [Google Pay API Documentation](https://developers.google.com/pay/api/web/)
* [xMoney API](https://docs.xmoney.com/)


By following these steps, you will have a functional Google Pay integration with xMoney, offering customers a smooth and secure checkout experience.