Skip to main content

Retrieve a price option group

Overview

Use the getPriceOptionGroup method to extract information about a specific price option group that you configured.

Parameters

Parameters Type/Description

ProductGroup

Object

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)

 

The code that the 2Checkout system generated or that you set for the product pricing options group.

Response

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$groupCode = 'USERS';

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

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

 

Retrieve cross-sell campaign texts

Overview

Use the getCrossSellTexts method to extract information on all cross-sell campaigns texts.

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.

LanguageCode

Required (string)

 

ISO language code. (ISO 639-1 two-letter code).

Response

Title

String

 

Cross-selling message title. Set here.

Description

String

 

Cross-selling message description. Set here.

Language

String

 

ISO language code. (ISO 639-1 two-letter code).

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

$LanguageCode = 'de'; //returns title and description texts you set under https://secure.avangate.com/cpanel/network_cross_selling_settings.php

try {
    $CrossSellCampaignsTexts = $client->getCrossSellTexts($sessionID, $LanguageCode);
}

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

var_dump("CrossSellCampaignsTexts", $CrossSellCampaignsTexts);
?>

Retrieve assigned price option groups

Overview

Use the getAssignedPriceOptionGroups method to extract information about the price option groups you assigned to one of your products.

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

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

$host   = "https://api.avangate.com";
$client = new SoapClient($host . "/soap/5.0/?wsdl", array(
    'location' => $host . "/soap/5.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 = 'AAA4643199';

try {
    $AssignedPriceOptionGroups = $client->getAssignedPriceOptionGroups($sessionID, $ProductCode);
}

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

var_dump("AssignedPriceOptionGroups", $AssignedPriceOptionGroups);

?>

Retrieve VAT or sales tax

Overview

  1. Populate the Order object with information. Avangate needs the BillingDetails (object) information to calculate taxes. 
  2. Use the getContents method to get info on all the products added to cart by the shopper in the current session.
  3. The output of the getContents method is the Order session content object.
  4. Under the Price, access information including for each product purchased. Find value added tax and sales tax details under the VAT parameter. 
  5. Tax information is also available for the entire order object. Find value added tax and sales tax details under the VAT parameter.
  6. Calculate the VAT/sales tax rates using the VAT and NetPrice values

 

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.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

Response

OrderContents

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)) {
        $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);
$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'usd';
$Order->Country = 'US';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->AffiliateId = NULL;
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1;
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false;
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->Promotion = NULL;
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'FirstName';
$Order->BillingDetails->LastName = 'LastName';
$Order->BillingDetails->CountryCode = 'us';
$Order->BillingDetails->State = 'California';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'customer@email.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'TEST';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->CardType = 'visa';
$Order->PaymentDetails->PaymentMethod->ExpirationYear = '2019';
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = '12';
$Order->PaymentDetails->PaymentMethod->HolderName = 'John';
$Order->PaymentDetails->PaymentMethod->CCID = '123';
$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;
$jsonRpcRequest = array (
'method' => 'getContents',
'params' => array($sessionID, $Order),
'id' => $i++,
'jsonrpc' => '2.0'
);
echo '<BR>';
echo 'The content of the current session:';
echo '<BR>';
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

Use Giropay

Overview

GiroPay is an online banking-based payment method for users in Germany. GiroPay supports online payments via secure online transfers directly between bank accounts. GiroPay accounted for a share of 2% of online payments in Germany in 2019.

Supported currencies

GiroPay is restricted to Germany and supports transactions in EUR.

Workflow

  1. Shoppers select GiroPay as a payment option in the checkout interface you provide to them.
  2. Create the order object. Use “GIROPAY” as the type of the PaymentDetails object.
  3. Use the placeOrder method to send the data to 2Checkout.
  4. Use the PaymentMethod object to create a redirect URL for the shoppers. Using the provided URL, make a request using the provided method (usually a GET request) and add the parameters (located in the Params object) as key-value pairs to the URL of the request.
  5. 2Checkout returns an Order object as the output of the placeOrder method. 
  6. Once you place the order, 2Checkout logs it into the system. At this point in time, the status of the order is PENDING.

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.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

See code sample for more details. 

