Skip to main content

Google Pay

Overview

Google Pay is a digital wallet and online payment method developed by Google. It's one of the most popular digital wallets, offering a fast and simple way to pay.

Availability

Supported countries: worldwide upon Google Pay local availability.

Supported currencies: EUR, USD, GBP, CHF, DKK, NOK, and SEK.

Supporting recurring payments: yes

Benefits

  • Merchants offer shoppers safe payments with their preferred localized payment methods.
  • Increased conversion and authorization rates, as Google Pay is used by over 150 million customers across 42 global markets.
  • Simplified payment acceptance across different sales channels for Verifone Merchants.

Activate Google Pay

Please contact your account representative and request the activation of Google Pay.

Shopper flow

  1. The shopper initiates an online purchase. 
  2. Once the products for purchase are selected, the 2Checkout checkout page will be displayed.
  3. The shopper selects Google Pay as a payment method and continues the checkout process.

Select Google Pay

4. On the confirmation page, the shopper clicks the Buy with GPay button.

Google Pay shopper flow

5. The shopper is redirected to the Google Pay payment flow. If the shopper is already logged into their Google Account, they are prompted with a pop-up where they can select their desired saved card, to be used for finalizing this purchase.

If the shopper is not yet logged into their Google Account at this step they will be asked to log in, and then they can select their desired card.

Google Pay saved cards

6. Additional authentication via 3DS might be required in the countries where SCA and 3DS are mandatory.

7. Once all steps are completed, the Finish page is displayed, as the order is confirmed.

Google Pay order confirmed

IPN read receipt response for 2Checkout

Overview

To validate the success of the notification process insert an inline response in the script output of your IPN listener. Once 2Checkout validates the response it considers the IPN successful. Otherwise, 2Checkout sends notifications per the failure recovery process until you provide a valid response.

Read receipt response from 2Checkout

The read receipt response is required in the IPN response body, unlike the previous hash string which is optional, with the EPAYMENT tag. We use this hash as a method of security.

To validate the success of the notification process, insert an inline response in the script output of your IPN listener. 2Checkout expects the following format:

<sig algo="sha256" date="DATE">HASH</sig>

   Note:  Possible values for algo: sha256, sha3-256.

Once 2Checkout validates that the above format is part of the response it considers the IPN successful. Otherwise, 2Checkout continues to send notifications per the failure recovery process until you provide a valid response.

DATE Datetime stamp. YmdHis. (20081117145935)
HASH

Calculate the HMAC_SHA signature using:

  • IPN_PID[0]
  • IPN_PNAME[0]
  • IPN_DATE
  • DATE
  • Your account’s secret key

HASH fields values are case insensitive.

The fields used in the HMAC_SHA signature are captured from the IPN payload just received, in the same order:

Field name Description
IPN_PID[0] First product ID from the IPN_PID[] array.
IPN_PNAME[0] First product name from the IPN_PNAME[] array.
IPN_DATE IPN date in the YmdHis format (ex: 20081117145935)
DATE Response issuing date (server time) in the YmdHis format (ex: 20081117145935)

For the example parameters included in this article, build the response using shorter data formats for date values. Use only the following values, in the same order, for the HMAC source string:

Field name Length Field value
IPN_PID[0] 1 1
IPN_PNAME[0] 16 Software program
IPN_DATE 14 20050303123434
DATE 14 20050303123434

Therefore, the HMAC source string is:

1116Software program14200503031234341420050303123434

while the HMAC SHA-2 string is: 

ea6f44c39b3d204b59500998fcb9221c92744d9721a94b45fc6d5cda99980176

and the HMAC SHA-3 string is:

85180497aaaa4844a278b52b1ce257d2820dbf5857470a5f678fef2266d0d4a8

Configure the response to output anywhere on the page defined as the IPN URL for:

  • SHA-2:
<sig algo="sha256" date="20050303123434">ea6f44c39b3d204b59500998fcb9221c92744d9721a94b45fc6d5cda99980176</sig>
  • SHA-3:
<sig algo="sha3-256" date="20050303123434">85180497aaaa4844a278b52b1ce257d2820dbf5857470a5f678fef2266d0d4a8</sig>

2Checkout checks the string’s validity and marks notifications as "successfully sent" in the 2Checkout system. Otherwise, 2Checkout resends the IPN notifications at specific time intervals described in the failure recovery process section, until successfully confirmed. Also, 2Checkout displays an error notification in the Dashboard area of your Merchant Control Panel.

Use ApplePay

Overview

Place an order using catalog products defined in your Control Panel, and collect the payment using ApplePay.

Currency support

