Skip to main content

Disable a subscription

Overview

Use the cancelSubscription method to disable an active subscription. 2Checkout disables the subscription immediately and no longer performs any recurring billing actions.

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.

ChurnReasons Array
 

Possible values for this field are:

CHURN_REASON_NOT_SATISFIED_PRODUCT

CHURN_REASON_ENABLED_BY_MISTAKE

CHURN_REASON_PREFER_MANUAL

CHURN_REASON_ALREADY_RENEWED

CHURN_REASON_DONT_NEED

CHURN_REASON_WANT_PAUSE

CHURN_REASON_COVID

CHURN_REASON_HIGH_PRICE

CHURN_REASON_NOT_SATISFIED_SUPPORT

CHURN_REASON_EXTRAORDINARY

CHURN_REASON_OTHER

ChurnReasonOther String
  This field should have a value only if the ChurnReasons has the CHURN_REASON_EXTRAORDINARY or CHURN_REASON_OTHER values

Response

Parameters Type/Description

Boolean

true or false depending on whether the call resulted in success or not.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

$jsonRpcRequest = array (
'method' => 'cancelSubscription',
'params' => array($sessionID, $subscriptionReference),
'id' => $i++,
'jsonrpc' => '2.0');

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

Shipping fees

Overview

Use this object via JSON-RPC API 3.0 to retrieve information about shipping fees. 

Parameters

Parameter Type/Description

ShippingFee

Array of objects

Name

String

 

The name of the shipping fee configuration. 

Code String
  Unique, system-generated shipping fee identifier. 

Amount

String

 

The shipping costs

Currency

String

 

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

ApplyTo

String

 

Possible values:

• PRODUCT

• ORDER

Type

String

 

 

Possible values:

• FIXED

• PERCENT

 

 

 

Update pricing configuration

Overview

Use the updatePricingConfiguration method to update/edit an existing pricing configuration.

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.

PricingConfiguration

Required (object)

 

Use this object to update/edit an existing pricing configuration for your account.

ProductCode

Required (string)

 

The unique product code that you control not the system-generated product identifier.

You cannot modify:

  • The pricing configuration CODE.
  • The PricingSchema from DYNAMIC to FLAT or vice versa.
  • The intervals of an existing pricing configuration (MinQuantity and MaxQuantity).

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;
}
$PricingConfiguration                                                 = new stdClass();
$PricingConfiguration->Default                                        = FALSE;
$PricingConfiguration->Name                                           = 'lnxbc2hls0';
$PricingConfiguration->BillingCountries                               = array();
$PricingConfiguration->BillingCountries[0]                            = 'UK';
$PricingConfiguration->BillingCountries[1]                            = 'DE';
$PricingConfiguration->PricingSchema                                  = 'DYNAMIC';
$PricingConfiguration->PriceType                                      = 'NET';
$PricingConfiguration->DefaultCurrency                                = 'EUR';
$PricingConfiguration->Prices                                         = new stdClass();
$PricingConfiguration->Prices->Regular                                = array();
$PricingConfiguration->Prices->Regular[0]                             = new stdClass();
$PricingConfiguration->Prices->Regular[0]->Amount                     = 69.09;
$PricingConfiguration->Prices->Regular[0]->Currency                   = 'USD';
$PricingConfiguration->Prices->Regular[0]->MinQuantity                = 1;
$PricingConfiguration->Prices->Regular[0]->MaxQuantity                = 35;
$PricingConfiguration->Prices->Regular[0]->OptionCodes                = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Code       = 'G77ICHEM1C';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[0] = 'zh5onfolw7';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[1] = '75rjldfcnz';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Code       = 'BAWAQB8LZP';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[0] = 'r3oi06opvi';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[1] = '76gqbq4bhd';
$PricingConfiguration->Prices->Regular[1]                             = new stdClass();
$PricingConfiguration->Prices->Regular[1]->Amount                     = 64.66;
$PricingConfiguration->Prices->Regular[1]->Currency                   = 'USD';
$PricingConfiguration->Prices->Regular[1]->MinQuantity                = 36;
$PricingConfiguration->Prices->Regular[1]->MaxQuantity                = 83;
$PricingConfiguration->Prices->Regular[1]->OptionCodes                = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Code       = '8RNXV3T3RE';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[0] = 'rorqkqnd9p';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[1] = 'aeu89gqdg6';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Code       = 'DJYD713MKC';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[0] = 'y2z2squ7c1';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[1] = 'g74qfskbjg';
$PricingConfiguration->Prices->Renewal                                = array();
$PricingConfiguration->Prices->Renewal[0]                             = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->Amount                     = 7.89;
$PricingConfiguration->Prices->Renewal[0]->Currency                   = 'USD';
$PricingConfiguration->Prices->Renewal[0]->MinQuantity                = 84;
$PricingConfiguration->Prices->Renewal[0]->MaxQuantity                = 100;
$PricingConfiguration->Prices->Renewal[0]->OptionCodes                = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Code       = '73QCSXYH0E';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[0] = '54xu7mngqm';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[1] = 'p6m8im2unl';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Code       = '0QD0CF0OIE';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[0] = 'ytbac9wpmh';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[1] = 'lpkxxqsqxb';
$PricingConfiguration->Prices->Renewal[1]                             = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->Amount                     = 76.99;
$PricingConfiguration->Prices->Renewal[1]->Currency                   = 'USD';
$PricingConfiguration->Prices->Renewal[1]->MinQuantity                = 101;
$PricingConfiguration->Prices->Renewal[1]->MaxQuantity                = 544;
$PricingConfiguration->Prices->Renewal[1]->OptionCodes                = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]             = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Code       = '03APF0H4QF';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options    = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[0] = '15ce5uw2j6';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[1] = 'e88d5hk0tb';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]             = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Code       = 'PT00TYI2VY';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options    = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[0] = '10c24smlbl';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[1] = '0ondbwdk3q';
$PricingConfiguration->PriceOptions                                   = array();
$PricingConfiguration->PriceOptions[0]                                = new stdClass();
$PricingConfiguration->PriceOptions[0]->Code                          = 'FKQ8CFLYKM';
$PricingConfiguration->PriceOptions[0]->Required                      = false;
$PricingConfiguration->PriceOptions[1]                                = new stdClass();
$PricingConfiguration->PriceOptions[1]->Code                          = 'TH1HKFOTFR';
$PricingConfiguration->PriceOptions[1]->Required                      = true;

