Skip to main content

Retrieve SKU code by details

Overview

Parameters

Response

Request

<?php

require ('PATH_TO_AUTH');

$skuDetailsObject = [];
$skuDetailsObject['PricingConfigurationCode'] = 'YOUR_CODE';
$skuDetailsObject['Currency'] = 'USD';
$skuDetailsObject['PurchaseType'] = 'NEW_PRODUCT';
$skuDetailsObject['PriceOptions'] = ['B'];
$skuDetailsObject['Quantity'] = 1;

try {
    $getProductByCode = $client->getSKUCodeByDetails($sessionID, $skuDetailsObject);
} catch (SoapFault $e) {

    echo  $e->getMessage();
}
var_dump($getProductByCode);

Shipping price

Overview

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

Retrieve shipping price

Shipping price object

Parameters Type/Description
Shipping prices available

Array of objects

Details below

  Name   String
      Name of the shipping method available for the cart configuration.
  Code   String
      System-generated identified assigned to the shipping method.
  TrackingURL String
      Tracking URL defined at shipping method leve.
  Currency   String
      Currency in which shipping prices are expressed.
  PriceDetails Object
          Details below.
           Net   Object
      Shipping price for a NET price configuration.
    TotalAmount Int
      Total shipping price charged from customers for a cart configuration.
    BasePrice Int
      Shipping method base price amount.
    OverweightAmount Int
      Overweight amount applied to the purchase.
    CountrySurcharge Int
      Surcharge applied based on customer delivery country.
    WeightSurcharge Int
      Surcharged applied based on total order weight.
    OrderSurcharge Int
      Surcharged applied based on total order amount.
           Gross   Object
      Shipping price for a GROSS price configuration.
    TotalAmount Int
      Total shipping price charged from customers for a cart configuration.
    BasePrice Int
      Shipping method base price amount.
    OverweightAmount Int
      Overweight amount applied to the purchase.
    CountrySurcharge Int
      Surcharge applied based on customer delivery country.
    WeightSurcharge Int
      Surcharged applied based on total order weight.
    OrderSurcharge Int
      Surcharged applied based on total order amount.

 

Add products to a promotion

Overview

Parameters

Response

Request

<?php 

class Client
{
    protected static $merchantCode;
    protected static $loginDate;
    protected static $hash;
    protected static $baseUrl;
    protected static $callCount = 0;
    protected static $sessionId = '';

    protected static $client;

    public static function setCredentials($code, $key)
    {
        static::$merchantCode = $code;
        static::$loginDate = gmdate('Y-m-d H:i:s');
        static::$hash = hash_hmac('md5', strlen($code) . $code . strlen(static::$loginDate) . static::$loginDate, $key);
        static::$sessionId = static::login();
    }

    public static function setBaseUrl($url)
    {
        static::$baseUrl = $url;
    }

    public static function login()
    {
        $client = static::getClient();
        return $client->login(static::$merchantCode, static::$loginDate, static::$hash);
    }

    public static function __callStatic($name, $arguments = array())
    {
        $client = static::getClient();

        array_unshift($arguments, static::$sessionId);
        $response = call_user_func_array(array($client, $name), $arguments);

        return $response;
    }

    protected static function getClient()
    {
        $opts = array(
            'http'=> ['user_agent' => 'PHPSoapClient'],
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        );

        if (null === static::$client) {
            static::$client = new \SoapClient(static::$baseUrl . '?wsdl', [
                'location' => static::$baseUrl,
                'cache_wsdl' => WSDL_CACHE_NONE,
                'stream_context' => stream_context_create($opts),
            ]);
        }

        return static::$client;
    }
}

Client::setBaseUrl('https://api.avangate.com/soap/3.1/');
Client::setCredentials('YOUR_MERCHANT_CODE', 'YOUR_SECRET_KEY');
Client::login();

// Define first product to add to promotion
$products1 = new stdClass;
$products1->Code = 'YOUR_PRODUCT_CODE';
$products1->PricingConfigurationCode = 'YOUR_PRICING_CONFIGURATION_CODE';
$products1->PricingOptionCodes = ['code1','code2','code3'];

// Define second product to add to promotion
$products2 = new stdClass;
$products2->Code = 'YOUR_PRODUCT_CODE2';
$products2->PricingConfigurationCode = 'YOUR_PRICING_CONFIGURATION_CODE2';

$promotionProducts = [$products1, products2]; // Array of product objects to be added to the promotion

// Retrieve promotion details
$promotionCode = 'YOUR_PROMOTION_CODE'; // code of the promotion that you want to add products to
$response = Client::addPromotionProducts($promotionCode,$promotionProducts);
var_dump($response);

Retrieve an affiliate by code

Overview

