Skip to main content

Create promotion

Overview

Use the addPromotion method via SOAP API 6.0 to create a new promotion.

Parameters

Parameters

Type/Description

sessionID

Required (String)

 

Output of the Login method.

Promotion

Object

 

Name

Optional(String)

 

 

Promotion name

 

Description

Optional(String)

 

 

Promotion description

 

StartDate

Optional(String)

 

 

Starting date. The date when you set the promotion to start. Is NULL for promotions that start immediately after they're created.

Format: Y-m-d

 

EndDate

Optional(String)

 

 

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

Format: Y-m-d

 

MaximumOrdersNumber

Optional(Int)

 

 

Avangate stops offering the discount when the promotion reaches the maximum number of orders. Can be NULL if you want the promotion to apply to an unlimited number of orders.

 

MaximumQuantity

Optional(Int)

 

 

Discount only applies to a specific number of products, smaller than the maximum quantity you defined. Can be NULL if you want the promotion to apply to an unlimited number of units. Any extra quantity added to the cart will be sold at full price.

 

InstantDiscount

Optional(Boolean)

 

 

Selecting the instant discount option will auto-apply the discount for ALL the selected products for all shoppers, without the need to enter the discount coupon.

Coupon

Optional(Object)

 

Type

Optional(String)

 

 

  • SINGLE = one coupon code shared by all shoppers
  • MULTIPLE = array of unique coupon codes, each designed for individual use

 

Code/Codes

Optional(String/Array)

 

 

Varies according to type. Send:

  • Code = 'single_code'; when Type = 'SINGLE';
  • Codes = ['code1', 'code2']; when Type = 'MULTIPLE';

Enabled

Optional(Boolean)

 

TRUE

FALSE

ChannelType

Optional(String)

 

Possible values:

  • ECOMMERCE
  • CHANNEL_MANAGER
  • ALL

Type

Optional(String)

 

REGULAR

Discount

Optional(Object)

 

Type

Optional(String)

 

 

Discount type:

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

 

Value / Values

Optional (Int / Array of objects)

 

 

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

 

 

Value

Optional(Object)

 

 

 

Currency

Optional (String)

 

 

 

 

ISO currency code

 

 

 

Amount

Optional (Int)

 

 

 

 

Discount amount in corresponding currency.

 

DefaultCurrency

Optional(String)

 

 

ISO code

Products

Optional(Object)

 

Code

Optional(Int)

 

 

Unique product code that you control.

 

PricingConfigurationCode

Optional(String)

 

 

Unique system generated pricing configuration code.

 

PricingOptionCodes

Array of strings

 

 

Array of pricing option codes controlled by you.

PriceThreshold

Object

 

Limits discount use only when total order value (taxes included) exceeds the threshold you configure.

 

Amount

Decimal

 

 

The minimum threshold you defined for the default currency.

 

Currency

String

 

 

Currency code available for the default currency of custom threshold settings.

Translations

Optional(Array of objects)

 

PromotionTranslation

Optional(Object)

 

 

Name

Optional(String)

 

 

 

Localized name corresponding to translated language.

Name: Le product

Language: FR

 

 

Language

Optional(String)

 

 

 

 

Sources

StringArray

 

Array of strings defining the sale source through the SRC parameter.

PublishToAffiliatesNetwork

Optional(Int)

 

 

ApplyRecurring

Optional(String)

 

  • NONE
  • ALL
  • CUSTOM

RecurringChargesNumber

Optional(Int)

 

Offer discounts for a number of recurring billing charges beyond the initial purchase.

Response

Parameters Type/Description
Promotion Object

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


$promotionObject = new stdClass;
$promotionObject->Name = 'YOUR_PROMOTION_TITLE';
$promotionObject->Description = 'YOUR_PROMOTION_DESCRIPTION';
$promotionObject->StartDate = date('Y-m-d', strtotime('1 month ago'));
$promotionObject->EndDate = date('Y-m-d', strtotime('+1 month'));
$promotionObject->Type = 'REGULAR';
$promotionObject->Enabled = 1;
$promotionObject->MaximumOrdersNumber = 0;
$promotionObject->MaximumQuantity = 0;
$promotionObject->InstantDiscount = false;
$promotionObject->ChannelType = 'ECOMMERCE';
$promotionObject->ApplyRecurring = 'NONE';
$promotionObject->RecurringChargesNumber = 3;
$promotionObject->PublishToAffiliatesNetwork = 0;
$promotionObject->InstantDiscount = 0;

