Skip to main content

Retrieve product by code

Overview

Use getProductByCode to extract product information using the unique identifier you assign to subscription plans/products.  

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.

ProductCode

String

 

The product code that you control.

Response

Parameters Type/Description
Product Object

Request

<?php

require ('PATH_TO_AUTH');

$ProductCode = "subscr1";

try {
    $ProdbyCode = $client->getProductByCode($sessionID, $ProductCode);
}

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

var_dump("ProductInfo", $ProdbyCode);


?>

 

Place an order with installments

Overview 

Use the placeOrder method to create an order and collect the payment.

Supported payment methods 

Credit/Debit cards: Visa and MasterCard local Brazilian cards.

Parameters 

Parameters Type/Description

sessionID

Required (string)

 

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

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

Requirements

  1. Payment methods: Visa, MasterCard or AMEX
  2. Country: Brazil
  3. Currency BRL
  4. Specified number of installments under the PaymentMethod object. (Minimum installment threshold is 5 BRL.)
    • Phone number
    • Fiscal code (CPF/CNPJ)
  5. Mandatory billing information must include:

  6. Transaction: non-recurring
  7. Installments are available only for:
    • Brazilian customers
    • Local Visa, MasterCard and AMEX cards
    • Non-recurring transactions

<?php

require ('PATH_TO_AUTH');
 
$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'brl';
$Order->Country = 'BR';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1; 
$Order->Items[0]->PriceOptions = NULL;

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'FirstName';
$Order->BillingDetails->LastName = 'LastName';
$Order->BillingDetails->CountryCode = 'BR';
$Order->BillingDetails->State = 'DF';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '70403-900';
$Order->BillingDetails->Email = 'customer@email.com';
$Order->BillingDetails->Phone = "556133127400";
$Order->BillingDetails->FiscalCode = "056.027.963-98";
$Order->BillingDetails->Company = NULL;

$Order->DeliveryDetails = NULL;

$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'CC';
$Order->PaymentDetails->Currency = 'brl';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->CardType = 'visa';
$Order->PaymentDetails->PaymentMethod->ExpirationYear = '2019';
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = '12';
$Order->PaymentDetails->PaymentMethod->HolderName = 'John';
$Order->PaymentDetails->PaymentMethod->CCID = '123';


$jsonRpcRequest = array (
'method' => 'getInstallments',
'params' => array($sessionID, $Order),
'id' => $i++,
'jsonrpc' => '2.0'
);
echo '<BR>';
echo 'The content of the current session:';
echo '<BR>';

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

Add promotion translations

Overview

Use the addPromotionTranslations method via JSON-RPC 4.0 to add localized texts to existing promotions.

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 add translations to.

promotions

Required (array of PromotionTranslations objects)

PromotionTranslations  Object

 

language

Required (string)

 

 

ISO country code corresponding to the country you want to set the translation for.

 

name

Required (string)

 

 

Localized promotion name applicable to the selected country.

Response

Parameters Type/Description

promotionTranslation

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 corresponding to the promotion you want to add translations to
$promotionCode = '';

// Defining a translation for German shoppers
$promotionTranslation1 = new stdClass;
$promotionTranslation1->Language = 'de'; 
$promotionTranslation1->Name = 'YOUR_GERMAN_PROMOTION_NAME';

// Defining a translation for Bulgarian shoppers
$promotionTranslation2 = new stdClass;
$promotionTranslation2->Language = 'bg'; 
$promotionTranslation2->Name = 'YOUR_BULGARIAN_PROMOTION_NAME';

$translations = [$promotionTranslation1, $promotionTranslation2];

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

 

One click (1-click) purchase

Overview

2Checkout supports 1-click purchases for returning customers who paid for their previous orders with:

  • Credit/Debit cards
  • PayPal

How does this work?

  1. Identify returning customers. 
  2. Access data on the previous purchases of returning customers.
  3. Validate previous order references for 1-click purchase scenarios using the isValidOrderReference method.
  4. Place a new order using a valid previous order reference as the payment method. 
  5. 2Checkout charges returning customers using their payment-on-file information, either a card or their PayPal account. 

Availability

Select 2Checkout accounts. Contact 2Checkout for more details. 

Requirements

  • Use only references of previous orders  with one of the following statuses AUTHRECEIVED or COMPLETE.
  • The email address of the BillingDetails object is mandatory and it needs to match the email address used as a part of the billing details of the initial order whose reference you're now using to place a new order. 2Checkout checks whether the email addresses are identical, and throws an error if they're not, blocking the order placement process. Note: You need to provide only the email address of the shopper, and can ignore the rest of the required customer billing information. If you enter any billing details in addition to the email address, you'll have to provide all information required in the BillingDetails object.

