Skip to main content

Retrieve upgrade options for a subscription

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

Upgrade options

Array of objects

Request


<?php
$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 = "YOUR_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 = "YOUR_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;
}
$subscriptionReference = '30E47F8699';
try {
    $upgradeOptions = $client->getProductUpgradeOptions($sessionID, $subscriptionReference);
}
catch (SoapFault $e) {
    echo "upgradeOptions: " . $e->getMessage();
    exit;
}
var_dump("upgradeOptions", $upgradeOptions);

 

SSO by subscription reference

Overview

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

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

email

Optional (string)

 

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

validityTime

Optional (int)

 

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

accessPage

Optional (string)

 

The specific myAccount page you want the user to be redirected to. Possible values: view_order, my_license, change_card, my_products, payment_methods, user_data, order_lookup, faq - default: index page.
In the payment_methods list is the new text for the available page or page type parameter.

 

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.

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 page of myAccount.

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

faq - redirects shoppers to the Support page of myAccount

https://store.YourCustomDomain.com/support/

default: index page - redirects shoppers to myAccount homepage

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

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

Parameter Type/Description

Single sign-on URL

String

 

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.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'DC47E143FA';
$email = 'iwanttestnow1981@yahoo.com';
$validityTime = 50;
$accessPage = 'my_license';
$validationIp = null;

try {
    $ssoLINK = $client->getSingleSignOn($sessionID, $subscriptionReference, $email, $validityTime, $accessPage, $validationIp);
}
catch (SoapFault $e) {
    echo "ssoLINK: " . $e->getMessage();
    exit;
}
var_dump("ssoLINK", $ssoLINK);

 

Retrieve a product’s cross-sell campaigns

Overview

Use the getProductCrossSellCampaigns method to extract information on all cross-sell campaigns triggered by the same primary 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 code of the primary product triggering cross-sell campaign that you can define for each of your offerings.

Response

CrossSellCampaign

Object

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 = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getProductCrossSellCampaigns';
$jsonRpcRequest->params = array($sessionID, $ProductCode);
$jsonRpcRequest->id = $i++;
 
var_dump(" \n Cross-sell campaigns: \n", callRPC($jsonRpcRequest, $host));
 
 
?>

Update a subscription and assign it to another customer

Overview

Move a subscription from under a customer to another customer entity.

Use the updateSubscription method. Avangate moves subscription under the customer for which you provide the Avangate customer reference or the External customer reference during the subscription update process.

update_diagram.png

Requirements

To move a subscription from a source customer to a target customer:

  • Use Avangate customer references or External customer references belonging to the target customer. Avangate re-assigns the subscription to the target customer. 
  • Customer references must be valid and associated to the target customer entity under which you move the subscription.

If you provide both the Avangate customer reference and External customer reference they need to belong to the same target customer entity.

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.

Subscription

Required (Object)

 

To only move a subscription from a source customer to a target customer, send only the Avangate customer reference or the External customer reference.

Response

Parameters Type/Description

Boolean

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

Request

<?php

require ('PATH_TO_AUTH');

$SubscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

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

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

$updatedSubscription->AvangateCustomerReference = 'YOUR_SUBSCRIPTION_REFERENCE';

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

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

Add/Import subscriptions without payment data

Overview

This article covers subscription import without credit/debit card information. Use the addSubscription method to import a subscription into 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.

Subscription import

Required (Object)

 

Object designed to provide 2Checkout with all the information to create a subscription.

Response

Parameters Type/Description

SubscriptionReference

String

 

Unique, system-generated subscription identifier.

Request

<?php

require ('PATH_TO_AUTH');

$Product = new stdClass ();
$Product->ProductCode = 'my_subscription_1';
$Product->ProductId = 4639321;
$Product->ProductName = '2Checkout Subscription Imported';
$Product->ProductVersion = 1.0;
$Product->ProductQuantity = 3;
$Product->PriceOptionCodes = array();
$EndUser = new stdClass ();
$EndUser->Address1 = 'Address line 1';
$EndUser->Address2 = 'Address line 2';
$EndUser->City = 'LA';
$EndUser->Company = 'Company Name';
$EndUser->CountryCode = "US";
$EndUser->Email = 'customerAPI@2Checkout.com';
$EndUser->FirstName = 'Customer';
$EndUser->Language = 'en';
$EndUser->LastName = '2Checkout';
$EndUser->Phone = '1234567890';
$EndUser->State = 'California';
$EndUser->Fax = NULL;
$EndUser->Zip = '90210';
$Subscription = new stdClass();
$Subscription->ExternalSubscriptionReference = '12345678912ImportedSubscription';
$Subscription->SubscriptionCode= NULL;
$Subscription->StartDate = '2013-01-01';
$Subscription->ExpirationDate = '2017-12-30';
$Subscription->Product = $Product;
$Subscription->EndUser = $EndUser;
$Subscription->ExternalCustomerReference = '12354678ExtCustRef';


try {
    $importedSubscriptionNoPayData = $client->addSubscription($sessionID, $Subscription);
}
catch (SoapFault $e) {
    echo "importedSubscriptionNoPayData: " . $e->getMessage();
    exit;
}
var_dump("importedSubscriptionNoPayData", $importedSubscriptionNoPayData);

 

Add/Import subscriptions without payment data

Overview

This article covers subscription import without credit/debit card information. Use the addSubscription method to import a subscription into 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.

Subscription import

Required (Object)

 

Object designed to provide 2Checkout with all the information to create a subscription.