$couponObject = new stdClass;
$couponObject->Type = 'SINGLE';
$couponObject->Code = 'single_code';
$promotionObject->Coupon = $couponObject;

$discountObj = new stdClass;
$discountObj->Type = 'PERCENT';
$discountObj->Value = 80;
$promotionObject->Discount = $discountObj;
$promotionObject->Products = [$productsObj1, $productsObj2, $productsObj3];
$promotionObject->Translations = [$translation1, $translation2];

Client::setBaseUrl('https://api.avangate.com/soap/3.1/');
Client::setCredentials('YOUR_MERCHANT_CODE', 'YOUR_SECRET_KEY');
Client::login();
$response = Client::addPromotion($promotionObject);
var_dump($response);

Top 3 converting purchase flows (funnels)

Overview

2Checkout offers you multiple purchases flows that you can use to drive your shoppers through the shopping cart, all the way to the 'Finish' page:

  1. Checkout with cart functionalities
  2. One page checkout without review
  3. One page checkout with review
  4. Add to Shopping Cart
  5. Checkout page
  6. Product page
  7. Express Payments Checkout

After carefully analyzing a selection of our customers' shopping cart performance, we've come up with the three recommended purchase flows that are generating the most sales.

If you are just starting to sell with 2Checkout and this is your first time choosing a purchase flow, you can't go wrong with one of the three detailed below.

If you already have some experience with the 2Checkout platform, we advise you to continually A/B test purchase funnel conversion rates, and you can begin by trying the purchase flows described below and compare their performance with the flow that you are currently using.

Performance

Before we dive into the actual flows, we'd like to give you a short overview of the conversion rates identified on them. 

  • The Checkout Page flow is the top performer
  • The One Page Checkout With Review flow is a runner up
  • The Express Payments Checkout funnel took home the bronze

Checkout page

The purchase flow with the highest measured conversion rate, this flow offers a non-editable purchase experience.

How it works: Your shoppers land on the billing page having the product options already added to their shopping cart.

Best fit: Quick and seamless checkout scenarios, with minimal input from your shoppers.

 

One page checkout with review

Another one of our best converting purchase flows, perfect if you want to provide a sleek and fast purchase experience to your shoppers.

How it works: The shopping cart summary, billing information and the payment details are all on the same page.

Best fit: The biggest advantage of this flow is giving your shoppers the opportunity to fill in all the required information in one page.

Express payments checkout

The third of our best converting purchase flows minimizes billing data entry depending on the selected payment method and facilitates high volumes of payments via PayPal.

How it works: Use the CARD URL parameter to control the flow:

  • use CARD=1 to enable Express payments checkout with review
  • use CARD=2 to enable Express payments checkout without review (this is the default behavior)

Best fit: This purchase flow allows you to take advantage of the optimized design to further streamline the available one page checkout flows.

Conclusion

These are our top three best converting purchase flows. 2Checkout offers you complete control over the shopping experience along with support to optimize the cart to boost conversion rates. However, keep in mind that conversion rate optimization is not a one size fits all technique, so we advise you to try them out and see what works best for you.

We also recommend running A/B testing campaigns to try out different purchase flows on different segments of your traffic and optimize your shopping cart accordingly.

When running an eCommerce business, one of the most important indicators of success is clearly your conversion rate. While many businesses invest a lot of time and money in optimizing the conversion rate of their websites or online stores, it's critical to understand that this process doesn't end with shoppers reaching the shopping cart. This is actually only half of the trick.

Curb cart abandonment and unfinished payments

Overview

As many as 70% to 80% of customers abandon online shopping carts. On top of this, issues preventing successful transaction finalization can impact the shoppers sticking with their order until the end of the purchase funnel. This leaves your business facing the harsh reality of converting only approximately 2 out of every 10 visitors into paying customers.

