Skip to main content

Customer

Overview

The object below is returned directly or within a successful response from the following API requests:

Retrieve a customer

Customer object

Parameters Type/Description

AvangateCustomerReference

Int

 

System-generated 2Checkout customer reference.

 

null when you create a new customer. The 2Checkout system generates default customer numerical (integer) IDs (AV_CUSTOMERID) automatically for all orders containing products that feature subscriptions.

 

 

Aggregate subscriptions under the same Customer account by adding the AV_CUSTOMERID (case sensitive) parameter to Buy links.

ExternalCustomerReference

String

 

Unique customer alphanumeric (string) identifiers you control. Aggregate subscriptions under the same Customer account by adding the CUSTOMERID (case sensitive) parameter to Buy links.

FirstName

String

 

Customer's first name. 

LastName

String

 

Customer's last name.

Company

String

 

Company name.

FiscalCode

String

 

Can be null for end users. For companies, it needs to be the VAT ID, which 2Checkout validates.

2Checkout throws an error if the VAT ID is invalid/incorrect. When present, you also need to provide the company name.

 

Can be null for end users.

Address1

String

 

Customer's address.

Address2

String

 

Customer's address.

City

String

 

Customer's city.

State

String

 

Customer's state. For example, "Alabama","Alaska","Arizona".

Zip

String

 

Zip code.

CountryCode

String

 

Customer's country code (ISO 3166 two-letter code).

Phone

String

 

Customer's phone number.

Fax

String

 

Customer's fax number.

Email

String

 

Customer's email.

ExistingCards

Array of objects

 

Details below.

 

TransientToken

Object

 

 

Populated only with when you retrieve customer information by SSOToken.

 

 

Token

String

 

 

 

Token for the EXISTING_PAYMENT_DATA flow. Use it to charge customers using cards they used in the past for purchases from your 2Checkout account.

 

CardType

String

 

 

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

 

LastDigits

String

 

 

Last four digits of the credit card.

 

ExpirationMonth

String

 

 

Card expiration month.

 

ExpirationYear

String

 

 

Card expiration year.

 

NameOnCard

String

 

 

Card holder name.

Enabled

Boolean

 

true or false, depending on whether the customer account is active or inactive. An active customer account features at least one Active or Past due subscription. Possible customer statuses:

 

  • Active - Customer account status is Active even if Trial and Cancelled/Expired subscriptions exist for the customer, along as there's at least one Active subscription. Customers with a single subscription featuring the Past due status (expired but in the grace period) are considered Active.
  • Inactive - All subscriptions associated to this Customer account are cancelled, expired or both.
  • Trial - Customer account status is Trial if all Active subscriptions for this customer are trials, regardless of any Cancelled/Expired subscriptions.

Trial

Boolean

 

true or false, depending on whether the customer account features only trials or also paid subscriptions.

Language

String

 

ISO 639-1 two-letter code. Example: “en.”

 

Customer

Attributes

Parameters

Type/Description

CustomerDetails

Object

 

2CheckoutCustomerReference

Optional (Int)

 

 

System-generated 2Checkout customer reference.

 

null when you create a new customer. The 2Checkout system generates default customer numerical (integer) IDs (AV_CUSTOMERID) automatically for all orders containing products that feature subscriptions.

 

 

Aggregate subscriptions under the same Customer account by adding the AV_CUSTOMERID (case sensitive) parameter to Buy links.

 

ExternalCustomerReference

Optional (string)

 

 

Unique customer alphanumeric (string) identifiers you control. Aggregate subscriptions under the same Customer account by adding the CUSTOMERID (case sensitive) parameter to Buy links.

 

FirstName

Required (string)

 

 

Customer's first name. 

 

LastName

Required (string)

 

 

Customer's last name.

 

Company

Optional (string)

 

 

Company name.

 

FiscalCode

Optional (string)

 

 

Can be null for end users. For companies, it needs to be the VAT ID, which 2Checkout validates.

2Checkout throws an error if the VAT ID is invalid/incorrect. When present, you also need to provide the company name.

 

Can be null for end users.

 

Address1

Required (string)

 

 

Customer's address.

 

Address2

Optional (string)

 

 

Customer's address.

 

City

Required (string)

 

 

Customer's city.

 

State

Optional (string)

 

 