Check with 2Checkout support for a list of currencies available for ApplePay.

Activation

For activation, you need to have Apple Pay enabled on your 2Checkout account. Contact the Merchant Support team in order to enable this. After 2Checkout sets up our domain, we will provide you with a domain verification file.

Host your domain verification file at the following path on our server: https://[DOMAIN_NAME]/.well-known/apple-developer-merchantid-domain-association.

Workflow

  1. Initialize an ApplePay session using our API.
  2. Collect the "ApplePayDataToken" provided by Apple Pay client side and pass it server side to make the placeOrder API call.
  3. Create the order object. Use APPLE_PAY as the type in the PaymentDetails object and pass the "ApplePayDataToken" through the "ApplePayToken" property in the PaymentMethod object. Place the order.

Parameters

Parameters Type/Description
sessionID Required (string)
  Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.
Order Required (Object)
  Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

Response parameters

Parameters Type/Description
Order information Object
  Object containing order information.

Request

<?php

declare(strict_types=1);

class Configuration
{
    public const MERCHANT_CODE = 'MERCHANT_CODE';
    public const MERCHANT_KEY = 'SECRET_KEY';
    public const URL = 'http://api.avangate.local/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": "K6DHJXGULK",
      "Quantity": 2
    }
],
  "BillingDetails": {
    "Address1": "Test Address",
    "City": "LA",
    "State": "California",
    "CountryCode": "US",
    "Email": "testcustomer@2Checkout.com",
    "FirstName": "Customer",
    "LastName": "2Checkout",
    "Zip": "12345"
  },
  "PaymentDetails":{
      "Type":"APPLE_PAY",
      "Currency":"USD",
      "CustomerIP":"10.10.10.10",
      "PaymentMethod":{
         "ApplePayToken":"ApplePayDataToken"
      }
   }
}
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);

Use ApplePay

Overview

Place an order using catalog products defined in your Control Panel, and collect the payment using ApplePay.

Currency support

Check with 2Checkout support for a list of currencies available for ApplePay.

Activation

For activation, you need to have Apple Pay enabled on your 2Checkout account. Contact the Merchant Support team in order to enable this. After 2Checkout sets up our domain, we will provide you with a domain verification file.

Host your domain verification file at the following path on our server: https://[DOMAIN_NAME]/.well-known/apple-developer-merchantid-domain-association.

Workflow

  1. Initialize an ApplePay session using our API.
  2. Collect the "ApplePayDataToken" provided by Apple Pay client side and pass it server side to make the placeOrder API call.
  3. Create the order object. Use APPLE_PAY as the type in the PaymentDetails object and pass the "ApplePayDataToken" through the "ApplePayToken" property in the PaymentMethod object. Place the order.

Parameters

Parameters Type/Description
sessionID Required (string)
  Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.
Order Required (Object)
  Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

Response parameters

Parameters Type/Description
Order information Object
  Object containing order information.

Request

<?php
declare(strict_types=1);
class Configuration
{
    public const MERCHANT_CODE = 'MERCHANT_CODE';
    public const MERCHANT_KEY = 'SECRET_KEY';
    public const URL = 'http://api.avangate.local/soap/6.0';
    public const ACTION = 'placeOrder';

    public const PAYLOAD =  <<<JSON
{
  "Currency": "usd",
  "Language": "en",
  "Country": "us",
  "Source": "API",
  "Affiliate": {
        "AffiliateCode": "ABCDE1234"
  },
  "Items": [
    {
      "Code": "K6DHJXGULK",
      "Quantity": 2
    }
],
  "BillingDetails": {
    "Address1": "Test Address",
    "City": "LA",
    "State": "California",
    "CountryCode": "US",
    "Email": "testcustomer@2Checkout.com",
    "FirstName": "Customer",
    "LastName": "2Checkout",
    "Zip": "12345"
  },
  "PaymentDetails":{
      "Type":"APPLE_PAY",
      "Currency":"USD",
      "CustomerIP":"10.10.10.10",
      "PaymentMethod":{
         "ApplePayToken":"ApplePayDataToken"
      }
   }
}
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);
}

Interface templates

2Checkout provides a list of responsive templates meant for improving the customer experience during the checkout process.

The templates presented below are available in your Merchant Control Panel under Setup → Interface templates → Template Gallery.

Omnicart Flow Checkout (default) 

Desktop Version

The Omnicart Flow Checkout is a B2B and B2C shopping cart template with add-on products for cross-sales, promotions, and AOV management, optimized for companies on a SaaS or renewal license model. We've recently updated its layout to encompass CRO key findings and best practices and, thus, help merchants using this template see a 5-10% increase in their conversion rates. 