Use the getAffiliate method to extract details about an affiliate by code.

Request Parameters

Parameters Required Type/Description
AffiliateCode Required String. Unique code which represents an affiliate.

Request Example

<?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',
        'Cookie: XDEBUG_SESSION=PHPSTORM',
    ));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);


    if ($Debug) {
        var_dump($RequestString);
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        var_dump($ResponseString);
    }

    if (!empty($ResponseString)) {
//        var_dump($ResponseString);
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        var_dump($Response);

        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}


$apiVersion = '6.0';
$host = "http://api.sandbox34.avangate.local/rpc/" . $apiVersion . "/";

$merchantCode = "lucian";
$key = "SECRET_KEY";

$date = gmdate('Y-m-d H:i:s');

$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$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, $date, $hash);
$jsonRpcRequest->id = $i++;

$sessionID = callRPC($jsonRpcRequest, $host);
var_dump($sessionID);

$affiliateId = "79396127BA";
// Active:
// 1295 - 964CF2AF42
// 11541 - E4B69882C2
// 12951 - E8A1DB473C
// 12950 - 44857BFE94

// Pending:
// 13639 - F56BCF1E2E

// Rejected
// 65602 - 79396127BA

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getAffiliate';
$jsonRpcRequest->params = array($sessionID, $affiliateId);
$jsonRpcRequest->id = $i++;
echo "\nRESPONSE: \n\n";
$getAffiliate = callRPC($jsonRpcRequest, $host, false);

print_r(json_encode($getAffiliate));

Response Parameters

Parameters Description

AffiliateCode

Unique, system-generated identifying code of the affiliate.
Status Merchant Affiliate relationship status.
AffiliateName Name of the affiliate.
Website Website of the affiliate.
CommissionList Affiliate commission list.
                                        ListName Name of the affiliate commission list.
                                        CommissionRate Value of the commission rate (in %).
RequestDate  
Categories Product category  of the affiliate.
NotifyUpdates Boolean. Value can be TRUE or FALSE.
TCSStatus  
AffiliateContact Affiliate contact details.
                                         FirstName Affiliate first name.
                                         LastName Affiliate last name.
                                        Phone Affiliate phone number.
                                        Email Affiliate email.
                                        Country Country of the affiliate.

Response Example

{  
   "AffiliateCode":"TFTF76455ee4YFCFCT6545465",
   "Status":"Active",
   "Affiliate Name":"STIC Soft E-Solutions Private Limited",
   "Website":"https://debasis.2checkout.com",
   "CommissionList":  {  
         "ListName":"CommissionList1",
         "CommissionRate":"25%"
    },
   "RequestDate":"2018-10-05",
   "Categories":["PC security","Mobile security","Tablet security"],
   "TCStatus":"Accepted",
   "AffiliateContact":{  
      "FirstName":"FN",
      "LastName":"LN",
      "Phone":"0040723483987",
      "Email":"FN.LN@2AFFLT.COM",
      "Country":"Spain"
   }
}

 

Update a product group

Overview

Use the updateProductGroup method to update a product group 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.

ProductGroup

Required (object)

 

The product group name is used to identify the product group and cannot be changed in API v2.0. Use API 2.5 and above to change additional characteristics of product groups.

Response

bool(true)

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


$ProductGroup = new stdClass();
$ProductGroup->Name = 'New Product Group from API';
$ProductGroup->Code = 'DBA13A4268';
$ProductGroup->TemplateName = 'Default Template';//'001 - Two Column Billing'; //the name of the cart template you want to associate with the product group
$ProductGroup->Description = 'This is a generic description';
$ProductGroup->Enabled = false;


try {
    $UpdatedProductGroup = $client->updateProductGroup($sessionID, $ProductGroup);
}

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

var_dump("UpdatedProductGroup", $UpdatedProductGroup);


?>

Control recurring billing

Overview

Use this feature to control recurring billing (the automatic renewal system) for a specific subscription,  limiting the number of future payments, and preventing automated and manual renewals. Stopping automatic recurring billing does not cancel the subscription unless you also check the Cancel subscription when automatic billing ends option. Otherwise, customers have the option of using their subscription beyond the current billing cycle, provided that they purchase renewals manually. 

By using this feature you can:

  • Stop automatic recurring billing for a subscription either immediately or at a certain time in the future/after a number of billing cycles.
  • Cancel manual renewal emails for the subscription for which automatic recurring billing was stopped after a specific number of billing cycles and prevent the customers from renewing the subscription both manually and automatically after the last payment is made.

Availability

You can stop automatic billing for:

  • Active subscriptions
  • Expired subscriptions
  • Past due subscriptions
  • Subscriptions generated for products purchased with a payment method that supports recurring billing, such as credit and debit cards, PayPal and Direct Debit

