Skip to main content

Mark leads as used and stop follow-ups

Overview

Use the markLeads method to mark a lead as used and/or stop follow-ups.

Request Parameters

Parameters Required Type/Description
LeadCode Required String. Unique system-generated identifier.
Used Required

Boolean. With possible values:

TRUE - 

FALSE - 

StopFollowups Required

Boolean. With possible values:

TRUE - 

FALSE - 

Request Example

<?php

require ('PATH_TO_AUTH');

$markLead = [
    'LeadCode' => '60E6C4B574',
    'StopFollowups' => false,
    'Used' => true
];

try {
    $leadData = $client->markLeads($sessionID, [$markLead]);
} catch (SoapFault $e) {
    echo "markLeads: " . $e->getMessage();
    exit;
}

var_dump("markLeads", $leadData);

Response Example

class stdClass#18 (2) {
  public $Response =>
  string(37) "1 leads have been marked successfully"
  public $Errors =>
  array(0) {
  }
}

Create EES token

Overview

Use the createEESToken method to be able to place orders with credit cards with installments and 2Pay.js.

Request Example

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.avangate.local/soap/6.0';
    public const ACTION = 'createToken';
    public const ADDITIONAL_OPTIONS = null;
    //array or JSON
    public const PAYLOAD = <<<JSON
{
    "Name": "Mike Doe",
    "CreditCard": "4111111111111111",
    "Cvv": "123",
    "ExpirationDate": "12\/21"
}
JSON;
}

class Client
{
    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?object {
        if (is_array($payload)) {
            $payload = json_encode($payload);
        }
        if (!empty($payload)) {
            // SoapClient works with objects(StdClass)
            $payload = json_decode($payload);
        }
        $soapClient = $this->getClient($url);
        $sessionId = $this->getSession($soapClient);
        $args = array_filter([$sessionId, $payload]);

        return $soapClient->$action(...$args);
    }

    public function getClient(string $url): SoapClient
    {
        return new SoapClient(
            $url.'?wsdl',
            [
                'location' => $url,
                'cache_wsdl' => WSDL_CACHE_NONE,
            ]
        );
    }

    public function getSession(SoapClient $client)
    {
        $date = gmdate('Y-m-d H:i:s');
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $string = strlen($merchantCode).$merchantCode.strlen($date).$date;
        $hash = hash_hmac('md5', $string, $key);
        $client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

        return $client->login($merchantCode, $date, $hash);
    }
}

$client = new Client();
$result = $client->call();
var_dump($result);

Upgrade price

Overview

Retrieve the upgrade price for a subscription.

Attributes

Parameters

Type/Description

BillingPrice

Double

 

The price Avangate charges the customer, without taxes.

BillingGrossPrice

Double

 

The price Avangate 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.

Discount Float
  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

Assign to product group

Overview

Use the assignProductGroup method to assign a product to a product group. Following the assignation, the 2Checkout system uses the shopping cart template associated with the product group as the default cart design when shoppers purchase a subscription plan/product.

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.

productCode

Required (string)

 

The code of the product you wish assigned to the group.

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

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$productCode = "YOUR_PRODUCT_CODE";
$groupCode = "YOUR_PRODUCT_GROUP_CODE";

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

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

?>

 

Renew a subscription

Overview

Renew a subscription in the Avangate system on-demand, controlling the number of days, price and currency of the extension. Use the renewSubscription method renew a subscription.

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.

subscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

 

Avangate charges customers using the payment data attached to subscriptions. In the case of credit/debit cards, if customers update their payment information in myAccount or if you update these details on behalf of your subscribers, the Avangate system uses the latest card info provided to charge subscription renewals.

days

Required (int)

 

The number of days the Avangate system extends the lifetime of the subscription.

price

Required (double)

 

The price that Avangate charges the customer for the renewal. This is the Net price.

currency

Required (string)

 

The currency associated to the renewal price - ISO 4217 code.

Response

Parameters Type/Description

Boolean

true or false depending on whether or not the operation succeeded.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$days = 4;
$price = 50;
$currency = 'eur';

$jsonRpcRequest = array (
'method' => 'renewSubscription',
'params' => array($sessionID, $subscriptionReference, $days, $price, $currency),
'id' => $i++,
'jsonrpc' => '2.0');

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

Set the pricing option for catalog products

Overview

Use the Product object option property to override the default pricing option defined in your 2Checkout Merchant Control Panel.

Use case

  1. Add an HTML link or button in your page like the one below.
  2. Create a JavaScript click handler to execute the InLine Client desired methods.
  3. Use theTwoCoInlineCart.products.add({code, quantity, options})method to prepare your catalog product.
  4. The options property should contain a list of objects with the name of the field and value.
  5. Use theTwoCoInlineCart.cart.checkout()method to show the cart on your page.

Sample request

HTML

<a href="#" class="btn btn-success" id="buy-button">Buy now!</a>

JavaScript

window.document.getElementById('buy-button').addEventListener('click', function() {
  TwoCoInlineCart.products.add({
    code: "74B8E17CC0",
    quantity: 3,
    options: [
      {
        name: '11234',
        value: 'new123'
      },
      {
        name: "DEMO_NUMBE_OF_PCS",
        value: "premiumversion"
      },
      {
        name: "DEVICES_5",
        value: "two_devices"
      }
    ]
  });
  TwoCoInlineCart.cart.checkout();
});

Demo

After overriding the default pricing option using the above method, your cart should look like this:

Retrieve SKU code by details

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

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

 

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