Skip to main content

Set grace period

Overview

Use the setSubscriptionGracePeriod method to set a custom grace period for an Active or Past Due subscription. This method changes per-subscription end user data and not customer details.

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.

subscriptionReference

Required (string)

 

Unique, system-generated subscription identifier. Needs to belong to an Active or Past Due subscription.

subscriptionGracePeriod

Required (int)

 

The number of days for the grace period, during which time, customers can still renew/upgrade expired subscriptions. During the grace period, subscriptions feature the Past Due status.

 

Can be NULL. When NULL, the grace period for a subscription is the same as that you defined in the per-product or per-account grace period settings. You can use this to set a custom grace period for a subscription.

 

Use 0 to remove the grace period from a subscription.

Response

Parameters Type/Description

Boolean

true or false depending on whether the changes were successful or not.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$gracePeriod = YOUR_GRACE_PERIOD;

try {
    $customGracePeriod = $client->setSubscriptionGracePeriod($sessionID, $subscriptionReference, $gracePeriod);
}
catch (SoapFault $e) {
    echo "customGracePeriod: " . $e->getMessage();
    exit;
}
var_dump("customGracePeriod", $customGracePeriod);

Search customers

Overview

Use the searchCustomers method via JSON-RPC API 6.0 to be able to identify customers by applying a set of filters.

Request parameters

Parameter name Type Required/Optional Description
Email String Optional Strict match of the email address. It should be case insensitive.
Phone String Optional Strict match of the phone number.
CountryCode String Optional Strict match of the customer's country code.
Language String Optional Strict match of the customer's language.
Trial Boolean Optional  
Status Enum Optional Can be active, inactive.
Pagination Object Optional  

Limit

Int Optional  

Page

Int Optional  

Request example

<?php
declare(strict_types=1);
class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    //public const URL = 'http://api.2checkout.com/rpc/6.0';
    public const URL = 'http://api.avangate.local:8081/rpc/6.0';
    public const ACTION = 'searchCustomers';
    public const ADDITIONAL_OPTIONS = null;
    //array or JSON
    public const PAYLOAD = <<<JSON
{
  "Email": "test@email.com",
  "Language": "en",
  "CountryCode": "us",
  "Trial": true,
  "Status": "ACTIVE",
  "Phone": "403324433234",
  "Pagination": {
    "Limit": 10,
    "Page": 1
  }
}
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;
        $hash = hash_hmac('md5', $string, $key);
        return compact('merchantCode', 'date', 'hash');
    }
    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

 

10 practices to optimize your checkout funnel

Overview

Let’s get one thing straight right from the start and set the proper expectations before diving into this long article. This is by no means the Holy Grail of conversion optimization, for one simple reason: everything is unique to your own scenario. Reading about a test that proved to be successful on a certain website doesn’t automatically make it a best practice for yours. You can’t just copy and paste best practices from one website or even industry to another, expecting the same (or even better) results. Not saying it can’t happen, but it’s simply not a general rule.

This article is meant to be used as a guideline for tests that you should be running when optimizing your shopping cart for better conversions.

The keyword here is test. All the strategies illustrated below have proven successful in different scenarios. Some of our merchants have seen increases in their conversion rate by adhering to one, two, or more of these practices, but only after investing time in testing multiple variations and tailoring the strategies below to their own industry, market, and target audience.

We encourage you to analyze the tactics explained below and test any of them on your own terms. We’d love to learn the impact any of these have on your conversion rate, so if you find a specific strategy that works for you, don’t hesitate to let us in on it and maybe we can help you optimize even further!

1. Optimize the checkout form

Shorten the checkout form by requesting only essential billing and/or delivery details. Extensive forms can discourage shoppers from completing a purchase. Marketing surveys or other information not required for placing the order should be moved to post-sale pages.

Use easily understandable error messages. Display only coherent error info and actionable remedies capable of helping shoppers resolve the issue. Provide visually distinctive cues when errors are generated and when they’re resolved. Most importantly, don’t blame your shoppers, and employ friendly and customer-centric instructions to help them correct the errors.