Request Example

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = "EUR" ;
$Order->Country = "DE";
$Order->Language = 'EN';
$Order->CustomerIP = '10.5.22.197';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = '67B4EDC822';
$Order->Items[0]->Quantity = 1;
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false;
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'John';
$Order->BillingDetails->LastName = 'Doe';
$Order->BillingDetails->CountryCode = "DE";
$Order->BillingDetails->State = 'Espírito Santo';
$Order->BillingDetails->City = 'City';
$Order->BillingDetails->Address1 = '-';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '1111111';
$Order->BillingDetails->Email = 'brazil1@2checkout.com';
$Order->BillingDetails->Phone = '123432323212';
$Order->BillingDetails->Company = 'blank';
$Order->DeliveryDetails = new stdClass();
$Order->DeliveryDetails->FirstName = 'John';
$Order->DeliveryDetails->LastName = 'Doe';
$Order->DeliveryDetails->CountryCode = 'NZ';
$Order->DeliveryDetails->State = 'Espírito Santo';
$Order->DeliveryDetails->City = 'City';
$Order->DeliveryDetails->Address1 = '-';
$Order->DeliveryDetails->Address2 = NULL;
$Order->DeliveryDetails->Zip = '1111111';
$Order->DeliveryDetails->Email = 'brazil1@2checkout.com';
$Order->DeliveryDetails->Phone = '123432323212';
$Order->DeliveryDetails->Company = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'GIROPAY';
$Order->PaymentDetails->Currency = "EUR" ;
$Order->PaymentDetails->HadPayPalToken = false;
$Order->PaymentDetails->CustomerIP = '10.5.22.197';

$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->PaymentMethod->ReturnURL = 'https://yourreturnurl.com';
$Order->PaymentDetails->PaymentMethod->CancelURL= 'https://yourcancelurl.com ';


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

$output = callRPC($jsonRpcRequest, $host);

var_dump($output);

Response Parameters

Parameter Type/Description

Order information

Object

  Object containing order information.

Response Example


class stdClass#9 (51) {
public $RefNo =>
string(8) "11796010"
public $OrderNo =>
int(0)
public $ExternalReference =>
NULL
public $ShopperRefNo =>
NULL
public $Status =>
string(7) "PENDING"
public $ApproveStatus =>
string(7) "WAITING"
public $VendorApproveStatus =>
string(2) "OK"
public $MerchantCode =>
string(7) "NCR_MCD"
public $Language =>
string(2) "en"
public $OrderDate =>
string(19) "2019-11-21 17:38:55"
public $FinishDate =>
NULL
public $Source =>
string(13) "sourceAPI.net"
public $Affiliate =>
class stdClass#10 (4) {
public $AffiliateCode =>
NULL
public $AffiliateSource =>
NULL
public $AffiliateName =>
NULL
public $AffiliateUrl =>
NULL
}
public $HasShipping =>
bool(false)
public $BillingDetails =>
class stdClass#11 (13) {
public $FiscalCode =>
NULL
public $TaxOffice =>
NULL
public $Phone =>
string(5) "12345"
public $FirstName =>
string(18) "Api First Name Bil"
public $LastName =>
string(17) "Api Last Name Bil"
public $Company =>
NULL
public $Email =>
string(20) "shopper@avangate.com"
public $Address1 =>
string(13) "Acasa Api Bil"
public $Address2 =>
string(14) "Acasa Api Bil2"
public $City =>
string(4) "Acre"
public $Zip =>
string(5) "12345"
public $CountryCode =>
string(2) "de"
public $State =>
string(4) "Acre"
}
public $DeliveryDetails =>
class stdClass#12 (11) {
public $Phone =>
string(5) "12345"
public $FirstName =>
string(18) "Api First Name Bil"
public $LastName =>
string(17) "Api Last Name Bil"
public $Company =>
NULL
public $Email =>
string(20) "shopper@avangate.com"
public $Address1 =>
string(13) "Acasa Api Bil"
public $Address2 =>
string(14) "Acasa Api Bil2"
public $City =>
string(4) "Acre"
public $Zip =>
string(5) "12345"
public $CountryCode =>
string(2) "de"
public $State =>
string(4) "Acre"
}
public $PaymentDetails =>
class stdClass#13 (4) {
public $Type =>
string(5) "OTHER"
public $Currency =>
string(3) "eur"
public $PaymentMethod =>
class stdClass#14 (6) {
public $Amount =>
string(3) "0.1"
public $Currency =>
string(3) "eur"
public $Redirect =>
class stdClass#15 (4) {
public $Url =>
string(37) "https://www.skrill.com/app/payment.pl"
public $Method =>
string(3) "GET"
public $Params =>
class stdClass#16 (1) {
public $sid =>
string(32) "c8cabebe0db1c280864e9ae294d956e2"
}
public $FullHtml =>
string(288) "<!DOCTYPE html><html><body><form action="https://www.skrill.com/app/payment.pl" method="GET" id="postform"><input type="hidden" name="sid" value="c8cabebe0db1c280864e9ae294d956e2" /></form><script type="text/javascript">document.getElementById(
        "postform").submit();</script></body></html>