Response

SubscriptionReference

String

 

Unique, system-generated subscription identifier.

Request


<?php
$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 = "YOUR_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 = "YOUR_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;
}
$Product = new stdClass ();
$Product->ProductCode = 'my_subscription_1';
$Product->ProductId = 4639321;
$Product->ProductName = '2Checkout Subscription Imported';
$Product->ProductVersion = 1.0;
$Product->ProductQuantity = 3;
$Product->PriceOptionCodes = array();
$EndUser = new stdClass ();
$EndUser->Address1 = 'Address line 1';
$EndUser->Address2 = 'Address line 2';
$EndUser->City = 'LA';
$EndUser->Company = 'Company Name';
$EndUser->CountryCode = "US";
$EndUser->Email = 'customerAPI@2checkout.com';
$EndUser->FirstName = 'Customer';
$EndUser->Language = 'en';
$EndUser->LastName = '2Checkout';
$EndUser->Phone = '1234567890';
$EndUser->State = 'California';
$EndUser->Fax = NULL;
$EndUser->Zip = '90210';
$Subscription = new stdClass();
$Subscription->ExternalSubscriptionReference = '12345678912ImportedSubscription';
$Subscription->SubscriptionCode= NULL;
$Subscription->StartDate = '2013-01-01';
$Subscription->ExpirationDate = '2017-12-30';
$Subscription->Product = $Product;
$Subscription->EndUser = $EndUser;
$Subscription->ExternalCustomerReference = '12354678ExtCustRef';
try {
    $importedSubscriptionNoPayData = $client->addSubscription($sessionID, $Subscription);
}
catch (SoapFault $e) {
    echo "importedSubscriptionNoPayData: " . $e->getMessage();
    exit;
}
var_dump("importedSubscriptionNoPayData", $importedSubscriptionNoPayData);

 

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));

Update a subscription's additional information field

Overview

Use the updateSubscriptionAdditionalInformationField method to update the additional information field from to a subscription.

Requirements 

The maximum field length is 100 characters.

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.

fieldName

Required (string)

 

The name of the additional information field. Used for identifying additional information fields.

fieldValue Optional (string)
  The value you assign to the additional information field/

Response

Parameters Type/Description
AdditionalSubscriptionInformation Object

 

Contains information related to the additional information field.

Request

<?php

require('PATH_TO_AUTH');

$subscriptionReference = 'F27CFE06ED';
$fieldName = 'subscription';
$fieldValue = 'test';

try {
    $subscriptionInfo = $client->updateSubscriptionAdditionalInformationField($sessionID, $subscriptionReference, $fieldName, $fieldValue);
}
catch (SoapFault $e) {
    echo "subscriptionInfo: " . $e->getMessage();
    exit;
}
var_dump("subscriptionInfo", $subscriptionInfo);


Single Sign On by subscription reference

Overview

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

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.  String is case sensitive.

Email

Optional (string)

 

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

ValidityTime

Optional (int)

 

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

AccessPage

Optional (string)

 

The specific myAccount page you want the user to be redirected to. Possible values: view_order, my_license, change_card, my_products, payment_methods, user_data, order_lookup, faq - default: index page.
In the payment_methods list is the new text for the available page or page type parameter.

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.

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 page of myAccount.

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

faq - redirects shoppers to the Support page of myAccount

https://store.YourCustomDomain.com/support/

default: index page - redirects shoppers to myAccount homepage

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

ValidationIp

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.

Response

Parameters Type/Description

Single sign-on URL

String

 

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.

Request


<?php
$host   = "https://api.2checkout.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 = "YOUR_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 = "YOUR_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;
}
$SubscriptionReference = 'DC47E143FA';
$Email = 'iwanttestnow1981@yahoo.com';
$ValidityTime = 50;
$AccessPage = 'my_license';
$ValidationIp = null;
try {
    $ssoLINK = $client->getSingleSignOn($sessionID, $SubscriptionReference, $Email, $ValidityTime, $AccessPage, $ValidationIp);
}
catch (SoapFault $e) {
    echo "ssoLINK: " . $e->getMessage();
    exit;
}
var_dump("ssoLINK", $ssoLINK);

 

Single Sign On by subscription reference

Overview

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

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.  String is case sensitive.

Email

Optional (string)

 

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

ValidityTime

Optional (int)

 

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

AccessPage

Optional (string)

 

The specific myAccount page you want the user to be redirected to. Possible values: view_order, my_license, change_card, my_products, payment_methods, user_data, order_lookup, faq - default: index page.
In the payment_methods list is the new text for the available page or page type parameter.

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.

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 page of myAccount.

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

faq - redirects shoppers to the Support page of myAccount

https://store.YourCustomDomain.com/support/

default: index page - redirects shoppers to myAccount homepage

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

ValidationIp

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.

Response

Parameter Type/Description

Single sign-on URL

String

 

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.

Request


<?php
$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 = "YOUR_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 = "YOUR_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;
}
$SubscriptionReference = 'DC47E143FA';
$Email = 'iwanttestnow1981@yahoo.com';
$ValidityTime = 50;
$AccessPage = 'my_license';
$ValidationIp = null;
try {
    $ssoLINK = $client->getSingleSignOn($sessionID, $SubscriptionReference, $Email, $ValidityTime, $AccessPage, $ValidationIp);
}
catch (SoapFault $e) {
    echo "ssoLINK: " . $e->getMessage();
    exit;
}
var_dump("ssoLINK", $ssoLINK);

 

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