Skip to main content

Single Sign On by subscription reference


Use the getSingleSignOn method to redirect and login shoppers automatically from your user portal into their 2Checkout myAccount based on subscription information. This method connects third-party user hubs with the 2Checkout myAccount, and allows your shoppers to seamlessly sign in to manage their information and perform tasks such as updating/changing credit card details.


Parameters Type/Description


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.


Required (string)


Unique, system-generated subscription identifier.  String is case sensitive.


Optional (string)


End user email address belonging to the customers associated with the subscription.


Optional (int)


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


Optional (string)


The specific myAccount page you want the user to be redirected to.

Possible values: view_order, my_license, change_card, my_products, user_data, order_lookup, faq - default: index page

view_order - based on the SubscriptionReference, redirects shoppers to the myAccount page for the initial order that served to purchase the subscription. The 2Checkout system will match the subscription to the order automatically, displaying its associated myAccount view_order page.

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

change_card - redirects shoppers to the subscription page of myAccount and opens up the change credit card pop-up window designed to update the payment details associated with a subscription.

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

user_data - redirects shoppers to the Personal Information page in myAccount

order_lookup - redirects shoppers to the Order Lookup page of myAccount.

faq - redirects shoppers to the Support page of myAccount

default: index page - redirects shoppers to myAccount homepage


Optional (string)


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

LanguageCode Optional (string)
  ISO 639-1 two-letter code.


Single sign-on URL



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


$host   = "";
$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 = "YOUR_MERCHANT_CODE";// your account's merchant code available in the 'System settings' area of the cPanel:
$key = "YOUR_SECRET_KEY";// your account's secret key available in the 'System settings' area of the cPanel:
$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();
$SubscriptionReference = 'DC47E143FA';
$Email = '';
$ValidityTime = 50;
$AccessPage = 'my_license';
$ValidationIp = null;
try {
    $ssoLINK = $client->getSingleSignOn($sessionID, $SubscriptionReference, $Email, $ValidityTime, $AccessPage, $ValidationIp);
catch (SoapFault $e) {
    echo "ssoLINK: " . $e->getMessage();
var_dump("ssoLINK", $ssoLINK);


  • Was this article helpful?