Skip to main content

Tracking capabilities in ConvertPlus and InLine Shopping Carts

Overview

Read below to find out how to take advantage of the tracking capabilities in ConvertPlus and InLine shopping carts.

Adobe Analytics

Our merchants can now implement the Adobe Analytics tracking tools, to help track and monitor their ConvertPlus and InLine checkout orders and further improve the shopping experience and increase the conversion rate. More information can be found here.

Adobe Analytics

Google Analytics 4

In ConvertPlus and InLine shopping carts, you can implement Google Analytics 4 directly (without Google Tag Manager) simply by adding your Google Analytics Measurement ID in the section Google Analytics 4 in your Merchant Control Panel. This way you will receive cart eCommerce information directly in your Google Analytics 4 account. More information on the implementation can be found here

GA4 measurement ID

Google Universal Analytics 

Google Universal Analytics could be implemented in ConvertPlus and InLine shopping carts, by adding the Google Analytics Tracking ID in the section Google Universal Analytics in your Merchant Control Panel. However, this is a deprecated version of Google Analytics that will be sunset starting July 1st, 2023, for free Universal Analytics properties and starting July 1st, 2024, for 360 Universal Analytics properties. We strongly recommend you migrate to Google Analytics 4 as soon as possible. 

Google Tag Manager for Google Analytics 4

You can also implement Google Tag Manager (GTM) in both your ConvertPlus or InLine carts and further add multiple tracking scripts.

We are currently supporting 2 dataLayers versions for Google Tag Manager – one dataLayer on the Google Universal Analytics format - section Google Tag Manager (with UA) from Merchant Control Panel and one on the Google Analytics 4 format - section Google Tag Manager (with GA4) from Merchant Control Panel. Since Google Universal Analytics will be sunset starting July 1st, 2023, for free Universal Analytics properties and starting July 1st, 2024, for 360 Universal Analytics properties, we recommend you use the dataLayer on the Google Analytics 4 format, by adding your Google Tag Manager Container ID in the section Google Tag Manager (with GA4) in your Merchant Control Panel. 

Google tag manager container ID

Adding Google Analytics 4 through Google Tag Manager (GTM) using the Google Analytics 4 dataLayer format

To implement Google Analytics 4 through Google Tag Manager, add your Google Tag Manager Container ID in the section Google Tag Manager (with GA4) in your Merchant Control Panel and follow this step-by-step guide.

After implementation, you will be sending shopping cart eCommerce information to your Google Analytics 4 like: 

  • product data at checkout – when the shoppers open the cart with certain products 
  • product data when items are viewed in a list (for example cross-sell products)
  • product data at a remove from the cart – when a product is deleted from the cart 
  • product data at add to cart – when a product is added to the cart from a list of cross-sell products for example
  • product data at purchase – when a successful order is completed for a product (name, price, quantity, product coupon data)

You will also be sending purchase data to your Google Analytics 4 (transaction id, purchase value, tax, shipping). 

Other tracking capabilities through Google Tag Manager (GTM)

In addition to Google Analytics 4, you can also use Facebook Pixel, Google Ads, or any other desired tracking scripts through Google Tag Manager and send eCommerce information to those tools.

The Google Tag Manager script is placed in an iFrame with a data layer that includes extensive shopping cart information.

To see the information available in the data layer, follow these steps:

  1. Open the browser console.
  2. Select tracking.avangate.net from the top left corner of the console.
  3. Type dataLayer in the console, as in the image below.

Under the ecommerce object, you can find product, checkout, and purchase details about the cart. This information is then passed to Google Analytics 4.

The cartUpdated event also provides further information about the cart (country, currency, language, page name, whether the product is catalog or dynamic, whether the flow is for new acquisitions or manual renewals, whether the order is a test one or not).

dataLayer

Tracking limitations in ConvertPlus and InLine carts

To ensure high-level security, the Google Tag Manager script is placed in an iFrame and not directly in the shopping cart, and the tracking scripts you are adding will only be able to pull information that is available in the data layer of the iFrame. For this reason, tools used for generating heatmaps, click maps, or user recordings, like Hotjar, will not be able to capture any information from the shopping cart, as the shopping cart screen information is not available in the iFrame.

A/B testing tools like Optimizely or Visual Website Optimizer will not work either when their scripts are placed in the Google Tag Manager, as those scripts will run in an iFrame and not in the actual cart. 

Assign a PricingOption Group

Overview

Use the assignPricingConfigurationOptionGroup method to assign a PricingOption Group to a PricingConfiguration.

Parameters

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.

PricingConfigurationCode

Required (string)

 

Unique, system-generated pricing configuration identifier.  

PriceOptionsGroupAssigned

Required (Object)

 

Details below.

 

PriceOptionsGroupAssigned

Object

Code

Required (string)

 

PricingOption Group identifier.

Required

Required (Object)

 

True or false depending on whether the pricing options group is required during the purchase process or not.

Response

bool(true)

Request

<?php

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


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

$merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$now          = gmdate('Y-m-d H:i:s'); //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;
}
 
$PricingConfigurationCode = 'C4940279';
$PriceOptionsGroupAssigned = new stdClass();
$PriceOptionsGroupAssigned->Code = 'USERSUSERS';
$PriceOptionsGroupAssigned->Required = TRUE;
 
