Skip to main content

Retrieve product price

Overview

Get the price for a product in a new purchase scenario, based on the product ID, the pricing list it's assigned to and specific pricing options.

Requirements

Parameters

Parameter Type/Description
sessionID Required (string)
  Session identifier, which is the output of the Login method. An exception will be thrown if the values are incorrect.
productId Required (string)
  The unique identifier of the product from your system.
pricingListCode Required (string)
  The unique identifier of the pricing list.
priceOptions Optional (StringArray)
  Array of pricing option codes. These identifiers mark the individual options inside pricing options configuration groups. Can be NULL.

Response

Parameter Type/Description
UnitPrice Object
  UnitPrice object.

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

$productId = 'YOUR_PRODUCT_ID';
$pricingListCode = 'YOUR_PRICING_LIST_CODE';
$priceOptions = array(
'Pricing_options_group_code1',
'Pricing_options_group_code2'
);

try {
    $ProdPrice= $client->getProductPrice($sessionID, $productId, $pricingListCode, $priceOptions);
} catch (SoapFault $e) {
    echo "ProductUnitPrice: " . $e->getMessage();
    exit;
}

Errors

Error Description

INVALID_PARTNER

No partner is set.

PRODUCT_ERROR

Invalid product ID.

PARTNER_PRICING_LISTS_NOT_FOUND

There are no pricing lists with the provided code.

PRODUCT_NOT_FOUND

There is no active product with the provided ID in the given pricing list.

 

Search shipping methods

Overview

Use searchShippingMethods to retrieve information on the shipping methods currently defined on your account.

Search filters

Use the parameters below to filter the results of your search for shipping methods.

Parameter Type/Description
Name

String / Optional

Name of the shipping method.

Codes

Array of strings / Optional

Codes assigned to the shipping methods.

Countries

Array of strings / Optional

Countries to which the shipping method is assigned.

Active

Boolean / Optional

TRUE - active shipping methods

FALSE - inactive shipping methods

Pagination

Object / Optional

Control the results pagination.

  Page

Integer / Optional

Number of pages to display the results

  Limit

Integer / Optional

Limit the number of results of the search

Sample request

<?php

require ('PATH_TO_AUTH'); // authentication call

$SearchOptions = new \stdClass();
$SearchOptions->Name = 'ShippingMethodName'; // search for a specific shipping method
$SearchOptions->Codes = ['Code1', 'Code2', 'Code3']; // array of shipping method codes
$SearchOptions->Countries = ['US', 'UK', 'AU']; // array of country codes
$SearchOptions->Active = true; // only active shipping methods
$SearchOptions->Pagination = new \stdClass();
$SearchOptions->Pagination->Page = 1; // set display pages
$SearchOptions->Pagination->Limit = 200; // limit the results

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'searchShippingMethods',
'params' => array($sessionID, $SearchOptions)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

Response

Parameter Type/Description
ShippingMethod

Object

 

Retrieve shipping price

Overview

Use getShippingPrice to retrieve the shipping method and price available, based on a current cart configuration. This API call returns the available shipping methods defined in your Control Panel, together with the fees you configured based on order total amount/weight/country.

Requirements

It's mandatory to have tangible products defined in your Control Panel, to retrieve shipping method and price information.

Parameters

Parameters Type/Description
Items

Object / Required

Contains information on the tangible product added in cart.

  Code

String / Required

Product code defined in the Information tab from the Product level, in the Control Panel.

  Quantity

Integer / Optional

Quantity of the product that is being purchased.

Default value is 1.

BillingDetails

Object / Required

Contains customer billing information.

  CountryCode

String / Required

Two-digits code of customer billing country. Example: 'US'.

DeliveryDetails

Object / Required

Contains customer delivery information.

  CountryCode

String / Required

Two-digits code of customer delivery country. Example: 'US'.

Currency

String / Optional

Three-digits code of purchase currency. Example: 'USD'.

CouponCodes

Array of strings / Optional

Discount codes that can be applied to the purchase.

Sample request

<?php

require ('PATH_TO_AUTH'); // authentication call

$cartItems = [];
$cartItem = new stdClass();
$cartItem->Code = 'my_product_code_1'; // product code defined in the Information tab, at product level
$cartItem->Quantity = 2; // quantity that is being purchased
$cartItems[0] = $cartItem;
$billingDetails = new stdClass();
$billingDetails->CountryCode = 'US'; // billing country
$deliveryDetails = new stdClass();
$deliveryDetails->CountryCode = 'AU'; // delivery country

