Skip to main content

Retrieve configuration by name

Overview

Use the getPricingConfigurationByName method to extract information on a specific pricing configuration you set for a 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 editable code that you control at product-level, not the unique, system-generated product ID.

pricingConfigurationName

Required (string)

 

The name of the pricing configuration.

schemaType

Required (string)

 

  • FLAT (without Base Price)
  • DYNAMIC (with Base Price)

priceType

Optional (string)

 

Possible values: NET or GROSS

Response

Parameters Type/Description

PricingConfiguration

Object

Request

<?php

require ('PATH_TO_AUTH');

$productCode = 'subscr1';
$pricingConfigurationName = 'EU prices';
$schemaType = 'DYNAMIC';// FLAT or DYNAMIC
$priceType = 'NET'; // or GROSS

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getPricingConfigurationByName',
'params' => array($sessionID, $productCode, $pricingConfigurationName, $schemaType, $priceType)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

?>

Retrieve configuration by code

Overview

Use the getPricingConfigurationByCode method to extract information on a specific pricing configuration you set for a 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 editable code that you control at product-level, not the unique, system-generated product ID.

pricingConfigurationCode

Required (string)

 

The code of the pricing configuration.

 

Response

Parameters Type/Description

PricingConfiguration

Object

Request

<?php

require ('PATH_TO_AUTH');

$productCode = 'YOUR_PRODUCT_CODE';
$pricingConfigurationCode = 'YOUR_PRICING_CONFIGURATION_CODE';

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getPricingConfigurationByCode',
'params' => array($sessionID, $productCode, $pricingConfigurationCode)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

?>

Subscription additional information fields

Overview

Use this object to create, update and retrieve additional information fields from your subscriptions.

Attributes

Parameters Type/Description

fieldName

String

 

The name of the additional information field. Used for identifying additional information fields.

fieldValue

String

 

The value of the additional information field.

 

Collect payment data for free orders

Overview

Configure 2Checkout to collect payment details for full discount/zero value orders, and charge shoppers for all subsequent renewals at full price. Take advantage of this feature to incentivize potential customers to start using your software/service by providing it free of charge initially.

Drive shoppers to use your service by offering it completely free of charge for the first month, or the first billing cycle, whatever it might be. Set zero value prices via On-the-fly-pricing when configuring the purchase flow for your products. Alternatively, you can define 100% discounts for specific products/services, applying solely to the first transaction. Note: Discounts need to be equal to the value of the product or larger.

SaaS businesses can benefit from the increased appeal added to services through promotions, but this feature can also contribute to increasing your customer base and revenue even if you're selling subscription-based software.

Free or paid trials with payment details are also a viable alternative to offering customers the chance to try out your software/service free of charge or for minimal costs. To kick-off the trial, users need to first provide valid payment information, ensuring that you'll be able to charge for usage once the trial period expires, provided that no cancelations occur.

Availability

All 2Checkout accounts.

If you are using ConvertPlus and InLine shopping carts, keep in mind that zero value orders are obtained using regular (product level) promotions, generating 100% discount. For the moment, order level promotions are not supported on ConvertPlus and InLine carts.

Requirements

For the billing information to be requested from the shopper the following criteria must be met:

  • The service/product needs to have a renewal interval defined.
  • The purchase flow needs to be Checkout with cart functionalities. When a different purchase flow is selected, the system automatically defaults to Checkout with cart functionalities (the same as for the trial process).
  • Supported payment methods: VISA/MasterCard/Eurocard, American Express, JCB, PayPal, Discover/Novus, Direct Debit, Dankort.

Usage

After we've activated the Collect payment data for free orders feature for your account, follow the steps below to enable it.

  1. Log into your Merchant Control Panel.
  2. Go to Setup -> Ordering options
  3. Enable the Collect Payment details for full discount or orders with zero value option.

Collect payment details for full discount or orders with zero value.PNG

3. Save the settings.

Note: If unchecked, shoppers that already benefited from the discount will not be affected. New customers attempting to purchase a service/product for which you offer a full discount but do not require payment information, will not need to enter their billing details to complete the order.