Parameters

Parameters

Type/Description

sessionID

Required (string)

 

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

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

Response

Order information

Object

Request


<?php
echo "<pre>";
$host   = "https://api.2Checkout.com";
$client = new SoapClient($host . "/soap/3.0/?wsdl", array(
    'location' => $host . "/soap/3.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 = "MERCHANT_CODE";// your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key = "SECRET_KEY";// your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$now = date('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;
}
$orderReference = '45452071';
try {
    $validOrderRef = $client->isValidOrderReference($sessionID, $orderReference);
}
catch (SoapFault $e) {
    echo "validOrderRef: " . $e->getMessage();
    exit;
}
var_dump("validOrderRef", $validOrderRef);
try {
    $existentOrder = $client->getOrder($sessionID, $orderReference);
}
catch (SoapFault $e) {
    echo "existentOrder: " . $e->getMessage();
    exit;
}
$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'usd';
$Order->Country = 'US';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->AffiliateId = NULL;
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1; 
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false; 
$Order->Items[0]->AdditionalFields = NULL;
$Order->BillingDetails = new stdClass();
$Order->BillingDetails = $existentOrder->BillingDetails;
$Order->DeliveryDetails = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'PREVIOUS_ORDER';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->RefNo = $orderReference;
$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;
try {
    $newOrderPaidWithPreviousRef = $client->placeOrder($sessionID, $Order);
}
catch (SoapFault $e) {
    echo "newOrderPaidWithPreviousRef: " . $e->getMessage();
    exit;
}
var_dump("newOrderPaidWithPreviousRef", $newOrderPaidWithPreviousRef);
?>

 

Checkout with expiration using the signature in InLine Cart

Overview

Use the expiration key to define the validity of a buy-link. The expiration needs to be signed before using the checkout in InLine Cart. In case the expiration is overdue, then the signature is considered invalid.

Use case

  1. Add an HTML link or button on your page like the one below.
  2. Create a JavaScript click handler to execute the Inline Client desired methods.
  3. In order to set expiration, use the TwoCoInlineCart.cart.setExpiration(TIMESTAMP) method.
  4. Use the TwoCoInlineCart.products.add({code, quantity, options, price}) method or the TwoCoInlineCart.products.addMany(products) method to prepare your product(s).
  5. Below it is a signature token request payload for this example. A success response contains a JSON with the property “signature“ which needs to be used to the next step to set the signature using the TwoCoInlineCart method.
{
  "merchant": "AVLRNG",
  "currency": "USD",
  "expiration": 2524608000,
  "products": [
    {
      "code": "74B8E17CC0"
    }
  ]
}

In this example we used a timestamp for January 1st, 2050 as an example. The signature obtained is 16ef22d988d356356ee2437d26114370e29e6293fb4f2e8b58cefad31020950d.

6. Use the TwoCoInlineCart.cart.setExpiration(2524608000) method to set the expiration.

7. Use the TwoCoInlineCart.cart.setSignature('16ef22d988d356356ee2437d26114370e29e6293fb4f2e8b58cefad31020950d') method to set the signature. It is important that you employ the TwoCoInlineCart.cart.removeAll() method just before the TwoCoInlineCart.products.addMany(products) or TwoCoInlineCart.products.add(product) to clear the products, as the signature is based on the products' definition, or simply request a new signature.

8. Use the TwoCoInlineCart.cart.checkout() method to show the cart on your page.

Sample request

HTML

<a href="#" class="btn btn-success" id="buy-button">Buy bundle now!</a>

JavaScript

window.document
  .getElementById('buy-button')
  .addEventListener('click', function() {
  TwoCoInlineCart.cart.setExpiration(2524608000);
  TwoCoInlineCart.products.add({
    code: "74B8E17CC0"
  });
  TwoCoInlineCart.cart.setSignature('16ef22d988d356356ee2437d26114370e29e6293fb4f2e8b58cefad31020950d');
  TwoCoInlineCart.cart.checkout();
});

Demo

Update promotion coupon

Overview

Use the updatePromotionCoupon method via SOAP API 4.0 to add single or multiple coupons to a promotion.

Updating a promotion with multiple coupons causes any existing single coupon to be removed.

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 update.

promotionCoupon

Required (object)

 

type

Required (string)

 

 

Coupon type. Available values:

  • SINGLE, use in conjunction with Code
  • MULTIPLE, use in conjunction with Codes

 

Code/Codes

Required (string / array of strings)

 

 

Coupon code (for SINGLE) or array of coupon codes (for MULTIPLE).

Response

Parameter Type/Description
promotionCoupon Object

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.2checkout.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);

 

Catalog order session content object

Overview