Follow-up emails for monetizable leads

Instead of settling for only $20 out of every potential $100 of revenue, you need to reach out to untapped leads. Follow-up emails can help you recover up to 20% of your lost customers. The 2Checkout system continually harvests monetizable leads, and it’s up to you to use them to:

  • Increase the conversion rate for the customer acquisition stage
  • Boost subscriber retention with dunning management for recurring billing

Follow the best practices below to curb cart abandonment and collect unfinished payments.

Shopping cart abandons

Shopping cart abandonment is a common issue and happens for various reasons: comparison shopping, lack of money, undecided shoppers, pricing research before trial & buy. A surprising number of shoppers return within a few days to continue shopping, and it's up to you to ease their conversion into paying customers. Here is an easy way to adopt the abandoned cart follow-up configuration:

Type

When

Why?

Basic follow-up

1 hour

Speed is of the essence. Short attention span plagues online shoppers, so the sooner the lead management system can generate and send a follow-up message the better. As a rule of thumb, the first follow-up should reach potential customers within one hour to be as efficient as it can.

Make it easy for customers to return to the shopping cart without having to go back through the purchase process.

Basic follow-up

1 day

Promotional follow-up

3 days

A little incentivizing goes a long way. Offer discounts to make it very hard for an already interested customer to say no.

For ConvertPlus and InLine cart initiated orders, promotions supported are product level promotions (regular and special price promotions) managed directly in the Promotions area.

Unfinished payments

Placed orders for which the payment process was not finished - reasons can vary: expired cards, insufficient funds, authorization declined, etc.

Type

When

Why?

Instant payment methods

1 hour

1 day

3 days

Configure follow-up messages for unfinished payments and increase order recovery rate to as much as 25% from all transaction failures.

 

Offline payment methods

1 day

3 days

7 days

Direct Debit

3 days

7 days

Dunning management

Instantaneous

2Checkout sends out email notifications to subscribers in danger of churning out because their recurring charge failed with a hard decline, an irrecoverable transaction error.

Hard declines recovery with Dunning management, leading to a 15% recovery rate.

Customize follow-up emails

Target your subscribers granularly for each of the scenarios detailed above. Differentiate the lead management emails sent to customers based on the types of unfinished payment, cart abandonment, or dunning events, building custom strategies to target failed recurring transactions effectively.

Contact 2Checkout directly to customize follow-up emails to increase their success rate.

Update customer

Overview

Use the updateCustomerInformation method to update the details of a customer entity from 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.

Customer

Object (required)

Use this object to update customer information.

UpdateEndUserSubscriptions

Optional (boolean)

You can push the changes made on the customer info to the end-user details for all subscriptions belonging to this customer. Set true to have the changes reflected on the end-user details for all subscriptions. If null or false, the changes are made only at the customer level. Default value is false.

Response

Parameters Type/Description

Boolean

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

Request

<?php

require ('PATH_TO_AUTH');

$customerReference = CUSTOMER_REFERENCE;
$externalCustomerReference = 'EXTERNAL_CUSTOMER_REFERENCE'; //Optional, but if you include it it needs to belong to the same customer as the internal 2Checkout customer reference

$jsonRpcRequest = array (
'method' => 'getCustomerInformation',
'params' => array($sessionID, $customerReference, $externalCustomerReference),
'id' => $i++,
'jsonrpc' => '2.0');

$existingCustomer = callRPC((Object)$jsonRpcRequest, $host, true);
$existingCustomer->Email = 'newemailaddress@email.com';
$UpdateEndUserSubscriptions = false; // Optional, but if true the changes made on customer info are pushed to all subscriptions from this customer.

$jsonRpcRequest = array (
'method' => 'updateCustomerInformation',
'params' => array($sessionID, $existingCustomer, $UpdateEndUserSubscriptions),
'id' => $i++,
'jsonrpc' => '2.0');

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

Add products

Overview

Use addPromotionProducts to add products to an existing promotion.

Parameters

Parameter Type/Description

sessionID

Required (string)

 

Output of the Login method.

promotionCode

Required (string)

 

The code corresponding to the promotion that you want to add products to.