$currency = 'USD'; // purchase currency

$couponCode = ['TANGIBLEPROMO']; // apply discount to promotion

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getShippingPrice';
$jsonRpcRequest->params = array($sessionID, $cartItems, $billingDetails, $deliveryDetails, $currency);
$jsonRpcRequest->id = $i++;

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

Response

Parameters Type/Description
ShippingPrice

Object

This method returns an object, containing the shipping price available for a certain cart configuration.

Add/edit cross-sell texts

Overview

Use the addCrossSellCampaignText method to customize the texts that are shown in the shopping cart when a cross-sell campaign is displayed.  

Editing a text can be done via the updateCrossSellCampaignText method with the same payload. If during a call to updateCrossSellCampaignText method, a text is not found in the database, it will be added automatically.  

Request parameters

Parameters 

Type 

Required

Description 

language 

String 

Required

The ISO 639-1 two-letter code of the language; Can be Arabic, Bulgarian, Chinese, Chinese (traditional), Czech, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Korean, Norwegian, Persian, Polish, Portuguese, Portuguese (Brazil), Slovak, Slovenian, Spanish, Swedish, Thai, Romanian, Russian 

title 

String 

Required

The title of the cross sell campaign as it is displayed in the cart 

description 

String 

Required

The description of the cross sell campaign as it is displayed in the cart 

Response

Both the addCrossSellCampaignText and updateCrossSellCampaignText methods will return the full list of texts available in the platform. 

Request sample

<?php 

require ('PATH_TO_AUTH'); 

$csCampaignText = []; 
 
$textObj = new stdClass(); 
$textObj->Language = "ro"; 
$textObj->Title = "Numele campaniei mele"; 
$textObj->Description = "Descrierea campaniei mele"; 

$csCampaignText[] = $textObj; 

$textObj = new stdClass(); 
$textObj->Language = "en"; 
$textObj->Title = "My campaign name"; 
$textObj->Description = "My campaign description"; 

$csCampaignText[] = $textObj; 
try { 

    $csCampaignTextResponse = $client->addCrossSellCampaignText($sessionID, $csCampaignText); 

} catch (SoapFault $e) { 

    echo  $e->getMessage(); 

} 

Subscription

Overview

Retrieve information and manage subscriptions for your account. Subscriptions can be retrieved starting with 5 minutes after their orders are generated in the 2Checkout system.

Object parameters

Parameters Type/Description

SubscriptionReference

String

 

Unique, system-generated subscription identifier.

StartDate

String

 

Subscription start date(YYYY-MM-DD) - StartDate is mandatory when importing subscription data. If you changed the time zone for the Avangate API by editing system settings under Account settings, then the StartDate you provide must be in accordance with your custom configuration.

ExpirationDate

String

 

Subscription expiration date(YYYY-MM-DD) - ExpirationDate is mandatory when importing subscription data. If you changed the time zone for the Avangate API by editing system settings under Account settings, then the ExpirationDate you provide must be in accordance with your custom configuration.

RecurringEnabled

Boolean

 

Possible values:

TRUE – recurring billing/automatic subscription renewals enabled

FALSE– recurring billing/automatic subscription renewals disabled

SubscriptionEnabled

Boolean

Possible values:

TRUE –subscription enabled

FALSE–subscription disabled

Product

Required (object)

 

The product for which Avangate generated the subscription. Details below.

 

ProductCode

String

 

 

Unique product identifier that you control.

 

ProductId

Int

 

 

Unique, system-generated product identifier.

 

ProductName

String

 

 

Product name.

 

ProductQuantity

Int

 

 

Ordered number of units.

 

ProductVersion

String

 

 

Product version.

 

PriceOptionCodes

Array

 

 

The product options codes the customer selected when acquiring the subscription. Pricing options codes are case sensitive.

EndUser

Object

 

The end user of the subscription. Details below.

 

Person

Object

 

 

FirstName

String

 

 

 

End user's first name

 

 

LastName

String

 

 

 

End user's last name

 

 

CountryCode

String

 

 

 

End user country code [ISO3166-1 Alpha 2].

 

 

State

String

 

 

 

End user state.

 

 

City

String

 

 

 

End user city.

 

 

Address1

String

 

 

 

End user first address line.

 

 

Address2

String

 

 

 

End user second address line.

 

 

Zip

String

 

 

 

End user zip code.

 

 

Email

String

 

 

 

End user email address.

 

 

Phone

String

 

 

 

End user phone number.

 

 

Company

String

 

 

 

Company name.

 

Fax

String

 

 

End user fax.

 

Language

String

 

 

Language [ISO639-2] the Avangate system uses for communications.

SKU

String

 

Stock keeping unit you defined.

DeliveryInfo

Object

 

The object contains information about the delivery/fulfillment made to the customer.

 

Description

String

 

 

Delivery description.

 

Codes

Array of objects

 

 

Code

String

 

 

 

Activation key/license code of the first order from this subscription. Use getSubscriptionHistory method if you want to retrieve the activation keys/license codes for all orders belonging to a subscription.

 

 

Description

String

 

 

 

Code description for dynamic lists from your key generator. 

 

 

ExtraInfo

Object

 

 

 

Info set by your key generator for dynamic lists only.

 

 

 

CodeExtraInfo

Object

 

 

 

Type

String

 

 

 

Label

String

 

 

 

Value

String

 

 

File

Array of objects

 

 

 

Content

String

 

 

 

 

Content of the file (base64 encoded).

 

 

 

ContentLength

Int

 

 

 

 

File size.

 

 

 

Filename

String

 

 

 

 

The name of the delivered file.

 

 

 

FileType

String

 

 

 

 

The type of the delivered file.

ReceiveNotifications

Boolean

 

1 – Subscribe: Avangate sends subscription notifications to the end user.

0 – Unsubscribe – Avangate does not send subscription notifications to the end user.

Lifetime

Boolean

 

Possible values:

  • True – the subscription is evergreen

False – the subscription has a recurring billing cycle less than or equal to three years.

PartnerCode

String

 

  • Empty: for ecommerce orders

Partner Code

AvangateCustomerReference

Int

 

Unique, system-generated customer identifier.

ExternalCustomerReference

String

 

Customer identifier that you control.

TestSubscription

Boolean

 

True for test subscriptions, false otherwise.

IsTrial

Boolean

 

True for trial subscriptions, false otherwise.

MerchantCode String
  Unique, system-generated ID in the Avangate system.

 

 

 

Product

Overview

Use the Product object to create/add, update/edit and retrieve subscription plans/products for your account. You can control:

  • Product information
  • Pricing
  • Subscription plan settings and renewal configuration
  • Subscription plan recurring billing
  • Fulfillment
  • Shipping classes
  • Localization

 

Parameters Type/Description

2CheckoutId

String

 

Unique, system-generated 2Checkout product ID. Read-only.

ProductCode

String

 

The product code that you can define for each of your offerings. Needs to be unique.

ProductType

String

 

REGULAR or BUNDLE

ProductName

String

 

The name of the product

ProductVersion

String

 

The product version number

GroupName

String

 

The name of the Product Group to which the product belongs. Cannot be set as part of the addProduct call.

ShippingClass

Object

 

Existing shipping class object with the structure detailed below.

GiftOption

boolean

 

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

ShortDescription

String

 

The product's short description

LongDescription

String

 

The product's long description

SystemRequirements

String

 

System requirements

PurchaseMultipleUnits boolean
 

Possible values:

  • TRUE - customers can purchase multiple units of this product.
  • FALSE - customers can purchase only one unit at a time.

 

Default value is TRUE.

ProductCategory

String

 

Product category

Platforms

Array of Platform objects

 

Array of objects detailing the platforms supported by the application. Details below.

ProductImages

Array of Image objects

 

Image object. Details below. Read-only.

TrialUrl

String (anyURI)

 

The URL from where shoppers can download trial software.

TrialDescription

String

 

Descriptive text entered for trials.

Enabled

Boolean

 

True/false depending on whether the products are active or disabled. When empty, 2Checkout marks the product as disabled.  

AdditionalFields

Array of AdditionalFieldAssigned objects

 

Array of existing additional fields assigned to products. Details below.

Translations

Array of ProductTranslation objects

 

Details below.

PricingConfigurations

Array of PricingConfiguration objects/Required

 

Details below. 2Checkout creates pricing configurations during the process when you add a product.

BundleProducts

Array of BundleProductCode objects

 

Details below.

Fulfillment

String

 

BY_2CHECKOUT

NO_DELIVERY – The 2Checkout system finalizes orders immediately after it receives payment confirmation.

BY_VENDOR – you are responsible for delivering/fulfilling orders

Prices

Array of Price objects

 

Use this object only when Pricing Configurations are not available for your account. Details below.

