# Use GooglePay

GooglePay 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.

## Supported currencies

GooglePay 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.<br>

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

   ```php
   {
             "tokenizationSpecification": {
               "type": "PAYMENT_GATEWAY",
               "parameters": {
                 "gateway": "verifone",
                 "gatewayMerchantId": "1ab01f9d-10a6-43fe-9c9e-941798a0813b"
               }
             }
           }
   ```
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.

## Request parameters

<table><thead><tr><th width="122.2666015625">Parameter</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>sessionID</code></td><td><p><strong>Required (string)</strong></p><p>Session identifier — the output of the Login method. Include <code>sessionID</code> into all your requests. <code>sessionID</code> expires in 10 minutes.</p></td></tr><tr><td><a href="/pages/ntYqWA3pWPLrpvzTn87M"><code>Order</code></a></td><td><p><strong>Required (object)</strong></p><p>Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details. See code sample for more details.</p></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/soap/6.0';
    public const ACTION = 'placeOrder';

    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
{
    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?object {
        if (is_array($payload)) {
            $payload = json_encode($payload);
        }
        if (!empty($payload)) {
            // SoapClient works with objects(StdClass)
            $payload = json_decode($payload);
        }
        $soapClient = $this->getClient($url);
        $sessionId = $this->getSession($soapClient);
        $args = array_filter([$sessionId, $payload]);
        return $soapClient->$action(...$args);
    }

    public function getClient(string $url): SoapClient
    {
        return new SoapClient(
            $url.'?wsdl',
            [\
                'location' => $url,\
                'cache_wsdl' => WSDL_CACHE_NONE,\
            ]
        );
    }

    public function getSession(SoapClient $client)
    {
        $date = gmdate('Y-m-d H:i:s');
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $string = strlen($merchantCode).$merchantCode.strlen($date).$date;
        $algo = 'sha256';
        $hash = hash_hmac($algo, $string, $key);
        $client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
        return $client->login($merchantCode, $date, $hash, $algo);
    }
}
try {
    $client = new Client();
    var_dump($client->call());
} catch (Exception $ex) {
    var_dump($ex);
}
```

## Response parameters

<table><thead><tr><th width="184.13330078125">Parameter</th><th>Type / Description</th></tr></thead><tbody><tr><td><a href="/pages/010708cd78f3efa4929d4374cb2abe08c3d2b686"><code>Order information</code></a></td><td><p><strong>Object</strong></p><p>Object containing order information.</p></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: 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/soap-api-reference/soap-api-6.0/api-requests/place-orders-with-catalog-products/use-googlepay.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.