Auto-renewal (automatic billing) is not available for:

  1. Lifetime subscriptions
  2. Expired subscriptions with the expiration deadline in the past (before the moment when you attempt to re-enable recurring billing).

Stop automatic recurring billing

To stop automatic recurring billing (auto-renewal):

  1. Go to Subscriptions management.
  2. Search for the subscription and edit its settings.
  3. Click Stop automatic billing.
  4. Enter the number of billing cycles to cancel the subscription after.
  5. Enable the Cancel subscription when automatic billing ends option.
  6. Click Apply.
  7. Once disabled, you can switch it back on, provided that payment data is available.

Options

Stop automatic billing:

  1. Now - This setting comes into effect at the end of the subscription's current billing cycle. If you also want to disable the subscription when it expires, check the Cancel subscription when automatic billing ends option. 2Checkout disables the automatic renewal system immediately after you click Apply and transitions the subscription to manual renewal payments. 2Checkout will no longer charge the customer automatically for the next billing cycle (when the automatic renewal of the subscription was scheduled). This option enables you to Send a notification email to the customer providing subscription level information about the automated recurring billing settings. When the Now option is selected, customers receive manual renewal emails according to the subscription renewal configuration and can use the links provided in the messages to purchase renewals. In addition, during the ordering process, customers will also have the option of re-enabling the automatic renewal system.
  2. After a specified number of billing cycles.  If you also want to disable the subscription when it expires, check the Cancel subscription when automatic billing ends option. The 2Checkout system stops automatic recurring billing after a specific number of billing cycles. Stopping automated recurring billing for subscriptions after a number of billing cycles cancels any manual renewal emails set to be sent to customers associated with the subscriptions according to the global or per-product renewal configurations. When recurring billing/the renewal system is disabled for a subscription, the 2Checkout system will no longer attempt to send the manual renewal messages to the customer using it. For subscriptions with the automatic recurring billing disabled after a number of billing cycles, the manual renewal link won't be visible to customers when they log into their myAccount platform.

FAQ

  1. Can I re-enable automated recurring billing?
    • You can re-enable automatic recurring billing and have subscriptions renewed automatically as well as customers charged per the recurring billing configuration of the products for which subscriptions were generated only in scenarios in which sufficient payment data is available in the 2Checkout system.  While re-enabling automatic recurring billing is possible for credit and debit cards, the option is missing for subscriptions paid using PayPal and Direct Debit, for which this functionality was disabled.
  2. Can I re-enable automatic billing for imported subscriptions?
    • Only for subscriptions that were imported into the 2Checkout system along with credit card information attached.
  3. Can I re-enable automatic billing for canceled subscriptions?
    • To re-enable automatic billing for canceled subscriptions, you need to first reactivate them. In addition, the subscriptions must have credit card information submitted in the 2Checkout system.
  4. Is this functionality supported for trial subscriptions?
    • Yes. You can disable and re-enable automatic recurring billing for trial subscriptions via the Control Panel or through the 2Checkout API. Customers can do the same when logged into their myAccount. The requirements mentioned above still have to be met. On top of the requirements enumerated above, the payment terminal must support auto-renewal, but the reference of the transaction made for the previous order is not required.
    • When the status of automatic billing is disabled, it means that the 2Checkout system has sufficient data for this functionality to be re-enabled to start charging the customer on the upcoming billing cycles.
    • When the status of automatic billing is N/A (not available), it means that the 2Checkout system does not have sufficient data for this functionality to be re-enabled to start charging the customer on the upcoming billing cycles. In this case, customers can renew their subscription manually and choose to reactivate automatic recurring billing (the renewal system) before placing their order.
    • Customers will be able to disable and re-enable the auto-renewal system of subscriptions on-demand, by logging into their myAccount.
    • Suggestion: In the eventuality in which you canceled automated recurring billing for a subscription after a number of billing cycles, but the new setting has yet to come into effect, you can increase the number of billing cycles and prolong the disabling of the automated recurring billing until after a maximum of 100 billing cycles, for example. Recurring billing will only stop when the number of billing cycles defined passes.
  5. Can customers continue to use any ongoing subscriptions they purchased?
    • Yes, but only through the duration of the current billing cycle or a number of billing cycles, as it was set when stopping recurring billing. Otherwise, disabling the renewal system has no impact on the subscription usage, it only keeps the 2Checkout system from automatically billing the customer, and the customer from renewing the subscription. Changes to automatic billing will only impact customers:
      • starting with the next automatic billing cycle/when the next payment is due - the option Now is selected;
      • after a number of billing cycles/payments according to the setting you configure.
  6. Can the subscription be manually renewed by the customer?
    • Only in scenarios in which you disabled automatic billing using the option Now. If you stop automatic billing after a number of billing cycles, customers will not be able to manually renew subscriptions for which the auto-renewal system/automated recurring billing was disabled.
    • Please bear in mind that when stopping automatic recurring billing after a number of billing cycles you also stop manual renewal subscriptions from being sent to customers, as such, the 2Checkout system will no longer offer the manual renewal link.
    • In addition, the manual renewal link is no longer available in myAccount for subscriptions with automatic recurring billing disabled.

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.

 