try {
    $AssignedOption = $client-> assignPricingConfigurationOptionGroup ($sessionID, $PricingConfigurationCode, $PriceOptionsGroupAssigned);
}

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

var_dump("Options", $AssignedOption);
 
 
 
?>

Subscription change deal

Overview

Use the changeDeal method to change the existing deal for a given subscription and operate the amendment order necessary to transition to the proposed deal immediately. The amendment order will use the due now prices returned by the getDealInfo method when called with the same relevant request parameters.

Request parameters

Parameter name Type Required/Optional Description

Currency

String

Required

The currency.

Country

String

Required

The country.

Language

String

Required

The language.

CustomerIp

String

Optional

The customer's IP address.

Items

Array

Required

Each item corresponds to a subscription.

 Items.DealDate

String

Required

The date when the deal is set to come into effect.

Items.SubscriptionReference

String

Required

The subscription code.

Items.ProductCode

String

Required

The product code.

Items.Quantity

String

Required

The product quantity.

Items.DealPriceScenario

String

Required

The upgrade scenario to be applied. Must be one of: using_last_order_price, using_last_product_price, price_total, product_price_difference.

Items.DealSubscriptionScenario

String

Required

The scenario for price calculation. Must be one of prolong, does_not_affect, disable_existing.

Items.PriceOptions

Array

optional

The array of price options.

Items.PriceOptions.Code

String

Required

The price options group code.

Items.PriceOptions.Options

Array

Required

The list of price option value (if the group is of type interval) or the price option code (otherwise).

Items.Price

Object

Required

The product price.

Items.Price.Amount

Float

Required

The actual numeric amount.

Items.Price.Type

String

Required

Describes if the price type is catalog or custom. Can be only CUSTOM.

Items.Price.AmountType

String

Required

Describes if the price is NET or GROSS. Can be on of NET, GROSS.

Items.SubscriptionCustomSettings

Object

Required

Product license custom settings.

Items.SubscriptionCustomSettings.CycleLength

Int

Required

The length of a single billing cycle.

Items.SubscriptionCustomSettings.CycleUnit

String

Required

The unit of a single billing cycle. Can be one of MONTH, DAY.

Items.SubscriptionCustomSettings.CycleAmount

Float

Required

The price of a single billing cycle.

Items.SubscriptionCustomSettings.CycleAmountType

String

Required

Describes the price type. Can be one of NET, GROSS.

Items.SubscriptionCustomSettings.ContractLength

Int

Required

The number of billing cycles contained in a single contract.

Items.SubscriptionCustomSettings.ClientDealAutoRenewal

Boolean

Optional

CDAR value (default false).

Items.SubscriptionCustomSettings.MerchantDealAutoRenewal

Boolean

Optional

MDAR value (default false).

BillingDetails

Object

required

The billing details.

BillingDetails.FirstName

String

Required

The first name.

BillingDetails.LastName

String

Required

The last name.

BillingDetails.CountryCode

String

Required

The country code. Must be one of the seller's associated country codes.

BillingDetails.State

String

Optional

Required only if the business model requires it.

BillingDetails.City

String

Required

The city name.

BillingDetails.Address1

String

Required

The address.

BillingDetails.Zip

String

Required

The zip code.

BillingDetails.Email

String

Required

The email address.

BillingDetails.Phone

String

Required

The phone number.

BillingDetails.Company

String

Required

The company's legal name.

BillingDetails.FiscalCode

String

Required

The fiscal code.

DeliveryDetails

Object

Required

The delivery details.

DeliveryDetails.FirstName

String

Required

The first name.

DeliveryDetails.LastName

String

Required

The last name.

DeliveryDetails.CountryCode

String

Required

The country code. Must be one of the seller's associated country codes.

DeliveryDetails.State

String

Optional

Required only if the business model requires it.

DeliveryDetails.City

String

Required

The city name.

DeliveryDetails.Address1

String

Required

The address.

DeliveryDetails.Zip

String

Required

The zip code.

DeliveryDetails.Email

String

Required

The email address.

DeliveryDetails.Phone

String

Required

The phone number.

DeliveryDetails.Company

String

Required

The company's legal name.

PaymentDetails

Object

Optional

The payment details.

PaymentDetails.Type

String

Required

Payment type. Can be CC (credit card) or EES_TOKEN_PAYMENT (2payJs token).

PaymentDetails.Currency

String

Required

Payment currency code.

PaymentDetails. CustomerIP

String

Required

Payment customer IP.

PaymentDetails.PaymentMethod

Object

Required

The payment method information.

PaymentDetails.PaymentMethod.EesToken

String

Optional

EES token (required when payment type is EES_TOKEN_PAYMENT).

PaymentDetails.PaymentMethod.CardNumber

Int

Optional

CC number (required when payment type is CC).

PaymentDetails.PaymentMethod.CardType

String

Optional

CC type (ex: VISA, MC; required when payment type is CC).

PaymentDetails.PaymentMethod.ExpirationYear

Int

Optional

4 digits CC expiration year (required when payment type is CC).

PaymentDetails.PaymentMethod.ExpirationMonth

Int

Optional

CC expiration month (required when payment type is CC).

PaymentDetails.PaymentMethod.CCID

String

Optional

CC CVV value (required when payment type is CC).

PaymentDetails.PaymentMethod.HolderName

String

Optional

CC holder name.

PaymentDetails.PaymentMethod.Vendor3DSReturnURL

String

Required

Merchant 3DS return URL.

PaymentDetails.PaymentMethod.Vendor3DSCancelURL

String

Required

Merchant 3DS cancel URL.

PaymentDetails.PaymentMethod.RecurringEnabled

Boolean

Optional

Flag to enable recurring on the new license when set true.

ExtraInformation

Object

Optional

Order extra information.

ExtraInformation.ProposalId

String

Optional

Related proposal object ID.

ExtraInformation.PurchaseOrderDownloadLink

String

Optional

PO Download link.

ExtraInformation.AMEmailB2B

String

Optional

AM email for B2B.

ExtraInformation.RetryFailedPaymentLink

String

Optional

Retry failed payment link.

Request example

<?php
declare(strict_types=1);
class Configuration
{
    public const MERCHANT_CODE = '1234554321';
    public const MERCHANT_KEY = 'D+~=z5R+R4])4D5&p56%';
    public const URL = 'http://api.avangate.local/rpc/6.0';
    public const ACTION = 'getDealInfo';
    //array or JSON
    public const PAYLOAD = <<<JSON
{
    "Currency": "usd",
    "Country": "us",
    "Language": "en",
    "CustomerIp": "91.220.121.21",
    "Source": "salesforce_cpq",
    "Items": [
        {
            "DealDate": "2021-03-18 13:36:47",
            "SubscriptionReference": "GUC9PFSIH8",
            "ProductCode": "PAV2019",
            "Quantity": 1,
            "DealPriceScenario": "using_last_order_price",
            "DealSubscriptionScenario": "prolong",
            "Price": {
                "Amount": 50,
                "Type": "CUSTOM",
                "AmountType": "GROSS"
            },
            "PriceOptions": [
                {
                    "Code": "interval_scale_grp1",
                    "Options": [
                        "25"
                    ]
                },
                {
                    "Code": "OPTGRP1",
                    "Options": [
                        "OptGrp1Code1"
                    ]
                }
            ],
            "SubscriptionCustomSettings": {
                "CycleLength": 1,
                "CycleUnit": "MONTH",
                "CycleAmount": 50,
                "CycleAmountType": "GROSS",
                "ContractLength": 12,
                "ClientDealAutoRenewal": true,
                "MerchantDealAutoRenewal": true
            }
        }
    ],
    "BillingDetails": {
        "FirstName": "Donald",
        "LastName": "Wilson",
        "CountryCode": "us",
        "State": "Texas",
        "City": "Dallas",
        "Address1": "4519 BlueBridge Road",
        "Zip": "02199",
        "Email": "dwilson@test.com",
        "Phone": "6172938133",
        "Company": "Integra Wealth",
        "FiscalCode": "85421564"
    },
    "DeliveryDetails": {
        "FirstName": "Gerard",
        "LastName": "Butler",
        "CountryCode": "us",
        "State": "Texas",
        "City": "Austin",
        "Address1": "2033 Nuzum Court",
        "Zip": "14216",
        "Email": "gerard.butler@integrawealth.net",
        "Phone": "7165708136",
        "Company": "Integra Wealth"
    },
    "PaymentDetails": {
        "Type": "EES_TOKEN_PAYMENT",
        "Currency": "usd",
        "CustomerIP": "91.220.121.21",
        "PaymentMethod": {
            "EesToken": "7886eebb-0aa0-482c-8636-28394e2b714d",
            "RecurringEnabled": true
        }
    },

    "ExtraInformation": {
       "ProposalId": "1de36a0a-a7b6-4cb7-9de5-34c802e4243b",
       "PurchaseOrderDownloadLink": "http://secure.avangate.local/proposal/po/342322/dl",
       "AMEmailB2B": "test@email.org",
       "RetryFailedPaymentLink": "http://secure.avangate.local/proposal/po/342322/retry?ref=[REFNO]"
    }
}
JSON;
}
class Client
{
    private const LOGIN_METHOD = 'login';
    private $calls = 1;
    private $sessionId;
    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $hash = hash_hmac('md5', $string, $key);
        return compact('merchantCode', 'date', 'hash');
    }
    public function login(string $url)
    {
        $payload = $this->generateAuth();
        $response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
        $this->sessionId = $response['result'];
    }
    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?array {
        if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
            $this->login($url);
        }
        if(is_string($payload)) {
            $payload = json_decode($payload, true);
        }
        if (!empty($this->sessionId)) {
            $payload = [$this->sessionId, $payload];
        }
        $payload = array_filter($payload);
        $request = json_encode([
            'jsonrpc' => '2.0',
            'method' => $action,
            'params' => $payload,
            'id' => $this->calls++,
        ]);
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSLVERSION, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if(empty($response)) {
            die('Server unavailable');
        }
        echo $response . '</br>';
        return json_decode($response, true);;
    }
}
$client = new Client();
$result = $client->call();
var_dump($result);

Response

The changeDeal method has (almost) the same response parameters as the getDealInfo method, plus the deal order details returned under the DealOrder key. These order details have the same structure as any placeOrder  API method response (see here).