$ProductCode = '4643199';

try {
    $UpdatedPricingConfiguration = $client->updatePricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
}

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

var_dump("UpdatedPricingConfiguration", $UpdatedPricingConfiguration);


?>

Set pricing option for dynamic products

Overview

Use the Product object option property in order to define pricing options for dynamic products.

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. Set the dynamic mode for cart by callingTwoCoInlineCart.setup.setMode('DYNAMIC').
  4. Set your currency using theTwoCoInlineCart.cart.setCurrency('USD')method.
  5. Use theTwoCoInlineCart.products.add({name, quantity, price, options})method to prepare your dynamic products.
  6. The options property should contain a list of objects with the name of the field, it's value and surcharge.
  7. You can see below a signature token request payload for this example. A success response contains a JSON with the property  “signature“ which needs to be used at the next step to set the signature using the TwoCoInlineCart method.
{
    "merchant": "2COLRNC",
    "dynamic": "1",
    "currency": "USD",
    "products": [
        {
            "name": "A test dynamic product",
            "quantity": 1,
            "price": 20,
            "options": [
                {
                    "name": "color",
                    "value": "red",
                    "surcharge": 10
                },
                {
                    "name": "shape",
                    "value": "squared",
                    "surcharge": 20
                }
            ]
        }
    ]
}

The above payload will generate the signature 50a651873d3d8926f6bb62397f34b1ec7dd3373fc885b28466db8f4022060138.

8. Use the TwoCoInlineCart.cart.setSignature('50a651873d3d8926f6bb62397f34b1ec7dd3373fc885b28466db8f4022060138') method to set the signature. It is important that you employ TwoCoInlineCart.cart.removeAll() just before the TwoCoInlineCart.products.addMany(products) or TwoCoInlineCart.products.add(product) methods to remove previous products as the signature is based on the products' definition.

9. 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.setup.setMode('DYNAMIC');
  TwoCoInlineCart.cart.setCurrency('USD');
  
  TwoCoInlineCart.products.add({
    name: 'A test dynamic product',
    quantity: 1,
    price: 20,
    options: [
      {
        name     : 'color',
        value    : 'red',
        surcharge: 10
      },
      {
        name     : 'shape',
        value    : 'squared',
        surcharge: 20
      }
    ],
  });
  
  TwoCoInlineCart.cart.setSignature('50a651873d3d8926f6bb62397f34b1ec7dd3373fc885b28466db8f4022060138');
  TwoCoInlineCart.cart.checkout();
});

Demo

After setting the pricing options for dynamic products using the above method, your cart should look like this:

 

Search subscriptions

Overview

Extract information on your account’s subscriptions. Use the searchSubscriptions method to retrieve details about your account’s subscriptions, based on a set of filters. Subscriptions can be retrieved starting with 5 minutes after their orders are generated in the 2Checkout system.

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.

searchBy

Optional (Object)

 

Unique, system-generated subscription identifier.

Additional search filters

SubscriptionSearchOptions Parameters Type/Description

CustomerEmail

Optional (string)

 

Customer email address. Can be NULL.

Note:  The CustomerEmail parameter must be paired always with another reference pointing to the correct customer, such as the 2CheckoutCustomerReference parameter or the ExternalCustomerReference parameter. Otherwise, the search call will return partial hits on the customer email address.

ExactMatchEmail Optional (Boolean)
 

Force search by email to perform exact match; recommended to keep this option set to true in order to avoid matching similar email addresses from multiple customers.

DeliveredCode

Optional (string)

 

Activation key/code. Can be NULL.

2CheckoutCustomerReference

Optional (int)

 

System-generated customer reference. Can be NULL.

ExternalCustomerReference

Optional (string)

 

External customer reference that you control. Can be NULL.

Aggregate

Optional (boolean)

 

true - search will work across all your aggregated 2Checkout accounts.