public $ReturnURL =>
string(25) “https://yourreturnurl.com”
public $CancelURL =>
string(25) “https://yourcancelurl.com”

Retrieve SKU code by details

Overview

Use the getSKUCodeByDetails method to retrieve an SKU based on its included 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.

 skuDetailsObject

Object

 

Details below

 

PricingConfigurationCode

Required (string)

 

 

Unique identifier of the pricing configuration.

 

Currency

Optional (string)

 

 

ISO currency code.

 

PurchaseType

Optional (string)

 

 

Purchase type identifier. Possible values:

  • NEW_PRODUCT
  • RENEWAL
  • UPGRADE

 

PriceOptions

Optional (stringArray)

 

 

Array of price options names.

 

Quantity

Optional (int)

 

 

Numeric identifier of product quantity.

Request Example

<?php
require ('PATH_TO_AUTH');

$skuDetailsObject = new stdClass();
$skuDetailsObject->PricingConfigurationCode = 'YOUR_CODE';
$skuDetailsObject->Currency = 'USD';
$skuDetailsObject->PurchaseType = 'NEW_PRODUCT';
$skuDetailsObject->PriceOptions = ['A'];
$skuDetailsObject->Quantity = 1;

try {
    $getSkuDetails = $client->getSkuDetails($sessionID, $skuDetailsObject);
} catch (SoapFault $e) {
    echo  $e->getMessage();
}
var_dump($getSkuDetails);

Response Example

{SKUCode} // eg: SKU-EUR-1-10-N-A

 

Use Test orders

Overview

Place a TEST order using catalog products defined in your Control Panel.

Requirements

Set the Payment details type to TEST in order to create an order in a test environment.

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.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

 

Response 

Parameters Type/Description

Order information

Object

Request

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'usd';
$Order->Country = 'US';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;

$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1;
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false;
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'John';
$Order->BillingDetails->LastName = 'Doe';
$Order->BillingDetails->CountryCode = 'us';
$Order->BillingDetails->State = 'California';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'cosmin.deftu@avangate.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;

$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'TEST';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->CardType = 'visa';
$Order->PaymentDetails->PaymentMethod->ExpirationYear = '2019';
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = '12';
$Order->PaymentDetails->PaymentMethod->HolderName = 'John';
$Order->PaymentDetails->PaymentMethod->CCID = '123';

$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

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

$order = callRPC($jsonRpcRequest, $host);

Subscription end user update

Overview

Use the updateSubscriptionEndUser method to update the details of a subscription’s end user. This method changes per-subscription end user data and not customer 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.

EndUser

Required (Object)

  Use this object to update end user information.

Response

Parameters Type/Description

Boolean

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

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 = '8F749B63E7';
$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 = 'New Customer';
$EndUser->Language = 'en';
$EndUser->LastName = '2Checkout';
$EndUser->Phone = '1234567890';
$EndUser->State = 'California';
$EndUser->Zip = '90210';
$EndUser->Fax = null;
try {
    $newEndUser = $client->updateSubscriptionEndUser($sessionID, $subscriptionreference, $EndUser);
}
catch (SoapFault $e) {
    echo "newEndUser: " . $e->getMessage();
    exit;
}
var_dump("newEndUser", $newEndUser);

 