When your shoppers provide payment details they're informed that no charges will be made and that a transaction will be done only for authorization purposes. Once the initial subscription period, which you offer for free, runs out, the 2Checkout system will use the payment data collected in order to charge customers the sum you set when configuring the pricing scheme of your service/product. Similarly, charges will continue to be made with every new renewal.

Why use Full discount/zero value orders with payment details and not Free trials with payment details?

It's really a matter of preference since the two options are somewhat similar in nature. However, there are a number of key differences that make Full discount/zero value orders with payment details a superior strategy for onboarding new shoppers compared to Free trials with payment details.

Full discount orders with payment details

Free trials with payment details

Customers actually acquire services/products.

Users only start a trial.

Shoppers feel more comfortable providing you with their billing information since they're purchasing offerings while taking advantage of a full discount for the initial subscription interval.

Since they're accessing a free trial, potential customers might be reluctant to hand over their sensitive payment details.

Discounts impact all sales of the product they're associated with, regardless of the buy links that your shoppers will use.

Free trials with payment details need to be configured for each buy link for the products you want your shoppers to try. Buy links are different from free trial links, and different pricing strategies might apply.

 

Renew a subscription

Overview

Renew a subscription in the 2Checkout system on-demand, controlling the number of days, price, and currency of the extension. Use the renewSubscription method to renew 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.

 

2Checkout 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 2Checkout system uses the latest card info provided to charge subscription renewals.

Days

Required  (int)

 

The number of days the 2Checkout system extends the lifetime of the subscription.

Price

Required (double)

 

The price that 2Checkout charges the customer for the renewal. The type of price, Gross or Net, is decided by the product setting in the Merchant Control Panel.

Currency

Required (string)

 

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

Response

Boolean

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

Request

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


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

    if (!empty($ResponseString)) {
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}

$host = 'https://api.2Checkout.com/rpc/3.0/';

$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

$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$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, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;

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

var_dump($sessionID);

var_dump($sessionID);
$subscriptionReference = 'AF168DD240';
$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));

Retrieve information on promotions

Overview

Use the searchPromotions method to extract information on promotions you set up for your account.

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.

Types

StringArray

 

Discount type:

  • REGULAR
  • GLOBAL
  • RENEWAL

Channel

String

 

Channel:

  • ECOMMERCE
  • CHANNEL_MANAGER
  • ALL

ProductCode

String

 

Unique code that you set for each of your products.

Limit

Int

 

Number of results returned by the method.

Page

Int

 

Results pagination.

Response

Promotion object.

Request

<?php

require ('PATH_TO_AUTH');

$searchOptions = new stdClass();
$searchOptions->Types = array ('REGULAR');
$searchOptions->Channel = 'ECOMMERCE';
$searchOptions->ProductCode = 'Product_Code_1';
$searchOptions->Enabled = TRUE;
$searchOptions->Limit = 99;
$searchOptions->Page = 1;

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'searchPromotions',
'params' => array($sessionID, $searchOptions)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
?>

Retrieve assigned price option groups

Overview

Use the getAssignedPriceOptionGroups method to extract information about the price option groups you assigned to one of your products.

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 editable code that you control at product-level, not the unique, system-generated product ID.

Response

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');
 
$productCode = 'YOUR_PRODUCT_CODE';
 
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getAssignedPriceOptionGroups',
'params' => array($sessionID, $productCode)
);

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

Upgrade a subscription

Overview

Use the setSubscriptionUpgrade method to upgrade a subscription.

Requirements

You can only upgrade subscriptions with automatic renewal enabled.

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.

productCode

Required (string)

 

Unique identifier of the target product for the subscription upgrade process. You control the product code and can set it up in the Control Panel.

options

Optional (string)

 

Pricing options of the target product for the subscription upgrade process.

 

String - ';' separated list of 'OptionValue' returned by getProductUpgradeOptions function.

If the pricing options groups is "scale" (interval), the Options parameter should be sent like this: [option group unique code] + "=" + value

