Skip to main content

Disable recurring billing

Overview

Use the disableRecurringBilling method to disable recurring billing for a subscription. When you disable recurring billing, the subscription status doesn’t change. Users continue to use subscriptions with recurring billing disabled until they expire, and Avangate provides them with the option to renew their subscription through manual payments.

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.

Response

Boolean

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

Request


<?php
 
 
function callRPC($Request, $hostUrl, $Debug = true) {
    $curl = curl_init($hostUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
 
 
    if ($Debug) {
        $RequestString;
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        $ResponseString;
    }
 
    if (!empty($ResponseString)) {
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}
 
$host = 'https://api.avangate.com/rpc/3.0/';
 
$merchantCode = "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; // counter for api calls
// call login
$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);
 
var_dump($sessionID);
$SubscriptionReferenceTest = '48F5AC7011';
$jsonRpcRequest = array (
'method' => 'disableRecurringBilling',
'params' => array($sessionID, $SubscriptionReferenceTest),
'id' => $i++,
'jsonrpc' => '2.0');

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

Add pricing configuration

Overview

Use the addPricingConfiguration method to add a new pricing configuration for your account.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

PricingConfiguration

Required (object)

 

Use this object to add a new pricing configuration for your account.

ProductCode

Required (string)

 

The code of the produt you assign the configuration to.

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$PricingConfiguration = new stdClass();
$PricingConfiguration->Default = True;
$PricingConfiguration->Name = 'New Pricing Configuration Through API';
$PricingConfiguration->BillingCountries = array();
$PricingConfiguration->BillingCountries[0] = 'RO';
$PricingConfiguration->BillingCountries[1] = 'DE';
$PricingConfiguration->PricingSchema = 'DYNAMIC';
$PricingConfiguration->PriceType = 'NET';
$PricingConfiguration->DefaultCurrency = 'USD';
$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= 'API_Imported_123456';

try {
    $NewPricingConfiguration = $client->addPricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
}

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

var_dump("NewPricingConfiguration", $NewPricingConfiguration);

?>

 

Retrieve assigned additional fields

Overview

Use the getAssignedAdditionalFields method to extract information about the additional fields assigned to a specific product.

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.

ProductCode

Required (string)

 

The editable code that you control at product-level, not the unique, system-generated product ID.

Response

AdditionalField

Array of objects

Request

<?php

$host   = "https://api.avangate.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 = "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;
}

$ProductCode = 'AAAA4643116';

try {
    $AssignedAdditionalField = $client->getAssignedAdditionalFields($sessionID, $ProductCode);
}

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

var_dump("AssignedAdditionalField", $AssignedAdditionalField);


?>

Add order/product additional fields

Overview

Use the addAdditionalField method to create new additional fields for your account.

Parameters

sessionID

Required (string)

 

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

AdditionalField

Object

 

Additional field object.

Response

bool(true)

Request

<?php

$host   = "https://api.avangate.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 = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')

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

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

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

$AdditionalField                             = new stdClass();
$AdditionalField->Label                      = 'Do you agree with the new newsletter policy 2015?';
$AdditionalField->Type                       = 'LISTBOX';
$AdditionalField->Code                       = 'NewsletterPolicy1234576';
$AdditionalField->ApplyTo                    = 'ORDER';
$AdditionalField->Values                     = array();
$AdditionalField->Values[0]                  = 'YES';
$AdditionalField->Values[1]                  = 'NO';
$AdditionalField->ValidationRule             = null;
$AdditionalField->Translations               = array();
$AdditionalField->Translations[0]            = new stdClass();
$AdditionalField->Translations[0]->Label     = "Êtes-vous d'accord avec la politique de la newsletter?";
$AdditionalField->Translations[0]->Values    = array();
$AdditionalField->Translations[0]->Values[0] = 'Oui';
$AdditionalField->Translations[0]->Values[1] = 'Non';
$AdditionalField->Translations[0]->Language  = 'fr';
$AdditionalField->Translations[1]            = new stdClass();
$AdditionalField->Translations[1]->Label     = 'Haben Sie mit dem Newsletter Politik zu?';
$AdditionalField->Translations[1]->Values    = array();
$AdditionalField->Translations[1]->Values[0] = 'Ja';
$AdditionalField->Translations[1]->Values[1] = 'Nein';
$AdditionalField->Translations[1]->Language  = 'de';