GeneratesSubscription

boolean

 

TRUE or FALSE depending on whether you set the product to generate subscriptions or not.

 

NULL for bundles for which you set the following subscription management option: “Use the subscription settings of each product in the bundle”

SubscriptionInformation

ProductSubscriptionInformation Object

 

Details below. NULL for bundles which you set to use the renewal settings of child products and not of the parent bundle.

FulfillmentInformation

Object

 

Details below. Can be NULL. Available only in Product API 2.5 and later.

 

ShippingClass

Object

Name

String

 

The name of the shipping class

Amount

Decimal

 

The shipping costs

Currency

String

 

The currency ISO code used for shipping costs - ISO 4217.

ApplyTo

String

 

Possible values:

• PRODUCT

• ORDER

Type

Possible values:

• FIXED

• PERCENT

 

Platform

Object

PlatformName

String

 

The label of the platform per the product configuration.

Category

String

 

Platform category per product configuration. 

 

ProductImage

Object (Read-only)

Default

Boolean

 

True or False depending on whether you set the image stored at the address in the URL parameter as default or not.

URL

String

 

The location of the image on the 2Checkout system.

 

AdditionalFieldAssigned

Object

Label

String

 

The name of the additional field assigned to a product.

Code

String

 

The code of the additional field assigned to a product.

Enabled

Boolean

 

True or false depending on whether the assigned product field is enabled or not.

Required

Boolean

 

True or false depending on whether the assigned product field is required or not.

URLParameter

String

 

The value of the system generated URL parameter for the product field that can be used in Buy Links.

 

Translation

Object – ISO 639-1 two-letter code

LongDescription

String

 

The translated long description in the language corresponding to the Translation object.

TrialUrl

String

 

The trial URL for users speaking the language corresponding to the Translation object.

TrialDescription

String

 

 

SystemRequirements

String

 

Localized system requirements.

Name

String

 

Localized product name.

Description

String

 

Localized product short description.

Language

String

 

ISO 639-1 two-letter code.

 

PricingConfiguration

Object

Name

String

 

Pricing configuration name

Code

String

 

System-generated identifier.

Default

boolean

 

True for the default pricing configuration

BillingCountries

Array of strings

 

ISO codes of the countries assigned to the pricing configuration.

Empty unless specific countries are assigned to a pricing configuration.

PricingSchema

String

 

DYNAMIC – With a base price

FLAT – Without a base price

PriceType

String

 

Possible values:  NET / GROSS

DefaultCurrency

String

 

The ISO code of the default currency for the pricing configuration

Prices

Object

 

Details below.

PriceOptions

Array of AssignedPriceOptionGroup objects

 

Details below.

 

Prices

Object

Regular

Array of objects

 

Details below.

Renewal

Array of objects

 

Details below.

 

Regular

Object

Amount

Int

 

The price of the product.

Currency

String

 

ISO code of the currency for the product price.

MinQuantity

Int

 

The minimum quantity of volume discounts. Default is 1.

MaxQuantity

Int

 

The maximum quantity of volume discounts. Default is 99999.

OptionCodes

Array of objects

 

Details below.

 

Renewal

Object

Amount

Int

 

The price of the product.

Currency

String

 

ISO code of the currency for the product price.

MinQuantity

Int

 

The minimum quantity of volume discounts. Default is 1.

MaxQuantity

Int

 

The maximum quantity of volume discounts. Default is 99999.

OptionCodes

Array of PriceOptionCode objects

 

Details below.

 

PriceOptions

Object

Code

String

 

System generated pricing options group code (you can also configure it) that the 2Checkout system uses to calculate product prices for pricing configurations without a base price.

Required

Boolean

 

True or False depending on whether you want to make it mandatory for shoppers to select the price option during the puyrchase process.

 

PriceOptionCode

Object

Code

String

 

Price option identifier.

Options

Array of strings

 

The pricing options group option code you configured that the 2Checkout system uses to calculate product prices for pricing configurations without a base price.

 

BundleProducts

Object

ProductId

String

 

Unique, system-generated product ID.

ProductCode

String

 

Editable product code that you control.

 

Prices

Object - Use this object only when Pricing Configurations are not available for your account.

Amount

Int

 

The price of the product.

Currency

String

 

ISO code of the currency for the product price.

MinQuantity

Int

 

The minimum quantity of volume discounts. Default is 1.

MaxQuantity

Int

 

The maximum quantity of volume discounts. Default is 99999.