Retrieve a subscription

Overview

Extract information on a single subscription. Use the getSubscription method to retrieve details about a subscription. 

Parameters

Parameters

Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

SubscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

Response

Subscription

Object

Request


<?php
$host   = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/6.0/?wsdl", array(
    'location' => $host . "/soap/6.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 = 'F27CFE06ED';
try {
    $subscriptionInfo = $client->getSubscription($sessionID, $subscriptionReference);
}
catch (SoapFault $e) {
    echo "subscriptionInfo: " . $e->getMessage();
    exit;
}
var_dump("subscriptionInfo", $subscriptionInfo);

Order object

Overview

Use this object to create new orders and collect payments from shoppers. 

Supported payment methods

  1. Credit/Debit cards: Visa, Visa electron, MasterCard, Maestro, Amex, Discover, Dankort, Cartebleue, JCB. 2Checkout supports local Brazilian cards.
  2. PayPal and PayPal Express
  3. Purchase Order
  4. Wire
  5. Check
  6. WeChat Pay
  7. iDEAL
  8. Previous order references - In addition to the payment methods enumerated above, 2Checkout also supports1-click purchase flows in which you use valid previous order references belonging to returning customers to pay for new orders with their previously used cards and PayPal accounts. 

Object parameters

Parameters   Type/Description

RefNo

 

Optional (string)

 

 

Unique, system-generated, order reference number.

 

Do not include it when placing new orders or send it as NULL.

Currency

 

Optional (string)

 

 

The currency ISO code for the payment - ISO 4217. Example: “usd.”

Country

 

Optional (string)

 

 

Shopper country. ISO 3166 two-letter code. Example: “us.”

Language

 

Optional (string)

 

 

ISO 639-1 two-letter code. Language used for the purchase process. Example: “en.”

ExternalReference

 

Optional (string)

 

 

Set external reference identifiers for orders. Enables you to replicate the functionality of the REF parameter included into Buy Links. Maximum 100 characters. If there is a need for longer references, you can apply an md5 hash for any string value, resulting in a 32 characters string. You can verify the hash after the order notification, on the client side.

Source

 

Optional (string)

 

 

The link source for the sales. Enables you to replicate the functionality of the SRC (separate link identifier) parameter when included into Buy Links. Use the SRC parameter to track sale sources.

 

Maximum length 255 characters.

AffiliateId

 

Optional (int)

 

 

Identifier belonging to affiliates who refer orders.

CustomerReference

 

Optional (Int)

 

 

System-generated 2Checkout customer reference. Aggregate subscriptions under the same Customer account by adding the AV_CUSTOMERID (case sensitive) parameter to buy links. The 2Checkout system generates default customer numerical (integer) IDs (AV_CUSTOMERID) automatically for all orders containing products that feature subscriptions.

MachineId

 

Optional (string)

 

 

Unique, system generated code for each unique customer, identifying returning customers.

Items

 

Required (array of objects)

 

 

Details below. 

 

OrderItem

 

Object

 

 

 

 

Details below. 

 

 

Code

 

Required (string)

 

 

 

 

Unique product identifier your control. Max length 256 characters.

 

 

Quantity

 

Required (integer)

 

 

 

 

Number of units

 

 

PriceOptions

 

Optional (array of strings)

 

 

 

 

Array of price option codes.

 

 

SKU

 

Optional (string)

 

 

 

 

SKU identifier.

 

 

Price

 

Object - Can be NULL

 

 

 

 

OrderPrice

Object - Can be NULL

 

 

 

 

Currency

Optional (string)

 

 

 

 

 

 

 

The currency ISO code for the payment - ISO 4217. Example: usd.

 

 

 

 

NetPrice

Optional (double)

 

 

 

 

 

 

 

Order value excluding sales tax/VAT expressed in the payment currency.

 

 

 

 

GrossPrice

Optional (double)

 

 

 

 

 

 

 

Total order value, including sales tax/VAT expressed in the payment currency. GrossPricedoes not reflect any discounts.

 

 

 

 

NetDiscountedPrice

Optional (double)

 

 

 

 

 

 

 

The NetPrice order value excluding sales tax/VAT, from which 2Checkout deducts discounts. NetDiscountedPrice is expressed in the payment currency.

 

 

 

 

 