e.g. Users=7

customPrice

Optional (string)

 

The price you want to charge customers for the upgrade. The currency used by default is the same as in the previous payment customers made.

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';
$productCode = 'YOUR_PRODUCT_CODE';
$options = 'YOUR_PRICE_CODES'; //case sensitive; include only price options codes (exclude spaces)
$customPrice = 1;

$jsonRpcRequest = array (
'method' => 'setSubscriptionUpgrade',
'params' => array($sessionID, $subscriptionReference, $productCode, $options, $customPrice),
'id' => $i++,
'jsonrpc' => '2.0');

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

Retrieve shipping price

Overview

Use getShippingPrice to retrieve the shipping method and price available, based on a current cart configuration. This API call returns the available shipping methods defined in your Control Panel, together with the fees you configured based on order total amount/weight/country.

Requirements

It's mandatory to have tangible products defined in your Control Panel, to retrieve shipping method and price information.

Parameters

Parameters Type/Description
Items

Object / Required

Contains information on the tangible product added in cart.

  Code

String / Required

Product code defined in the Information tab from the Product level, in the Control Panel.

  Quantity

Integer / Optional

Quantity of the product that is being purchased.

Default value is 1.

BillingDetails

Object / Required

Contains customer billing information.

  CountryCode

String / Required

Two-digits code of customer billing country. Example: 'US'.

DeliveryDetails

Object / Required

Contains customer delivery information.

  CountryCode

String / Required

Two-digits code of customer delivery country. Example: 'US'.

Currency

String / Optional

Three-digits code of purchase currency. Example: 'USD'.

CouponCodes

Array of strings / Optional

Discount codes that can be applied to the purchase.

Sample request

<?php

require ('PATH_TO_AUTH'); // authentication call

$cartItems = [];
$cartItem = new stdClass();
$cartItem->Code = 'my_product_code_1'; // product code defined in the Information tab, at product level
$cartItem->Quantity = 2; // quantity that is being purchased
$cartItems[0] = $cartItem;
$billingDetails = new stdClass();
$billingDetails->CountryCode = 'US'; // billing country
$deliveryDetails = new stdClass();
$deliveryDetails->CountryCode = 'AU'; // delivery country

$currency = 'USD'; // purchase currency

$couponCode = ['TANGIBLEPROMO']; // apply discount to promotion

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getShippingPrice';
$jsonRpcRequest->params = array($sessionID, $cartItems, $billingDetails, $deliveryDetails, $currency);
$jsonRpcRequest->id = $i++;

$getShippingPrice = callRPC($jsonRpcRequest, $host);

Response

Parameters Type/Description
ShippingPrice

Object

This method returns an object, containing the shipping price available for a certain cart configuration.

Create fixed discount

Overview

Use setPromotionDiscount to set a fixed promotion discount.

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 set the discount for.

promotionDiscount

Required(Object)

 

Type

Required (String)

 

 

Discount type:

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

 

Value / Values

Required (Int / Array of objects)

 

 

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

 

 

Value

Required (Object)

 

 

 

Currency

Required (String)

 

 

 

 

Discount currency ISO code (ISO 4217).

 

 

 

Amount

Required (Int)

 

 

 

 

Discount amount in corresponding currency.

 

DefaultCurrency

Required (String)

 

 

Default discount currency ISO code (ISO 4217).

Response

Parameter Type/Description
promotionDiscount Object

Request

<?php
require ('PATH_TO_AUTH');

// Promotion code assigned to the promotion you want to update
$promotionCode = 'MY_PROMO_CODE';

$promotionDiscount = new stdClass;
$promotionDiscount->Type = 'FIXED';
$promotionDiscount->DefaultCurrency = 'USD';

// Define the first discount object for a specific currency
$discount1 = new stdClass;
$discount1->Currency = 'USD';
$discount1->Amount = 22;

// Define the second discount object for a specific currency
$discount2 = new stdClass;
$discount2->Currency = 'EUR';
$discount2->Amount = 50;

$promotionDiscount->Values = [$discount1, $discount2];

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

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