promotionProducts

Required (object)

 

Code

Required (string)

 

 

System generated product code.

 

pricingConfigurationCode

Optional (string)

 

 

System generated pricing configuration code.

 

pricingOptionCodes

Optional (array of strings)

 

 

Pricing option codes that you control.

Response

Parameter Type/Description
PromotionProducts Object

Request

<?php

require ('PATH_TO_AUTH');

$promotionCode = 'MY_PROMO_CODE_1';

// Define a product to add to the promotion
$newProduct1 = new stdClass;
$newProduct1->Code = '';
$newProduct1->PricingConfigurationCode = '';
$newProduct1->PricingOptionCodes = ['',''];

// Define another product to add to the promotion
$newProduct2 = new stdClass;
$newProduct2->Code = '';
$newProduct2->PricingOptionCodes = [''];

$productPromotion = [$newProduct1, $newProduct2];

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addPromotionProducts',
'params' => array($sessionID, $promotionCode, $productPromotion)
);
var_dump (callRPC($jsonRpcRequest, $host));

Single sign-on (SSO)

Overview

Use this method to redirect and login users of the Channel Manager/Partner account automatically from your system into their CM/Partner account based on their email address. This method connects third-party systems with the 2Checkout Channel Manager/Partner Control Panel and enables your partners to seamlessly sign in to their Control Panel.

getPartnerSingleSignOn logs the partner users only into the Channel Manager account associated with your 2Checkout account. This method will not replicate the functionality of a full sign-in operation for users who partnered with multiple 2Checkout vendors and are leveraging connected partner accounts.

Requirements

This method requires you to set a specific partner using setPartner.

Parameters

Parameter Type/Description
sessionID Required (String)
  Session identifier, output of the Login method. An exception is thrown if the values are incorrect.
email Required (String)
  Channel Manager/Partner user account email address.
partnerCode Required (String)
  Unique partner identifier.
accessPage Required (String)
 

The specific Channel Manager / Partner control panel page you want the user to be redirected to.

Possible values:

You can use any URL in the Channel Manager/Partner Control Panel, including links to specific orders, subscriptions/licenses, and partner invoices.

validityTime Optional (Int)
  The time, in seconds, before the single sign-on URL returned by this method expires. By default, the URL expires after 10 seconds.
validationIP Optional (String)
  The IP address of the Channel Manager/Partner Control Panel user, required for security purposes. Can be an empty string or a valid IP, but cannot be NULL.

Response

Parameter Type/Description
Single sign-on URL String
 

The string is the complete single sign-on URL with a token to allow authentication into Channel Manager from external domains. Partner account users are logged in automatically to their Channel Manager accounts.

The URL can be used only once and only within the interval of time in which it's valid. Call this method again to generate a new single sign-on URL for a subsequent login action.

Request

<?php

