Skip to main content

Retrieve product groups

Overview

Use the getProductGroups method to extract information about the product groups you created for your account.

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.

Response

ProductGroup

Array of objects

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

try {
    $ProductGroups = $client->getProductGroups($sessionID);
}

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

var_dump("ProductGroups", $ProductGroups);


?>

ProductInfo Object Structure

Parameters

Parameter Type/Description
SimpleProduct Object
  Product object with the structure detailed below.
PriceOptions Object
  PriceOptionsGroupItem object with the structure detailed below.

 

Upgrade price

Overview

Retrieve the upgrade price for a subscription.

Attributes

Parameters Parameters

BillingPrice

Double

 

The price 2Checkout charges the customer, without taxes.

BillingGrossPrice

Double

 

The price 2Checkout charges the customer, including taxes.

BillingCurrency

String

 

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

Quantity

Int

 

The mandatory quantity for the upgrade (you cannot make partial upgrades)

DisplayPrice

Double

 

Display price.

DisplayGrossPrice

Double

 

Display price before deductions.

DisplayCurrency

String

 

Display currency. ISO 4217 code.

ProratedPrice String
 

Net prorated price for the upgrade.

If the calculated upgrade price is 0, the prorated price is also send as 0. 

If customers upgrade to a product with a lower price, the total and net prices will be 0, however, the Prorated Price will be the negative calculated value. Use this information in case you want to refund customers for upgrades to lower priced subscription plans.

ProratedGrossPrice String
 

Gross prorated price for the upgrade.

If the calculated upgrade price is 0, the prorated gross price is also 0. 

If customers upgrade to a product with a lower price, the total and net prices will be 0, however, the Prorated Gross Price will be the negative calculated value. Use this information in case you want to refund customers for upgrades to lower priced subscription plans.

Discount     Float
  Applied discounts
DiscountedProratedPrice Float
  Prorated net price for the upgrade with applied discounts
DiscountedProratedGrossPrice Float
  Prorated gross price for the upgrade with applied discounts
DiscountedBillingPrice Float
  Net billing price available for  the upgrade process with applied discounts
DiscountedBillingGrossPrice Float
  Gross billing price available for  the upgrade process with applied discounts
DisplayDiscount Float
  Discount displayed for the upgrade process
DiscountedDisplayPrice     Float
  Net display price available for the upgrade process with applied discounts
DiscountedDisplayGrossPrice     Float
  Gross display price available for the upgrade process with applied discounts

 

Retrieve product info by code

Overview

Use getProductByCode to extract product information using the unique identifier you assign to subscription plans/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

String

 

The product code that you control.

Response

Parameters Type/Description

Product

Object

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

$ProductCode = 'my_subscription_1';

try {
    $ProdbyCode = $client->getProductByCode($sessionID, $ProductCode);
}

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

var_dump("ProductInfo", $ProdbyCode);


?>

Retrieve price option groups

Overview

Use the searchPriceOptionGroups to extract information on the price option groups you configured.

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.

PriceOptionGroupSearch

Optional (object)

 

Details below

PriceOptionGroupSearch

Object

Details below

Name

Optional (string)

 

The name of the pricing options groups configured in the 2Checkout system.

Can be NULL.

Types

Optional (array)

 

Possible values:

  • RADIO
  • CHECKBOX
  • INTERVAL
  • COMBO

Can be NULL.

Limit

Optional (int)

 

Number of results displayed per page. Default maximum value is 10.

Can be NULL.

Page

Optional (int)

 

A specific page of search results. Default value is 1.

Can be NULL.

Response

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

try {
    $existentPriceOptions = $client->searchPriceOptionGroups($sessionID, $SearchOptions);
}

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

var_dump("existentPriceOptionst", $existentPriceOptions);

?>

Shipping method

Overview

The object below is returned directly or within a successful response from the following API requests:

Search shipping method

Shipping method object

Parameters   Type/Description
Items   Array of objects
      Contains shipping methods objects.
  ShippingMethod

Shipping method object.

Details below.

          Name String
      Shipping method name that you define when creating the method.
          Code String
      System-generated identified for the shipping method.
          TrackingURL String
      URL assigned to the shipping method. Provided to your customers that purchase physical products.
          BasePrice String
      Base fee attached to the shipping method, that will be charged to customers when shipping method is available in cart, regardless of their country, product value or weight.
          Currency String
      Currency in which the base fee is expressed. Example: 'USD'.
           Active Boolean
     

Possible values:

  • TRUE - if shipping method is active.
  • FALSE - if shipping method is inactive.
    Availability Strings
     

Defined where the shipping method is active.

Possible values:

  • ALL - all delivery countries.
  • CUSTOM - selected delivery countries.
  • HOME - only your home country.
    Countries Array of objects
      Countries where the shipping method applies.
                  CountryCode String
                  Two-letters country code.
                  Surcharge String
      Surcharge defined for each country.
    Surcharge Array of objects
      Additional fee assigned to the shipping method.
                 Type String
                 

Order property based on which the surcharge is added.

Possible values:

  • PRICE -  surcharge is based on total order amount.
  • WEIGHT -  surcharged is based on total order weight.
                 From Float
                  Lower interval limit.
                 To Int
      Higher interval limit.
                  Amount Int
      Surcharge defined based on order price/weight.
                 ApplyTo String
     

Possible values:

  • interval - surcharge is added for a given interval. Example: from 1 kg to 4kg.
  • unit - surcharge is added for each additional unit. Example: $5 for each unit over 4 kg.
  Pagination Object
      Pagination filters.
    Page Int
      Number of pages used for displaying the results.
    Limit Int
      Number for limiting the results.
    Count Int
      Total number of results.

 

Extend a subscription

Overview