OptionCodes

Array of objects

 

Details below.

 

PriceOptions

Object

Code

String

 

System generated pricing options group code (you can also configure it) that the 2Checkout system uses to calculate product prices for pricing configurations without a base price.

Required

Boolean

 

True or False depending on whether you want to make it mandatory for shoppers to select the price option during the puyrchase process.

 

SubscriptionInformation

Object

 

NULL for bundles for which you set the following subscription management option: “Use the subscription settings of each product in the bundle”

DeprecatedProducts

Array

 

Deprecated products.

BundleRenewalManagement

String

 

Possible values:

  • GLOBAL
  • INDIVIDUAL

Can be NULL.

UpgradeProductCode

String

 

Code belonging to the upgrade product.

BillingCycle

String

 

The number of subscription billing cycle units (months or days).  Possible values:

  • 0 (zero represents a one-time fee)

Days

  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

 

Months

  • 1
  • 2
  • 3
  • 6
  • 12
  • 15
  • 18
  • 24
  • 36 (max)

BillingCycleUnits

String

 

The units of the billing cycle:

  • M - months
  • D - days

IsOneTimeFee

Boolean

 

True or False depending on whether the subscription is evergreen or not.

ContractPeriod

Object

 

Details below.

UsageBilling

Int

 

The usage billing interval must be smaller than or equal to the grace period.

 

Interval of time within the grace period, when the 2Checkout system attempts to automatically charge customers for recurring costs and additional metered usage fees (in arrears). 2Checkout renews subscriptions only after subscribers make all outstanding payments per the renewal settings (from the expiration or the renewal date). If automatic renewal and usage charges fail, subscriptions can be manually renewed only by the end of the grace period, after which they expire.

 

Can be NULL.

GracePeriod

Object

 

Details below.

RenewalEmails

Object

 

Details below. Can be NULL. Available only in Product API 2.5 and later.

 

ContractPeriod

Object

Period

Int

 

The contract period in months or days. -1 for unlimited contracts.

PeriodUnits

String

 

The contract period units

days | months

IsUnlimited

boolean

 

This flag is true if the contract is for an unlimited period

Action

String

 

The action performed after the subscription expires.

Possible values CANCEL | RESTART

EmailsDuringContract

Boolean

 

True or False depending on whether you suppress renewal notification emails throughout the duration of the contract or not.

GracePeriod

Object

Type

String

 

CUSTOM – you configured grace period setting at product level.

GLOBAL – global grace period settings apply.

Period

String

 

Number of days set for the grace period.

PeriodUnits

String

 

D - Days.

IsUnlimited

Boolean

 

True or False depending on whether you set the grace peri2od to unlimited or not.

 

RenewalEmails 

Object (can be NULL)

Type 

String

 

GLOBAL - Send emails according to the global renewal notification settings.

CUSTOM – per product renewal notification settings

Settings

Object (can be NULL)

 

Details below.

 

Settings 

Object (can be NULL)

ManualRenewal

Object (can be NULL)

 

Details below.

AutomaticRenewal

Object (can be NULL)

 

Details below.

 

ManualRenewal

Object (can be NULL)

Before30Days 

Boolean

 

True or False.

Before15Days 

Boolean

 

True or False.

Before7Days 

Boolean

 

True or False.

Before1Day 

Boolean

 

True or False.

OnExpirationDate 

Boolean

 

True or False.

After5Days

Boolean

 

True or False.

After15Days 

Boolean

 

 

 

AutomaticRenewal

Object (can be NULL)

Before30Days 

Boolean

 

True or False.

Before15Days 

Boolean

 

True or False.

Before7Days 

Boolean

 

True or False.

Before1Day 

Boolean

 

True or False.

OnExpirationDate 

Boolean

 

True or False.

After5Days

Boolean

 

True or False.

After15Days 

Boolean

 

 

FulfillmentInformation

Object (can be NULL)

IsStartAfterFulfillment 

Boolean

 

True or False. Depending on whether you want the subscription lifetime to start afther the completion of the fulfillment process or not.

IsElectronicCode 

Boolean

 

True or False. Depending on whether you configure the delivery of keys/codes for the product or not.

IsDownloadLink 

Boolean

 

True or False. Depending on whether you configure the delivery of a product file or not.

IsBackupMedia 

Boolean

 

True or False. Depending on whether you configure the delivery of backup media or not.

IsDownloadInsuranceService 

Boolean

 