[
    {
        "SubscriptionReference": "GUC9PFSIH8",
        "DealPriceScenario": "using_last_order_price",
        "DealSubscriptionScenario": "prolong",
        "DealDate": "2021-03-18 13:36:47",
        "DealDueNowPriceNet": 47.06,
        "DealDueNowPriceGross": 50,
        "DealTaxAmount": 2.94,
        "DealTaxPercent": 6.25,
        "CurrentInfo": {
            "ProductCode": "BKG20193",
            "ProductName": "Backgammon 2019.3",
            "ProductDescription": "",
            "BillingPriceNet": 45,
            "UnitBillingPriceNet": 45,
            "BillingPriceGross": 47.81,
            "UnitBillingPriceGross": 47.81,
            "NoOfBillingCycles": 13,
            "CurrentBillingCycle": 1,
            "PayedBillingCycles": 1,
            "RemainingBillingCycles": 11,
            "CurrentBillingCycleEndDate": "2021-03-15 11:35:02",
            "ClientDealAutoRenewal": false,
            "MerchantDealAutoRenewal": false,
            "Quantity": 1,
            "CurrencyCode": "usd",
            "TaxAmount": 2.81,
            "TaxPercent": 6.25,
            "BillingCyclesFrequency": 1,
            "BillingCycleFrequencyUnit": "MONTH",
            "ContractLength": 12,
            "ContractLengthUnit": "MONTH",
            "ProductOptions": []
        },
        "NewDealInfo": {
            "ProductCode": "PAV2019",
            "ProductName": "Pipera AntiVirus 2019",
            "ProductDescription": "",
            "BillingPriceNet": 47.06,
            "BillingPriceGross": 50,
            "NoOfBillingCycles": 12,
            "CurrentBillingCycle": 1,
            "PayedBillingCycles": 0,
            "RemainingBillingCycles": 12,
            "CurrentBillingCycleEndDate": "2021-04-18 13:36:47",
            "TaxAmount": 2.94,
            "TaxPercent": 6.25,
            "CurrencyCode": "usd",
            "BillingCyclesFrequency": 1,
            "BillingCycleFrequencyUnit": "MONTH",
            "ContractLength": 12,
            "ContractLengthUnit": "MONTH",
            "ProductOptions": [
                {
                    "Code": "interval_scale_grp1",
                    "Options": [
                        "25"
                    ]
                },
                {
                    "Code": "OPTGRP1",
                    "Options": [
                        "OptGrp1Code1"
                    ]
                }
            ]
        },
        "TotalsDealInfo": {
            "DealsNumber": 0,
            "ContractsNumber": 1,
            "PaidBillingCycles": 1,
            "ElapsedBillingCycles": 1
        },
        "DealOrder": {
            "RefNo": "11591805",
            "OrderNo": 0,
            "ExternalReference": null,
            "ShopperRefNo": null,
            "Status": "AUTHRECEIVED",
            "ApproveStatus": "WAITING",
            "VendorApproveStatus": "OK",
            "MerchantCode": "120000589445",
            "Language": "en",
            "OrderDate": "2021-02-15 13:39:29",
            "FinishDate": null,
            "Source": null,
            "Affiliate": {
                "AffiliateCode": null,
                "AffiliateSource": null,
                "AffiliateName": null,
                "AffiliateUrl": null
            },
            "HasShipping": true,
            "BillingDetails": {
                "FiscalCode": "85421564",
                "TaxOffice": null,
                "Phone": "6172938133",
                "FirstName": "Donald",
                "LastName": "Wilson",
                "Company": "Integra Wealth",
                "Email": "dwilson@test.com",
                "Address1": "4519 BlueBridge Road",
                "Address2": null,
                "City": "Dallas",
                "Zip": "02199",
                "CountryCode": "us",
                "State": "Texas"
            },
            "DeliveryDetails": {
                "Phone": "7165708136",
                "FirstName": "Gerard",
                "LastName": "Butler",
                "Company": "Integra Wealth",
                "Email": "gerard.butler@integrawealth.net",
                "Address1": "2033 Nuzum Court",
                "Address2": null,
                "City": "Austin",
                "Zip": "14216",
                "CountryCode": "us",
                "State": "Texas"
            },
            "PaymentDetails": {
                "Type": "CC",
                "Currency": "usd",
                "PaymentMethod": {
                    "FirstDigits": "4111",
                    "LastDigits": "1111",
                    "CardType": "visa",
                    "RecurringEnabled": true,
                    "Vendor3DSReturnURL": null,
                    "Vendor3DSCancelURL": null,
                    "InstallmentsNumber": null
                },
                "CustomerIP": "91.220.121.21"
            },
            "DeliveryInformation": {
                "ShippingMethod": {
                    "Code": null,
                    "TrackingUrl": null,
                    "TrackingNumber": null,
                    "Comment": null
                }
            },
            "CustomerDetails": null,
            "Origin": "API",
            "AvangateCommission": 4.4,
            "OrderFlow": "REGULAR",
            "GiftDetails": null,
            "PODetails": null,
            "ExtraInformation": {
                "RetryFailedPaymentLink": "http:\/\/secure.avangate.local\/proposal\/po\/342322\/retry?ref=11591805",
                "ProposalId": "1de36a0a-a7b6-4cb7-9de5-34c802e4243b",
                "PurchaseOrderDownloadLink": "http:\/\/secure.avangate.local\/proposal\/po\/342322\/dl",
                "B2B": true,
                "AMEmailB2B": "test@email.org"
            },
            "PartnerCode": null,
            "PartnerMargin": null,
            "PartnerMarginPercent": null,
            "ExtraMargin": null,
            "ExtraMarginPercent": null,
            "ExtraDiscount": null,
            "ExtraDiscountPercent": null,
            "LocalTime": null,
            "TestOrder": false,
            "FxRate": 0.76357124584292,
            "FxMarkup": 10.456,
            "PayoutCurrency": "EUR",
            "DeliveryFinalized": false,
            "Errors": null,
            "Items": [
                {
                    "ProductDetails": {
                        "Name": "Pipera AntiVirus 2019",
                        "ShortDescription": "",
                        "Tangible": false,
                        "IsDynamic": false,
                        "ExtraInfo": null,
                        "RenewalStatus": false,
                        "Subscriptions": null,
                        "DeliveryInformation": {
                            "Delivery": "NO_DELIVERY",
                            "DownloadFile": null,
                            "DeliveryDescription": "",
                            "CodesDescription": "",
                            "Codes": []
                        }
                    },
                    "PriceOptions": [
                        {
                            "Code": "OPTGRP1",
                            "Name": "OptGrp1",
                            "Required": false,
                            "Options": [
                                {
                                    "Name": "2 users",
                                    "Value": "OptGrp1Code1",
                                    "Surcharge": "5.00"
                                }
                            ]
                        },
                        {
                            "Code": "interval_scale_grp1",
                            "Name": "Interval scale group1",
                            "Required": false,
                            "Options": [
                                {
                                    "Name": "Interval scale group1: 25",
                                    "Value": "interval_scale_grp1=25",
                                    "Surcharge": "125.00"
                                }
                            ]
                        }
                    ],
                    "Price": {
                        "UnitNetPrice": 47.06,
                        "UnitGrossPrice": 50,
                        "UnitVAT": 2.94,
                        "UnitDiscount": 0,
                        "UnitNetDiscountedPrice": 47.06,
                        "UnitGrossDiscountedPrice": 50,
                        "UnitAffiliateCommission": 0,
                        "ItemUnitNetPrice": null,
                        "ItemUnitGrossPrice": null,
                        "ItemNetPrice": null,
                        "ItemGrossPrice": null,
                        "VATPercent": 6.25,
                        "HandlingFeeNetPrice": 0,
                        "HandlingFeeGrossPrice": 0,
                        "Currency": "usd",
                        "NetPrice": 47.06,
                        "GrossPrice": 50,
                        "NetDiscountedPrice": 47.06,
                        "GrossDiscountedPrice": 50,
                        "Discount": 0,
                        "VAT": 2.94,
                        "AffiliateCommission": 0
                    },
                    "LineItemReference": "f703af791bca619bbd42cc6964192456dc243f27",
                    "PurchaseType": "PRODUCT",
                    "Code": "PAV2019",
                    "ExternalReference": "PAV2019QWE",
                    "Quantity": 1,
                    "SKU": null,
                    "CrossSell": null,
                    "Trial": null,
                    "AdditionalFields": null,
                    "Promotion": null,
                    "RecurringOptions": null,
                    "SubscriptionStartDate": null,
                    "SubscriptionCustomSettings": {
                        "CycleUnit": "MONTH",
                        "CycleLength": 1,
                        "CycleAmount": 50,
                        "CycleAmountType": "GROSS",
                        "ContractLength": 12,
                        "MerchantDealAutoRenewal": true,
                        "ClientDealAutoRenewal": true
                    }
                }
            ],
            "Promotions": [],
            "AdditionalFields": null,
            "CustomParameters": null,
            "Currency": "usd",
            "NetPrice": 47.06,
            "GrossPrice": 50,
            "NetDiscountedPrice": 47.06,
            "GrossDiscountedPrice": 50,
            "Discount": 0,
            "VAT": 2.94,
            "AffiliateCommission": 0
        }
    }
]