require('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.2checkout.com/Integration/Channel_Manager_API/SOAP/02Authentication
require('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.2checkout.com/Integration/Channel_Manager_API/SOAP/06Reference/Partner/00Set_partner

$email = 'YOUR_PARTNER_EMAIL';
$partnerCode = 'YOUR_PARTNER_CODE';
$accessPage = 'YOUR_ACCESS_PAGE_URL';
$validityTime = VALIDITY_TIME;
$validationIP = 'VALIDATION_IP_ADDRESS';

try {
    $PartnerSingleSignon= $client-> getPartnerSingleSignOn ($sessionID, $email, $partnerCode , $accessPage, $validityTime, $validationIP);
} catch (SoapFault $e) {
    echo "SSO: " . $e->getMessage();
    exit;
}
var_dump ("SSO", $PartnerSingleSignon);

Errors

Error Description

INVALID_EMAIL

The email address is mandatory.

INVALID_EMAIL

Please specify a valid email address.

INVALID_PARTNER

The partner code is mandatory.

INVALID_PARTNER

Partner code provided is not associated to an active partner account.

INVALID_USER

Email address provided is not associated to a partner account user.

INVALID_URL

The page URL is mandatory.

INVALID_URL

The page URL provided is not valid.

INVALID_VALIDITY_TIME

Validity time needs to be a positive numeric value.

INTERNAL_ERROR

Cannot save security token. Please try again.

 

Turn on auto-advance feature

Overview

Use the Cart object to turn on the auto-advance feature (if mandatory fields are filled in) on the InLine checkout by calling the TwoCoInlineCart.cart.setAutoAdvance(true) method.

Use case

  1. Add an HTML link or button on your page like the one below.
  2. Create a JavaScript click handler to execute the InLine Client desired methods.
  3. Use the TwoCoInlineCart.products.add({code, quantity, options}) method to prepare your catalog product.
  4. Turn on the auto-advance feature by calling the TwoCoInlineCart.cart.setAutoAdvance(true) method.
  5. Set all the mandatory fields for billing.
TwoCoInlineCart.billing.setCountry('US');
TwoCoInlineCart.billing.setEmail('some@email.com');
TwoCoInlineCart.billing.setName('John Doe');

6. Use the TwoCoInlineCart.cart.checkout() method to show the cart on your page.

Request sample

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"
    });
    TwoCoInlineCart.cart.setAutoAdvance(true);
      TwoCoInlineCart.billing.setCountry('US');
    TwoCoInlineCart.billing.setEmail('some@email.com');
    TwoCoInlineCart.billing.setName('John Doe');
    TwoCoInlineCart.cart.checkout();
});

Demo

After turning on the cart auto-advance feature using the above method, your cart should look like this:

 

 

Set cart lock in the InLine Cart

Overview

Use the Cart object to lock products by calling the TwoCoInlineCart.cart.setCartLockedFlag(true)method.

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. In order to set currency use TwoCoInlineCart.cart.setCurrency(currency-code).
  5. To lock products use TwoCoInlineCart.cart.setCartLockedFlag(true)method.
  6. 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": "AVLRNG",
    "currency": "USD",
    "lock": 1,
    "products": [
        {
            "code": "74B8E17CC0",
            "quantity": 3
        }
    ]
}

The above payload will generate the signature ba6ad53ac1cb699daad64bb1d3ef6ab72050787f62a3137d5090c96173a05e85.

7. Use the TwoCoInlineCart.cart.setSignature('ba6ad53ac1cb699daad64bb1d3ef6ab72050787f62a3137d5090c96173a05e85') method to set the signature.

8. 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.cart.setCurrency('USD');
  TwoCoInlineCart.products.add({
    code: "74B8E17CC0",
    quantity: 3
  });
  TwoCoInlineCart.cart.setSignature('ba6ad53ac1cb699daad64bb1d3ef6ab72050787f62a3137d5090c96173a05e85');
  TwoCoInlineCart.cart.setCartLockedFlag(true);
  TwoCoInlineCart.cart.checkout();
});

Demo

After locking the product page using the above method, your cart should look like this:

 

Product Upgrade Schema

Overview

Use the setProductUpgradeSchema method to set a product’s upgrade schema via API.

Parameters

Parameter Type Required Description
UpgradeSettings Object Required Details below.

          PricingScheme

Integer Required

The Upgrade pricing scheme.
1 – Shopper pays the full upgrade product price;
2 – Shopper pays the difference between the original subscription and the upgraded product;
3 - Shopper pays a prorated upgrade price calculated using the most recent costs incurred by the customer;
4 – Shopper pays prorated upgrade price calculated using the product's pricing set up at the time of the order.

          OptionPriceOperator String Optional The operator that specifies how is the upgrade price impacted (not used for prorated upgrade pricing schemes):
- ADD – the value set as OptionPricePercentage is added to the  upgrade price;
- SUBTRACT – the value set as OptionPricePercentage is subtracted from the upgrade price.
          OptionPricePercentage Integer Optional The percentage of the upgrade price to be added/subtracted from this one (not used for pro-rated upgrade pricing schemes).
          UseProductCatalogPricing Boolean Optional When true, it enables the usage of product catalog pricing. Removing custom prices also disables any existing retention campaigns for the selected subscriptions.
          ProrateIgnoreGracePeriod Boolean Optional When true, it makes the grace period be ignored when calculating Upgrade. Use this option to ignore the grace period set in your Renewal Settings when computing the prorated price for the upgrade.
          SubscriptionUpgradeType Integer Required Determines the Subscription period option for the upgrade:
1 - Create a new subscription (disable the existing one);
2 - Prolong the subscription from the upgrade purchase date;
3 - The upgrade does not affect the original subscription duration. If you upgrade a lifetime subscription to a product that has recurring options, the subscription will remain lifetime, as its duration is not affected by the upgrade process.
AllowUpgradeFrom Array of Strings Required List of product codes corresponding to the products that can be upgraded to the product of reference.

Request sample

<?php

//require_once(realpath(__DIR__ . '/../../../../../') . "/lib/api/v6.0/vendor/autoload.php");
require_once("/srv/www/app/live/htdocs/lib/api/v6.0/vendor/autoload.php");

$apiVersion = '6.0';
$domain = 'api.avangate.local:8081';
$host = "http://{$domain}/soap/{$apiVersion}/";

$client = new SoapClient($host . "?wsdl", array('location' => $host, 'cache_wsdl' => WSDL_CACHE_NONE));
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

// AlexB Inc account #21478
$merchantCode = "120000589445";
$key = "i9u2+w8%s4^5#8%t)A8?";
$productCode = "ADEV17962UPGRADE";            // main upgrade product offered as upgrade for other products
$upgradeFromProductCode1 = "ADEV17962UPOPT1"; // product that can be upgraded #1
$upgradeFromProductCode2 = "ADEV17962UPOPT12"; // product that can be upgraded #2

$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);

try {
    $sessionID = $client->login($merchantCode, $date, $hash);
} catch (SoapFault $e) {
    echo  $e->getMessage();

}
echo "SessionID: " . $sessionID . PHP_EOL;

$upgradeSchema = new stdClass();

/** @var \Api\Resources\Product\Assets\UpgradeSettings $upgradeSettings */
$upgradeSettings = new stdClass();
$upgradeSettings->PricingScheme = \Api\Resources\Product\Assets\UpgradeSettings::PRICING_SCHEME_PRICE_DIFFERENCE;
$upgradeSettings->OptionPriceOperator = \Api\Resources\Product\Assets\UpgradeSettings::OPTION_PRICE_OPERATOR_SUBSTRACT;
$upgradeSettings->OptionPricePercentage = 2;
$upgradeSettings->SubscriptionUpgradeType = \Api\Resources\Product\Assets\UpgradeSettings::SUBSCRIPTION_UPGRADE_TYPE_PROLONG_SUBSCRIPTION;
#$upgradeSettings->SubscriptionUpgradeType = 8; // invalid value
$upgradeSettings->UseProductCatalogPricing = true;
#$upgradeSettings->UseProductCatalogPricing = new SoapVar(5, XSD_INTEGER); // integer value 5 => will trigger exception
$upgradeSettings->ProrateIgnoreGracePeriod = false;

$upgradeSchema->UpgradeSettings = $upgradeSettings;
$upgradeSchema->AllowUpgradeFrom = [$upgradeFromProductCode1, $upgradeFromProductCode2];

$payload = json_encode($upgradeSchema, JSON_PRETTY_PRINT);

echo PHP_EOL . 'Calling ' . $host . ' with productCode: ' . $productCode . ' and payload: ' . PHP_EOL . $payload . PHP_EOL;

try {
    $resp = $client->setProductUpgradeSchema($sessionID, $productCode, $upgradeSchema);
} catch (SoapFault $e) {
    echo  '(SoapFault) Exception caught: ' . $e->getMessage() . PHP_EOL;
    die();
}

echo PHP_EOL . 'SetUpgradeSchema response:' . PHP_EOL . var_export($resp, true) . PHP_EOL;

Response

{
    "UpgradeSettings": {
        "PricingScheme": 1,
        "OptionPriceOperator": "ADD",
        "OptionPricePercentage": 3,
        "SubscriptionUpgradeType": 2,
        "UseProductCatalogPricing": false,
        "ProrateIgnoreGracePeriod": false
    },
    "AllowUpgradeFrom": [
        "ADEV17962UPOPT12"
    ]
}

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