For new customers, avoid introducing a separate registration or “create account” step prior to the shopping cart. Instead, allow the cart to double as the registration process, collecting the shopper’s name and email. If a password is required, ideally this can be generated after the order is completed with a redirect from the Thank You/Order Confirmation page. Alternatively, include a password field in the Checkout form itself to avoid a separate step in the purchase funnel.

For returning customers purchasing an upgrade or subscription renewal, the shopping cart should automatically pre-fill their contact information on the Checkout page. Shoppers should not need to register or enter a password to access the shopping cart. The goal is to make it as easy as possible to complete the order.

Example

A solid example of a successful optimization project involved a SaaS provider working with 2Checkout and improving conversions by 36% with a cleaner design and by a further 12% with fewer form fields and optimized payment methods display.

2. Use consistent branding

To deliver a seamless customer experience, the shopping cart should become an extension of your website, product, or app – with consistent branding, design, and layout throughout the purchase flow. Having a consistent brand, design, and style is crucial in building trust. You don’t want your cart to look more like a phishing attempt than a real cart. Apply the same Style Guide to the cart pages for a consistent look and feel.

Example

The header and footer of the cart pages should look exactly the same as the previous page in the purchase funnel. If you have different purchase funnels, for example, if some shoppers are coming from landing pages, some from a product page on your main site, and some from within your software, then use a unique template for each funnel to create a seamless customer experience.

Here are the elements that should be consistent between your site and the cart pages:

  • Your company logo – size and position
  • Header and footer - use the same color and layout even if the content is slightly different.
  • Replicate any background patterns that are present on your website.
  • Use the same style guide elements: font style, font size, colors, text links.
  • Same button styles, shapes, and colors.

In addition, hosting the cart on a custom domain allows you to use the same URL as your website (e.g. store.yourdomain.com). This avoids redirecting the shopper to an unfamiliar URL which can create confusion or distrust.

For example, shoppers would go from www.yourdomain.com to store.yourdomain.com instead of going from yourdomain.com to secure.ecommerce provider.com. At the same time, for simplicity or if you have just started selling online, it may benefit you to leverage the trust and credibility of your eCommerce or payments provider by using their domain name for the online store.

3. Don’t just translate. Localize!

Speaking to your shoppers in their native language increases their trust in your services. However, don’t just translate the same message and interface texts into their language. Localize them instead, by first understanding how the people in a specific market actually refer to a product or service and how they talk about it. Ask for feedback when trials end and you might get useful information about how your product 'talks' to specific audiences.

Localization doesn’t just include text translations. Optimize your checkout pages to adapt to your shoppers’ locale. For instance, if somebody selects the United States of America as a billing country, make sure to include a State field that only they can see. Shoppers in the United Kingdom, on the other hand, should be allowed to select their county, so show them that specific field.

4. Multi-language, multi-currency, and geolocation

Make your shopping cart as friendly as possible for your shoppers by allowing them to select their own interface language to eliminate confusion. Equally important, try to support as many currencies as possible, so that sales tax and/or VAT don’t come as unexpected charges.

Take things one step further by using geolocation to dynamically adjust these settings to each shopper’s location. All content on the page, including cross-sell and upsell offers, should be displayed in the shopper’s local language. The currency and ultimately price of the product should be automatically configured according to the shopper’s geo-detected country. In-country pricing, where merchants establish a set price point for their top 10 countries, tends to convert better than real-time currency conversion, where the price point is automatically determined by currency exchange rates with a default currency, such as USD.

Example

This practice helps you prevent strange price points like $23.67 instead of in-country pricing such as $24.99, and also allows you to display consistent price points on your website before the shopper reaches the cart.

5. Local payment methods/local payment processing

Allow your customers to complete their order with the payment method of their choice. In many countries, credit cards are not the most utilized type of payment method. Ensure that your shopping cart supports all popular local payment methods specific to your target markets. Make sure that the payment methods are clearly visible, and that express options are available for payment methods such as PayPal, where the user is redirected to another site to complete their order.