Error handling

Whenever there is a validation error, this will trigger an error response is returned, like below:

{
    "error_code": "INVALID_EES_TOKEN",
    "message": "The token is not valid. In order to proceed with the place order a valid token is required"
}

In this case, the deal order is not created, and you must correct the request parameters, as indicated, and retry the API call.

Most of the validation errors are common with the ones listed for the getDealInfo method (see the Errors handling).

Whenever there is a payment level error encountered, the amendment order is still created, and the payment processing error will be returned in the DealOrder.Errors element, in the usual format used by the placeOrder response as well, for example: 

[
    {
        "SubscriptionReference": "GUC9PFSIH8",
        ……
        "DealOrder": {
            "RefNo": "11662596",
            ……
            "Errors": {
                  "ORDER_PAYMENT_METHOD_CARD_PROCESS_ERROR": "Couldn't complete the payment validation process: Error processing the credit card transaction. Please contact the issuer bank for more details, or enter another card."
            }
        }
    }
]

You can check the list of possible order-level errors on this page

Disable a subscription

Overview

Use the cancelSubscription method to disable an active subscription. 2Checkout disables the subscription immediately and no longer performs any recurring billing actions.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

SubscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

ChurnReasons Array
 

Possible values for this field are:

CHURN_REASON_NOT_SATISFIED_PRODUCT