try {
    $NewAdditionalField = $client->addAdditionalField($sessionID, $AdditionalField);
}

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

var_dump("NewAdditionalField", $NewAdditionalField);


?>

 

Subscribe/unsubscribe to shopping cart events for InLine Checkout

Overview

Subscribe and unsubscribe to Inline checkout events.

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. Use theTwoCoInlineCart.products.add({code, quantity, options})method to prepare your catalog product.
  4. In order to subscribe to an event use:
TwoCoInlineCart.events.subscribe('cart:opened', function () {
    alert('Cart was opened.');
});

5. In order to unsubscribe from an event use the Handler GUID that you can obtain when subscribing to the event.

let cartClosedhandlerGuid = TwoCoInlineCart.events.subscribe('cart:closed', function () {
    alert('Cart was closed.');
});
TwoCoInlineCart.events.unsubscribe('cart:closed', cartClosedhandlerGuid);

6. 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.addEventListener('load', function() {
  TwoCoInlineCart.events.subscribe('cart:opened', function () {
    alert('Cart was opened.');
  });
  
  TwoCoInlineCart.events.subscribe('payment:finalized', function () {
    alert('Payment was finalized.');
  });
  
  TwoCoInlineCart.events.subscribe('fulfillment:finalized', function () {
    alert('Fulfillment was finalized.');
  });
  
  var cartClosedhandlerGuid = TwoCoInlineCart.events.subscribe('cart:closed', function () {
    alert('Cart was closed.');
  });
  TwoCoInlineCart.events.unsubscribe('cart:closed', cartClosedhandlerGuid);
});

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

Demo

After setting the subscribe/unsubscribe details for the InLine cart using the above methods, your cart should look like this:

Retrieve subscription plan/product info

Overview

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

Parameters

sessionID

Required (string)

 

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

SearchOptions

Object

 

 

SearchOptions

 

Object

Name

Optional (string)

 

Product name.

Can be NULL.

Types

Optional (StringArray)

 

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

  • REGULAR
  • BUNDLE

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

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

Enabled

Optional (boolean)

 

True or false.

Can be NULL.

GroupName

Optional (string)

 

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

Can be NULL.

Limit

Optional (integer)

 

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

Can be NULL.

Page

Optional (integer)

 

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

Can be NULL.

Response

Product

Object

Request

<?php

$host   = "https://api.avangate.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 = "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 error " . $e->getMessage();
}

var_dump($sessionID);

$SearchOptions        = new stdClass();
$SearchOptions->Name  = 'Avangate'; //Product name
$SearchOptions->Types = array(
    'REGULAR',
    'BUNDLE'
);
//You can also use additiona search options to narrow down results
// $SearchOptions->Enabled = ;
// $SearchOptions->GroupName = '';

$SearchOptions->Limit = '10';
$SearchOptions->Page  = '10';

try {
    $ProdSearch = $client->searchProducts($sessionID, $SearchOptions);
}

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

var_dump("Query", $ProdSearch);

?>

 

SSO in cart

Overview

Use the getSingleSignOnInCart method.  2Checkout attaches a unique token to links, designed to identify the returning shoppers and support the automatic extraction of payment data and billing information from the 2Checkout system. For example, you can generate single sign-on in cart links for existing customers logged into your website based on their external or 2Checkout customer IDs.

How does this work?