Customer's state. For example, "Alabama","Alaska","Arizona".

 

Zip

Required (string)

 

 

Zip code.

 

CountryCode

Required (string)

 

 

Customer's country code (ISO 3166 two-letter code).

 

Phone

Optional (string)

 

 

Customer's phone number.

 

Fax

Optional (string)

 

 

Customer's fax number.

 

Email

Required (string)

 

 

Customer's email.

 

ExistingCards

Optional (Array of objects)

 

 

 

 

 

TransientToken

Optional (Object)

 

 

 

Populated only with when you retrieve customer information by SSOToken.

 

 

 

Token

Optional (string)

 

 

 

 

Token for the EXISTING_PAYMENT_DATA flow. Use it to charge customers using cards they used in the past for purchases from your 2Checkout account.

 

 

CardType

Optional (string)

 

 

 

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

 

 

LastDigits

Optional (string)

 

 

 

Last four digits of the credit card.

 

 

ExpirationMonth

Optional (string)

 

 

 

Card expiration month.

 

 

ExpirationYear

Optional (string)

 

 

 

Card expiration year.

 

 

NameOnCard

Optional (string)

 

 

 

Card holder name.

 

Enabled

Optional (boolean)

 

 

true or false, depending on whether the customer account is active or inactive. An active customer account features at least one Active or Past due subscription. Possible customer statuses:

 

  • Active - Customer account status is Active even if Trial and Cancelled/Expired subscriptions exist for the customer, along as there's at least one Active subscription. Customers with a single subscription featuring the Past due status (expired but in the grace period) are considered Active.
  • Inactive - All subscriptions associated to this Customer account are cancelled, expired or both.
  • Trial - Customer account status is Trial if all Active subscriptions for this customer are trials, regardless of any Cancelled/Expired subscriptions.

 

Trial

Optional (boolean)

 

 

true or false, depending on whether the customer account features only trials or also paid subscriptions.

 

Language

Optional (string)

 

 

ISO 639-1 two-letter code. Example: “en.”

 

Create percentage discount

Overview

Use setPromotionDiscount to set a percentage based promotion discount.

Parameters

Parameter Type/Description

sessionID

Required (string)

 

Output of the Login method.

promotionCode

Required (string)

 

The code corresponding to the promotion that you want to set the discount for.

promotionDiscount

Required(Object)

 

Type

Required (String)

 

 

Discount type:

  • PERCENT, use in combination with Value
  • FIXED, use in combination with Values and DefaultCurrency

 

Value / Values

Required (Int / Array of objects)

 

 

  • Value = Int, determines the discount percentage from 0 to 100
  • Values = Array of Value objects

 

 

Value

Required (Object)

 

 

 

Currency

Required (String)

 

 

 

 

Discount currency ISO code (ISO 4217).

 

 

 

Amount

Required (Int)

 

 

 

 

Discount amount in corresponding currency.

 

DefaultCurrency

Required (String)

 

 

Default discount currency ISO code (ISO 4217).

Response

Parameter Type/Description
promotionDiscount Object

Request

<?php

function callRPC($Request, $host, $Debug = true) {
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    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.1/';

$merchantCode = "YOUR_MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.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.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;

$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);

// Promotion code assigned to the promotion you want to update
$promotionCode = '';

$promotionDiscount = new stdClass;
$promotionDiscount->Type = 'PERCENT';
$promotionDiscount->Value= '25';

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'setPromotionDiscount',
'params' => array($sessionID, $promotionCode, $promotionDiscount)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

Update promotion coupon

Request

<?php 

class Client
{
    protected static $merchantCode;
    protected static $loginDate;
    protected static $hash;
    protected static $baseUrl;
    protected static $callCount = 0;
    protected static $sessionId = '';

    protected static $client;

    public static function setCredentials($code, $key)
    {
        static::$merchantCode = $code;
        static::$loginDate = gmdate('Y-m-d H:i:s');
        static::$hash = hash_hmac('md5', strlen($code) . $code . strlen(static::$loginDate) . static::$loginDate, $key);
        static::$sessionId = static::login();
    }

    public static function setBaseUrl($url)
    {
        static::$baseUrl = $url;
    }

    public static function login()
    {
        $client = static::getClient();
        return $client->login(static::$merchantCode, static::$loginDate, static::$hash);
    }