True or False. Depending on whether you enable the Download Insurance Service or not, for a product for which you configure a product file.

IsInstantDeliveryThankYouPage 

Boolean

 

True or False. Depending on whether you enable instant delivery in the Thank You page or not.

IsDisplayInPartnersCPanel 

Boolean

 

True or False. Depending on whether you share access to the product file with your channel partners or not.

CodeList 

Object (can be NULL)

 

Details below.

BackupMedia 

Object (can be NULL)

 

Details below.

ProductFile

Object (can be NULL)

 

Details below.

AdditionalInformationByEmail 

String (can be NULL)

 

The text you set up in the Additional fulfillment information - by email area.

AdditionalInformationEmailTranslations 

Object (can be NULL)

 

Array of localized Additional fulfillment information - by email texts.

AdditionalThankYouPage 

String (can be NULL)

 

The text you set up in the Additional fulfillment information - "Thank you" page area.

AdditionalThankYouPageTranslations 

Array (can be NULL)

 

Array of localized Additional fulfillment information - "Thank you" page texts.

 

CodeList 

Object (can be NULL)

Code 

String

 

The unique code list identifier.

Name 

String

 

Name of the code list.

Type 

String

 

Code list type:

  • STATIC
  • DYNAMIC

 

BackupMedia 

Object (can be NULL)

Code 

String

 

The unique backup media identifier.

Name 

String

 

Name of the backup CD/DVD.

Type 

String

 

Media type:

  • CD

 

ProductFile

Object (can be NULL)

Code 

String

 

Unique product file identifier.

Name 

String

 

Display name.

File 

String

 

Name of the product file.

Version 

String

 

File version.

Size

String

 

File size.

Type 

String

 

File type.

LastUpdate 

String

 

YYYY-MM-DD HH-MM-SS. Date time stamp when you last updated the file.

 

Create fixed discount

Overview

Use setPromotionDiscount to set a fixed promotion discount.

Parameters

Parameter Type/Description

sessionID

Required (string)

 

Output of the Login method.

promotionCode

Required (string)

 

The code corresponding to the promotion that you want to set the discount for.

promotionDiscount

Required(Object)

 

Type

Required (String)

 

 

Discount type:

  • PERCENT, use in combination with Value
  • FIXED, use in combination with Values and DefaultCurrency

 

Value / Values

Required (Int / Array of objects)

 

 

  • Value = Int, determines the discount percentage from 0 to 100
  • Values = Array of Value objects

 

 

Value

Required (Object)

 

 

 

Currency

Required (String)

 

 

 

 

Discount currency ISO code (ISO 4217).

 

 

 

Amount

Required (Int)

 

 

 

 

Discount amount in corresponding currency.

 

DefaultCurrency

Required (String)

 

 

Default discount currency ISO code (ISO 4217).

Response

Parameter Type/Description
promotionDiscount Object

Request

<?php
declare(strict_types=1);

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.2checkout.com/soap/6.0';
    public const ACTION = 'setPromotionDiscount';
    public const PROMOTION_CODE = "AB3WMME0UA";
    //array or JSON
    public const PAYLOAD = <<<JSON
{
  "Type": "FIXED",
  "DefaultCurrency": "USD",
  "Values": [
    {
        "Currency": "USD",
        "Amount": 10
    },
    {
        "Currency": "EUR",
        "Amount": 10
    }
  ]
}
JSON;
}

class Client
{
    private const LOGIN_METHOD = 'login';
    private $calls = 1;
    private $sessionId;


    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $hash = hash_hmac('md5', $string, $key);

        return compact('merchantCode', 'date', 'hash');
    }


    public function login(string $url)
    {
        $payload = $this->generateAuth();
        $response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
        $this->sessionId = $response['result'];
    }


    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION,
        string $promotionCode = Configuration::PROMOTION_CODE
    ): ?array {
        if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
            $this->login($url);
        }
        if(is_string($payload)) {
            $payload = json_decode($payload, true);
        }
        if (!empty($this->sessionId)) {
            $payload = [$this->sessionId, $promotionCode, $payload];
        }
        $payload = array_filter($payload);

        $request = json_encode([
            'jsonrpc' => '2.0',
            'method' => $action,
            'params' => $payload,
            'id' => $this->calls++,
        ]);
        $curl = curl_init($url);
        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', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if(empty($response)) {
            die('Server unavailable');
        }
        echo $response . '</br>';
        return json_decode($response, true);;
    }
}
$client = new Client();
$result = $client->call();
var_dump($result);