CHURN_REASON_ENABLED_BY_MISTAKE

CHURN_REASON_PREFER_MANUAL

CHURN_REASON_ALREADY_RENEWED

CHURN_REASON_DONT_NEED

CHURN_REASON_WANT_PAUSE

CHURN_REASON_COVID

CHURN_REASON_HIGH_PRICE

CHURN_REASON_NOT_SATISFIED_SUPPORT

CHURN_REASON_EXTRAORDINARY

CHURN_REASON_OTHER

ChurnReasonOther String
  This field should have a value only if the ChurnReasons has the CHURN_REASON_EXTRAORDINARY or CHURN_REASON_OTHER values

Response

Parameters Type/Description

Boolean

true or false depending on whether the call resulted in success or not.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

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

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

Shipping fees

Overview

Use this object via JSON-RPC API 3.0 to retrieve information about shipping fees. 

Parameters

Parameter Type/Description

ShippingFee

Array of objects

Name

String

 

The name of the shipping fee configuration. 

Code String
  Unique, system-generated shipping fee identifier. 

Amount

String

 

The shipping costs

Currency

String

 

The currency ISO code used for shipping costs - ISO 4217.

ApplyTo

String

 

Possible values:

• PRODUCT

• ORDER

Type

String

 

 

Possible values:

• FIXED

• PERCENT

 

 

 

Update pricing configuration

Overview

Use the updatePricingConfiguration method to update/edit an existing pricing configuration.

Parameters

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.

PricingConfiguration

Required (object)

 

Use this object to update/edit an existing pricing configuration for your account.

ProductCode

Required (string)

 

The unique product code that you control not the system-generated product identifier.

You cannot modify:

  • The pricing configuration CODE.
  • The PricingSchema from DYNAMIC to FLAT or vice versa.
  • The intervals of an existing pricing configuration (MinQuantity and MaxQuantity).

Response

bool(true)

Request

<?php

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


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

$merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$now          = gmdate('Y-m-d H:i:s'); //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;
}
$PricingConfiguration                                                 = new stdClass();
$PricingConfiguration->Default                                        = FALSE;
$PricingConfiguration->Name                                           = 'lnxbc2hls0';
$PricingConfiguration->BillingCountries                               = array();
$PricingConfiguration->BillingCountries[0]                            = 'UK';
$PricingConfiguration->BillingCountries[1]                            = 'DE';
$PricingConfiguration->PricingSchema                                  = 'DYNAMIC';
$PricingConfiguration->PriceType                                      = 'NET';
$PricingConfiguration->DefaultCurrency                                = 'EUR';
$PricingConfiguration->Prices                                         = new stdClass();
$PricingConfiguration->Prices->Regular                                = array();
$PricingConfiguration->Prices->Regular[0]                             = new stdClass();
$PricingConfiguration->Prices->Regular[0]->Amount                     = 69.09;
$PricingConfiguration->Prices->Regular[0]->Currency                   = 'USD';
$PricingConfiguration->Prices->Regular[0]->MinQuantity                = 1;
$PricingConfiguration->Prices->Regular[0]->MaxQuantity                = 35;
$PricingConfiguration->Prices->Regular[0]->OptionCodes                = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Code       = 'G77ICHEM1C';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[0] = 'zh5onfolw7';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[1] = '75rjldfcnz';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Code       = 'BAWAQB8LZP';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[0] = 'r3oi06opvi';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[1] = '76gqbq4bhd';
$PricingConfiguration->Prices->Regular[1]                             = new stdClass();
$PricingConfiguration->Prices->Regular[1]->Amount                     = 64.66;
$PricingConfiguration->Prices->Regular[1]->Currency                   = 'USD';
$PricingConfiguration->Prices->Regular[1]->MinQuantity                = 36;
$PricingConfiguration->Prices->Regular[1]->MaxQuantity                = 83;
$PricingConfiguration->Prices->Regular[1]->OptionCodes                = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Code       = '8RNXV3T3RE';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[0] = 'rorqkqnd9p';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[1] = 'aeu89gqdg6';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Code       = 'DJYD713MKC';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[0] = 'y2z2squ7c1';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[1] = 'g74qfskbjg';
$PricingConfiguration->Prices->Renewal                                = array();
$PricingConfiguration->Prices->Renewal[0]                             = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->Amount                     = 7.89;
$PricingConfiguration->Prices->Renewal[0]->Currency                   = 'USD';
$PricingConfiguration->Prices->Renewal[0]->MinQuantity                = 84;
$PricingConfiguration->Prices->Renewal[0]->MaxQuantity                = 100;
$PricingConfiguration->Prices->Renewal[0]->OptionCodes                = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Code       = '73QCSXYH0E';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[0] = '54xu7mngqm';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[1] = 'p6m8im2unl';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Code       = '0QD0CF0OIE';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[0] = 'ytbac9wpmh';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[1] = 'lpkxxqsqxb';
$PricingConfiguration->Prices->Renewal[1]                             = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->Amount                     = 76.99;
$PricingConfiguration->Prices->Renewal[1]->Currency                   = 'USD';
$PricingConfiguration->Prices->Renewal[1]->MinQuantity                = 101;
$PricingConfiguration->Prices->Renewal[1]->MaxQuantity                = 544;
$PricingConfiguration->Prices->Renewal[1]->OptionCodes                = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Code       = '03APF0H4QF';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[0] = '15ce5uw2j6';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[1] = 'e88d5hk0tb';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Code       = 'PT00TYI2VY';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[0] = '10c24smlbl';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[1] = '0ondbwdk3q';
$PricingConfiguration->PriceOptions                                   = array();
$PricingConfiguration->PriceOptions[0]                                = new stdClass();
$PricingConfiguration->PriceOptions[0]->Code                          = 'FKQ8CFLYKM';
$PricingConfiguration->PriceOptions[0]->Required                      = false;
$PricingConfiguration->PriceOptions[1]                                = new stdClass();
$PricingConfiguration->PriceOptions[1]->Code                          = 'TH1HKFOTFR';
$PricingConfiguration->PriceOptions[1]->Required                      = true;