    public static function __callStatic($name, $arguments = array())
    {
        $client = static::getClient();

        array_unshift($arguments, static::$sessionId);
        $response = call_user_func_array(array($client, $name), $arguments);

        return $response;
    }

    protected static function getClient()
    {
        $opts = array(
            'http'=> ['user_agent' => 'PHPSoapClient'],
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        );

        if (null === static::$client) {
            static::$client = new \SoapClient(static::$baseUrl . '?wsdl', [
                'location' => static::$baseUrl,
                'cache_wsdl' => WSDL_CACHE_NONE,
                'stream_context' => stream_context_create($opts),
            ]);
        }

        return static::$client;
    }
}

Client::setBaseUrl('https://api.avangate.com/soap/3.1/');
Client::setCredentials('YOUR_MERCHANT_CODE', 'YOUR_SECRET_KEY');
Client::login();

$promotionCode = 'YOUR_PROMOTION_CODE'; // code of the promotion that you want to update

// // Define single coupon object
// $promotionCoupon = new stdClass;
// $promotionCoupon->Type = 'SINGLE';
// $promotionCoupon->Code = 'YOUR_CODE_HERE';

// Define multiple coupon object
// $promotionCoupon = new stdClass;
// $promotionCoupon->Type = 'MULTIPLE';
// $promotionCoupon->Codes = ['YOUR_CODE_1', 'YOUR_CODE_2'];

$response = Client::updatePromotionCoupon ($promotionCode,$promotionCoupon); // Update existing coupons
var_dump($response);

Retrieve a price option group

Overview

Use the getPriceOptionGroup method to extract information about a specific price option group that you configured.

Parameters

Parameters Type/Description

ProductGroup

Object

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.

groupCode

Required (string)

 

The code that the 2Checkout system generated or that you set for the product pricing options group.

Request

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$groupCode = 'USERS';

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

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

 

Set cross-selling settings

Overview

Use the setCrossSellSettings method to customize the way your cross-sell campaigns are displayed in the shopping cart.  

Request parameters

Parameters 

Type 

Required

Description 

displayShortDescription 

Boolean 

Optional 

Determines if the product short description is displayed next to the thumbnail or not.

displayProductsMax 

Int 

Optional 

The maximum number of recommended products; We recommend adding a maximum of 3 products as cross-selling options. 

maxThumbSize 

Int 

Optional 

Maximum product thumbnail size. Must be any of [60, 80, 100, 150].

Response

The response of the setCrossSellSettings method is the input object with the settings updated. 

Request sample

<?php 
require ('PATH_TO_AUTH'); 
 
try { 
    $sessionID = $client->login($merchantCode, $date, $hash); 
    $setCrossSellSettingResponse = $client->setCrossSellSettings($sessionID, (object)[ 
        'maxThumbSize' => 60, 
        'displayProductsMax' => 5, 
        'displayShortDescription' => false, 
    ]); 
} catch (SoapFault $e) { 
    echo  $e->getMessage(); 
} 

Subscription search

Overview

2Checkout has upgraded the Subscription search (formerly Customers (License Management)) area of the Control Panel introducing major changes to support more granularity and control over the data returned, increasing efficiency, and providing you with better insight into the evolution of subscriptions associated with the products you're selling.

Subscription search returns results in real-time, enabling you to closely monitor order evolution.

Basic filters

  1. Product filter. Select specific products, or get information on all your offerings.
  2. Subscription status:
    • Active: all subscriptions in use neither expired nor canceled; The date when the subscription status is calculated/requested precedes the expiration date.
    • Pending activation: The subscription start date begins at a future date.
    • Expired: subscriptions past their renewal date and that were not prolonged by customers, but that are not canceled; The date when the subscription status is calculated/requested comes after the expiration and the grace period deadlines. Customers can no longer make any changes to the subscription. The expiration date of a recurring subscription is calculated based on a 'last day of the month' principle. Let's say for instance that a monthly recurring subscription is starting on January 31st. In February, this subscription will expire on February 28th (or 29th for leap years). In March, the subscription will expire on 31st again.
    • Past due: subscriptions that were not renewed ahead of the expiration deadline for which a grace period was configured. Past due subscriptions still can be renewed at any time by customers while still in the grace period.
    • Canceled: the subscription has been deactivated through the Merchant Control Panel, API, or an operation such as refund or upgrade, thus canceling any future renewals, manual or automatic, and the possibility of upgrading. Customers can no longer make any changes to the subscription.
    • Paused: all automatic charges are suspended for a predefined time period. When subscribers request to pause a subscription, this remains active until the end of the current billing cycle, at which point the subscription will move into a paused status.
  3. Expiration date. You can search for subscriptions that either expired, are going to expire in the day you run the search or in the future.
    • Anytime: select to have the report display all subscriptions including lifetime/evergreen items.
    • Never: select to have the report display only lifetime subscriptions.
  4. Subscription type. This filter allows you to select all subscriptions, the trials offered to customers, subscriptions that resulted from the successful conversion of trials, or all of the above.
  5. Subscription channel. The subscription channel is designed to let you filter only eStore subscriptions or those sold through your partners or affiliates (if any).
  6. Subscription renewal.
    • Auto-recurring: subscriptions for which the auto-renewal process is enabled. Note: subscriptions with the manual renewal option enabled that were switched to auto-renewal will be displayed when the Auto- recurring filter is checked.
    • Manual payment: subscriptions which customers can renew manually. Note: subscriptions for which the auto-renewal process was switched off and transformed to manual renewal will be displayed when the Manual payment filter is checked.
    • Non-recurring: evergreen subscription which lacks an expiration date, as well as non-evergreen items for which customers made a one-time payment.

Advanced filters

You can further narrow down the results returned using filters such as:

  1. Geographic regions
  2. Countries. Select the location of the customer that purchased the subscription. When all countries are selected the search results returned will not include subscriptions sold to partners for which customer registration is lacking.
  3. Partner
  4. Customer registration
  5. Purchase date. Enables you to filter results according to the date when the subscription was generated by the 2Checkout system.
  6. Renewal date. Returns all subscriptions that were renewed during the time interval selected for the filter.
  7. Upgrade date. Return all subscriptions that were upgraded during the time interval selected for the filter.
  8. Customer/partner notification date.  Filters subscriptions for which notifications were sent during the time interval selected.

Maximum number of results

The subscription search displays a maximum of 1,000 results.

When exporting, a maximum of 100,000 items can be included in a single CSV (comma separated values) file. If you'd like more results beyond the first 100,000 to be exported, simply modify date settings to export results in batches of 100,000.

Time zone support

Customer search supports time zone selection, enabling you to choose either the default 2Checkout time zone (GMT + 02:00) or a custom time zone that you control via Account settings/Edit system settings.

The timezone selected in the Subscription search area controls the timestamps in which data on specific subscription details pages is reported.

The 2Checkout system calculates the status of subscriptions dynamically based on their expiration date, grace period deadline, and the date when the subscription information is requested (when info is displayed in the Control Panel or when a relevant API method is invoked). Only Canceled subscriptions are marked as disabled in the 2Checkout system

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

<?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, array('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/5.0/';

$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

$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 = array($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);
}

Perform action

Overview

Use the performAction method via JSON-RPC APIv6 to execute an action on the proposal.

Request parameters

Request parameters for the performAction method via JSON-RPC APIv6
Action Parameters Type Required/Optional Description
  sessionId String Required Unique 2Checkout session ID code.

 

 

 

 

 

 

 

 

SEND

proposalId String Required The unique merchant proposal ID generated by the 2Checkout system.
exirationDate Date Required The date at which the proposal expires; date-time ISO 8601 format
userId String Optional The unique user ID generated by the 2Checkout system.
action String Required The action to be executed on the proposal.
statusComment String Optional Free text comments that can accompany a status.
sentBy String Required Represents the account manager of the merchant.

FirstName

String Required The first name of the email sender.

LastName

String Required The last name of the email sender.

Email

String Required The email address of the email sender.

 

ACCEPT

action String Required The action to be executed on the proposal.
statusComment String Optional Free text comments that can accompany a status.

 

 

CLOSE

action String Required The action to be executed on the proposal.
statusComment String Optional Free text comments that can accompany a status.
userId String Optional The unique user ID generated by the 2Checkout system.

 

 

DISCARD

action String Required The action to be executed on the proposal.
statusComment String Optional Free text comments that can accompany a status.
userId String Optional The unique user ID generated by the 2Checkout system.

 

 

REOPEN

action String Required The action to be executed on the proposal.
statusComment String Optional Free text comments that can accompany a status.
userId String Optional The unique user ID generated by the 2Checkout system.

 

DECLINE

action String Required The action to be executed on the proposal.
statusComment String Optional Free text comments that can accompany a status.

Request sample

<?php

require ('PATH_TO_AUTH');

$proposalId = "0573e71d-38bb-4d61-88ca-b3c557517c68";

$actionPayload = new stdClass();
$actionPayload->ExpirationDate = "2021-01-05T17:21:42+00:00";
$actionPayload->UserId = "john.doe@email.com";
$actionPayload->action = "decline";
$actionPayload->StatusComment = "The price is too high for the first product";
$actionPayload->SentBy = new stdClass();
$actionPayload->SentBy->FirstName = "John";
$actionPayload->SentBy->LastName = "Doe";
$actionPayload->SentBy->Email = "john.doe@email.com";

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'performAction';
$jsonRpcRequest->params = array($sessionID, $actionPayload);
$jsonRpcRequest->id = $i++;

try {
    $result = callRPC($jsonRpcRequest, $host);
    echo "Proposal: </br>", 
    var_dump($result);
}
catch (SoapFault $e) {
    echo "Could not fetch proposal: " . $e->getMessage();
    exit;
}

Response

The performAction call via JSON-RPC APIv6 returns the Proposal object.

Place orders with catalog products

Overview

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

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

You can find a list of common errors that may arise when using the placeOrder call via API 6.0 here.

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. Alipay
  9. UnionPay
  10. Trustly
  11. TEST orders
  12. Free orders (no payment information required)
  13. 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.
  14. 2Pay.js

Requirements

For credit card orders placed using 2Checkout API 6.0 or a more recent version, 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 password 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, as part of the PaymentDetails object:

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.

Response

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

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. The 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.
Affiliate Object/Optional
                 AffiliateCode String/Required
  The affiliate unique code (as returned by the affiliates API methods).
AffiliateSource String/Optional
  The affiliate source.
Items Array of objects / Required
  Details below. 
  OrderItem Object
    Details below. 
    Code String / Mandatory
      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.

    SubscriptionCustomSettings Object/Optional
      To use this, the ExtraInformation object with AssistedSale property set to "true" is required.
   

CycleAmountType

String/Required
      Billing cycle unit NET/GROSS.
   

CycleUnit

String/Required
      DAY/MONTH. Can be NULL.
   

CycleAmount

Float/Required
      Billing cycle (renewal) price.
   

CycleLength

Integer/Required
      Billing cycle length. Can be NULL.
   

ContractLength

Integer/Optional
   
 
Contract period length (expressed in the specified CycleUnit; must be multiple of CycleLength). Can be NULL.
   

MerchantDealAutoRenewal

Boolean/Optional
      Merchant deal auto-renewal flag.
   

ClientDealAutoRenewal

Boolean/Optional
      Client deal auto-renewal flag.
BillingDetails Object / Required
  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, Canada, Brazil, Turkey, India and Romania
    The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two-letter code.
  City String /Required
    Shopper city.
  Address1 String/Required
    Shopper address.
  Address2 String / Optional
    Shopper address.
  Zip               String/Required
    ZIP/ Postal code.
  Email String/Required
    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.

  TaxExemptionId  Optional (string)
    Tax Exempt Certification id used to deduct taxes for US orders
Example: 1b80eecc349v
DeliveryDetails Object / Required
  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, Canada, Brazil, Turkey, India and Romania
      The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India 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.
  • ALIPAY
  • UNIONPAY
  • DIRECT_EBANKING
  • TRUSTLY (for Trustly payments)
  • EES_TOKEN_PAYMENT (2Pay.js)

 

  Currency Required (string)
    The currency ISO code for the payment - ISO 4217. Example: “usd.”
  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.

                                                              RecurringEnabled Optional (boolean)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.

      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)
          Cardholder 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 enters 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 that reached the Approved/Complete status. You can use orders for which customers paid with credit/debit cards or with PayPal. The status of orders 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.
      TRUSTLY  Optional (string)
        Details below.
        ReturnURL Optional (string)
     

 
  The return URL is the page to which your customers are redirected after their successful payment. The return URL is the page to which your customers are redirected after their successful payment. 
  CustomerIP Optional (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.

 

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