Skip to main content

LoyaltyAccount.java

namespace payment_sdk

class LoyaltyAccount

  • A single record of a loyalty account

Public Functions

inline LoyaltyAccount(String entryMode, String identificationType, String identificationSupport, String loyaltyId, String additionalLoyaltyData, String loyaltyBrand)

inline String getEntryMode()

  • Entry mode of this loyalty

inline String getIdentificationType()

  • Type of identification of this loyalty

inline String getIdentificationSupport()

  • Support of the loyalty account identification

inline String getLoyaltyId()

  • The main ID of this loyalty

inline String getAdditionalLoyaltyData()

  • Base64 encoded additional data associated with this loyalty

inline String getLoyaltyBrand()

  • Brand of loyalty

inline String toString()

Package Attributes

final String mEntryMode
final String mIdentificationType
final String mIdentificationSupport
final String mLoyaltyId
final String mAdditionalLoyaltyData
final String mLoyaltyBrand

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.PNGtemplateF_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. Register as merchant with Google Pay. Visit Google Pay and Wallet Console (https://pay.google.com/business/console) to setup your account and get your Google merchant ID.
  2. Follow the Google Pay Web documentation (https://developers.google.com/pay/api/web/overview) to add a Google Pay button to your web page.
  3. Use your Google merchant Id when building the merchantInfo object.
    {
      "merchantInfo": {
        "merchantId": "GOOGLE_MERCHANT_ID"
      }
    }
    Set gateway to "verifone" and gatewayMerchantId to your Verifone merchant id when building the tokenizationSpecification object.
    {
      "tokenizationSpecification": {
        "type": "PAYMENT_GATEWAY",
        "parameters": {
          "gateway": "verifone",
          "gatewayMerchantId": "VERIFONE_MERCHANT_ID"
        }
      }
    }
    
  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 = 'http://api.qat30.aws.avancart.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": "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. Register as merchant with Google Pay. Visit Google Pay and Wallet Console (https://pay.google.com/business/console) to setup your account and get your Google merchant ID.
  2. Follow the Google Pay Web documentation (https://developers.google.com/pay/api/web/overview) to add a Google Pay button to your web page.
  3. Use your Google merchant Id when building the merchantInfo object.
    {
      "merchantInfo": {
        "merchantId": "GOOGLE_MERCHANT_ID"
      }
    }
    Set gateway to "verifone" and gatewayMerchantId to your Verifone merchant id when building the tokenizationSpecification object.
    {
      "tokenizationSpecification": {
        "type": "PAYMENT_GATEWAY",
        "parameters": {
          "gateway": "verifone",
          "gatewayMerchantId": "VERIFONE_MERCHANT_ID"
        }
      }
    }
    
  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 = 'http://api.qat30.aws.avancart.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": "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
}

Electronic delivery of codes upgrade to the SHA algorithm

 

   You only need to follow this procedure if you’re using active lists for your delivery keys. Check this article to learn how to generate the hash algorithm. 
  1. Log into your 2Checkout account.

  2. Navigate to Dashboard > Setup > Fulfillment.

  3. Open an existing dynamic list or add a new code list, selecting the List type Dynamic.

    New code list

  4. Click on Set URL if you’re creating a new list.

    Set URL

  5. If you’re editing an existing dynamic list, click on Change or Debug key generator to modify the hash algorithm.

    change

  6. Select SHA2 or SHA3 as a hashing algorithm.

    Hash algorithm

  7. Select a product and fill in the delivery information form with test data.

    product info

  8. Click on Step 4. Debug >>.

    debug

  9. A successfully green banner is displayed if all is correct. Click on Step 5. Change URL >>.

    change URL

  10. A second confirmation message will be displayed if the change was successfully applied (Successfully saved the key generator URL).

    confirmation message

Buy links upgrade to the SHA algorithm

If you’re using buy links with MD5 hash on your website or in any other part of your flow, you’ll need to re-create the links with SHA2/ SHA3. For more information on how to manually re-create these links check the Buy-link parameters article.

To re-create the “On the fly pricing” buy links with the SHA algorithm, follow the steps below:

  1. Log into your 2Checkout account.

  2. Navigate to Dashboard > Setup > Generate links.

    Generate links screen

  3. Select the purchase flow, the product and click on the On the fly pricing option.

    On the fly pricing option

  4. Select the pricing options and click Generate link. This will generate a link signed with SHA that you can copy and use in your integrations. 

Shopping cart integration upgrade to the SHA algorithm

  SHA3 is already supported for Shopify and Wix and no actions are required.
  1. Locate your plugin in the following list:
  2. Download the latest 2Checkout payment module from GitHub by clicking on the Code button and then on Download ZIP.
  3. Follow the installation instructions listed in the README section of GitHub or in the README file downloaded from the ZIP folder.

  4. After following the installation instructions from GitHub, make sure you have switched your IPN endpoint to SHA. If you have any issues making the switch, follow the instructions for adding the SHA256/3 hash and deselecting the MD5 hash to your webhook URLs.

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