GrossDiscountedPrice

Optional (double)

 

 

 

 

 

 

 

Total costs shoppers incurexpressed in the payment currencyThis value includes sales tax/VAT, 2Checkout and affiliate commissions, but 2Checkout deducts the value of any discounts.

 

For example:

 

  • Currency: "usd"
  • NetPrice: 396
  • GrossPrice: 486.29
  • NetDiscountedPrice: 376.2
  • GrossDiscountedPrice: 466.49
  • Discount: 19.8
  • VAT: 90.29

AffiliateCommission: 94.05

 

 

 

 

 

Discount

Optional (double)

 

 

 

 

 

 

 

Value of the discounts for an order expressed in the payment currency.

 

 

 

 

 

VAT

 

Optional (double)

 

 

 

 

 

 

 

Value of sales tax/VAT expressed in the payment currency.

 

 

 

 

 

AffiliateCommission

Optional (double)

 

 

 

 

 

 

 

Value of the affiliate commission for the order calculated from the NetDiscountedPriceexpressed in the payment currency. Or NULL. 2Checkout does not take into account shipping costs when calculating affiliate commissions.

 

 

 

 

UnitNetPrice

Optional (double)

 

 

 

 

 

 

The value per product unit, excluding sales tax/VAT expressed in the payment currency.

 

 

 

 

UnitGrossPrice

Optional (double)

 

 

 

 

 

 

Total value per product unit, including sales tax/VAT expressed in the payment currency. UnitGrossPrice does not reflect any discounts.

 

 

 

 

UnitVAT

 

Optional (double)

 

 

 

 

 

 

Sales tax/VAT per product unit expressed in the payment currency.

 

 

 

 

UnitDiscount

Optional (double)

 

 

 

 

 

 

Value of the discount per product unit expressed in the payment currency.

 

 

 

 

UnitNetDiscountedPrice

Optional (double)

 

 

 

 

 

 

The value per product unit, expressed in the payment currency, excluding sales tax/VAT, from which 2Checkout deducts the unit discount.

 

 

 

 

UnitGrossDiscountedPrice

Optional (double)

 

 

 

 

 

 

Total costs shoppers incur per product unitexpressed in the payment currencyThis value includes sales tax/VAT, 2Checkout and affiliate commissions, but 2Checkout deducts the value of any discounts.

 

 

 

 

UnitAffiliateCommission

Optional (double)

 

 

 

 

 

 

Value of the affiliate commission per product unit calculated expressed in the payment currency.

 

2Checkout deducts discounts from the costs incurred by shoppers before calculating affiliate commissions.

 

2Checkout does not take into account shipping costs when calculating affiliate commissions.

 

NULL when 2Checkout does not apply an affiliate commission.

 

 

CrossSell

 

Object – Can be NULL

 

 

 

 

 

Details below. 

 

 

 

ParentCode

 

Optional (string)

 

 

 

 

 

The product code of the master product you set to trigger the campaign.

 

 

 

CampaignCode

 

Optional (string)

 

 

 

 

 

Unique, system-generated identifier for cross-sell campaigns.

 

 

Trial

 

Optional (Object) – Can be NULL

 

 

 

 

 

Details below. 

 

 

 

Period

 

Optional (integer)

 

 

 

 

 

The length of the trial subscription lifetime in days.

 

 

 

Price

 

Optional (double)

 

 

 

 

 

Total trial price in the payment currency before 2Checkout deducts any taxes, discounts, etc.

 

 

AdditionalFields

 

Optional (array of objects) – Can be NULL

 

 

 

AdditionalFieldSet

 

Optional (Object) – Can be NULL

 

 

 

 

Code

 

Optional (string)

 

 

 

 

 

 

The alpha-numeric characters, underscores and dashes that are set as the field identifier.

 

 

 

 

Value

 

Optional (string)

 

 

 

 

 

 

Selected field value.

    SubscriptionStartDate   Optional (string)
       

Specify the date time stamp when the subscription becomes active. Format 2016-07-02 22:22:22 (YYYY-MM-DD HH:mm:ss). Available for JSON-RPC and REST.

Send empty or NULL to activate subscriptions on the same date when customers purchase them.

You can exclude HH:mm:ss when sending the date and include only YYYY-MM-DD. In this case, 2Checkout uses 00:00:01. Default time zone GMT+02:00.

 

 

Promotion

 

Optional (Object)

 

 

 

 

 

Details below. 

 

 

 

Name

 

Optional (string)

 

 

 

 

 

Promotion name.

 

 

 

Description

 

Optional (string)

 

 

 

 

 

Promotion description.

 

 

 

StartDate

 

Optional (string)

 

 

 

 

 