Use this object to retrieve session content and to guide shoppers through advanced payment flows, such as those of PayPal, PayPal Express, Wire, Check, etc. 

Attributes

Order session  contents

                                                                            Type/Description

Errors

 

Optional (StringArray)

 

 

Payment gateway processing errors.

Items

Array of objects

    Details below. 

 

ProductDetails

Object

      Details below. 

 

 

Name

Optional (string)

 

 

 

Product name.

 

 

ExtraInfo

Optional (string)

 

 

 

The text entered in the Additional information field when generating Buy links, or via the INFO[PRODUCT_ID] parameter used in Buy links.

 

 

RenewalStatus

Optional (boolean)

 

 

 

  • true for orders renewing subscriptions.
  • false for all other orders: new purchases, upgrades.

 

 

Subscriptions

Object

        Details below. 

 

 

 

SubscriptionReference

Optional (string)

 

 

 

 

Unique, system-generated subscription identifier.

 

 

 

PurchaseDate

Optional (string)

 

 

 

 

The date time stamp when shoppers acquired their subscriptions corresponding to the moment when the Avangate system marks the purchase as finished. Format (YYYY-MM-DD HH:mm:ss). Default GMT+02:00.

 

e.g. 2015-08-11 15:18:52

 

 

 

SubscriptionStartDate

Optional (string)

 

 

 

 

 

Example: 2015-09-29 17:57:59

 

 

 

ExpirationDate

Optional (string)

 

 

 

 

The date time stamp of upcoming renewal/expiration for subscriptions not taking into account grace period settings.

 

Format (YYYY-MM-DD HH:mm:ss). Default GMT+02:00.

 

e.g. 2015-09-11 15:18:52

 

 

 

Lifetime

Optional (boolean)

 

 

 

 

  • true – For non-recurring, evergreen subscriptions.
  • false – For recurring subscriptions with a specific billing cycle from 7 days to 36 months.

 

 

 

Trial

Optional (boolean)

 

 

 

 

  • true – For trial subscriptions.
  • false – For non-trial, recurring subscriptions with a specific billing cycle from 7 days to 36 months.

 

 

 

Enabled

Optional (boolean)

 

 

 

 

  • true – For active and past due subscriptions.
  • false – For expired and cancelled subscriptions.

 

 

 

RecurringEnabled

Optional (boolean)

 

 

 

 

  • true - customers opted for subscriptions to renew automatically when they expire.
  • false - customers did not choose to renew the subscription automatically.

                    

PriceOptions

Optional (Array of strings)

 

 

Product price options.

 

Price

Object

 

 

This object returns the price per unit at order line level.

 

In the case of trials, the object returns the costs for the trial to full subscription conversion.

 

 

UnitNetPrice

Optional (double)

 

 

 

The value per product unit, excluding sales tax/VAT expressed in the payment currency.

 

 

UnitGrossPrice

Optional (double)

 

 

 

Total value per product unit, including sales tax/VAT expressed in the payment currency. UnitGrossPrice does not reflect any discounts.

 

 

UnitVAT

Optional (double)

 

 

 

Sales tax/VAT per product unit expressed in the payment currency.

 

 

UnitDiscount

Optional (double)

 

 

 

Value of the discount per product unit expressed in the payment currency.

 

 

UnitNetDiscountedPrice

Optional (double)

 

 

 

The value per product unit, expressed in the payment currency, excluding sales tax/VAT, from which Avangate deducts the unit discount.

 

 

UnitGrossDiscountedPrice

Optional (double)

 

 

 

Total costs shoppers incur per product unit, expressed in the payment currency. This value includes sales tax/VAT, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.

 

 

UnitAffiliateCommission

Optional (double)

 

 

 

Value of the affiliate commission per product unit calculated expressed in the payment currency.

 

Avangate deducts discounts from the costs incurred by shoppers before calculating affiliate commissions.

 

Avangate does not take into account shipping costs when calculating affiliate commissions.

 

NULL when Avangate does not apply an affiliate commission.

 

 

Currency

Optional (string)

 

 

 

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

 

 

NetPrice

Optional (double)

 

 

 

The value per order line, excluding sales tax/VAT expressed in the payment currency.

 

 

GrossPrice

Optional (double)

 

 

 

Total value per order line, including sales tax/VAT expressed in the payment currency. UnitGrossPrice does not reflect any discounts.

 

 

NetDiscountedPrice

Optional (double)

 

 

 

The NetPrice value per order line, excluding sales tax/VAT, from which Avangate deducts discounts. NetDiscountedPrice is expressed in the payment currency.

 

 

GrossDiscountedPrice

Optional (double)

 

 

 

Total costs shoppers incur per order line, expressed in the payment currency. This value includes sales tax/VAT, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.

 

