> For the complete documentation index, see [llms.txt](https://docs.2checkout.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.2checkout.com/json-rpc-api-reference/json-rpc-api-6.0/api-requests/place-orders-with-catalog-products/use-googlepay-tm.md).

# Use GooglePay™

GooglePay<sup>TM</sup> has over 150 million users across 42 global markets using the app each month. The wallet is used on nearly 800.000 websites as a secure payment gateway. Roughly 20% of all mobile purchases are made using this digital payment gateway.

## Availability&#x20;

To check in which countries or regions you can use Google Pay, read more on availability and geographical coverage [here](https://support.google.com/pay/answer/9023773?hl=en-GB). If you need more information on Google Pay, you can also refer to these Google resources: &#x20;

* Here is the documentation for Android: [Google Pay API terms of service](https://payments.developers.google.com/terms/sellertos), [Tutorial](https://developers.google.com/pay/api/android/guides/tutorial?authuser=1), [Brand guidelines for Android](https://developers.google.com/pay/api/android/guides/brand-guidelines?authuser=1), [Integration checklist for Android](https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist?authuser=1), Google Pay implementation for Google Pay API for [Android](https://developers.google.com/pay/api/android/overview)&#x20;
* Here is the documentation for web: [Google Pay API terms of service](https://payments.developers.google.com/terms/sellertos), [Tutorial](https://developers.google.com/pay/api/web/guides/tutorial), [Brand guidelines for Web](https://developers.google.com/pay/api/web/guides/brand-guidelines), [Integration checklist for web](https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist), Google Pay implementation for Google Pay API for [Web](https://developers.google.com/pay/api/web/overview)
* Here are the Google policies: All merchants are required to follow the [Google Pay and Wallet API's 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).&#x20;

## Supported features&#x20;

Since Google Pay is not a classical payment method, but a digital wallet, the supported features depend on the payment means that are used.&#x20;

Furthermore, the merchant can only accept payment methods that are activated on the specified terminal ID. &#x20;

The payment means within the wallet are then processed via the normal processors.&#x20;

For example, if a cardholder selects his Visa card, the card is then processed as such, through Google Pay as the wallet.&#x20;

Only Visa, Mastercard, and American Express are supported through Google Pay at this point.&#x20;

## Supported Google Pay Features&#x20;

Within Google Pay itself, 2Checkout Supports the following feature set:&#x20;

| Feature               | Via Payment Page | Via Server-To-Server |
| --------------------- | ---------------- | -------------------- |
| Pay with Cryptogram   | ✅                | ✅                    |
| Pay with PAN only     | ✅                | ✅                    |
| 3-D Secure            | ✅                | ✅                    |
| (Cryptogram/PAN only) | ✅                | ✅                    |

The Difference between PAN only and Cryptogram lies in the way authentication/3D Secure is handled:&#x20;

PAN Only: 3DS/Authentication is handled through 2Checkout.&#x20;

Cryptogram: Authentication is handled by the device, e.g. by using the devices fingerprint sensor. This is limited to Android devices, using the Google Chrome browser! All other devices and browsers will always chose PAN Only!&#x20;

## Supported currencies

GooglePay<sup>TM</sup> supports EUR, USD, GBP, CHF, DKK, NOK and SEK transactions.

## Workflow

1. Follow the Google Pay Web documentation (<https://developers.google.com/pay/api/web/overview>) to add a **Google Pay** button to your web page.
2. Use 2Checkout's Google merchant ID when building the `merchantInfo` object.

   ```php
   {
     "merchantInfo": {
       "merchantId": "BCR2DN6T2OAK7HIW"
     }
   }
   ```
3. Set gateway to **verifone** and gatewayMerchantId to your 2Checkout's gateway ID found below when building the tokenizationSpecification object.

   ```php
   {
   "allowedPaymentMethods": [ 
               { 
                 "type": "CARD", 
                 "parameters": { 
                   "billingAddressRequired": true, 
                   "billingAddressParameters": { 
                     "phoneNumberRequired": true, 
                     "format": "MIN" 
                   }, 
                   "allowedCardNetworks": [“VISA”,”MASTERCARD”,”AMEX”], 
                   "allowedAuthMethods": [“PAN_ONLY”,”CRYPTOGRAM_3DS”] 
                 }, 
                 "tokenizationSpecification": {...} 
               },
                "tokenizationSpecification": {
               "type": "PAYMENT_GATEWAY",
               "parameters": {
                 "gateway": "verifone",
                 "gatewayMerchantId": "1ab01f9d-10a6-43fe-9c9e-941798a0813b"
               }
             }
           }
   ```

GooglePay supports two authorization methods:&#x20;

\- PAN\_ONLY: physical card stored in Google Pay™&#x20;

&#x20; \- 3DS required: yes (managed by 2Checkout)&#x20;

\- CRYPTOGRAM\_3DS: device-tokenized card&#x20;

&#x20; \- 3DS required: no (authenticated by Google Pay™)&#x20;

4. After the shopper authorizes the payment, pass the token from the Google response to Verifone to process the payment. To do this, encode the token to base64 and add it to the `placeOrder` call payload in the `PaymentToken` property.
5. When the customer completes the Google Pay payment sheet, Google returns a PaymentData response object. Extract the encrypted token from:&#x20;

   &#x20;

```php
PaymentMethodData.tokenizationData.token  
```

&#x20;Encode the token value to Base64, then pass it to the placeOrder API call in the PaymentToken field:

```php
{ 

 "PaymentDetails": { 

   "Type": "GOOGLEPAY", 

   "PaymentToken": "<Base64-encoded token from paymentMethodData.tokenizationData.token>" 

 } 

} 
```

6. Go-live &#x20;

## Request parameters

<table><thead><tr><th width="121.2000732421875">Parameter</th><th>Type/Description</th></tr></thead><tbody><tr><td><code>sessionID</code></td><td><strong>Required (string)</strong><br>Session identifier, the output of the <strong>Login</strong> method. Include <code>sessionID</code> into all your requests. 2Checkout throws an exception if the values are incorrect. The <code>sessionID</code> expires in <strong>10 minutes</strong>.</td></tr><tr><td><a href="/pages/1Nzq8FH3DErKvpOktB0W"><code>Order</code></a></td><td><strong>Required (object)</strong><br>Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.<br>See code sample for more details.</td></tr></tbody></table>

### Request sample

```php
<?php
declare(strict_types=1);
class Configuration
{
    public const MERCHANT_CODE = 'your_code';
    public const MERCHANT_KEY = 'SECRET_KEY';
    public const URL = 'https://api.2checkout.com/rpc/6.0';
    public const ACTION = 'placeOrder';
    //array or JSON
    public const PAYLOAD =  <<<JSON
{
  "Currency": "usd",
  "Language": "en",
  "Country": "us",
  "Source": "API",
  "Affiliate": {
        "AffiliateCode": "ABCDE1234"
  },
  "Items": [\
    {\
      "Code": "WP1",\
      "Quantity": 2\
    }\
],
  "BillingDetails": {
    "Address1": "Test Address",
    "City": "LA",
    "State": "California",
    "CountryCode": "US",
    "Email": "testcustomer@2Checkout.com",
    "FirstName": "Customer",
    "LastName": "2Checkout",
    "Zip": "12345"
  },
  "PaymentDetails": {
        "Type": "GOOGLEPAY",
        "Currency": "USD",
        "PaymentMethod": {
            "RecurringEnabled": true,
            "PaymentToken": "eyJzaWduYXR1cmUiOiJNRVlDSVFDVDBrek53RDFpcmRqTlYxZDJXT2k4eFplSDBhdnRwNXFsVWVoejdsenpkd0loQUxYdWlzNlMwNnJPemNZdUVPYW0rb0tiUDZzd3J5K1dMcnA1ajVGRkhialIiLCJpbnRlcm1lZGlhdGVTaWduaW5nS2V5Ijp7InNpZ25lZEtleSI6IntcImtleVZhbHVlXCI6XCJNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUyZjBxZllRMHZ1OTlzNFlXOUwzZ3RERUZYdW5yMmhhRUdMSTI1Q3ZObkxzMk9tV3FHbW8zSFZHYnVhL1IvamQyWHNWeFFBbFVPdDRzUFBpQ0RMQ3pHQVxcdTAwM2RcXHUwMDNkXCIsXCJrZXlFeHBpcmF0aW9uXCI6XCIxNjkzMjk2NjUzNTAwXCJ9Iiwic2lnbmF0dXJlcyI6WyJNRVVDSVFEQUFPQmJlQXpDWWF4VWVWbmNMekg0L3ZpSGNZTUFrNUU1Z3RUc0NoWGJsZ0lnRi81eDAzM2d2a25kQ1V6WmJVTzJnbjBuZ001cEFWbEZkNXhlNFE2b3pnSVx1MDAzZCJdfSwicHJvdG9jb2xWZXJzaW9uIjoiRUN2MiIsInNpZ25lZE1lc3N"
        }
    }
}
JSON;

}
class Client
{
    private const LOGIN_METHOD = 'login';
    private $calls = 1;
    private $sessionId;

    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $algo = 'sha256';
        $hash = hash_hmac($algo, $string, $key);
        return compact('merchantCode', 'date', 'hash', 'algo');
    }

    public function login(string $url)
    {
        $payload = $this->generateAuth();
        $response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
        $this->sessionId = $response['result'];
    }

    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?array {
        if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
            $this->login($url);
        }
        if(is_string($payload)) {
            $payload = json_decode($payload, true);
        }
        if (!empty($this->sessionId)) {
            $payload = [$this->sessionId, $payload];
        }
        $payload = array_filter($payload);
        $request = json_encode([\
            'jsonrpc' => '2.0',\
            'method' => $action,\
            'params' => $payload,\
            'id' => $this->calls++,\
        ]);
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSLVERSION, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if(empty($response)) {
            die('Server unavailable');
        }
        echo $response . '</br>';
        return json_decode($response, true);;
    }
}
$client = new Client();
$result = $client->call();
var_dump($result);
}
```

## Response parameters

<table><thead><tr><th width="179.86669921875">Parameter</th><th>Type / Description</th></tr></thead><tbody><tr><td><a href="/pages/296f77b2320970fcc8c6d6047e6ecabcaa996ffa"><code>Order information</code></a></td><td><strong>Object</strong><br>Object containing order information.</td></tr></tbody></table>

### Response sample

```php
{
    "RefNo": "74980739",
    "OrderNo": 0,
    "ExternalReference": "1692609928",
    "ShopperRefNo": null,
    "Status": "AUTHRECEIVED",
    "ApproveStatus": "WAITING",
    "VendorApproveStatus": "OK",
    "MerchantCode": "uniqueVendorCode123",
    "Language": "en",
    "OrderDate": "2023-08-21 13:26:10",
    "FinishDate": null,
    "Source": "API",
    "WSOrder": null,
    "HasShipping": false,
    "BillingDetails": {
        "FirstName": "John",
        "LastName": "Doe",
        "Company": "Wayne corp",
        "Email": "jhonnydoe@example.com",
        "Address1": "Street 223",
        "Address2": null,
        "City": "Bucharest",
        "Zip": "10460",
        "CountryCode": "ro",
        "State": "Bucharest",
        "FiscalCode": null,
        "TaxOffice": null,
        "Phone": null
    },
    "DeliveryDetails": {
        "FirstName": "John",
        "LastName": "Doe",
        "Company": "Wayne corp",
        "Email": "jhonnydoe@example.com",
        "Address1": "Street 223",
        "Address2": null,
        "City": "Bucharest",
        "Zip": "2002",
        "CountryCode": "ro",
        "State": "Bucharest",
        "Phone": null
    },
    "PaymentDetails": {
        "Type": "GOOGLEPAY",
        "Currency": "usd",
        "CustomerIP": "172.18.0.1"
    },
    "CustomerDetails": null,
    "Origin": "API",
    "AvangateCommission": 0,
    "OrderFlow": "REGULAR",
    "GiftDetails": null,
    "PODetails": null,
    "ExtraInformation": null,
    "PartnerCode": null,
    "PartnerMargin": null,
    "PartnerMarginPercent": null,
    "ExtraMargin": null,
    "ExtraMarginPercent": null,
    "ExtraDiscount": null,
    "ExtraDiscountPercent": null,
    "LocalTime": null,
    "TestOrder": false,
    "FxRate": 1,
    "FxMarkup": 0,
    "PayoutCurrency": "USD",
    "DeliveryFinalized": false,
    "Errors": null,
    "Items": [\
        {\
            "PurchaseType": "PRODUCT",\
            "Code": "M5S5M35YX1",\
            "ExternalReference": "",\
            "Quantity": 1,\
            "PriceOptions": [],\
            "SKU": null,\
            "Price": {\
                "Currency": "usd",\
                "NetPrice": 10,\
                "GrossPrice": 11.9,\
                "NetDiscountedPrice": 10,\
                "GrossDiscountedPrice": 11.9,\
                "Discount": 0,\
                "VAT": 1.9,\
                "AffiliateCommission": 0,\
                "UnitNetPrice": 10,\
                "UnitGrossPrice": 11.9,\
                "UnitVAT": 1.9,\
                "UnitDiscount": 0,\
                "UnitNetDiscountedPrice": 10,\
                "UnitGrossDiscountedPrice": 11.9,\
                "UnitAffiliateCommission": 0,\
                "ItemUnitNetPrice": null,\
                "ItemUnitGrossPrice": null,\
                "ItemNetPrice": null,\
                "ItemGrossPrice": null,\
                "VATPercent": 19,\
                "HandlingFeeNetPrice": 0,\
                "HandlingFeeGrossPrice": 0\
            },\
            "CrossSell": null,\
            "Trial": null,\
            "AdditionalFields": null,\
            "Promotion": null,\
            "RecurringOptions": null,\
            "SubscriptionStartDate": null,\
            "SubscriptionCustomSettings": null,\
            "UpSell": null,\
            "ProductDetails": {\
                "Name": "AntiVirus123Subscription",\
                "ShortDescription": "",\
                "Tangible": false,\
                "IsDynamic": false,\
                "ExtraInfo": null,\
                "RenewalStatus": false,\
                "Subscriptions": null,\
                "DeliveryInformation": {\
                    "Delivery": "NO_DELIVERY",\
                    "DownloadFile": null,\
                    "DeliveryDescription": "",\
                    "CodesDescription": "",\
                    "Codes": []\
                }\
            },\
            "LineItemReference": "2bc911a264d3b92750fbd06363465f408f2a89d8"\
        }\
    ],
    "Promotions": [],
    "AdditionalFields": null,
    "Currency": "usd",
    "NetPrice": 10,
    "GrossPrice": 11.9,
    "NetDiscountedPrice": 10,
    "GrossDiscountedPrice": 11.9,
    "Discount": 0,
    "VAT": 1.9,
    "AffiliateCommission": 0,
    "CustomParameters": null,
    "Refunds": null,
    "ContainsRenewableProducts": null,
    "RequestDeliveryData": false
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.2checkout.com/json-rpc-api-reference/json-rpc-api-6.0/api-requests/place-orders-with-catalog-products/use-googlepay-tm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