Just keep in mind that these so-called “alternative payment methods” can make international customers feel sufficiently “at home” in your shopping cart to result in many successful purchases.

Worldmap local processing

In-context checkouts are also useful, as they provide a single-page checkout experience, improving conversion rates.

Example

Display payment methods based on their market share according to the shopper's country. Make the checkout process easier by letting customers quickly select their preferred payment methods without going through long drop-down menus or complicated selectors.

We highly recommend going through our local processing recommendations to learn more about specific payment method market trends and optimizations:

6. Display the total cost

The cart should list the total price the customer will be charged, broken out with separate line items for the product price, taxes, and shipping fees (if any). Hidden costs only frustrate shoppers and can lead to refunds and chargebacks.

7. Add intuitive navigation

Be sure to communicate the number of steps needed to place an order, and where the shopper currently is in the overall process. A progress map or indicator should be placed at the top of the page. Headlines and subheadings can also be used to describe the purpose of each section of the form.

When using a checkout flow with a Review page, letting customers know that they can review their order before it is finalized has been proven to increase conversion rates. Other navigation elements, such as the main navigation menu of your website, should not be displayed on the shopping cart pages in order to keep the shopper’s attention focused on completing their order.

 

8. Keep shoppers in the cart with discounts

Use exit offers to provide a discount or display a message to shoppers who are about to abandon the cart without completing a purchase. If shoppers close the browser, edit the URL, or move their mouse to the browser bar, an exit offer can be displayed.

For example, offering a 10% discount or showing a testimonial or a 30-day money-back guarantee can convince the shopper to return to the cart and complete their purchase.

Exit offers have a much higher conversion rate than remarketing emails, since only 30-50% of shoppers open emails.

9. Recover abandoned shopping carts

Don’t expect shoppers to return to an abandoned cart and pick up where they left off.

Create a comprehensive marketing campaign focused on recovering abandoned carts. Don’t limit remarketing efforts to just a single follow-up email.

Example

Consider sending out as many as three messages in the first 72 hours after a cart is abandoned. For example, email #1 is sent within 1 hour, email #2 is sent after 24 hours, and email #3 is sent after 72 hours. Each email should have unique content and link directly back to the cart pre-populated with the relevant product.

Craft the remarketing emails with customized data from the shopper; their name, products in the cart, and order value. Go a step further and incentivize the shopper to complete their purchase by offering a discount, free shipping, or a free upgrade.

10. Increase trust with the right messaging

Include relevant visual cues, such as thumbnail images of the product, to assure the shopper that they’ve added the correct item to the cart. When a shopper enters their information in a form field, display a checkmark to create positive momentum.

Another best practice is to display the specific credit card logo (e.g. VISA, MasterCard, Amex) after the shopper enters their credit card number. It’s also essential that you build trust in your business. Inform your shoppers that their online transactions are secure and their private information is kept safe.

 

Adding a well-known trust mark, such as Norton Security, VeriSign, ScanAlert, and Better Business Bureau logos, provides shoppers with comfort and increases conversion rates. You can use these as visual cues on the cart pages.

Example

A software provider working with 2Checkout has increased conversion rates by over 5% by simply adding a security logo and a refund guarantee to the cart. Overall, A/B testing their shopping cart delivered a 22% increase in revenue per visitor.

Conclusion

When optimizing your purchase funnel, it’s important to first identify the key performance metrics for your software or SaaS business. Then craft an optimization plan specifically designed for each metric.

Best practices serve as a starting point and foundation, and then you must split-test to optimize cart templates, purchase flow, and offers to maximize revenue for each specific target market.

The key takeaway is the absence of a one-size-fits-all solution to increase cart conversion rates and decrease cart abandonment. Optimization is an ongoing process and investing in this area can deliver a solid return on your investment.

Update product

Overview

Use the updateProduct method to update the configuration of a subscription plan/product you already configured for your account. 

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.

Product

Required (object)

 

Use this object to configure your subscription plans/products.

 

You can update/edit all parameters, except the following:

  • AvangateID
  • ProductType

Exceptions

When updating a subscription plan/product, you also update its PricingConfigurations. However, you cannot modify:

  • The pricing configuration CODE.
  • The PricingSchema from DYNAMIC to FLAT or vice versa.  

Request

<?php

require ('PATH_TO_AUTH');

$ProductCode = 'NewProdCodeAPI12345';

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getProductByCode',
'params' => array($sessionID, $ProductCode)
);

$myProduct = callRPC($jsonRpcRequest, $host);

$myProduct->ProductName = 'Edited_From_API_Again';

var_dump ($myProduct);

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'updateProduct',
'params' => array($sessionID, $myProduct)
);

$updatedProduct = callRPC($jsonRpcRequest, $host);
var_dump ($updatedProduct);

?>

Response

bool(true)

Authentication

Overview

Use the login method for the authentication process in the 2Checkout system.

Parameters

Parameters Type/Description
merchantCode Required (String)
  Your merchant identification code.
date Required (String)
  GMT ISO Date format (e.g. 2010-01-01 12:13:14)
hash Required (Object)
  Calculated HMAC_SHA256 signature based on merchantCode and date, using your secret key.

Response

Parameters

Type/Description

sessionID

String

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.

Request

To create the HMAC_SHA256 source string use your merchant code and the date of the request, prefixing them with the length in bytes of each respective value, along with your account’s secret key (for UTF-8 characters the length in bytes might be longer than the string length). For example:

Parameters

Type/Description

MerchantCode

Your merchant account code.

 

8AVANGATE

 

Date

2010-05-13 12:12:12

 

192010-05-13 12:12:12

 

HMAC source string

8AVANGATE192010-05-13 12:12:12

 

Secret key

SECRET_KEY

Calculated HMAC_SHA256 signature based on MerchantCode and Date, using your secret key:

bf763db7d333e9c3038698cf59ada3e6

Request Example

<?php

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

$key          = "SECRET_KEY";
//your account's secret key available in the 'System settings' area of the cPanel:
//https://secure.avangate.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/5.0/?wsdl", array(
        'location' => $host . "/soap/5.0/",
        "stream_context" => stream_context_create(array(
            'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false
            )
        ))
    ));
    $sessionID = $client->login($merchantCode, $now, $hash, $algo);
    echo("Token: {$sessionID}" . PHP_EOL);
}
catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage() . PHP_EOL;
    exit;
} 

 

Trial conversion links

Overview

Create trial conversion links to offer to your customers.These links enable shoppers using a trial to purchase a full subscription by landing them in a shopping cart prefilled with their details. 

Requirements

Trial subscription status needs to be either Active or Past Due (in the grace period).

Create the manual trial conversion link

To manually build trial conversion links you need the following two elements:

The simplest trial conversion link you can build is:

https://secure.2checkout.com/renewal/?LICENSE=1A22223BC4

Query parameters

The following table summarizes the additional URL parameters that you can insert into links to customize manual trial conversions.

Parameter Required Description

LICENSE

YES

The system generated unique subscription reference.

COUPON

NO

Promotion coupon code to be applied in the order.

DESIGN_TYPE

NO

Value = 1. When DESIGN_TYPE=1 is used in Buy Links the parameter changes the layout of the shopping cart template interface, positioning the payment methods selector in a more prominent position, above the billing details area. Value = 1. Use DESIGN_TYPE=1 in Buy Links to change the layout of the shopping cart template interface, positioning the payment methods selector in a more prominent position, above the billing details area. 

LAYOUT_TYPE

NO

LAYOUT_TYPE enables you to control which version of the shopping cart 2Checkout serves to shoppers. Possible values:

  • CLASSIC - the desktop variant of the shopping cart (using LAYOUT_TYPE=CLASSIC - 2Checkout serves the desktop version of the cart even to mobile device users.
  • MOBILE - 2Checkout mobile cart 
  • LAYOUT_TYPE=MOBILE - 2Checkout serves the mobile version of the shopping cart, even to users of desktop browsers.

CARD

NO

Possible values:

  • 1 - use this parameter with value 1 to display the payment form in the selected landing page. Shoppers get to place orders from the Review page.
  • 2 - enable 2Checkout to display payment form in the selected landing page, and shoppers to place orders immediately after entering their payment data, excluding the Review page.

ORDERSTYLE

NO

Allows you to set the corresponding template, overriding the default template assigned to the product group. Each template defined in the Interface Templates area of the Control Panel has a unique identifier associated which is visible in the browser address bar when previewing the shopping cart.

The 2Checkout system includes some parameters automatically in the renewal link from the initial trial order. such as: QTY, PRODS, PRICES, LANG, PAY_TYPE, CURRENCY, DOTEST.

You can't customize these parameters manually.

Domain use

Secure.2Checkout.com domain

If your account uses 2Checkout's secure.2checkout.com domain, then your custom on-demand trial conversion links would look like this: https://secure.2checkout.com/renewal/?

Custom domains such as store.YourDomain.com

If your account uses a custom domain such as store.YourDomain.com, then your custom on-demand renewal links would look like this: https://store.YourDomain.com /renewal/?

Search SKU codes

Overview

Use the searchSku method to perform product SKU search calls with the below parameters.

Request Parameters

Parameters Required Type Description
ProductCode Required String The product code that you can define for each of your offerings. Needs to be unique.
PricingConfigurations Required Array of objects  

Code

Required String  

Currencies

Required Array of Objects ISO currency code.

Code

Required String  

PurchaseTypes

Required Array of objects Purchase type identifier. Possible values:
  • NEW_PRODUCT
  • RENEWAL
  • UPGRADE

Code

Required String  

QuantityIntervals

Required Object Numeric identifier of product quantity.

MinQuantity

Required Int  

MaxQuantity

Required Int  

PriceOptionGroups

Required Array of objects  

Code

Required String  

Options

Required Array of objects  

OptionValue

Required String  
Pagination Required Object  

Page

Required Int  

Limit

Required Int  

Request Example

<?php

require ('PATH_TO_AUTH');

$inputSchema = new \stdClass();
$inputSchema->ProductCode= '6B3CB17DDA_COPY1';

$pricingConfiguration = new \stdClass();
$pricingConfiguration->Code = 'E684EC99B0';

$currency = new \stdClass();
$currency->Code = 'EUR';
$pricingConfiguration->Currencies = [$currency];

$purchaseType = new \stdClass();
$purchaseType->Code = 'RENEWAL';
$pricingConfiguration->PurchaseTypes = [$purchaseType];

$quantityIntervals = new \stdClass();
$quantityIntervals->MinQuantity= 1;
$quantityIntervals->MaxQuantity= 10;
$pricingConfiguration->QuantityIntervals = [$quantityIntervals];

$pagination = new \stdClass();
$pagination->Page = 1;
$pagination->Limit = 10;

$inputSchema->PricingConfigurations = [$pricingConfiguration];
$inputSchema->Pagination = $pagination;

$jsonRpcRequest = array (
    'method' => 'searchSku',
    'params' => array($sessionID, $searchSchema),
    'id' => $i++,
    'jsonrpc' => '2.0'
);

var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

Response Parameters

Parameters Type/Description
Items Object

{ProductCode}

Object. This element will be replaced by the code of the product.

SkuPricingOptions

Array of strings

Code

String

Details

Array

ProductSKU

String

Currency

String

FromQty

Int

ToQty

Int

PurchaseTypes

String

Groups

Array

GroupCode

String

Options

Array

               Name

String
                                                                                Value String

Errors

Array
Pagination Object

Limit

Int

Page

Int

Count

Int

Response Example

object(stdClass)#22 (2) {
    public $Items" =>
    object(stdClass)#21 (1) {
      public $6B3CB17DDA_COPY1 =>
      object(stdClass)#4 (2) {
        public $ProductCode =>
        string(18) "6B3CB17DDA_COPY1"
        public $SkuPricingOptions =>
        array(1) {
          [0]=>
          object(stdClass)#5 (3) {
            public $Code =>
            string(10) "E684EC99B0"
            public $Details =>
            array(5) {
              [0]=>
              object(stdClass)#6 (7) {
                public $ProductSKU =>
                string(4) "Product_Test_SKU_008899"
                public $Currency =>
                string(4) "EUR"
                public $FromQty =>
                int(1)
                public $ToQty =>
                int(10)
                public $PurchaseType =>
                string(11) "RENEWAL"
                public $Groups =>
                array(1) {
                  [0]=>
                  object(stdClass)#7 (2) {
                    public $GroupCode =>
                    string(7) "GRUP_2"
                    public $Options =>
                    array(1) {
                      [0]=>
                      object(stdClass)#8 (2) {
                        public $Name =>
                        string(7) "grup 2"
                        public $Value =>
                        string(4) "option_code_4"
                      }
                    }
                  }
                }
                public $Options =>
                string(32) "a:1:{i:16885;a:1:{i:0;i:78164;}}"
              }
              [1]=>
              object(stdClass)#9 (7) {
                public $ProductSKU =>
                string(4) "Product_Test_SKU_008902"
                public $Currency =>
                string(4) "EUR"
                public $FromQty =>
                int(1)
                public $ToQty =>
                int(10)
                public $PurchaseType =>
                string(11) "RENEWAL"
                public $Groups =>
                array(1) {
                  [0]=>
                  object(stdClass)#10 (2) {
                    public $GroupCode =>
                    string(7) "GRUP_2"
                    public $Options =>
                    array(1) {
                      [0]=>
                      object(stdClass)#11 (2) {
                        public $Name =>
                        string(6) "grup 2"
                        public $Value =>
                        string(13) "option_code_4"
                      }
                    }
                  }
                }
                public $Options =>
                string(6) "a:0:{}"
              }
            public $Errors =>
            array(0) {
            }
          }
        }
      }
    }
    public $Pagination =>
    object(stdClass)#23 (3) {
      public $Limit =>
      int(10)
      public $Page =>
      int(1)
      public $Count =>
      int(5)
    }

 

Retrieve available countries

Overview

Use the getAvailableCountries method to get the list of available countries for the current merchant. If the language parameter is provided, all the returned countries will be translated into that language.

Request Parameters

Parameter Name Type Required/Optional Description
sessionId String Required 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.
language String Optional The ISO language code (two-letter code). If the language parameter is empty, the default language will be English.

Request Example

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.2checkout.com/rpc/6.0';
    public const ACTION = 'getAvailableCountries';
    public const ADDITIONAL_OPTIONS = null;
    public const PAYLOAD =  "nl";
}

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;
        $hash = hash_hmac('md5', $string, $key);

        return compact('merchantCode', 'date', 'hash');
    }


    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 (!empty($this->sessionId)) {
            $payload = [$this->sessionId, $payload, Configuration::ADDITIONAL_OPTIONS];
        }
        $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 Name Type Description
countries Array An array of country objects, mode of country code, and translated country name.

Response Example

[
    {
    “Code”: “AE”,
    “Label”: “Verenigde Arabische Emiraten”
},
{
    “Code”: “AF”,
    “Label”: “Afghanistan”
}
]

 

Search affiliates

Overview

Use the searchAffiliates method to find out details about one or more affiliates.

Request Parameters

Parameters Required Type/Description

AffiliateCode

Required String. Unique, system-generated identifying code of the affiliate.
Status Optional String.  Merchant Affiliate relationship status. Can be ACTIVE or DISABLED.
RequestDateStart Optional Date. Format is YYYY-MM-DD. Affiliate Request start date.
RequestDateEnd Optional Date. Format is YYYY-MM-DD. Affiliate Request end date.
Page Optional Integer. Page number. Value = '1' to '9999'.
Limit Optional Integer. Number of results on a page. Value = '1' to '9999'.
Name Optional String. Affiliate name.
Country Optional Array. Affiliate country.
TargetCountry Optional Array. Countries where the affiliate sells into.
CommissionList Optional Array. Value = default. Affiliate commission list.
Type Optional Array. Affiliate type.

Request Example 


Response Parameters

Parameters Description

AffiliateCode

Unique, system-generated identifying code of the affiliate.
Status Merchant Affiliate relationship status.
AffiliateName Name of the affiliate.
Website Website of the affiliate.
CommissionList Affiliate commission list.
                                        ListName Name of the affiliate commission list.
                                        CommissionRate Value of the commission rate (in %).
RequestDate  
Categories Product category  of the affiliate.
NotifyUpdates Boolean. Value can be TRUE or FALSE.
TCSStatus  
AffiliateContact Affiliate contact details.
                                         FirstName Affiliate first name.
                                         LastName Affiliate last name.
                                        Phone Affiliate phone number.
                                        Email Affiliate email.
                                        Country Country of the affiliate.

Response Example

{  
   "AffiliateCode":"TFTF76455ee4YFCFCT6545465",
   "Status":"Active",
   "Affiliate Name":"Affiliate 1",
   "Website":"https://affiliate1.com",
   "CommissionLists":[  
      {  
         "ListName":"CommissionList1",
         "CommissionRate":"25%"
      }
   ],
   "RequestDate":"2018-10-05",
   "Categories":["PC security","Mobile security","Tablet security"],
   "NotifyUpdates":true,
   "TCStatus":"Accepted",
   "AffiliateContact":{  
      "FirstName":"FN",
      "LastName":"LN",
      "Phone":"0040723483987",
      "Email":"FN.LN@2AFFLT.COM",
      "Country":"Spain"
   }
},
{  
   "AffiliateCode":"TFTF76455ee4YFCFCT6545466",
   "Status":"Active",
   "Affiliate Name":"Affiliate2",
   "Website":"https://Affiliate2.com",
   "CommissionLists":[  
      {  
         "ListName":"CommissionList1",
         "CommissionRate":"25%"
      }
   ],
   "RequestDate":"2018-10-05",
   "Categories":["PC security","Mobile security","Tablet security"],
   "NotifyUpdates":true,
   "TCStatus":"Agreed",
   "AffiliateContact":{  
      "FirstName":"FN",
      "LastName":"LN",
      "Phone":"0040723483987",
      "Email":"FN.LN@2AFFLT.COM",
      "Country":"Spain"
   }
}

 

Retrieve a lead

Overview

Use the getLead method to retrieve leads created in the 2Checkout systems by fetching the lead code.

Request Parameters

Parameters Required Type/Description

LeadCode

Optional

String/Array of strings. Retrieves all leads based on their unique identification code (system-generated).

 

 

Email

Optional

String. A valid email address used by the customer

Type

Optional String. Must be one of the existing types of leads:
  • New
  • Used
  • UsedSuccess
  • Stopped
  • NotStopped

StartDate

Optional String. The start date of the interval; format must be yyyy-mm-dd.

EndDate

Optional String. The end date of the interval; format must be yyyy-mm-dd.

ProductCode 

Optional

String/Array of strings. Searches for all leads containing the product code.

Language

Optional String. The language of the shopper cart; ISO 639-1 two-letter code.

Country

Optional String. The customers billing country; ISO 3166 two-letter code.

GeneratedFrom 

Optional String. API, shopping cart, ConvertPlus. Display the leads based on the source where they were created – via API or via the 2Checkout ordering engines.

Request Example

<?php

require ('PATH_TO_AUTH');

$jsonRpcRequest = array (
    'method' => 'getLead',
    'params' => array($sessionID, '60E6C4B574'),
    'id' => $i++,
    'jsonrpc' => '2.0'
);

var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

Response Parameters

Response Example