Example:

  • UnitNetPrice: 99
  • UnitGrossPrice: 120.39
  • UnitVAT: 21.39
  • UnitDiscount: 9.9
  • UnitNetDiscountedPrice: 89.1
  • UnitGrossDiscountedPrice: 110.49
  • UnitAffiliateCommission: 22.28
  • Currency: "usd"
  • NetPrice: 198
  • GrossPrice: 240.77
  • NetDiscountedPrice: 178.2
  • GrossDiscountedPrice: 220.97
  • Discount: 19.8
  • VAT: 42.77
  • AffiliateCommission: 44.56

 

 

Discount

Optional (double)

 

 

 

Value of the discounts per order line expressed in the payment currency.

 

 

VAT

Optional (double)

 

 

 

Value of sales tax/VAT per order line expressed in the payment currency.

 

 

AffiliateCommission

Optional (double)

 

 

 

Value of the affiliate commission per order line, calculated from the NetDiscountedPrice expressed in the payment currency. Or NULL. Avangate does not take into account shipping costs when calculating affiliate commissions.

 

Code

Optional (string)

 

 

Unique product identifier your control. Max length 256 characters.

 

Quantity

Optional (integer)

 

 

Number of units

 

SKU

Optional (string)

 

 

SKU identifier.

 

CrossSell

Optional (Object)

      Details below. 

 

 

ParentCode

Optional (string)

 

 

 

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

 

 

CampaignCode

Optional (string)

 

 

 

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

 

Trial

Optional (Object)

      Details below. 

 

 

Period

Optional (integer)

 

 

 

The length of the trial subscription lifetime in days.

 

 

GrossPrice

Optional (double)

 

 

 

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

 

 

VAT

Optional (double)

 

 

 

The total value of taxes for the trial in the payment currency, before Avangate deducts any discounts.

 

 

NetPrice

Optional (double)

 

 

 

Total trial price in the payment currency, not including taxes, before Avangate deducts any discounts.

 

AdditionalFields

Optional (array of objects)

      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.

 

Promotion

Optional (object)

      Details below. 

 

 

Name

Optional (string)

 

 

 

Promotion name.

 

 

Description

Optional (string)

 

 

 

Promotion description.

 

 

StartDate

Optional (string)

 

 

 

The date when you set the promotion to start. NULL for promotions that start immediately after you create them.

 

 

EndDate

Optional (string)

 

 

 

The date when you set the promotion to end. NULL for promotions you want active indefinitely.

 

 

MaximumOrdersNumber

Optional (integer)

 

 

 

Avangate only applies the promotion to a maximum number of orders you define.

 

Can be NULL if you want the promotion to apply to an unlimited number of orders.

 

 

MaximumQuantity

Optional (integer)

 

 

 

Discount only applies to a maximum number of units purchased through a single order, smaller than the quantity you defined. Shoppers purchase any extra units at full price. Can be NULL if you want the promotion to apply to an unlimited number units.

 

 

InstantDiscount

Optional (boolean)

 

 

 

The instant discount option auto-applies the discount for ALL selected products, without the need for shoppers to enter a discount coupon.

 

 

Coupon

Optional (string)

 

 

 

Promotion coupon/voucher.

 

 

DiscountLabel

Optional (string)

 

 

 

Discounts can be set as a percentage from the product price or as a fixed amount in the chosen currency.

 

 

Enabled

Optional (string)

 

 

 

true or false, depending on whether a promotion is active or disabled. 

 

 

Type

Optional (string)

 

 

 

  • REGULAR – product/cart line level discounts.
  • ORDER – quantity discounts.
  • GLOBAL – order-level discounts.

Promotions

Optional (Array of objects)

    Details below. 

 

Name

Optional (string)

 

 

Promotion name.

 

Description

Optional (string)

 

 

Promotion description.

 

StartDate

Optional (string)

 

 

The date when you set the promotion to start. NULL for promotions that start immediately after you create them.

 

EndDate

Optional (string)

 

 

The date when you set the promotion to end. NULL for promotions you want active indefinitely.

 

MaximumOrdersNumber

Optional (integer)

 

 

Avangate only applies the promotion to a maximum number of orders you define.

 

Can be NULL if you want the promotion to apply to an unlimited number of orders.

 

MaximumQuantity

Optional (integer)

 

 

Discount only applies to a specific number of units purchased at once, smaller than the maximum quantity you defined. Shoppers purchase any extra units at full price. Can be NULL if you want the promotion to apply to an unlimited number units.

 

InstantDiscount

Optional (boolean)

 

 

The instant discount option auto-applies the discount for ALL selected products, without the need for shoppers to enter a discount coupon.

 

Coupon

Optional (string)

 

 