When accessing the shopping cart using tokenized payment links:

  • 2Checkout prefills automatically customer billing and delivery details associated with their 2Checkout customer accounts (linked based on their unique customer IDs).
  • 2Checkout presents shoppers with an optimized payment area featuring the credit/debit cards used to make previous purchases/transactions in the 2Checkout system. Customers have the option of selecting one of the payment methods depending on available card-on-file data.

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.

Customer

Required (string)

 

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

customerType

Required (string)

 

Possible values:

  • ExternalCustomerReference
  • AvangateCustomerReference

url

Required (string)

 

The shopping cart URL. 2Checkout redirects shoppers to this URL.

 

Possible values:

 

Any buy link you generate from the cPanel or using the API. Note: For the time being, payment tokenization does not support Express Payments Checkout or the 2Checkout mobile shopping cart.

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 generated string is the tokenized time-limited single sign-on URL pointing to 2Checkout shopping cart.

 

Note: Each SSO link cleans any previous cart sessions. Shoppers using multiple SSO links would purchase only a single product at a time.

 

If shoppers add multiple products to cart via SSO buy links and then use a non-SSO link, they’ll purchase all items using the same order.

When you use single sign on in cart for customers without card on files in the 2Checkout system, the generated tokenized link prefills the billing information but the purchase process requires that shoppers provide payment information, such as a credit or debit card.

Example: https://store.YourCustomDomain.com/order/checkout.php?PRODS=1112233&logintoken=8b74ac97f8277654563c44da6915b054ba0d21be

 

Important! You can use the value of the logintoken to retrieve customer information by SSO token.

 

Request

<?php

require ('PATH_TO_AUTH');

$idCustomer = '352365983';
$customerType = 'AvangateCustomerReference';
$url = 'https://store.avancart.com/order/checkout.php?PRODS=4639321&QTY=1&CART=1&CARD=2';
$validityTime = 50;
$validationIp = null;

try {
    $ssoLINK = $client->getSingleSignOnInCart($sessionID, $idCustomer, $customerType, $url, $validityTime, $validationIp);
}
catch (SoapFault $e) {
    echo "ssoLINK: " . $e->getMessage();
    exit;
}
var_dump("ssoLINK", $ssoLINK);

 

Retrieve product group

Overview

Use the getProductGroup method to extract information about a specific product group you created for your account.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

groupCode Required (string)
  Unique, system-generated identifier assigned to product groups. 

Response

Parameters Type/Description

ProductGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$groupCode = 'YOUR_GROUP_CODE';

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

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

Retrieve assigned additional fields

Overview

Use the getAssignedAdditionalFields method to extract information about the additional fields assigned to a specific product.

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.

ProductCode

Required (string)

 

The editable code that you control at product-level, not the unique, system-generated product ID.

 

Response

AdditionalField

Array of objects

Request

<?php
 
function callRPC($Request, $hostUrl, $Debug = true) {
    $curl = curl_init($hostUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
 
    if ($Debug) {
        $RequestString;
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        $ResponseString;
    }
 
    if (!empty($ResponseString)) {
//        var_dump($ResponseString);
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}
 
$host = 'https://api.avangate.com/rpc/3.0/';
 
$merchantCode = "YOURCODE12345";//your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key = "SECRET_KEY";//your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
 
$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$hash = hash_hmac('md5', $string, $key);
 
$i = 1; // counter for api calls
 
// Call the login method for authentication
 
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;
 
$sessionID = callRPC($jsonRpcRequest, $host);
$productCode = 'subscr1';
 
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getAssignedAdditionalFields',
'params' => array($sessionID, $productCode)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
 
?>

Retrieve next renewal price

Overview

Use the getNextRenewalPrice method to retrieve information on the costs customers incur on the next renewal for a subscription, per the recurring billing configuration.

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.

Currency

Required (string)

 

ISO 4217 code.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$Currency = 'eur';

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

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

Response

Parameters Type/Description

Next renewal price

Object

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