The date when you set the promotion to start. NULL for promotions that start immediately after you create them.

 

 

 

EndDate

 

Optional (string)

 

 

 

 

 

The date when you set the promotion to end. NULL for promotions you want active indefinitely.

 

 

 

MaximumOrdersNumber

Optional (integer)

 

 

 

 

 

2Checkout only applies the promotion to a maximum number of orders you define.

 

Can be NULL if you want the promotion to apply to an unlimited number of orders.

 

 

 

MaximumQuantity

 

Optional (integer)

 

 

 

 

 

Discount only applies to a maximum number of units purchased through a single order, smaller than the quantity you defined. Shoppers purchase any extra units at full price. Can be NULL if you want the promotion to apply to an unlimited number units.

 

 

 

InstantDiscount

 

Optional (boolean)

 

 

 

 

 

The instant discount option auto-applies the discount for ALL selected products, without the need for shoppers to enter a discount coupon.

 

 

 

Coupon

 

Optional (string)

 

 

 

 

 

Promotion coupon/voucher.

 

 

 

DiscountLabel

 

Optional (string)

 

 

 

 

 

Discounts can be set as a percentage from the product price or as a fixed amount in the chosen currency.

 

 

 

Enabled

 

Optional (string)

 

 

 

 

 

true or false, depending on whether a promotion is active or disabled. 

 

 

 

Type

 

Optional (string)

 

 

 

 

 
  • REGULAR – product/cart line level discounts.
  • ORDER – quantity discounts.
  • GLOBAL – order-level discounts.

BillingDetails

 

Required (Object)

 

 

 

Details below. 

 

Person

 

Object

 

 

 

Details below. 

 

 

FirstName

Required (string)

 

 

 

Shopper name.

 

 

LastName

Required (string)

 

 

 

Shopper surname.

 

 

CountryCode

Optional (string)

 

 

 

Shopper country. ISO 3166 two-letter code.

 

 

State

Optional (string) – Required for US, Brazil, India and Romania

The state in the shopper's country. Mandatory when you set the Billing Country to US, Brazil, India and Romania. Use case insensitive utf8 strings for the full name, or just the two letter code.

 

 

 

 

 

City

Optional (string)

 

 

 

Shopper city.

 

 

Address1

Optional (string)

 

 

 

Shopper address.

 

 

Address2

Optional (string)

 

 

 

Shopper address.

 

 

Zip

Optional (string)

 

 

 

ZIP/ Postal code.

 

 

Email

Optional (string)

 

 

 

Shopper email address.

 

 

Phone

Optional (string)

 

 

 

Shopper phone number. Mandatory when you set Brazil as the Billing Country. Can be NULL.

 

 

Company

Optional (string)

 

 

 

Company name. Can be null for end users. When present, you also need to provide the FiscalCode.

 

FiscalCode

Optional (string) – Required for Brazil

 

 

• For companies, it needs to be the VAT ID. 2Checkout will validate the value provided and throw an error if the VAT ID is invalid/incorrect when calling setPaymentDetails. When present, you also need to provide the Company name.

• Mandatory when you set Brazil as the Billing Country. For Brazilian customers it represents the Fiscal Code (CPF/CNPJ).

• Mandatory when you set India as Billing Country, and purchase is made by a Company.

• Can be NULL for end users.

DeliveryDetails

Required (Object)

 

 

Details below. 

 

Person

Object

 

 

 

Details below. 

 

 

FirstName

Required (string)

 

 

 

Shopper name from the delivery details.

 

 

LastName

Required (string)

 

 

 

Shopper surname from the delivery details.

 

 

CountryCode

Optional (string)

 

 

 

Shopper country. ISO 3166 two-letter code from the delivery details.

 

 

State

Optional (string) – Required for US, Brazil and Romania

 

 

 

The state in the shopper's country from the delivery details. Mandatory when you set the Billing Country to US, Brazil and Romania. Use case insensitive utf8 strings for the full name, or just the two letter code.

 

 

City

Optional (string)

 

 

 

Shopper city from the delivery details.

 

 

Address1

Optional (string)

 

 

 

Shopper address from the delivery details.

 

 

Address2

Optional (string)

 

 

 

Shopper address from the delivery details.

 

 

Zip

Optional (string)

 

 

 

ZIP/ Postal code from the delivery details.

 

 

Email

Optional (string)

 

 

 

Shopper email address from the delivery details.

 

 

Phone

Optional (string)

 

 

 

Shopper phone number from the delivery details. Mandatory when you set Brazil as the Billing Country. Can be NULL.

 

 

Company

Optional (string)

 

 

 

Company name from the delivery details. Can be null for end users. When present, you also need to provide the FiscalCode.

PaymentDetails

 

Required (Object)

 

 

Adapt this object to the desired payment method.

 

Type

 

Required (string)

 

 

 

The payment method:

  • CC (credit/debit card - including local Brazilian cards).
  • ENCRYPTED_PAYMENT_DATA (client-side encryption)
  • PAYPAL
  • PAYPAL_EXPRESS
  • CCNOPCI(credit/debit card for non-PCI certified merchants).
  • TEST (for test orders).
  • PREVIOUS_ORDER(place new orders using the reference of a previous order).
  • EXISTING_PAYMENT_DATA  (use a card one of your customers already used to purchase from your account).
  • WIRE – the placeOrder response includes Wire payment details.
  • CHECK – the placeOrder response includes Check payment details.
  • WE_CHAT_PAY (for WeChat payments).
  • IDEAL (for iDEAL payments).
  • PURCHASEORDER - use for orders with POs.
  • FREE – for 0 value orders for which you’re not requiring customers to provide payment details.

 

 

Currency

 

Optional (string)

 

 

 

The currency ISO code for the payment - ISO 4217. Example: “usd.”

 

PaymentMethod

 

Optional (object)

 

 

 

Object structure and parameters differ according to payment method selected and API method (placing orders (POST) vs. retrieving order data (GET)).

 

NULL for 0 value orders for which you’re not requiring customers to enter payment details.

                                                         RecurringEnabled   Optional (boolean)
     

true – shopper checks the auto-renewal checkbox and 2Checkout charges subscription renewals using a recurring billing process.

false – shopper doesn’t check the auto-renewal checkbox.

 

 

 

CardPayment

 

Optional (object)

 

 

 

 

 

 

Details below. 

 

 

 

 

CardNumber

 

Optional (string)

 

 

 

 

 

 

The credit/debit card number.

 

 

 

 

CardType

 

Optional (string)

 

 

 

 

 

 

visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb, hipercard, elo

 

 

 

 

ExpirationYear

 

Optional (string)

 

 

 

 

 

 

The year in which the card expires.

 

 

 

 

ExpirationMonth

 

Optional (string)

 

 

 

 

 

 

The month in which the card expires.

 

 

 

 

HolderName

 

Optional (string)

 

 

 

 

 

 

Card holder name.

 

 

 

 

CCID

 

Optional (string)

 

 

 

 

 

 

Credit Card Identification - an extra ID printed on the card, usually a 3-4 digit number, the CVC2/CVV2.

        HolderNameTime Optional (float)
           

The interval of time in seconds in which shoppers enter their name in the HolderName field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

        CardNumberTime Optional (float)
           

The interval of time in seconds in which shopper enter their card number in the CardNumber field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

 

 

 

 

InstallmentsNumber 

Optional (Int)

 

 

 

 

 

 

Number of installments. Available only when customers un Brazil pay with Visa or MasterCard using Brazilian Real as the order currency. Use 1 or exclude the parameter for full payments. 

 

 

 

PayPalExpress

 

Optional (object)

 

 

 

 

 

 

Details below. 

 

 

 

 

Email

 

Optional (string)

 

 

 

 

 

 

Email address customers use for their PayPal account.

 

 

 

 

ReturnURL

 

Optional (string)

 

 

 

 

 

 

The PayPal Express Checkout redirect URL returned by calling the getPayPalExpressCheckoutRedirectURL method. The return URL is the page on your website to which PayPal redirects your buyer's browser after the buyer logs into PayPal and approves the payment. Typically, this is a secure page (https://...) on your site.

 

 

 

 

CancelURL

 

Optional (string)

 

 

 

 

 

 

The cancel URL is the page on your website to which PayPal redirects your buyer's browser if the buyer does not approve the payment. Typically, this is the secure page (https://...) on your site from which you redirected the buyer to PayPal.

 

 

 

PreviousOrder

 

Optional (Object)

 

 

 

 

 

 

Details below. 

 

 

 

 

RefNo

 

Optional (string)

 

 

 

 

 

 

Order reference a previous purchase which reached the Approved/Complete status. You can use order for which customers paid with credit/debit cards or with PayPal. The status of order should be AUTHRECEIVED or COMPLETE.

 

Check the validity of references with the isValidOrderReference method.

 

The 2Checkout system blocks you from using references for fraudulent or potentially fraudulent orders.

 

 

 

PurchaseOrderPaymentDetails

 

Optional (Object)

 

 

 

 

 

 

Details below. 

 

 

 

 

InternalPONumber

Optional (string)

 

 

 

 

 

 

Identifier that business customers use internally in their organization to track and manage Purchase Orders (PO). Can be NULL.

 

 

 

 

AutoApprove

 

Optional (boolean)

 

 

 

 

 

 