Among the key UX improvements, you can notice the reduced overall height and scroll on-page for the whole form by merging some sections and removing all redundant elements. We've also redesigned the Company/Person selector, changed the order of fields in the form, updated the Paypal payment method with optimized up-to-date flows, simplified texts, and payment method button selector, and added certification and trust logos immediately below the Place Order button on the Review Page.

omnicart flow checkout_desktop view_3.png

Mobile Version

omnicart flow checkout_mobile view_1.png 

omnicart flow checkout_mobile view_2.png

omnicart flow checkout_mobile view_3.png

omnicart flow checkout_mobile view_4.png

Scale Express Checkout 

Desktop version

templateA_1.png

templateA_2.png

Mobile Version

templateA_3.PNG  templateA_4.PNG  templateA_5.PNG

Swift-Pay Checkout 

Desktop version

templateB_1.PNG

templateB_2.PNG

Mobile Version

templateB_3.png  templateB_4.PNG  templateB_5.PNG

Global Optimizer Checkout 

Desktop version

templateC_1.PNG

templateC_2.PNG

templateC_3.PNG

Mobile Version

templateC_4.PNG  templateC_5.PNG  templateC_6.PNG

Digital Horizontal Flow Checkout 

Desktop version

templateD_1.PNG

Mobile Version

templateD_2.PNG  templateD_3.PNG  templateD_4.PNG

Drop-down Monetize Checkout 

Desktop version

templateE_1.PNG

templateE_2.PNG

Mobile Version

templateE_3.PNG  templateE_4.PNG  templateE_5.PNG  templateE_6.PNG

CompactPlus Checkout 

Desktop version

templateF_1.PNG

 Mobile Version

templateF_2.PNG  templateF_3.PNG  templateF_4.PNG templateF_5.PNG

 

Attach PayPal to a subscription

Overview

Use the attachToPayPal method to build the PayPal URL that can be used to attach a subscription to a PayPal account.

Request parameters

Parameters

Type

Required

Description

subscriptionCode

String

Yes

The subscription code that will be attached to the PayPal account.

paypalEmail

String

Yes

The PayPal email associated with the subscription.

returnURL

String

Yes

The URL the user will be redirected to if the subscription is successfully attached to PayPal.

cancelURL

String

Yes

The URL the user will be redirected to if the subscription fails to attach to PayPal.

Request example

<?php


$host = "https://api.2checkout.com";


$merchantCode = "MERCHANT_CODE";
//your account's merchant code available in the 'System settings' area of the cPanel:
//https://secure.2checkout.com/cpanel/account_settings.php

$key = "SECRET_KEY";
//your account's secret key available in the 'System settings' area of the cPanel:
//https://secure.2checkout.com/cpanel/account_settings.php


$now = gmdate('Y-m-d H:i:s'); //GMT date format)
$algo = "sha256";
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash = hash_hmac($algo, $string, $key);

try {
    $client = new SoapClient($host . "/soap/6.0/?wsdl", [
        'location'       => $host . "/soap/6.0/",
        "stream_context" => stream_context_create([
            'ssl' => [
                'verify_peer'      => false,
                'verify_peer_name' => false
            ]
        ])
    ]);
    $sessionID = $client->login($merchantCode, $now, $hash, $algo);
    echo("Auth token: {$sessionID}" . PHP_EOL);

    $subscriptionCode = 'SUBSCRIPTIONCODE';
    $paypalEmail = 'PAYPALEMAIL';
    $returnURL = 'RETURNURL';
    $cancelURL = 'CANCELURL';

   var_dump($res);
} catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage() . PHP_EOL;
   exit;
} catch (Exception $ex) {
   echo $ex->getMessage() . PHP_EOL;
   exit;
}

Response parameters

Parameters

Type

Description

status

String

Can be "success" if no errors occurred or "error" otherwise.

url

String

The PayPal redirect URL if no errors occurred or empty otherwise.

error

Array

Empty if no errors occurred or the error message otherwise.

Error response parameters

Parameters

Type

Description

error_code

String

The error code of the returned exception

message

String

The error message of the returned exception

If the API throws an error, an error response will be received, similar to:

{
    "error_code": "SUBSCRIPTION_PAYPAL_ATTACH_ERR",
    "message": "Failed to link subscription to PayPal account"
}

 

Attach PayPal to a subscription

Overview

Use the attachToPayPal method to build the PayPal URL that can be used to attach a subscription to a PayPal account.

Request parameters