Order object structure

Parameters

Parameters Type/Description
RefNo String
  The unique, system-generated identifier of a partner order.
Status String
  Order status. Possible values: CANCELED, REFUND, TEST, REJECTED, COMPLETE, SUSPECT, AWAITING_PAYMENT, PENDING_APPROVAL, DELIVERY_NEEDS_INFO.
OrderLockReason StringArray
 

The reason why the order is blocked in a certain status.

 

For AWAITING_PAYMENT order status, the OrderLockReason can be: UNPAID_PROFORMA, NOT_ENOUGH_CREDIT

 

For order status DELIVERY_NEEDS_INFO, the OrderLockReason can be:

  • REQUIRED_END_USER_INFORMATION,
  • REQUIRED_RESELLER_INFORMATION,
  • REQUIRED_VENDOR_DELIVERY_CONFIRMATION

Can be NULL.

ProformaNumber String
 

The unique number of the partner invoice associated with this order. Can be NULL.

TotalAmount double
  The total value of the order, including tax, but excluding partner margins and discounts.
Currency String
  The order currency ISO code.
TotalSubbscriptionsNumber Int
  The total number of subscriptions generated for the products included in the order. Can be NULL, if subscriptions have yet to be generated for an order.

 

Pricing

Overview

Update subscription plan/product pricing using the Price Options Group and the Pricing Configuration objects. 

Price options group

Use this object to add/create and edit/update price options for your account.

Parameters

PriceOptionsGroup

Array of objects

Name

String

 

Price option group name.

 

Use this parameter when adding a new price options group.

 

To edit the name of a price option group use the Name parameter under the Translations object.

Description

String

 

Pricing option group description.

Translations

Array of objects

 

Details below.

Code

String

 

Unique code that the 2Checkout system generates or set for each pricing options group.

Type

String

 

The type of the pricing options group. Possible values:

· RADIO

· CHECKBOX

· INTERVAL

· COMBO

Options

Array of objects

 

Details below.

Required

boolean

 

True if you made the pricing option group mandatory.

 

Options

Object

Name

String

 

Pricing option child name.

Description

String

 

Pricing option child description.

Translations

Array of objects

 

Details below.

Code

String

 

The code you set or that the 2Checkout system generated for each pricing option child inside a pricing options group parent.

ScaleMin

Int

 

The minimum value of a scale interval set for each pricing option child inside a pricing options group parent of the type INTERVAL.

ScaleMax

Int

 

The maximum value of a scale interval set for each pricing option child inside a pricing options group parent of the type INTERVAL.

SubscriptionImpact

Object

 

Details below.

PriceImpact

Object

 

Details below.

Default

Boolean

 

TRUE for preselected options.

Missing for options that are not preselected.

 

SubscriptionImpact

Object

Months

String

 

The value in months the 2Checkout system adds or subtracts from the initial billing cycle of a subscription.

Impact

String

 

Possible values:

  • ADD
  • SUBTRACT
  • LIFETIME

 

PriceImpact

Object

ImpactOn

String

 

Possible values:

  • BASE corresponding to impact on base price
  • GLOBAL for impact on calculated sum.

Impact

String

 

Impact on price per unit:

  • ADD
  • SUBTRACT

Percent

String

 

The value of the percentage out of the price per product unit, when you use PERCENT for Method.

Method

String

 

Possible values:

· PERCENT

· FIXED

Amounts

Array of objects.

 

Details below.

 

Amount

Object

Currency

String

 

Currency ISO code - ISO 4217.

Amount

String

 

The amount defined for each specific currency active for your account, when you use FIXED for Method.

 

Translations

Object

Name

String

 

Localized product pricing options group name under PriceOptionGroup.

Localized pricing option child name under Options.

Description

String

 

Localized product pricing options group description under PriceOptionGroup.

Localized pricing option child description under Options.

Language

String

 

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

Price option group

Use this object to search for, retrieve information on price option groups (including those assigned to specific products) for your account.

Parameters

PriceOptionGroup

Array of objects

 

Name

String

 

Price option group name.

 

Use this parameter when adding a new price options group.

 

To edit the name of a price option group use the Name parameter under the Translations object.

Description

String

 

Pricing option group description.

Translations

Array of objects

 

Details below.

Code

String

 

Unique code that the 2Checkout system generates or set for each pricing options group.

Type

String

 