TRUE - requires activation of the PO AutoApprove package (If the package is inactive 2Checkout returns an error). Please contact 2Checkout. When AutoApprove is TRUE, 2Checkout no longer requires that business customers upload a PO document. As such, PO orders are automatically approved for your account, without a PO doc. 2Checkout sets the PURCHASE_PENDING status for auto-approved PO orders.

FALSE - Default. Send this if the PO AUtoApprove package is not available for your account. 2Checkout uses the same flow as cart purchases with Purchase Orders for business customers placing orders with POs via API. This means that customers receive the same emails as if they made the purchase using the cart and need to update the PO document, which is reviewed by 2Checkout and that you need to approve. 2Checkout sets the AVAITING_UPLOAD status for POs andUnfinished for their orders.

 

Can be NULL.

      WE_CHAT_PAY   Optional (string)
          Details below
        ReturnURL   Optional (string)
            The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL   Optional (string)
            The cancel URL is the page to which your customers are redirected after their failed payment attempt.
      IDEAL   Optional (string)
          Details below
        ReturnURL   Optional (string)
            The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL   Optional (string)
            The cancel URL is the page to which your customers are redirected after their failed payment attempt.
        BankCode   Required (string)
            String contains the SWIFT code of the bank, the plus sign "+", and the first 3 characters from the bank name. E.q.: in the case of Rabobank, code parameter is "RABONL2U+RAB".

 

 

 

EXISTING_PAYMENT_DATA

 

Optional (Object)

 

 

 

 

 

By using EXISTING_PAYMENT_DATA you no longer require shoppers to enter any payment details.

 

 

 

 

TransientToken

 

Optional (string)

 

 

 

 

 

 

Returned as a part of the process of retrieving customer information by SSOToken.

 

CustomerIP

 

Required (string)

 

 

 

Shopper IP.

Promotions

 

Optional (Array of strings)

 

 

Array of promotion codes.

AdditionalFields

 

 

 

 

 

Details below. 

 

Code

 

Optional (string)

 

 

 

The alpha-numeric characters, underscores and dashes that are set as the field identifier.

 

Text

 

Optional (string)

 

 

 

Field text visible to shoppers in the cart.

 

Value

 

Optional (string)

 

 

 

Selected field value.

LocalTime

 

Optional (string)

 

 

Local shopper time in the following format: Y-m-d H:i:s.

This parameter can impact the fraud score of an order when it's missing, NULL or incorrectly formatted.

GiftDetails

 

Optional (object)

 

 

Contains contact details for the recipient of a gift purchase.

 

FirstName

 

Optional (string)

 

 

 

First name of gift recipient.

 

LastName

 

Optional (string)

 

 

 

Last name of gift recipient.

 

Email

 

Optional (string)

 

 

 

Email of gift recipient. 2Checkout uses this email for the delivery/fulfillment process.

 

GiftNote

 

Optional (string)

 

 

 

Custom text shoppers provide as a message to the gift recipient.

 

 

Add reseller information

Overview

Use this method to add information about a reseller in the Avangate system.

Requirements

Parameters

Parameters Type/Description
sessionID Required (string)
  Session identifier, output of the Login method. An exception will be thrown if the values are incorrect.
Reseller Required (object)

Response

Parameters Type/Description
ResellerCode String
  Unique code identifying a specific reseller.

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

$NewReseller = new stdClass();
$NewReseller->ResellerCode = '1234565';
$NewReseller->Company = 'Avangate';
$NewReseller->FirstName = 'John';
$NewReseller->LastName = 'Doe';
$NewReseller->Email = 'johndoe@example.com';
$NewReseller->Phone = '123456789';
$NewReseller->Fax = '12345';
$NewReseller->Country = 'US';
$NewReseller->State = 'CA';
$NewReseller->City = 'Palo Alto';
$NewReseller->Address = 'Street';
$NewReseller->PostaCode = '90210';

try {
    $NewReseller= $client->createReseller($sessionID, $NewReseller);
} catch (SoapFault $e) {
    Echo "NewReseller: " . $e->getMessage();
    exit;
}
var_dump ("NewReseller ", $NewReseller);

Errors

Error Description

NOT_FOUND_PARTNER

A partner must be set first.

EMPTY_RESELLER_FIRST_NAME

Reseller first name is mandatory.

EMPTY_RESELLER_LAST_NAME

Reseller last name is mandatory.

EMPTY_RESELLER_COMPANY

Reseller company is mandatory.

INVALID_RESELLER_EMAIL

Reseller email is mandatory.

INVALID_RESELLER_EMAIL

Invalid reseller email provided.

INVALID_COUNTRY

Invalid reseller country code.

INTERNAL_ERROR

Reseller information could not be saved.

 

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