Parameters Type Required Description
subscriptionCode String Yes The subscription code that will be attached to the PayPal account.
paypalEmail String Yes The PayPal email associated with the subscription.
returnURL String Yes The URL the user will be redirected to if the subscription is successfully attached to PayPal.
cancelURL String Yes The URL the user will be redirected to if the subscription fails to attach to PayPal.

Request example

<?php
 
/**
 * @throws JsonException
 */
function callRPC($Request, $host)
{
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Accept: application/json']);
    $RequestString = json_encode($Request, JSON_THROW_ON_ERROR);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
 
    $ResponseString = curl_exec($curl);
 
    if (!empty($ResponseString)) {
        echo($ResponseString);
        $Response = json_decode($ResponseString, false, 512, JSON_THROW_ON_ERROR);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            echo("Method: {$Request->method}" . PHP_EOL);
            echo("Error: {$Request->error}" . PHP_EOL);
        }
    } else {
        return null;
    }
 
    return null;
}
 
$host = 'https://api.avangate.com/rpc/6.0/';
 
$merchantCode = "MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key = "SECRET_KEY"; // your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
 
$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$algo = "sha256";
$hash = hash_hmac($algo, $string, $key);
 
$i = 1;
 
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = [$merchantCode, gmdate('Y-m-d H:i:s'), $hash, $algo];
$jsonRpcRequest->id = $i++;
 
try {
    $sessionID = callRPC($jsonRpcRequest, $host);
    echo("Auth token: {$sessionID}" . PHP_EOL);
} catch (JsonException $e) {
    echo("Error: {$e->getMessage()}" . PHP_EOL);
}
 
$subscriptionCode = 'SUBSCRIPTIONCODE';
$paypalEmail = 'PAYPALEMAIL';
$returnURL = 'RETURNURL';
$cancelURL = 'CANCELURL';
 
$jsonRpcRequest = array (
    'method' => 'attachToPayPal',
    'params' => array($sessionID, $subscriptionCode, $paypalEmail, $returnURL, $cancelURL),
    'id' => $i++,
    'jsonrpc' => '2.0');
 
var_dump (callRPC((Object)$jsonRpcRequest, $host, true)); 

Response parameters

Parameters Type Description
status String Can be "success" if no errors occurred or "error" otherwise.
url String The PayPal redirect URL if no errors occurred or empty otherwise.
error Array Empty if no errors occurred or the error message otherwise.

Error response parameters

Parameters

Type

Description

error_code

String

The error code of the returned exception

message

String

The error message of the returned exception

If the API throws an error, an error response will be received, similar to:

{
    "error_code": "SUBSCRIPTION_PAYPAL_ATTACH_ERR",
    "message": "Failed to link subscription to PayPal account"
}

Inline Trials Flow

In order to generate an Inline trial checkout cart, it’s mandatory to have the following parameters in the inline script.

  • Signature: for building a Trial buy link it is required to generate a signature - ConvertPlus Buy-Link Signature for Catalog Products
  • Price (define trial price for the corresponding currency - 0 for free trial, higher than 0 for paid trial)
  • Period (define period – not less than 7 days)
  • Currency (define currency)
  • Product Code (define the product for which the trial is applied)

How your script should look like:

TwoCoInlineCart.cart.setCurrency('EUR');
TwoCoInlineCart.products.add({
                       code: 'ANTV_2016',
                       tperiod: 7,
                       tprices: {EUR: 5, RON: 20},
                  });
TwoCoInlineCart.cart.setSignature('520ba411696e37f1839145bfa793f7199d8d0295a228ea42dc20a3f39196e358');

For more details on parameters setup, check the ConvertPlus URL parameters documentation.

Limitations:

  • the trial period/price applies to a single product
  • the trial period can be a minimum of 7 days
  • 2Checkout uses the custom prices and ignores the per-product pricing configuration
  • supported payment methods: credit and debit cards, PayPal, and Direct Debit
  • 2Checkout automatically converts the trial to a paid subscription when the trial interval expires by charging shoppers based on the payment-on-file information. Customers can opt-out at any time using their myAccount

Use GooglePay

Overview

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.

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

    {
              "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

Parameters Type/Description
sessionID Required (string)
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes.
Order Required (Object)
Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.
See code sample for more details.

Request Example

<?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

Parameter Type/Description
Order information Object
Object containing order information.

Response Example

{
    "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
}

Use GooglePay

Overview

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.

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

    {
              "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

Parameters Type/Description
sessionID Required (string)
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes.
Order Required (Object)
Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.
See code sample for more details.

Request Example

<?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

Parameter Type/Description
Order information Object
Object containing order information.

Response Example

{
    "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
}

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo