Skip to main content

Retrieve campaign texts

Overview

Use the getCrossSellTexts method to extract information on all cross-sell campaigns texts.

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.

LanguageCode

Required (string)

 

ISO language code. (ISO 639-1 two-letter code).

Response

Parameters Type/Description

Title

String

 

Cross-selling message title. Set here.

Description

String

 

Cross-selling message description. Set here.

Language

String

Request

<?php

require ('PATH_TO_AUTH');

$LanguageCode = 'de'; //returns title and description texts you set under https://secure.2checkout.com/cpanel/network_cross_selling_settings.php

try {
    $CrossSellCampaignsTexts = $client->getCrossSellTexts($sessionID, $LanguageCode);
}

catch (SoapFault $e) {
    echo "CrossSellCampaignsTexts: " . $e->getMessage();
    exit;
}

var_dump("CrossSellCampaignsTexts", $CrossSellCampaignsTexts);
?>

 

Update a subscription

Overview

Change specific details about a subscription. Use the updateSubscription method to change specific details about a subscription. 

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 sessionIDexpires in 10 minutes.

Subscription

Required (Object)

 

You need to include the entire Subscription object keeping its structure unchanged (retrieve it using getSubscription) but you can update only specific parameters enumerated below.

 

EndUser

Object

 

 

End user details.

 

ExpirationDate

String

 

 

Subscription expiration date - If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then 2Checkout calculates the ExpirationDate according to your custom configuration. Note: The default 2Checkout API time zone is GMT+02:00.

You cannot set an expiration date from the past.

 

SubscriptionEnabled

Boolean

 

 

Possible values: TRUE/FALSE

 

RecurringEnabled

Boolean

 

 

Possible values: TRUE/FALSE

 

ExternalCustomerReference

String

 

 

Unique customer alphanumeric (string) identifiers that you control. 

Move a subscription from under a customer to another customer entity.

Use the updateSubscription method. 2Checkout moves subscription under the customer for which you provide the 2Checkout customer reference or theExternal customer reference during the subscription update process. View example.

 

ProductId

Int

 

 

System-generated unique product ID. Needs to be the ID of an existing product in the 2Checkout system created under your account.

The product ID governs the product to which the subscription is associated with.

Product types must match Regular - Regular or Bundle - Bundle.

IDs must identify products with the renewal system enabled (max billing cycle 36 months).

 

ProductName

String

 

 

The name of the product for identifier used under ProductID.

 

ProductQuantity

Int

 

 

Ordered quantity.

 

PriceOptionCodes

Array

 

 

Array of product options codes. Pricing options codes are case sensitive.

To impact the renewal price, the PriceOptionsCodes need to belong to price options of pricing configurations used for the product with which the subscription is associated.

All other parameters of the Subscription object are non-editable.

The 2Checkout system uses the updated subscription information for:

  • Manual and automatic renewals
  • Upgrades
  • Trial conversions

Response

Boolean

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

Request


<?php
$host   = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
    'location' => $host . "/soap/4.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));

function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}
$merchantCode = "YOUR_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 = "YOUR_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'); //date_default_timezone_set('UTC')
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);
try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}
catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage();
    exit;
}
$SubscriptionReferenceTest = '0177AAA92B';
try {
    $retrievedSubscription = $client->getSubscription($sessionID, $SubscriptionReferenceTest);
}
catch (SoapFault $e) {
    echo "retrievedSubscription: " . $e->getMessage();
    exit;
}
var_dump("retrievedSubscription", $retrievedSubscription);
var_dump ($retrievedSubscription);
$retrievedSubscription->RecurringEnabled = false;
$retrievedSubscription-> SubscriptionEnabled = true;
$retrievedSubscription->ExpirationDate = '2020-12-12';
try {
    $updatedSubscription = $client->updateSubscription($sessionID, $retrievedSubscription);
}
catch (SoapFault $e) {
    echo "updatedSubscription: " . $e->getMessage();
    exit;
}
var_dump("updatedSubscription", $updatedSubscription);

 

Retrieve an order field

Overview

Use the getAdditionalField method to extract information about a specific additional field you set up for your account. 

PRAMETERS

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. Avangate throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

FieldCode

Required (string)

 

Field identifier. Alpha-numeric chars, underscores and dashes.

 

Response

AdditionalField

Array of objects

Request

<?php
 
function callRPC($Request, $hostUrl, $Debug = true) {
    $curl = curl_init($hostUrl);
    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'));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
 
    if ($Debug) {
        $RequestString;
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        $ResponseString;
    }
 
    if (!empty($ResponseString)) {
//        var_dump($ResponseString);
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}
 
$host = 'https://api.avangate.com/rpc/3.0/';
 
$merchantCode = "YOURCODE12345";//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
 
$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$hash = hash_hmac('md5', $string, $key);
 
$i = 1; // counter for api calls
 
// Call the login method for authentication
 
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;
 
$sessionID = callRPC($jsonRpcRequest, $host);
$FieldCode = 'HiddenID123';
 
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getAdditionalField',
'params' => array($sessionID, $FieldCode)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
 ?>

Create price option groups

Overview

Use the addPriceOptionGroup method to create price option groups for your subscription plans/products.

  • Send options for each pricing group or 2Checkout throws an exception.
  • When adding an interval with no min/max values or overlapping values, 2Checkout throws an exception. 

Parameters

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.

PriceOptionsGroup

Required (object)

 

Use this object to create a new price option group for your account.

Response

bool(true)

Request

<?php

$host   = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
    'location' => $host . "/soap/4.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));


function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}

$merchantCode = "YOURCODE123"; //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'); //date_default_timezone_set('UTC')

$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);

try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}

catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage();
    exit;
}


$PriceOptionGroup = new stdClass();
$PriceOptionGroup->Name = 'New Multi Users';
$PriceOptionGroup->Description = 'Quos aut ipsam ipsum omnis aut molestiae. Et quod molestias distinctio. Fugiat sit asperiores reprehenderit officia eaque quae quia. Aperiam quia quia illo eos nesciunt accusamus.';
$PriceOptionGroup->Translations = array();
$PriceOptionGroup->Translations[0] = new stdClass();
$PriceOptionGroup->Translations[0]->Name = 'xdrki7ljix';
$PriceOptionGroup->Translations[0]->Description = 'Beatae doloribus ipsam voluptatem et. Iure dignissimos non amet. Quibusdam fugiat dolor repudiandae temporibus harum.';
$PriceOptionGroup->Translations[0]->Language = 'en';
$PriceOptionGroup->Translations[1] = new stdClass();
$PriceOptionGroup->Translations[1]->Name = '37wr8ie2dj';
$PriceOptionGroup->Translations[1]->Description = 'Esse distinctio voluptatibus omnis et et quia dolor. Quibusdam dicta dolores odio consequatur velit voluptate. Laboriosam reiciendis libero vel quae molestiae ad.';
$PriceOptionGroup->Translations[1]->Language = 'ru';
$PriceOptionGroup->Type = 'RADIO';
$PriceOptionGroup->Options = array();
$PriceOptionGroup->Options[0] = new stdClass();
$PriceOptionGroup->Options[0]->Name = 'SingleUser';
$PriceOptionGroup->Options[0]->Description = 'Nisi ea autem a labore similique. Minus natus cumque nemo. Aut aliquam laboriosam dolorem ad.';
$PriceOptionGroup->Options[0]->Translations = array();
$PriceOptionGroup->Options[0]->Translations[0] = new stdClass();
$PriceOptionGroup->Options[0]->Translations[0]->Name = '0q2r3kcj0q';
$PriceOptionGroup->Options[0]->Translations[0]->Description = 'Voluptatem in vitae rerum ea tempore. Non cumque ullam optio quis. Laborum maxime sunt facere. Dolor fugit a fugiat quasi facere totam.';
$PriceOptionGroup->Options[0]->Translations[0]->Language = 'en';
$PriceOptionGroup->Options[0]->Translations[1] = new stdClass();
$PriceOptionGroup->Options[0]->Translations[1]->Name = 'dwfxuw4lrn';
$PriceOptionGroup->Options[0]->Translations[1]->Description = 'Debitis omnis maiores quia praesentium totam error corrupti. Consectetur eum magnam quam vero. Sit aperiam natus perspiciatis iusto sint ut fugit. Adipisci illum non voluptatem voluptas.';
$PriceOptionGroup->Options[0]->Translations[1]->Language = 'it';
$PriceOptionGroup->Options[0]->Code = 'singleuser1';
$PriceOptionGroup->Options[0]->SubscriptionImpact = new stdClass();
$PriceOptionGroup->Options[0]->SubscriptionImpact->Impact = 'Add';
$PriceOptionGroup->Options[0]->SubscriptionImpact->Months = 1;
$PriceOptionGroup->Options[0]->PriceImpact = new stdClass();
$PriceOptionGroup->Options[0]->PriceImpact->Method = 'FIXED';
$PriceOptionGroup->Options[0]->PriceImpact->Amounts = array();
$PriceOptionGroup->Options[0]->PriceImpact->Amounts[0] = new stdClass();
$PriceOptionGroup->Options[0]->PriceImpact->Amounts[0]->Currency = 'USD';
$PriceOptionGroup->Options[0]->PriceImpact->Amounts[0]->Amount = 90.61;
$PriceOptionGroup->Options[0]->PriceImpact->Amounts[1] = new stdClass();
$PriceOptionGroup->Options[0]->PriceImpact->Amounts[1]->Currency = 'EUR';
$PriceOptionGroup->Options[0]->PriceImpact->Amounts[1]->Amount = 6.70;
$PriceOptionGroup->Options[0]->PriceImpact->ImpactOn = 'BASE';
$PriceOptionGroup->Options[0]->PriceImpact->Impact = 'ADD';
$PriceOptionGroup->Options[0]->PriceImpact->Percent = 39;
$PriceOptionGroup->Options[0]->Default = false;
$PriceOptionGroup->Options[1] = new stdClass();
$PriceOptionGroup->Options[1]->Name = 'MultiUser';
$PriceOptionGroup->Options[1]->Description = 'Vero voluptatum fuga et repellendus sed qui. Dolores molestiae error non ad aperiam. In error quos eum quas repudiandae pariatur et suscipit.';
$PriceOptionGroup->Options[1]->Translations = array();
$PriceOptionGroup->Options[1]->Translations[0] = new stdClass();
$PriceOptionGroup->Options[1]->Translations[0]->Name = 'MultiUser';
$PriceOptionGroup->Options[1]->Translations[0]->Description = 'Debitis et saepe facere blanditiis. Tempore et nemo aut ullam possimus ipsum nisi. Ad libero et consequuntur aliquam libero. Rerum aut illum eveniet earum.';
$PriceOptionGroup->Options[1]->Translations[0]->Language = 'en';
$PriceOptionGroup->Options[1]->Translations[1] = new stdClass();
$PriceOptionGroup->Options[1]->Translations[1]->Name = 'dw5zgkcki9';
$PriceOptionGroup->Options[1]->Translations[1]->Description = 'Vel et excepturi veniam. In iusto eveniet pariatur hic labore. Et qui dolorem accusantium molestias iusto.';
$PriceOptionGroup->Options[1]->Translations[1]->Language = 'pt';
$PriceOptionGroup->Options[1]->Code = 'multiuser999';
$PriceOptionGroup->Options[1]->SubscriptionImpact = new stdClass();
$PriceOptionGroup->Options[1]->SubscriptionImpact->Impact = 'ADD';
$PriceOptionGroup->Options[1]->SubscriptionImpact->Months = 2;
$PriceOptionGroup->Options[1]->PriceImpact = new stdClass();
$PriceOptionGroup->Options[1]->PriceImpact->Method = 'FIXED';
$PriceOptionGroup->Options[1]->PriceImpact->Amounts = array();
$PriceOptionGroup->Options[1]->PriceImpact->Amounts[0] = new stdClass();
$PriceOptionGroup->Options[1]->PriceImpact->Amounts[0]->Currency = 'USD';
$PriceOptionGroup->Options[1]->PriceImpact->Amounts[0]->Amount = 65.03;
$PriceOptionGroup->Options[1]->PriceImpact->Amounts[1] = new stdClass();
$PriceOptionGroup->Options[1]->PriceImpact->Amounts[1]->Currency = 'EUR';
$PriceOptionGroup->Options[1]->PriceImpact->Amounts[1]->Amount = 64.58;
$PriceOptionGroup->Options[1]->PriceImpact->ImpactOn = 'BASE';
$PriceOptionGroup->Options[1]->PriceImpact->Impact = 'ADD';
$PriceOptionGroup->Options[1]->PriceImpact->Percent = 51;
$PriceOptionGroup->Options[1]->Default = true;
$PriceOptionGroup->Code = null;
$PriceOptionGroup->Required = false;
try {
    $NewPriceOptionGroup = $client->addPriceOptionGroup($sessionID, $PriceOptionGroup);
}

catch (SoapFault $e) {
    echo "NewPriceOptionGroup: " . $e->getMessage();
    exit;
}

var_dump("NewPriceOptionGroup", $NewPriceOptionGroup);


?>

 

Create product group

Overview

Use the addProductGroup method to create product groups for your account:

  • Send null for product group Code. 2Checkout ignores any values you send for Code and generates identifiers itself. 
  • Use unique product group names. 
  • 2Checkout throws an exception if you send a blank product group.
  • If you send only the name of the product group 2Checkout creates the new product group entity. 

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.

ProductGroup

Required (object)

 

Use this object to create product groups. Send null for the Code. 2Checkout generates unique product group code identifiers. 

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$ProductGroup = new stdClass();
$ProductGroup->Name = 'New Product Group from API';
$ProductGroup->Code = null;//Send null for the Code. 2Checkout generates unique product group code identifiers.
$ProductGroup->TemplateName = 'Default Template';//'001 - Two Column Billing'; //the name of the cart template you want to associate with the product group
$ProductGroup->Description = 'This is a generic description';
$ProductGroup->Enabled = true;

try {
    $NewProductGroup = $client->addProductGroup($sessionID, $ProductGroup);
}

catch (SoapFault $e) {
    echo "NewProductGroup: " . $e->getMessage();
    exit;
}

var_dump("NewProductGroup", $NewProductGroup);


?>

 

Update price options

Overview

Use the updatePriceOptionGroup method to update/edit an existing price options group you configured for your account. Price options intervals cannot overlap. 

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.

PriceOptionsGroup

Required (object)

 

Use this object to update/edit a new price option group for your account.

You cannot update the Code and Required parameters of the price options group.

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$SearchOptions = new stdClass ();
$SearchOptions->Name = 'New Users from API';
$SearchOptions->Types = array('INTERVAL', 'RADIO'); //RADIO, CHECKBOX, INTERVAL, COMBO

$SearchOptions->Pagination = new stdClass ();
$SearchOptions->Pagination->Limit = 10;
$SearchOptions->Pagination->Page = 1;

try {
$existentPriceOptions = $client->searchPriceOptionGroups($sessionID, $SearchOptions);
}

catch (SoapFault $e) {
    echo "existentPriceOptions: " . $e->getMessage();
    exit;
}

var_dump ($existentPriceOptions);

$updatedPriceOptions = $existentPriceOptions->Items[0]; //assigning pricing option into a new variable
$updatedPriceOptions->Translations[0]->Name = 'New Users from API3';
$updatedPriceOptions->Translations[0]->Language = 'EN';

echo ($updatedPriceOptions->Name);

try {
    $NewPriceOptionGroup = $client->updatePriceOptionGroup($sessionID, $updatedPriceOptions);
}

catch (SoapFault $e) {
    echo "NewPriceOptionGroup: " . $e->getMessage();
    exit;
}

var_dump("NewPriceOptionGroup", $NewPriceOptionGroup);


?>

 

Enable a subscription

Overview

Use the enableSubscription method to enable a subscription.

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.

Response

Boolean

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

Request


<?php
$host   = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
    'location' => $host . "/soap/4.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));

function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}
$merchantCode = "YOUR_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 = "YOUR_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'); //date_default_timezone_set('UTC')
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);
try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}
catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage();
    exit;
}
$SubscriptionReferenceTest = '0742B179DD';
try {
    $enabledSubscription = $client->enableSubscription($sessionID, $SubscriptionReferenceTest);
}
catch (SoapFault $e) {
    echo "enabledSubscription: " . $e->getMessage();
    exit;
}
var_dump("enabledSubscription", $enabledSubscription);

 

Place orders with catalog products

Overview

Use this object to create new orders and collect payments from shoppers using catalog products defined in your Control Panel.

For orders that require physical delivery, if no shipping methods are provided, 2Checkout will add to cart your account's default shipping configuration.

For more details about how to be PCI compliant before accepting CC payments, see this page.

Supported payment methods/flows

  1. Credit/Debit cards: Visa, Visa Electron, MasterCard, Maestro, Amex, Discover, Dankort, Carte Bleue, JCB. 2Checkout supports local Brazilian cards.
  2. PayPal and PayPal Express
  3. Purchase Order
  4. Wire
  5. Check
  6. WeChat Pay
  7. iDEAL
  8. TEST orders
  9. Free orders (no payment information required)
  10. Previous order references - In addition to the payment methods enumerated above, 2Checkout also supports 1-click purchase flows in which you use valid previous order references belonging to returning customers to pay for new orders with their previously used cards and PayPal accounts.

Requirements

For credit card orders placed using API 5.0, you need to pass through additional parameters that support the 3D Secure flow. 3D Secure works by redirecting customers to pages provided by their banks, where they need to enter additional security tokens or passwords to trigger the completion of the charge. By using 3D Secure, you get additional protection from liability for fraudulent card payments, with customers having to go through an extra layer of authentication. Send the following parameters in the placeOrder call:

Parameters Description
Vendor3DSReturnURL Required (string)
  URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.
Vendor3DSCancelURL Required (string)
  URL address to which customers are redirected if the 3DS details were not validated or the order could not be authorized.

Parameters

Parameters Type/Description

Currency

String / Optional

 

The currency ISO code for the payment - ISO 4217. Example: “usd.”

Country

String / Optional

 

Shopper country. ISO 3166 two-letter code. Example: “us.”

Language

String / Optional

 

ISO 639-1 two-letter code. Language used for the purchase process. Example: “en.”

ExternalReference

String / Optional

 

Set external reference identifiers for orders. Enables you to replicate the functionality of the REF parameter included into Buy Links. Maximum 100 characters. If there is a need for longer references, you can apply an md5 hash for any string value, resulting in a 32 characters string. You can verify the hash after the order notification, on the client side.

Source

String / Optional

 

The link source for the sales. Enables you to replicate the functionality of the SRC (separate link identifier) parameter when included into Buy Links. Use the SRC parameter to track sale sources.

 

Maximum length 255 characters.

CustomerReference

Integer / Optional

 

Set an external customer ID, attached to the customer.

Items

Array of object / Required

 

Details below. 

 

OrderItem

Object

 

 

 

Details below. 

 

 

Code

String / Optional

 

 

 

Unique product identifier your control. Max length 256 characters. Only for catalog products.

 

 

Quantity

Integer / Optional

 

 

 

Number of units

 

 

PriceOptions

Array of strings / Optional

 

 

 

Array of price option codes.

 

 

SKU

String / Optional

 

 

 

SKU identifier.

 

 

Price

Object - Can be NULL. If Price Type is set to 'CUSTOM', dynamic pricing can be added to the order via the Amount parameter.

 

 

CrossSell

Object – Can be NULL

 

 

 

 

Details below. 

 

 

 

ParentCode

String 

 

 

 

 

The product code of the master product you set to trigger the campaign.

 

 

 

CampaignCode

String 

 

 

 

 

Unique, system-generated identifier for cross-sell campaigns.

 

 

Trial

Object – Can be NULL

 

 

 

 

Details below. 

 

 

 

Period

Integer 

 

 

 

 

The length of the trial subscription lifetime in days.

 

 

 

Price

Double / Optional

 

 

 

 

Total trial price in the payment currency before 2Checkout deducts any taxes, discounts, etc.

 

 

AdditionalFields

Array of objects – Can be NULL

 

 

 

AdditionalFieldSet

Object – Can be NULL

 

 

 

 

Code

String

 

 

 

 

 

The alpha-numeric characters, underscores and dashes that are set as the field identifier.

 

 

 

 

Value

String

 

 

 

 

 

Selected field value.

    SubscriptionStartDate String
     

Specify the date time stamp when the subscription becomes active. Format 2016-07-02 22:22:22 (YYYY-MM-DD HH:mm:ss). Available for JSON-RPC and REST.

Send empty or NULL to activate subscriptions on the same date when customers purchase them.

You can exclude HH:mm:ss when sending the date and include only YYYY-MM-DD. In this case, 2Checkout uses 00:00:01. Default time zone GMT+02:00.

BillingDetails

Object / Required

 

 

Details below. 

 

Person

Object

 

 

 

Details below.

 

 

FirstName

String / Required

 

 

 

Shopper name.

 

 

LastName

String / Required

 

 

 

Shopper surname.

 

 

CountryCode

String / Required

 

 

 

Shopper country. ISO 3166 two-letter code.

 

 

State

String / Optional – Required for US, Turkey, India and Romania

 

 

 

The state in the shopper's country. Mandatory when you set the Billing Country to US, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two letter code.

 

 

City

String / Optional

 

 

 

             

Shopper city.

 

 

Address1

String / Optional

 

 

 

             

Shopper address.

 

 

Address2

String / Optional

 

 

 

             

Shopper address.

 

 

Zip

              String / Optional

 

 

 

             

ZIP/ Postal code.

 

 

Email

String / Optional

 

 

 

             

Shopper email address.

 

 

Phone

String / Optional

 

 

 

             

Shopper phone number. Mandatory when you set Brazil as the Billing Country. Can be NULL.

 

 

Company

String / Optional

 

 

 

             

Company name. Can be null for end users. When present, you also need to provide the FiscalCode.

 

FiscalCode

String / Optional– Required for Brazil

 

 

               

• For companies, it needs to be the VAT ID. 2Checkout will validate the value provided and throw an error if the VAT ID is invalid/incorrect when calling setPaymentDetails. When present, you also need to provide the Company name.

• Mandatory when you set Brazil as the Billing Country. For Brazilian customers it represents the Fiscal Code (CPF/CNPJ).

Mandatory when you set India as the Billing Country, and purchase is made by a Company.

• Can be NULL for end users.

DeliveryDetails

Object / Required

 

 

               

Details below. 

 

Person

Object

 

 

 

             

Details below. 

 

 

FirstName

String / Required

 

 

 

             

Shopper name from the delivery details.

 

 

LastName

String / Required

 

 

 

             

Shopper surname from the delivery details.

 

 

CountryCode

String / Required

 

 

 

             

Shopper country. ISO 3166 two-letter code from the delivery details.

 

 

State

String / Optional – Required for US, Turkey, and Romania

 

 

 

             

The state in the shopper's country from the delivery details. Mandatory when you set the Billing Country to US, Turkey, and Romania. Use case insensitive utf8 strings for the full name, or just the two letter code.

 

 

City

String / Optional

 

 

 

             

Shopper city from the delivery details.

 

 

Address1

String / Optional

 

 

 

             

Shopper address from the delivery details.

 

 

Address2

String / Optional

 

 

 

             

Shopper address from the delivery details.

 

 

Zip

              String / Optional

 

 

 

             

ZIP/ Postal code from the delivery details.

 

 

Email

String / Optional

 

 

 

Shopper email address from the delivery details.

 

 

Phone

String / Optional

 

 

 

Shopper phone number from the delivery details. Mandatory when you set Brazil as the Billing Country. Can be NULL.

 

 

Company

String / Optional

 

 

 

Company name from the delivery details. Can be null for end users. When present, you also need to provide the FiscalCode.

DeliveryInformation

Object / Optional

For products that require physical delivery, use this object to send the shipping method.

    ShippingMethod        

Object

Details below

      Code           String
  System-generated identified for your shipping method configuration

PaymentDetails

Object / Required

 

Adapt this object to the desired payment method.

 

Type

Required (string)

 

 

The payment method:

  • CC (credit/debit card - including local Brazilian cards).
  • ENCRYPTED_PAYMENT_DATA (client-side encryption)
  • PAYPAL
  • PAYPAL_EXPRESS
  • CCNOPCI(credit/debit card for non-PCI certified merchants).
  • TEST (for test orders).
  • PREVIOUS_ORDER(place new orders using the reference of a previous order).
  • EXISTING_PAYMENT_DATA  (use a card one of your customers already used to purchase from your account).
  • WIRE – the placeOrder response includes Wire payment details.
  • CHECK – the placeOrder response includes Check payment details.
  • WE_CHAT_PAY (for WeChat payments).
  • IDEAL (for iDEAL payments).
  • PURCHASEORDER - use for orders with POs.
  • FREE – for 0 value orders for which you’re not requiring customers to provide payment details.

 

 

Currency

Optional (string)

 

 

The currency ISO code for the payment - ISO 4217. Example: “usd.”

  RecurringEnabled Optional (boolean)
   

true – shopper checks the auto renewal checkbox and 2Checkout charges subscription renewals using a recurring billing process.

false – shopper doesn’t check the auto renewal checkbox.

 

PaymentMethod

Optional (object)

 

 

Object structure and parameters differ according to payment method selected and API method (placing orders (POST) vs. retrieving order data (GET)).

 

NULL for 0 value orders for which you’re not requiring customers to enter payment details.

 

 

 

CardPayment

Optional (object)

 

 

 

 

 

Details below. 

 

 

 

 

CardNumber

Required (string)

 

 

 

 

 

The credit/debit card number.

 

 

 

 

CardType

Required (string)

 

 

 

 

 

visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb, hipercard, elo

 

 

 

 

ExpirationYear

Required (string)

 

 

 

 

 

The year in which the card expires.

 

 

 

 

ExpirationMonth

Required (string)

 

 

 

 

 

The month in which the card expires.

 

 

 

 

HolderName

Required (string)

 

 

 

 

 

Card holder name.

 

 

 

 

CCID

Required (string)

 

 

 

 

 

Credit Card Identification - an extra ID printed on the card, usually a 3-4 digit number, the CVC2/CVV2.

        Vendor3DSReturnURL Required (string)
          URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.
        Vendor3DSCancelURL Required (string)
          URL address to which customers are redirected if the 3DS details were not validated or the order could not be authorized.
        HolderNameTime Optional (float)
         

The interval of time in seconds in which shoppers enter their name in the HolderName field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

        CardNumberTime Optional (float)
         

The interval of time in seconds in which shopper enter their card number in the CardNumber field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

 

 

 

 

InstallmentsNumber 

Optional (Int)

 

 

 

 

 

Number of installments. Available only when customers un Brazil pay with Visa or MasterCard using Brazilian Real as the order currency. Use 1 or exclude the parameter for full payments. 

 

 

 

PayPalExpress

Optional (object)

 

 

 

 

 

Details below. 

 

 

 

 

Email

Optional (string)

 

 

 

 

 

Email address customers use for their PayPal account.

 

 

 

 

ReturnURL

Optional (string)

 

 

 

 

 

The PayPal Express Checkout redirect URL returned by calling the getPayPalExpressCheckoutRedirectURL method. The return URL is the page on your website to which PayPal redirects yourbuyer's browser after the buyer logs into PayPal and approves the payment. Typically, this is a secure page (https://...) on your site.

 

 

 

 

CancelURL

Optional (string)

 

 

 

 

 

The cancel URL is the page on your website to which PayPal redirects your buyer's browser if the buyer does not approve the payment. Typically, this is the secure page (https://...) on your site from which you redirected the buyer to PayPal.

 

 

 

PreviousOrder

Optional (Object)

 

 

 

 

 

Details below. 

 

 

 

 

RefNo

Optional (string)

 

 

 

 

 

Order reference a previous purchase which reached the Approved/Complete status. You can use order for which customers paid with credit/debit cards or with PayPal. The status of order should be AUTHRECEIVED or COMPLETE.

 

Check the validity of references with the isValidOrderReference method.

 

The 2Checkout system blocks you from using references for fraudulent or potentially fraudulent orders.

 

 

 

PurchaseOrderPaymentDetails

Optional (Object)

 

 

 

 

 

Details below. 

 

 

 

 

InternalPONumber

Optional (string)

 

 

 

 

 

Identifier that business customers use internally in their organization to track and manage Purchase Orders (PO). Can be NULL.

 

 

 

 

AutoApprove

Optional (boolean)

 

 

 

 

 

TRUE - requires activation of the PO AutoApprove package (If the package is inactive 2Checkout returns an error). Please contact 2Checkout. When AutoApprove is TRUE, 2Checkout no longer requires that business customers upload a PO document. As such, PO orders are automatically approved for your account, without a PO doc. 2Checkout sets the PURCHASE_PENDING status for auto-approved PO orders.

FALSE - Default. Send this if the PO AUtoApprove package is not available for your account. 2Checkout uses the same flow as cart purchases with Purchase Orders for business customers placing orders with POs via API. This means that customers receive the same emails as if they made the purchase using the cart and need to update the PO document, which is reviewed by 2Checkout and that you need to approve. 2Checkout sets the AVAITING_UPLOAD status for POs andUnfinished for their orders.

 