false - default value. You limit the search to the account whose details you used for authentication.

Can be NULL.

SubscriptionEnabled

Optional (boolean)

 

true for enabled subscriptions.

false for disabled subscriptions.

Can be NULL.

RecurringEnabled

Optional (StringArray)

 

true – 2Checkout charges customers using recurring billing for subscriptions.

false – customers need to make manual payments to renew their subscriptions.

Can be NULL.

ProductCodes

Optional (StringArray)

 

Product identifier that you control. Can be NULL.

CountryCodes

Optional (string)

 

Country code (ISO 3166 two-letter code). Can be NULL.

PartnerCode Optional (string)
  Can be NULL.

PurchasedAfter

Optional (string)

 

YYYY-MM-DD. Subscription search interval start. You can search for subscriptions purchased between the dates you set using PurchasedAfter and PurchasedBefore. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

PurchasedBefore

Optional (string)

 

YYYY-MM-DD. Subscription search interval end. You can search for subscriptions purchased between the dates you set using PurchasedAfter and PurchasedBefore. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

ExpireAfter

Optional (string)

 

YYYY-MM-DD. Search subscriptions set to expire after a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

ExpireBefore

Optional (string)

 

YYYY-MM-DD. Search subscriptions set to expire before a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

ModifiedAfter Optional (string)
  YYYY-MM-DD HH-MM-SS. Search subscriptions modified after a specific date.
ModifiedBefore Optional (string)
  YYYY-MM-DD HH-MM-SS. Search subscriptions modified before a specific date.

RenewedAfter

Optional (string)

 

YYYY-MM-DD. Search subscriptions renewed after a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

RenewedBefore

Optional (string)

 

YYYY-MM-DD. Search subscriptions renewed before a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

NotificationAfter

Optional (string)

 

YYYY-MM-DD. Search subscriptions for which the 2Checkout system sent out notifications after a specific date. Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

NotificationBefore

Optional (string)

 

YYYY-MM-DD. Search subscriptions for which the 2Checkout system sent out notifications before a specific date Note: The default 2Checkout API time zone is GMT+02:00. Can be NULL.

NextBillingDateAfter Optional (string)
  YYYY-MM-DD. Search subscriptions with the next billing date after the specified date
NextBillingDateBefore Optional (string)
  YYYY-MM-DD. Search subscriptions with the next billing date before the specified date

Type

Optional (string)

 

trial - trial subscriptions.

regular - all generated subscriptions that are not trials.

regularfromtrial - subscriptions generated from a trial conversion.

Can be NULL.

TestSubscription

Optional (boolean)

 

true

false, depending on whether you want to include test subscriptions in the search or not. Can be NULL.

LifetimeSubscription

Optional (boolean)

 

true – evergreen subscriptions.

false - subscriptions with a limited recurring billing cycle, typically no larger than 36 months.

Can be NULL.

Page

Optional (int)

 

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

Can be NULL.

Limit

Optional (int)

 

Number of results (subscriptions) displayed per page. Default value is 10.

Can be NULL.

Response

Parameters Type/Description

Subscription

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$SubscriptionSearch = new stdClass();
$SubscriptionSearch->CustomerEmail  = 'example@email.com';
$SubscriptionSearch->DeliveredCode = null;
$SubscriptionSearch->AvangateCustomerReference = null;
$SubscriptionSearch->ExternalCustomerReference = null;
$SubscriptionSearch->Aggregate = false;
$SubscriptionSearch->SubscriptionEnabled = null; //true false null
$SubscriptionSearch->RecurringEnabled = null; // true - autorenewal, false - manual renewal, null = both(default)
$SubscriptionSearch->ProductCodes = null; //array('Product_Code1', 'Product_Code2');
$SubscriptionSearch->CountryCodes = null;//array ('au')
$SubscriptionSearch->PurchasedAfter = null;
$SubscriptionSearch->PurchasedBefore = null;
$SubscriptionSearch->ExpireAfter = null;
$SubscriptionSearch->ExpireBefore = null;
$SubscriptionSearch->LifetimeSubscription = null;
$SubscriptionSearch->Type = 'regular'; //'trial', 'regular', 'regularfromtrial'
$SubscriptionSearch->TestSubscription = null; // true, false, null = both(default) $SubscriptionSearch->Page = 1;$SubscriptionSearch->Limit = 25;
$SubscriptionSearch->Page = 1;
$SubscriptionSearch->Limit = 10;

$jsonRpcRequest = array (
'method' => 'searchSubscriptions',
'params' => array($sessionID, $SubscriptionSearch),
'id' => $i++,
'jsonrpc' => '2.0');

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

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

Optional (int)

 

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

Price

Optional (double)

 

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

Currency

Optional (string)

 

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

Response

Boolean

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


Retrieve options

Overview

Use the getProductUpgradeOptions method to retrieve the possible upgrade options for 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

Parameters Type/Description

Subscription upgrade

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

$jsonRpcRequest = array (
'method' => 'getProductUpgradeOptions',
'params' => array($sessionID, $subscriptionReference),
'id' => $i++,
'jsonrpc' => '2.0');

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

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

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