The type of pricing options group. Possible values:

  • RADIO
  • CHECKBOX
  • INTERVAL
  • COMBO

Options

Array of PriceOption objects

 

Details below.

 

PriceOption

Object

Code

String

 

The code you set or that the 2Checkout system generated for each pricing option child inside a pricing options group parent.

ScaleMin

Int

 

The minimum value of a scale interval set for each pricing option child inside a pricing options group parent of the type INTERVAL.

ScaleMax

Int

 

The maximum value of a scale interval set for each pricing option child inside a pricing options group parent of the type INTERVAL.

SubscriptionImpact

SubscriptionLifetimeImpact object

 

Details below.

PriceImpact

Object

 

Details below.

Default

Boolean

 

TRUE for preselected options.

Missing for options that are not preselected.

Name

String

 

Pricing option child name.

Description

String

 

Pricing option child description.

Translations

Array of objects

 

Details below.

 

SubscriptionLifetimeImpact

Object

Months

String

 

The value in months the 2Checkout system adds or subtracts from the initial billing cycle of a subscription.

Impact

String

 

Possible values:

  • ADD
  • SUBTRACT
  • LIFETIME

 

PriceImpact

Object

ImpactOn

String

 

Possible values:

  • BASE corresponding to impact on base price
  • GLOBAL for impact on calculated sum.

Impact

String

 

Impact on price per unit:

  • ADD
  • SUBTRACT

Percent

String

 

The value of the percentage out of the price per product unit, when you use PERCENT for Method.

Method

String

 

Possible values:

· PERCENT

· FIXED

Amounts

Array of objects.

 

Details below.

 

Amount

Object

Currency

String

 

Currency ISO code - ISO 4217.

Amount

String

 

The amount defined for each specific currency active for your account, when you use FIXED for Method.

 

Translations

Object

Name

String

 

Localized product pricing options group name under PriceOptionGroup.

Localized pricing option child name under Options.

Description

String

 

Localized product pricing options group description under PriceOptionGroup.

Localized pricing option child description under Options.

Language

String

 

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

Pricing configuration

Use this object to add/create and update/edit pricing configurations for your account. You can assign one or multiple price option groups to pricing configurations.

You identify a pricing configuration using its unique identifier: Code

Parameters

PricingConfiguration

Object

Name

String

 

Pricing configuration name.

Code

String

 

System-generated identifier. Read-only.

Default

Boolean

 

True for the default pricing configuration

BillingCountries

Array of strings

 

ISO codes of the countries assigned to the pricing configuration.

Empty unless specific countries are assigned to a pricing configuration.

PricingSchema

String

 

DYNAMIC – With a base price

FLAT – Without a base price

PriceType

String

 

Possible values:

• NET

• GROSS

DefaultCurrency

String

 

The ISO code of the default currency for the pricing configuration

Prices

Object

 

Details below.

PriceOptions

Array of objects

 

Details below.

 

Prices

Object

Regular

Array of objects

 

Details below.

Renewal

Array of objects

 

Details below.

 

Regular

Object

Amount

Int

 

The price of the product. Use -1 to delete it.

Currency

String

 

ISO code of the currency for the product price.

MinQuantity

Int

 

The minimum quantity of volume discounts. Default is 1.

MaxQuantity

Int

 

The maximum quantity of volume discounts. Default is 99999.

OptionCodes

Array of objects

 

Details below.

 

Renewal

Object

Amount

Int

 

The price of the product. Use -1 to delete it.

Currency

String

 

ISO code of the currency for the product price.

MinQuantity

Int

 

The minimum quantity of volume discounts. Default is 1.

MaxQuantity

Int

 

The maximum quantity of volume discounts. Default is 99999.

OptionCodes

Array of objects

 

Details below.

 

PriceOptions

Object

Code

String

 

System generated pricing options group code (you can also configure it) that the 2Checkout system uses to calculate product prices for pricing configurations without a base price.

Options

StringArray

 

The pricing options group option code you configured that the 2Checkout system uses to calculate product prices for pricing configurations without a base price.

 

Retrieve product group

Overview

Use the getProductGroup method to extract information about a specific product group you created for your account.

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.

groupCode Required (string)
  Unique, system-generated identifier assigned to product groups. 

Response

Parameters Type/Description

ProductGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$groupCode = 'YOUR_GROUP_CODE';

try {
    $MyProductGroup = $client->getProductGroup($sessionID, $groupCode);
}

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

var_dump("My Product Group", $MyProductGroup);


?>

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