class stdClass#18 (14) {
  public $LeadCode =>
  string(10) "60E6C4B574"
  public $GeneratedFrom =>
  string(3) "API"
  public $CartId =>
  string(11) "CartIdValue"
  public $Currency =>
  string(3) "EUR"
  public $Language =>
  string(2) "BG"
  public $ExternalReference =>
  string(18) "REST_API_3CHECKOUT"
  public $MachineId =>
  string(6) "123asd"
  public $LocalTime =>
  string(19) "2019-11-05 16:48:28"
  public $Items =>
  class stdClass#19 (1) {
    public $0 =>
    class stdClass#20 (15) {
      public $Code =>
      string(10) "04C26C50F8"
      public $Quantity =>
      string(1) "2"
      public $SKU =>
      NULL
      public $Name =>
      string(5) "softy"
      public $Description =>
      NULL
      public $IsDynamic =>
      bool(false)
      public $Tangible =>
      bool(false)
      public $PurchaseType =>
      string(7) "PRODUCT"
      public $PriceOptions =>
      NULL
      public $RecurringOptions =>
      class stdClass#21 (5) {
        public $CycleLength =>
        NULL
        public $CycleUnit =>
        NULL
        public $CycleAmount =>
        NULL
        public $ContractLength =>
        NULL
        public $ContractUnit =>
        NULL
      }
      public $RenewalInformation =>
      class stdClass#22 (1) {
        public $SubscriptionReference =>
        NULL
      }
      public $MarketingCampaigns =>
      class stdClass#23 (3) {
        public $Type =>
        string(2) "23"
        public $ParentCode =>
        string(1) "m"
        public $CampaignCode =>
        string(2) "23"
      }
      public $Price =>
      class stdClass#24 (2) {
        public $Amount =>
        string(2) "20"
        public $Type =>
        string(6) "CUSTOM"
      }
      public $AdditionalFields =>
      NULL
      public $SubscriptionStartDate =>
      string(19) "2019-11-05 16:48:28"
    }
  }
  public $BillingDetails =>
  class stdClass#25 (12) {
    public $FirstName =>
    string(8) "Customer"
    public $LastName =>
    string(9) "2Checkout"
    public $Phone =>
    NULL
    public $Company =>
    NULL
    public $FiscalCode =>
    string(8) "32423423"
    public $Email =>
    string(22) "customer@2checkout.com"
    public $Address1 =>
    string(12) "Test Address"
    public $Address2 =>
    NULL
    public $City =>
    string(2) "LA"
    public $Zip =>
    string(5) "12345"
    public $CountryCode =>
    string(2) "RO"
    public $State =>
    string(2) "CA"
  }
  public $DeliveryDetails =>
  class stdClass#26 (12) {
    public $FirstName =>
    string(8) "Customer"
    public $LastName =>
    string(9) "2Checkout"
    public $Phone =>
    NULL
    public $Company =>
    NULL
    public $FiscalCode =>
    string(8) "32423423"
    public $Email =>
    string(22) "customer@2checkout.com"
    public $Address1 =>
    string(12) "Test Address"
    public $Address2 =>
    NULL
    public $City =>
    string(2) "LA"
    public $Zip =>
    string(5) "12345"
    public $CountryCode =>
    string(2) "RO"
    public $State =>
    string(2) "CA"
  }
  public $DeliveryInformation =>
  class stdClass#27 (1) {
    public $ShippingMethod =>
    class stdClass#28 (1) {
      public $Code =>
      string(5) "sdfsd"
    }
  }
  public $PaymentDetails =>
  class stdClass#29 (4) {
    public $Type =>
    string(2) "CC"
    public $Currency =>
    string(3) "EUR"
    public $PaymentMethod =>
    class stdClass#30 (2) {
      public $RecurringEnabled =>
      bool(false)
      public $CardPayment =>
      class stdClass#31 (1) {
        public $InstallmentsNumber =>
        string(2) "23"
      }
    }
    public $CustomerIP =>
    string(7) "1.2.3.4"
  }
  public $Promotions =>
  array(1) {
    [0] =>
    string(0) ""
  }
}

 

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