Skip to main content

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.

 

Use Trustly

Overview

Place an order for catalog products defined in your Merchant Control Panel and collect the payment using Trustly via JSON-RPC API 6.0.

Request parameters

Parameter name Type Required/Optional Description
sessionID String Required 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 Object Required

Object designed to collect all data necessary for an order, including billing, product/subscription plan, and payment details. To place an order with Trustly, use TRUSTLY as the type of the PaymentDetails object and provide a ReturnURL and a CancelURL as part of the PaymentMethod object. See code sample.

Request example

<?php

    require ('PATH_TO_AUTH');

    $Order = new stdClass();
    $Order->RefNo = NULL;
    $Order->Currency = 'EUR';
    $Order->Country = 'SE';
    $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]->Promotion = 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 = 'SE';
    $Order->BillingDetails->State = 'Beijing';
    $Order->BillingDetails->City = 'Beijing';
    $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 = 'TRUSTLY';
    $Order->PaymentDetails->Currency = 'EUR';
    $Order->PaymentDetails->PaymentMethod = new stdClass ();
    $Order->PaymentDetails->CustomerIP = '91.220.121.21';
    $Order->PaymentDetails->PaymentMethod->ReturnURL = 'http://yourreturnurl.com';
    $Order->PaymentDetails->PaymentMethod->CancelURL= 'http://yourcancelurl.com';

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

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

    $trustlyredirect = $output->PaymentDetails->PaymentMethod->Authorize->Href."/?avng8apitoken=".$output->PaymentDetails->PaymentMethod->Authorize->Params->avng8apitoken;

    header('Location:' . $trustlyredirect);

Response parameters

Parameter name Type Description
Order Object Object containing order information.

Update end-user information

Overview

Use this method to add end user information to a subscription.

Requirements

Parameters

Parameter Type/Description

sessionID

Required (String)

 

Session identifier, output of the Login method. An exception is thrown for incorrect values.

subscriptionReferencesList

Required (StringArray)

 

 

EndUser

Object

 

Details below

 

FirstName

String

 

 

End user first name

 

LastName

String

 

 

End user last name

 

Company

String

 

 

End user company name. Can be NULL.

 

CountryCode

String

 

 

End user country code (ISO 3166 two-letter code).

 

State

String

 

 

End user state. Example: "Alabama". Can be NULL.

 

Email

String

 

 

End user email.

 

Fax

String

 

 

End user fax number. Can be NULL.

 

City

String

 

 

End user city.

 

Address1

String

 

 

End user address line 1. Can be NULL.

 

Address2

String

 

 

End user address line 2. Can be NULL.

 

Phone

String

 

 

End user phone number. Can be NULL.

 

Zip

String

 

 

End user zip. Can be NULL.

 

Language

String

 

 

ISO 639-1 two-letter language code for the end user language. Can be NULL.

Response

Parameter Type/Description
result Boolean
  True or false

Request

<?php

require('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/02Authentication
require('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/Partner/00Set_partner

$subscriptionReferencesList = array('REFERENCE_1', 'REFERENCE_2');

$endUser = new stdClass();
$endUser->FirstName = 'FirstName';
$endUser->LastName = 'LastName';
$endUser->CountryCode = 'US';
$endUser->Email = 'email@example.com';
$endUser->City = 'LA';

try {
    $UpdatedEndUser= $client->updateSubscriptionsEndUser($sessionID, $subscriptionReferencesList, $endUser);
} catch (SoapFault $e) {
    Echo "UpdatedEndUser: " . $e->getMessage();
    exit;
}
var_dump ("UpdatedEndUser ", $UpdatedEndUser);

Errors

Error Description

NOT_FOUND_PARTNER

A partner must be set first.

INVALID_SUBSCRIPTIONS_LIST_SIZE

Too many subscription references provided.

INVALID_COUNTRY

Invalid end user country code.

INVALID_END_USER_EMAIL

Invalid end user email provided.

EMPTY_END_USER_FIRST_NAME

End user first name is mandatory.

EMPTY_END_USER_LAST_NAME

End user last name is mandatory.

EMPTY_END_USER_CITY

End user city is mandatory.

 

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