Promotion coupon/voucher.

 

DiscountLabel

Optional (string)

 

 

Discounts can be set as a percentage from the product price or as a fixed amount in the payment currency.

 

Enabled

Optional (string)

 

 

true or false, depending on whether a promotion is active or disabled. 

 

Type

Optional (string)

 

 

  • REGULAR – product/cart line level discounts.
  • ORDER – quantity discounts.
  • GLOBAL – order-level discounts.

AdditionalFields

Optional (array of objects)

    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.

Currency

Optional (string)

 

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

NetPrice

Optional (double)

 

Order value excluding sales tax/VAT expressed in the payment currency.

GrossPrice

Optional (double)

 

Total order value, including sales tax/VAT expressed in the payment currency. GrossPrice does not reflect any discounts.

NetDiscountedPrice

Optional (double)

 

The NetPrice order value excluding sales tax/VAT, from which Avangate deducts discounts. NetDiscountedPrice is expressed in the payment currency.

GrossDiscountedPrice

Optional (double)

 

Total costs shoppers incur, expressed in the payment currency. This value includes sales tax/VAT, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.

 

For example:

  • Currency: "usd"
  • NetPrice: 396
  • GrossPrice: 486.29
  • NetDiscountedPrice: 376.2
  • GrossDiscountedPrice: 466.49
  • Discount: 19.8
  • VAT: 90.29
  • AffiliateCommission: 94.05

Discount

Optional (double)

 

Value of the discounts for an order expressed in the payment currency.

VAT

Optional (double)

 

Value of sales tax/VAT expressed in the payment currency.

AffiliateCommission

Optional (double)

 

Value of the affiliate commission for the order calculated from the NetDiscountedPrice expressed in the payment currency. Or NULL. Avangate does not take into account shipping costs when calculating affiliate commissions.

Orders with installments

Overview

2Checkout supports local Brazilian Visa, MasterCard and AMEX credit/debit cards limited to national purchases in the local currency BRL (Brazilian Real)

Requirements

  1. Installments are available only for:
    • Brazilian customers
    • Local Visa, MasterCard or AMEX cards
    • Non-recurring transactions
  2. Minimum installment threshold is 5 BRL. The maximum number of installments is 6.
  3. Mandatory information for payments also includes a shopper phone number and  Fiscal Code (CPF/CNPJ).

Do local BR cards with/without installments require an addendum to my contract?

Yes. Please contact 2Checkout for activation.

How does it work?

  1. Create the Order object.
  2. Validate the number of installments available based on total order value. 
  3. Place the order specifying the number of installments. 

Funds collection for installment payments

2Checkout pays you in full, regardless of the number of installments (this is covered directly by the banks). 

 

 

Dynamic order session content object

Overview

Use this object to retrieve session content and to guide shoppers through advanced payment flows, such as those of PayPal, PayPal Express, Wire, Check, etc. 

Attributes

Parameters Type/Description

Errors

                        Optional (StringArray)

 

                        Payment gateway processing errors.

Items

Array of objects

   

Details below. 

 

ProductDetails

Object

   

Name

Optional (string)

     

Product name.

   

ExtraInfo

Optional (string)

     

The text entered in the Additional information field when generating Buy links, or via the INFO[PRODUCT_ID] parameter used in Buy links.

   

RenewalStatus

Optional (boolean)

     
  • true for orders renewing subscriptions.
  • false for all other orders: new purchases, upgrades.
   

Subscriptions

Object

     

SubscriptionReference

Optional (string)

       

Unique, system-generated subscription identifier.

     

PurchaseDate

Optional (string)

       

The date time stamp when shoppers acquired their subscriptions corresponding to the moment when the Avangate system marks the purchase as finished. Format (YYYY-MM-DD HH:mm:ss). Default GMT+02:00.

 

e.g. 2015-08-11 15:18:52

     

SubscriptionStartDate

Optional (string)

       

 

Example: 2015-09-29 17:57:59

     

ExpirationDate

Optional (string)

       

The date time stamp of upcoming renewal/expiration for subscriptions not taking into account grace period settings.

 

Format (YYYY-MM-DD HH:mm:ss). Default GMT+02:00.

 

e.g. 2015-09-11 15:18:52

     

Lifetime

Optional (boolean)

       
  • true – For non-recurring, evergreen subscriptions.
  • false – For recurring subscriptions with a specific billing cycle from 7 days to 36 months.
     

Trial

Optional (boolean)

       
  • true – For trial subscriptions.
  • false – For non-trial, recurring subscriptions with a specific billing cycle from 7 days to 36 months.
     

Enabled

Optional (boolean)

       
  • true – For active and past due subscriptions.
  • false – For expired and cancelled subscriptions.
     