Use the Extend functionality available in the Subscription info area to prolong the lifetime of a subscription or to reduce the period of time it can be used by a customer.

When the subscription lifetime settings are updated using the Extend functionality, these will take precedence and override per-product configuration.

Retrieve account balance

Overview

Use getPendingPayout to retrieve a detailed estimation of the amount that 2Checkout owes you, based on the sales from your current payout period.

The amounts returned by this API method are approximations, and may not represent the final amount that 2Checkout will pay you at the end of the billing period.

Parameters

Parameters Type/Description
inputParameters

Object (Optional)

Details below

  Currency String (Optional)
   

Use this parameter to show the balance only for a single order currency. Example: 'USD'.

If not sent, or sent as NULL, 2Checkout sends the balance for all order currencies.

  TotalCurrency String (Optional)
   

Use this parameter to show the total account balance in the preferred currency. Example: 'EUR'.

If not sent, or sent as NULL, 2Checkout sends the total balance in the default account currency.

Request

<?php

require('PATH_TO_AUTH');

$inputParameters = new StdClass();
$inputParameters->Currency = "USD";
$inputParameters->TotalCurrency = "EUR";

try {
    $pendingPayout = $client->getPendingPayout($sessionID, $inputParameters);
}
catch (SoapFault $e) {
    echo "pendingPayout: " . $e->getMessage();
    exit;
}
var_dump("pendingPayout", $pendingPayout);

Response

Pending Payout Object

Parameters   Type/Description
Currencies

Array of objects

Details below

  CurrencyObject

Object

Details below

    Currency

String

      Order currency.
    OrdersTotal

Object

Total order amounts, divided per order source.

                        estore Float
      eStore order amounts from the current payout cycle.
                       affiliates Float
      Amounts from your affiliates orders, during the current payout cycle.
                       partner Float
      Amounts from your partner sales, during the current payout cycle.
                        total Float
      Total sales amount made in the order currency from this object, during the current payout cycle.
  RetainedToDisputesBalance Float
      Amounts retained to your dispute balance reports, in the object order currency.
  ReleasedFromDisputesBalance Float
      Amounts released from your dispute balance reports, in the object order currency.
  RetainedToRollingReserveBalance Float
      Amounts retained to your rolling reserve, in the object order currency.
  ReleasedFromRollingReserveBalance Float
      Amounts retained to your rolling reserve, in the object order currency
  ChargebackFees Float
      Chargeback fees retained in the object order currency.
  ProcessingFees Float
      Processing fees retained by 2Checkout in the object order currency.
  AffiliatesCommission Float
      Affiliate commissions paid by 2Checkout in the object order currency.
  TaxCollected Float
      Tax collected by 2Checkout in the object order currency.
  EstimatedTotalRevenue Float
      The estimated total revenue for the object order currency.
Total    

Object

Total account balance amount

  Currency  

String

      Currency in which the total account balance is expressed. If not sent during the API call, 2Checkout uses the account default currency.
  OrdersTotal

 

Object

Total order amounts, divided per order source.

    estore Float
      Amounts from total eStore orders during the currency payout cycle.
                      affiliates Float
      Amounts from total affiliates orders during the currency payout cycle.
                      partner Float
      Amounts from total partner orders during the currency payout cycle.
                      total Float
      Total sales amount during the currency payout cycle.
  RetainedToDisputesBalance Float
      Total amounts retained to your dispute balance during the current payout cycle.
  RetainedFromDisputesBalance Float
      Total amounts released from your dispute balance during the current payout cycle.
  RetainedToRollingReserveBalance Float
      Total amounts retained to your rolling reserve during the current payout cycle.
  RetainedFromRollingReserveBalance Float
      Total amounts released from your rolling reserve during the current payout cycle.
  ChargebackFees Float
      Total chargeback fees retained from your account during the currency payout cycle.
  ProcessingFees Float
      Total processing fees retained by 2Checkout during the current payout cycle.
  AffiliatesCommission Float
      Total affiliates commissions paid by 2Checkout during the current payout cycle.
  TaxCollected Float
      Total tax amount collected by 2Checkout during the current payout cycle.
  EstimatedTotalRevenue Float
      Total estimated revenue for the current payout cycle.

 

Remove product coupon

Overview

Use this method to remove discount coupons applied to products added to cart.

Requirements

Parameters

Parameters Type/Description
sessionID Required (String)
  Session identifier, which is the output of the Login method. An exception is thrown if the values are incorrect
coupon Required (String)
  The coupon/voucher code for a promotion impacting a product added to cart.

Response

Parameters 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
require('PATH_TO_addProduct'); // addProduct example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/08Place_an_order/00Add_product_to_cart
require('PATH_TO_setCoupon'); // setCoupon example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/08Place_an_order/06Add_product_coupon

$couponCode = 'COUPON_CODE_TO_REMOVE';

try {
    $DeletedCoupon = $client->deleteCoupon ($sessionID, $couponCode);
} catch (SoapFault $e) {
    echo "Promotion: " . $e->getMessage();
    exit;
}
var_dump ("Promotion ", $DeletedCoupon);

Errors

Error Description

EMPTY_CART

The shopping cart is empty

INVALID_COUPON_CODE

The coupon code is empty

INVALID_COUPON

The coupon code is not applied to cart

 

Product group

Overview

Use the ProductGroup object to create/add and update/edit product groups. 

Parameters 

ProductGroup Object

Name

(string) Required when creating a product group.

 

The name of the product group.

Code (string ) Required when updating/retrieving a product group.
  Unique, system-generated identifier assigned to product groups. 

TemplateName

(string) Optional

 

Leave empty to assign the Default Template to the product.

 

Or use the name of an active shopping cart template.

Description

(string) Optional

 

The description of the product group.

 

 

 

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