$ProductCode = '4643199';

try {
    $UpdatedPricingConfiguration = $client->updatePricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
}

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

var_dump("UpdatedPricingConfiguration", $UpdatedPricingConfiguration);


?>

Set pricing option for dynamic products

Overview

Use the Product object option property in order to define pricing options for dynamic products.

Use case

  1. Add an HTML link or button in your page like the one below.
  2. Create a JavaScript click handler to execute the Inline Client desired methods.
  3. Set the dynamic mode for cart by callingTwoCoInlineCart.setup.setMode('DYNAMIC').
  4. Set your currency using theTwoCoInlineCart.cart.setCurrency('USD')method.
  5. Use theTwoCoInlineCart.products.add({name, quantity, price, options})method to prepare your dynamic products.
  6. The options property should contain a list of objects with the name of the field, it's value and surcharge.
  7. You can see below a signature token request payload for this example. A success response contains a JSON with the property  “signature“ which needs to be used at the next step to set the signature using the TwoCoInlineCart method.
{
    "merchant": "2COLRNC",
    "dynamic": "1",
    "currency": "USD",
    "products": [
        {
            "name": "A test dynamic product",
            "quantity": 1,
            "price": 20,
            "options": [
                {
                    "name": "color",
                    "value": "red",
                    "surcharge": 10
                },
                {
                    "name": "shape",
                    "value": "squared",
                    "surcharge": 20
                }
            ]
        }
    ]
}

The above payload will generate the signature 50a651873d3d8926f6bb62397f34b1ec7dd3373fc885b28466db8f4022060138.

8. Use the TwoCoInlineCart.cart.setSignature('50a651873d3d8926f6bb62397f34b1ec7dd3373fc885b28466db8f4022060138') method to set the signature. It is important that you employ TwoCoInlineCart.cart.removeAll() just before the TwoCoInlineCart.products.addMany(products) or TwoCoInlineCart.products.add(product) methods to remove previous products as the signature is based on the products' definition.

9. Use theTwoCoInlineCart.cart.checkout()method to show the cart on your page.

Sample request

HTML

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

JavaScript

window.document.getElementById('buy-button').addEventListener('click', function() {
  TwoCoInlineCart.setup.setMode('DYNAMIC');
  TwoCoInlineCart.cart.setCurrency('USD');
  
  TwoCoInlineCart.products.add({
    name: 'A test dynamic product',
    quantity: 1,
    price: 20,
    options: [
      {
        name     : 'color',
        value    : 'red',
        surcharge: 10
      },
      {
        name     : 'shape',
        value    : 'squared',
        surcharge: 20
      }
    ],
  });
  
  TwoCoInlineCart.cart.setSignature('50a651873d3d8926f6bb62397f34b1ec7dd3373fc885b28466db8f4022060138');
  TwoCoInlineCart.cart.checkout();
});

Demo

After setting the pricing options for dynamic products using the above method, your cart should look like this:

 

Search subscriptions

Overview

Extract information on your account’s subscriptions. Use the searchSubscriptions method to retrieve details about your account’s subscriptions, based on a set of filters. Subscriptions can be retrieved starting with 5 minutes after their orders are generated in the 2Checkout system.

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.

searchBy

Optional (Object)

 

Unique, system-generated subscription identifier.

Additional search filters

SubscriptionSearchOptions Parameters Type/Description

CustomerEmail

Optional (string)

 

Customer email address. Can be NULL.

Note:  The CustomerEmail parameter must be paired always with another reference pointing to the correct customer, such as the 2CheckoutCustomerReference parameter or the ExternalCustomerReference parameter. Otherwise, the search call will return partial hits on the customer email address.

ExactMatchEmail Optional (Boolean)
 

Force search by email to perform exact match; recommended to keep this option set to true in order to avoid matching similar email addresses from multiple customers.

DeliveredCode

Optional (string)

 

Activation key/code. Can be NULL.

2CheckoutCustomerReference

Optional (int)

 

System-generated customer reference. Can be NULL.

ExternalCustomerReference

Optional (string)

 

External customer reference that you control. Can be NULL.

Aggregate

Optional (boolean)

 

true - search will work across all your aggregated 2Checkout accounts.

false - default value. You limit the search to the account whose details you used for authentication.

Can be NULL.

SubscriptionEnabled