RecurringEnabled

Optional (boolean)

       
  • true – For subscriptions with active recurring options
  • false – For subscriptions without recurring options.
    Tangible   Optional (boolean)
       
  • true – For products with physical delivery.
  • false – For products that don't require physical delivery.
    IsDynamic   Optional (boolean)
       
  • true – For products created with dynamic information.
  • false – For catalog products.
    ShortDescription   Optional (string)
        Short product description
    DeliveryInformation   Optional (object)
        Details below.
      Delivery Optional (string)
        Delivery information.
      DownloadFile Optional (object)
        Information related to the download file.
      DeliveryDescription Optional (string)
        Delivery description.
      CodesDescription Optional (string)
        Description of the codes delivered.
      Codes Optional (array)
        Array with the codes delivered.

                   

PriceOptions

Optional (array of objects)

   

Array of price option groups.

   

Code

Optional (strings)

     

Pricing option code. 

   

Required

Optional (boolean)

     
  • true – you require shoppers to select the price option  through the way in which you configured pricing.
  • false – you do not require shoppers to select the price option.
   

Options

Optional (array of objects)

     

Array of pricing options.

      Name Optional (string)
        Pricing option name.
      Value Optional (string)
        Pricing option code.
      Surcharge Optional (string)
        Surcharge of the pricing option. The value is not added to the product amount, but it will be stated in the cart as part of the total product price.
 

Price

Object

   

This object returns the price per unit at order line level.

 

In the case of trials, the object returns the costs for the trial to full subscription conversion.

   

UnitNetPrice

Optional (double)

     

The value per product unit, excluding sales tax/VAT expressed in the payment currency.

   

UnitGrossPrice

Optional (double)

     

Total value per product unit, including sales tax/VAT expressed in the payment currency. UnitGrossPrice does not reflect any discounts.

   

UnitVAT

Optional (double)

     

Sales tax/VAT per product unit expressed in the payment currency.

   

UnitDiscount

Optional (double)

     

Value of the discount per product unit expressed in the payment currency.

   

UnitNetDiscountedPrice

Optional (double)

     

The value per product unit, expressed in the payment currency, excluding sales tax/VAT, from which Avangate deducts the unit discount.

   

UnitGrossDiscountedPrice

Optional (double)

     

Total costs shoppers incur per product unit, expressed in the payment currency. This value includes sales tax/VAT, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.

   

UnitAffiliateCommission

Optional (double)

     

Value of the affiliate commission per product unit calculated expressed in the payment currency.

 

Avangate deducts discounts from the costs incurred by shoppers before calculating affiliate commissions.

 

Avangate does not take into account shipping costs when calculating affiliate commissions.

 

NULL when Avangate does not apply an affiliate commission.

   

Currency

Optional (string)

     

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

   

NetPrice

Optional (double)

     

The value per order line, excluding sales tax/VAT expressed in the payment currency.

   

GrossPrice

Optional (double)

     

Total value per order line, including sales tax/VAT expressed in the payment currency. UnitGrossPrice does not reflect any discounts.

   

NetDiscountedPrice

Optional (double)

     

The NetPrice value per order line (in the payment currency), excluding sales tax/VAT, from which Avangate deducts discounts.

   

GrossDiscountedPrice

Optional (double)

     

Total costs shoppers incur per order line, expressed in the payment currency. This value includes sales tax/VAT, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.

 

Example:

  • UnitNetPrice: 99
  • UnitGrossPrice: 120.39
  • UnitVAT: 21.39
  • UnitDiscount: 9.9
  • UnitNetDiscountedPrice: 89.1
  • UnitGrossDiscountedPrice: 110.49
  • UnitAffiliateCommission: 22.28
  • Currency: "usd"
  • NetPrice: 198
  • GrossPrice: 240.77
  • NetDiscountedPrice: 178.2
  • GrossDiscountedPrice: 220.97
  • Discount: 19.8
  • VAT: 42.77
  • AffiliateCommission: 44.56
   

Discount

Optional (double)

     

Value of the discounts per order line expressed in the payment currency.

   

VAT

Optional (double)

     

Value of sales tax/VAT per order line expressed in the payment currency.

   

AffiliateCommission

Optional (double)

     

Value of the affiliate commission per order line, calculated from the NetDiscountedPrice expressed in the payment currency. Or NULL. Avangate does not take into account shipping costs when calculating affiliate commissions.

 

Quantity

Optional (integer)

   

Number of units

 

SKU

Optional (string)

   

SKU identifier.

  PurchaseType Optional (string)
   

Purchase type for orders placed with dynamic information. Possible values:

  • PRODUCT
  • TAX
  • COUPON
  • SHIPPING
  ExternalReference Optional (string)
    External order reference.
  SubscriptionStartDate Optional (string)
    Set subscription starting date. 
 

CrossSell

Optional (Object)

     

Details below. 

   

ParentCode

Optional (string)

     

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

   

CampaignCode

Optional (string)

     

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

 

Trial

Optional (Object)

     

Details below. 

   

Period

Optional (integer)

     

The length of the trial subscription lifetime in days.

   

GrossPrice

Optional (double)

     

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

   

VAT

Optional (double)

     

The total value of taxes for the trial in the payment currency, before Avangate deducts any discounts.

   

NetPrice

Optional (double)

     

Total trial price in the payment currency, not including taxes, before Avangate deducts any discounts.

 

AdditionalFields

Optional (array of objects)

     

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.

 

Promotion

Optional (object)

     

Details below. 

   

Name

Optional (string)

     

Promotion name.

   

Description

Optional (string)

     

Promotion description.

   

StartDate

Optional (string)

     

The date when you set the promotion to start. NULL for promotions that start immediately after you create them.

   

EndDate

Optional (string)

     

The date when you set the promotion to end. NULL for promotions you want active indefinitely.

   

MaximumOrdersNumber

Optional (integer)

     

Avangate only applies the promotion to a maximum number of orders you define.

 

Can be NULL if you want the promotion to apply to an unlimited number of orders.

   

MaximumQuantity

Optional (integer)

     

Discount only applies to a maximum number of units purchased through a single order, smaller than the quantity you defined. Shoppers purchase any extra units at full price. Can be NULL if you want the promotion to apply to an unlimited number units.

   

InstantDiscount

Optional (boolean)

     

The instant discount option auto-applies the discount for ALL selected products, without the need for shoppers to enter a discount coupon.

   

Coupon

Optional (string)

     

Promotion coupon/voucher.

   

DiscountLabel

Optional (string)

     

Discounts can be set as a percentage from the product price or as a fixed amount in the chosen currency.

   

Enabled

Optional (string)

     

true or false, depending on whether a promotion is active or disabled. 

   

Type

Optional (string)

     
  • REGULAR – product/cart line level discounts.
  • ORDER – quantity discounts.
  • GLOBAL – order-level discounts.

BillingDetails

Optional (Object)

   

Details below. 

 

FirstName

Optional (string)

   

Shopper name.

 

LastName

Optional (string)

   

Shopper surname.

 

CountryCode

Optional (string)

   

Shopper country. ISO 3166 two-letter code.

 

State

Optional (string) – Required for US, Brazil and Romania

   

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

 

City

Optional (string)

   

Shopper city.

 

Address1

Optional (string)

   

Shopper address.

 

Address2

Optional (string)

   

Shopper address.

 

Zip

Optional (string)

   

ZIP/ Postal code.

 

Email

Optional (string)

   

Shopper email address.

 

Phone

Optional (string)

   

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

 

Company

Optional (string)

   

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

 

FiscalCode

Optional (string) – Required for Brazil

   

• For companies, it needs to be the VAT ID. Avangate 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 the Billing Country is set to Brazil. For Brazilian customers it represents the Fiscal Code (CPF/CNPJ).

• Can be null for end users.

DeliveryDetails

Optional (Object)

Optional. When missing, Avangate uses the same details as for the BillingDetails object.

   

Details below. 

 

FirstName

Optional (string)

   

Shopper name from the delivery details.

 

LastName

Optional (string)

   

Shopper surname from the delivery details.

 

CountryCode

Optional (string)

   

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

 

State

Optional (string) – Required for US, Brazil and Romania

   

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

 

City

Optional (string)

   

Shopper city from the delivery details.

 

Address1

Optional (string)

   

Shopper address from the delivery details.

 

Address2

Optional (string)

   

Shopper address from the delivery details.

 

Zip

Optional (string)

   

ZIP/ Postal code from the delivery details.

 

Email

Optional (string)

   

Shopper email address from the delivery details.

 

Phone

Optional (string)

   

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

 

Company

Optional (string)

   

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

Promotions

Optional (Array of objects)

   

Details below. 

 

Name

Optional (string)

   

Promotion name.

 

Description

Optional (string)

   

Promotion description.

 

StartDate

Optional (string)

   

The date when you set the promotion to start. NULL for promotions that start immediately after you create them.

 

EndDate

Optional (string)

   

The date when you set the promotion to end. NULL for promotions you want active indefinitely.

 

MaximumOrdersNumber

Optional (integer)

   

Avangate only applies the promotion to a maximum number of orders you define.

 

Can be NULL if you want the promotion to apply to an unlimited number of orders.

 

MaximumQuantity

Optional (integer)

   

