Skip to main content

Retrieve subscription plan/product info

Retrieve subscription plan/product info

Last updated: 25-Sep-2019
Rate this article:

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. Avangate 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, Avangate 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/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 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);

?>
Rate this article:
Logo of Verifone