Can be NULL.

      WE_CHAT_PAY Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
      IDEAL Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
        BankCode Required (string)
          String contains the SWIFT code of the bank, the plus sign "+", and the first 3 characters from the bank name. E.q.: in the case of Rabobank, code parameter is "RABONL2U+RAB".

 

 

 

EXISTING_PAYMENT_DATA

Optional (Object)

 

 

 

 

By using EXISTING_PAYMENT_DAT you no longer require shoppers to enter any payment details.

 

 

 

 

TransientToken

Optional (string)

 

 

 

 

 

Returned as a part of the process of retrieving customer information by SSOToken.

 

CustomerIP

Required (string)

 

 

Shopper IP.

Promotions

Optional (Array of strings)

 

Array of promotion codes.

AdditionalFields

Object / Optional

 

 

Details below. 

 

Code

Optional (string)

 

 

The alpha-numeric characters, underscores and dashes that are set as the field identifier.

 

Text

Optional (string)

 

 

Field text visible to shoppers in the cart.

 

Value

Optional (string)

 

 

Selected field value.

LocalTime

Optional (string)

 

Local shopper time in the following format: Y-m-d H:i:s.

This parameter can impact the fraud score of an order when it's missing, NULL or incorrectly formatted.

GiftDetails

Optional (object)

 

Contains contact details for the recipient of a gift purchase.

 

FirstName

Optional (string)

 

 

First name of gift recipient.

 

LastName

Optional (string)

 

 

Last name of gift recipient.

 

Email

Optional (string)

 

 

Email of gift recipient. 2Checkout uses this email for the delivery/fulfillment process.

 

GiftNote

Optional (string)

 

 

Custom text shoppers provide as a message to the gift recipient.

 

 

Search products

Overview

Use the searchProducts method to extract information about the subscription plan/products you configured for your account.

Pagination

Use pagination to decrease the request loading time, while better handling the returning responses.

Pagination works on all the search methods existing on 2Checkout API 5.0. The default pagination behavior is to display page 1 with 10 results. The maximum number of items displayed on a single page is 200.

To use pagination, include the Pagination object inside the search method call, using the parameters below:

Parameters Type/Description
Pagination Object
  Details below.
  Page Int
    Set the number of pages that should be returned.
  Limit Int
    Set a limit for the number of results that should be returned.

 

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.

SearchOptions

Object

 

Name

Optional (string)

 

Product name. Can be NULL.

 

Codes

Optional (StringArray)

 

Array of product codes.

 

Types

Optional (StringArray)

 

Array of the values representing the type of products. Possible values:

  • REGULAR
  • BUNDLE

Leave empty to have all product types returned to the search.

Can be NULL. If NULL, 2Checkout returns both regular and bundle products.

 

Enabled

Optional (boolean)

 

True or false. Can be NULL.

 

GroupName

Optional (string)

 

The name of the group that the product is associated with.

Can be NULL.

 

Limit

Optional (integer)

 

Number of results (products) displayed per page. Default value is 10.

Can be NULL.

 

Page

Optional (integer)

 

A specific page of search results. Default value is 1.

Can be NULL.

 

OrderBy

Object

 

Defines the order of the returned results.

 

Field

Optional (string)

 

The name of the field to order the results by. Allowed values: 'ProductStatus', 'ProductName', 'ProductCode', 'UpdateDatetime', 'AvangateId'. Can be NULL.

 

Direction

Optional (string)

 

Sort results ascending or descending. Allowed values:

  • asc
  • desc (default)

Can be NULL (defaults to desc).

 

Response

Parameter Type/Description

Product

Object

Request

<?php

require ('PATH_TO_AUTH');

$SearchOptions = new stdClass();
$SearchOptions->Name = '2Checkout Subscription'; //Product name
$SearchOptions->Types = array ('REGULAR', 'BUNDLE'); //product type (standalone), regular or bundle
$SearchOptions->Enabled = True;
//$SearchOptions->GroupName = '';
$SearchOptions->Limit = '10';
$SearchOptions->Page = '10';

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'searchProducts',
'params' => array($sessionID, $SearchOptions)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

?>

Retrieve account's time zone

Overview

Use the getTimezone method to retrieve information on the time zone used by your account for the 2Checkout API.

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.

Response

Parameters Type/Description

Timezone

String

 

The time zone you selected or the default GMT+02:00 time zone of the 2Checkout system.

Request

<?php

require ('PATH_TO_AUTH');

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

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

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