Update pricing configuration

Overview

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

Requirements

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

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

 

    Response

    bool(true)
    

    Request

    <?php
    require ('PATH_TO_AUTH');
    $productCode = 'YOUR_PRODUCT_CODE';
    try {
        $ProductPricingConfigurations = $client->getPricingConfigurations($sessionID, $productCode);
        var_dump("InitialPricingConfiguration", $ProductPricingConfigurations);
    }
    catch (SoapFault $e) {
        echo "Pricing Configurations: " . $e->getMessage();
        exit;
    }
    $ProductPricingConfigurations[1]->Prices->Renewal[0]->Currency = 'USD';
    $ProductPricingConfigurations[1]->Prices->Renewal[0]->Amount = 99;
    
    $newPriceConfig = $ProductPricingConfigurations[1];
    try {
        $UpdatedPricingConfiguration = $client->updatePricingConfiguration($sessionID, $newPriceConfig, $ProductCode);
    }
    catch (SoapFault $e) {
        echo "UpdatedPricingConfiguration: " . $e->getMessage();
        exit;
    }
    var_dump("UpdatedPricingConfiguration", $UpdatedPricingConfiguration);
    ?>
    

    Upgrade a subscription

    Overview

    Retrieve information about the upgrade options for a specific subscription.

    Parameters

    Array of upgrade options

    ProductInfo

    Object

                   

    Details below.

     

    ProductId

    Int

     

     

    Unique, system-generated product identifier belonging to the upgrade product.

     

    ProductCode

    String

     

     

    Unique product identifier that you control belonging to the upgrade product.

     

    ProductName

    String

     

     

    Product name

     

    ProductVersion

    String

     

     

    The product version number that you control.

     

    ProductEnabled

    Boolean

     

     

    Possible values:

    0 – You disabled this product.

    1 – You enabled this product.

     

    ProductType

    String

     

     

    REGULAR or BUNDLE

     

    Currency

    String

     

     

    The currency for prices. The currency ISO code used for the payment - ISO 4217.

     

    DefaultCurrency

    String

     

     

    The product's default currency which is set in the Control Panel. The currency ISO code to be used for the payment - ISO 4217.

     

    Price

    Double

     

     

    Product price. Can be null for flat pricing schemes. You need to call getPrice with Quantity, Currency and Price Options parameters to get a valid price.

     

    GiftOption

    String

     

     

    True or false depending on whether the product can be gifted or not.

     

    IdGroup

    Int

     

     

    Product Group ID number.

     

    GroupName

    String

     

     

    The name of the Product Group.

     

    ShortDescription

    String

     

     

    The product's short description.

     

    ProductImage

    String

     

     

    URLs to the product images uploaded into the Avangate platform.

     

    Languages

    Array of strings

     

     

    Array of ISO language codes for the product - ISO 639-1.

     

    PriceIntervals

    Array of objects

     

     

    Pricing intervals.

     

    PriceType

    String

     

     

    NET or GROSS

     

    PriceSchema

    String

     

     

    FLAT or DYNAMIC

    Quantity

    Int

     

    Number of units available for the upgrade order.

    PriceOptions

    Array of objects

     

    Details below.

     

    Id

    String

     

     

    Pricing options ID.

     

    Name

    String

     

     

    Pricing options group name.

     

    Description

    String

     

     

    The description of the Pricing options group

     

    Required

    Boolean

     

     

    True or False depending on whether you set the Pricing options group asrequired or not.

     

    Type

    String

     

     

    Pricing options group type:

    • COMBO
    • CHECKBOX
    • RADIO

    INTERVAL

     

    Options

    Array of objects

     

     

    Details below.

     

     

    Name

    String

     

     

     

    The name of the option inside the Pricing options group

     

     

    Value

    String

     

     

     

    The code of the option inside the Pricing options group

     

     

    Default

    Boolean

     

     

     

    True or false.

     

     

    Description

    String

     

     

     

    The description of the option inside the Pricing options group.

     

     

    MinValue

    Int

     

     

     

    Start value of a scale interval.

     

     

    MaxValue

    Int

     

     

     

    End value of a scale interval.

     

    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