Optional (boolean)

 

true for enabled subscriptions.

false for disabled subscriptions.

Can be NULL.

RecurringEnabled

Optional (StringArray)

 

true – 2Checkout charges customers using recurring billing for subscriptions.

false – customers need to make manual payments to renew their subscriptions.

Can be NULL.

ProductCodes

Optional (StringArray)

 

Product identifier that you control. Can be NULL.

CountryCodes

Optional (string)

 

Country code (ISO 3166 two-letter code). Can be NULL.

PartnerCode Optional (string)
  Can be NULL.

PurchasedAfter

Optional (string)

 

YYYY-MM-DD. Subscription search interval start. You can search for subscriptions purchased between the dates you set using PurchasedAfter and PurchasedBefore. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

PurchasedBefore

Optional (string)

 

YYYY-MM-DD. Subscription search interval end. You can search for subscriptions purchased between the dates you set using PurchasedAfter and PurchasedBefore. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

ExpireAfter

Optional (string)

 

YYYY-MM-DD. Search subscriptions set to expire after a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

ExpireBefore

Optional (string)

 

YYYY-MM-DD. Search subscriptions set to expire before a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

ModifiedAfter Optional (string)
  YYYY-MM-DD HH-MM-SS. Search subscriptions modified after a specific date.
ModifiedBefore Optional (string)
  YYYY-MM-DD HH-MM-SS. Search subscriptions modified before a specific date.

RenewedAfter

Optional (string)

 

YYYY-MM-DD. Search subscriptions renewed after a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

RenewedBefore

Optional (string)

 

YYYY-MM-DD. Search subscriptions renewed before a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

NotificationAfter

Optional (string)

 

YYYY-MM-DD. Search subscriptions for which the 2Checkout system sent out notifications after a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

NotificationBefore

Optional (string)

 

YYYY-MM-DD. Search subscriptions for which the 2Checkout system sent out notifications before a specific date Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

NextBillingDateAfter Optional (string)
  YYYY-MM-DD. Search subscriptions with the next billing date after the specified date
NextBillingDateBefore Optional (string)
  YYYY-MM-DD. Search subscriptions with the next billing date before the specified date

Type

Optional (string)

 

trial - trial subscriptions.

regular - all generated subscriptions that are not trials.

regularfromtrial - subscriptions generated from a trial conversion.

Can be NULL.

TestSubscription

Optional (boolean)

 

true

false, depending on whether you want to include test subscriptions in the search or not. Can be NULL.

LifetimeSubscription

Optional (boolean)

 

true – evergreen subscriptions.

false - subscriptions with a limited recurring billing cycle, typically no larger than 36 months.

Can be NULL.

Page

Optional (int)

 

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

Can be NULL.

Limit

Optional (int)

 

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

Can be NULL.

Response

Parameters Type/Description

Subscription

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$SubscriptionSearch = new stdClass();
$SubscriptionSearch->CustomerEmail  = 'example@email.com';
$SubscriptionSearch->DeliveredCode = null;
$SubscriptionSearch->AvangateCustomerReference = null;
$SubscriptionSearch->ExternalCustomerReference = null;
$SubscriptionSearch->Aggregate = false;
$SubscriptionSearch->SubscriptionEnabled = null; //true false null
$SubscriptionSearch->RecurringEnabled = null; // true - autorenewal, false - manual renewal, null = both(default)
$SubscriptionSearch->ProductCodes = null; //array('Product_Code1', 'Product_Code2');
$SubscriptionSearch->CountryCodes = null;//array ('au')
$SubscriptionSearch->PurchasedAfter = null;
$SubscriptionSearch->PurchasedBefore = null;
$SubscriptionSearch->ExpireAfter = null;
$SubscriptionSearch->ExpireBefore = null;
$SubscriptionSearch->LifetimeSubscription = null;
$SubscriptionSearch->Type = 'regular'; //'trial', 'regular', 'regularfromtrial'
$SubscriptionSearch->TestSubscription = null; // true, false, null = both(default) $SubscriptionSearch->Page = 1;$SubscriptionSearch->Limit = 25;
$SubscriptionSearch->Page = 1;
$SubscriptionSearch->Limit = 10;

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

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

Renew a subscription

Overview

Renew a subscription in the Avangate system on-demand, controlling the number of days, price and currency of the extension. Use the renewSubscription method renew a subscription.

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.

SubscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

 

Avangate charges customers using the payment data attached to subscriptions. In the case of credit/debit cards, if customers update their payment information in myAccount or if you update these details on behalf of your subscribers, the Avangate system uses the latest card info provided to charge subscription renewals.

Days

Optional (int)

 

The number of days the Avangate system extends the lifetime of the subscription.

Price

Optional (double)

 

The price that Avangate charges the customer for the renewal. This is the Net price.

Currency

Optional (string)

 

The currency associated to the renewal price - ISO 4217 code.

Response

Boolean

true or false depending on whether or not the operation succeeded.


Retrieve options

Overview

Use the getProductUpgradeOptions method to retrieve the possible upgrade options for a subscription.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

subscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

Response

Parameters Type/Description

Subscription upgrade

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

$jsonRpcRequest = array (
'method' => 'getProductUpgradeOptions',
'params' => array($sessionID, $subscriptionReference),
'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