Discount only applies to a specific number of units purchased at once, smaller than the maximum quantity you defined. Shoppers purchase any extra units at full price. Can be NULL if you want the promotion to apply to an unlimited number units.

 

InstantDiscount

Optional (boolean)

   

The instant discount option auto-applies the discount for ALL selected products, without the need for shoppers to enter a discount coupon.

 

Coupon

Optional (string)

   

Promotion coupon/voucher.

 

DiscountLabel

Optional (string)

   

Discounts can be set as a percentage from the product price or as a fixed amount in the payment currency.

 

Enabled

Optional (string)

   

true or false, depending on whether a promotion is active or disabled. 

 

Type

Optional (string)

   
  • REGULAR – product/cart line level discounts.
  • ORDER – quantity discounts.
  • GLOBAL – order-level discounts.

AdditionalFields

Optional (array of objects)

   

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.

Currency

Optional (string)

 

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

NetPrice

Optional (double)

 

Order value excluding sales tax/VAT expressed in the payment currency.

GrossPrice

Optional (double)

 

Total order value, including sales tax/VAT expressed in the payment currency. GrossPrice does not reflect any discounts.

NetDiscountedPrice

Optional (double)

 

The NetPrice order value excluding sales tax/VAT, from which Avangate deducts discounts. NetDiscountedPrice is expressed in the payment currency.

GrossDiscountedPrice

Optional (double)

 

Total costs shoppers incur, expressed in the payment currency. This value includes sales tax/VAT, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.

 

For example:

  • Currency: "usd"
  • NetPrice: 396
  • GrossPrice: 486.29
  • NetDiscountedPrice: 376.2
  • GrossDiscountedPrice: 466.49
  • Discount: 19.8
  • VAT: 90.29
  • AffiliateCommission: 94.05

Discount

Optional (double)

 

Value of the discounts for an order expressed in the payment currency.

VAT

Optional (double)

 

Value of sales tax/VAT expressed in the payment currency.

AffiliateCommission

Optional (double)

 

Value of the affiliate commission for the order calculated from the NetDiscountedPrice expressed in the payment currency. Or NULL. Avangate does not take into account shipping costs when calculating affiliate commissions.

Single Sign On by customer reference

Overview

Use the getSingleSignOnByCustomer method to create Single Sign On links into Avangate myAccount based on customer references (IDs). Use either the Avangate Customer Reference or the External Customer Reference to identify specific customers.

Parameters

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.

idCustomer

Required (string)

 

Unique customer identifiers. Can be either the ExternalCustomerReference you control or the system-generated AvangateCustomerReference.

customerType

Required (string)

 

Possible values:

  • ExternalCustomerReference
  • AvangateCustomerReference

page

Optional (string)

 

The specific myAccount page where you redirect the customer.

Possible values:

my_subscription - redirect shoppers to the subscription's page of myAccount based on the SubscriptionReference you provide.

my_products - redirects shoppers to the myAccount page designed to list all products purchased from Avangate.

https://store.YourCustomDomain.com/m...t/my_products/?

user_data - redirects shoppers to the Personal Information page in myAccount

https://store.YourCustomDomain.com/m...unt/user_data/?

order_lookup - redirects shoppers to the Order Lookup area of myAccount:

https://store.YourCustomDomain.com/m.../order_lookup/

faq - redirects shoppers to the Support page of myAccount

https://secure. YourCustomDomain.com/support/

payment_methods – redirect shoppers to the Payment Methods area of myAccount:

https://store.YourCustomDomain.com/m...yment_methods/

Do not include PAGE in the URL to redirect shoppers to myAccount homepage

https://store.YourCustomDomain.com/myaccount/?

 

request

Optional (string)

 

Needed for 'my_subscription'

Request[]=code=123D40F123 redirects customers to the page for the subscription with the 123D40F123 SubscriptionReference value.

 

validityTime

Optional (int)

 

The time, in seconds, before the single sign-on URL expires. By default, the URL expires after 10 seconds. (optional)

validationIp

Optional (string)

 

The IP address of the shopper, necessary for security purposes. Can be an empty string or a valid IP, or null.

Response

Parameters Type/Description

Single sign-on URL

String

 

The string generated is the complete single sign-on URL pointing to Avangate myAccount, containing the unique URL. Shoppers using it log into their Avangate myAccount automatically.

Request

<?php

require ('PATH_TO_AUTH');

$idCustomer = '352365983';
$customerType = 'AvangateCustomerReference';
$page = 'my_license';
$request = null;
$validityTime = 50;
$validationIp = null;

$jsonRpcRequest = array (
'method' => 'getSingleSignOnByCustomer',
'params' => array($sessionID, $idCustomer, $customerType, $page, $request, $validityTime, $validationIp),
'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