Tips for cultural conversion
|
Do you sell digital goods (Software, SaaS, eBooks, etc) outside of North America? Have you optimized your website to grow your global revenue? With 44% of digital commerce sales coming from outside of the US, there is a huge opportunity cost if you do not customize your website and marketing campaigns for your international web traffic. Watch this 25-minute webinar to learn how to go beyond translation and localize for unique countries and cultures. Together with our partner Oban Digital we'll show you:
|
![]() |
Add usage
Overview
Use the addSubscriptionUsage method via JSON-RPC API 6.0 to update specific usage easier, to add one usage line at a time, without having to create a file to do so, or to add multiple usages at the same time.
Request Parameters
| Parameters | Type | Required | Description |
|---|---|---|---|
| merchantCode | String | Required | Your unique 2Checkout merchant code. |
| sessionId | String | Required | Unique 2Checkout session ID code. |
| hash | String | Required | The MD5 hmac key for the request. |
| SubscriptionReference | String | Required | Unique code that represents a subscription. Example: 83FE4FEF2. |
| OptionCode | String | Required | Unique 2Checkout option code. The pay-per-usage price options group for which the usage is uploaded. Example: metered pricing. |
| UsageStart | Datetime | Required |
The datetime when the usage started; can be the same as UsageEnd. Example: 2018-09-03 17:28:32. |
| UsageEnd | Datetime | Required | The datetime when the usage ended and is recorded. Example: 2018-09-03 17:28:32. |
| Units | Number | Required | Number of units recorded. Example: 10. |
| Description | String | Optional | It can be used to store a short merchant comment of the usage being uploaded. This can be anything, from the source of usage (mobile, web, etc.), to why changes occurred, etc. Example: Subscription usage for September. |
Request Sample
<?php
require ('PATH_TO_AUTH'); // authentication call
$SubscriptionReference = 'B7D8E72224';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'method' => 'addSubscriptionUsage',
'params' => array($sessionID, $SubscriptionReference, array(array("OptionCode" => "MeteredPricing", "UsageStart" => "2020-02-22 15:40:00", "UsageEnd" => "2020-03-22 15:40:00","Units" => 10))),
'id' => $i++
);
var_dump ("addSubscriptionUsage", callRPC((Object)$jsonRpcRequest, $host));
Response
The successful addSubscriptionUsage call via JSON-RPC APIv6 returns the Usage object.
{
"jsonrpc": "2.0",
"id": 260,
"result": [
{
"UsageReference": "120011112631",
"SubscriptionReference": "67F3AD6A32",
"OptionCode": "USG_MN",
"UsageStart": "2020-07-06 12:00:00",
"UsageEnd": "2020-07-07 12:00:00",
"Units": 10,
"Description": "",
"RenewalOrderReference": 0
}
]
}
Error handling
| Error message description | Error code | Error message |
|---|---|---|
| LICENCECODE is not a valid licence code for the merchant | INPUT_ERROR | Usage was not added as the license code provided is invalid. |
| OPTIONCODE is invalid for the Merchant and Licence or is not a usage-based option code | INPUT_ERROR | Usage was not added as the option code provided is invalid. |
| Provided usage entries overlap within themselves or with existing usage entries | INPUT_ERROR | Usage was not added as the usage interval provided overlaps with an existing usage interval for the same LICENCECODE and OPTIONCODE combination. |
|
Provided date formats are unsupported |
INPUT_ERROR | Usage start format unsupported. Please use YYYY-MM-DD HH:MM:SS. |
| Usage end format unsupported. Please use YYYY-MM-DD HH:MM:SS. | ||
|
One or more mandatory parameters are missing or do not have the required format |
INPUT_ERROR | Usage was not added as one or more of the mandatory parameters are missing. |
| Usage was not added as one or more of the parameters do not match the required format. | ||
| Units not allowed. | ||
| Provided usages' start date is prior to the subscription start date or end date is after the subscription expiration date. | INPUT_ERROR | Usage interval out of bounds. |
| Unexpected error happens | INTERNAL_ERROR | <unexpected_error> |
Cookie Management in the Merchant Control Panel
Overview
A cookie is a small text file that a website places on a user’s computer (including smartphones, tablets, or other connected devices) to store information about the user’s activity. Throughout the world, regulating entities see cookies as a “persistent identifier”, thus falling under the rules applied to protect Internet users' personal information.
Regulatory entities:
- For California – CCPA
- For EU – GDPR, ePrivacy Directive, Cookies and other tracking technologies
- National regulations (per country) on privacy and protection of personal information
Availability
All merchants have access to Merchant Control Panel. Consequently, all of them will be seeing the cookie consent displayed (in one form or another, depending on where they are located when they access the portal. See more details below).
Cookie Management in the Merchant Control Panel
For merchants in California (USA), the European Union, and the rest of the world (ROW), 2Checkout uses three types of cookies:
- Security (mandatory) - These cookies help protect merchants' data available during and after logging into their 2Checkout account and cannot be disabled.
- Preference (optional) - These cookies are used to remember customers’ choices during navigation through their 2Checkout accounts, such as pagination selection or list types.
- Statistics (optional) - These cookies help 2Checkout understand the merchants' interaction with their Merchant Control Panel so that our system can identify issues and continuously improve the overall experience merchants have. Data is collected and reported anonymously.
2Checkout collects consent upon the merchants' first access in the Merchant Control Panel through a link at the bottom of the landing page, where the user can:
- Accept all cookies - This will check all the above 3 types of cookies (Security, Preference, Statistics)
- Customize settings/Do not sell my info (for California users only) - This will enable the user to check any cookies other than the mandatory ones
- Access the 2Checkout cookie policy.
For US users with unidentified state locations, 2Checkout will display the rules applied for California users.
For ROW users with unidentified state location 2Checkout will display the rules applied for EU users.
Cookie Module Display Based on Merchant Location
The Cookie module will be displayed differently depending on merchants' locations.
Cookie module displayed for merchants in the European Union

.png)
By clicking on the Customize settings button, the user will be prompted with a separate window where they can choose their preferred settings.
Once the merchant performs an action on the Cookie Settings link in the footer, this will not be shown during any other subsequent accessing of the portal (for a one-year period). A link to Cookie settings will be available (bottom right corner), where the user will be able to change options for the optional types of cookies at any time. After one year, the merchant will be once again prompted with the collect consent for the placed cookies.
.png)
Cookie module displayed for merchants in California
For merchants in California, the cookie module will display the Do not sell my information button. Once merchants click on it they will be prompted with the Cookies Management Center window, where they can enable their preferred cookies.

Cookie module displayed for merchants in the Rest of the World, including the US (non-EU, non-California)


Create promotion
Overview
Use the addPromotion method 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 product, smaller than the maximum quantity you defined. Can be NULL if you want the promotion to apply to an unlimited number 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) |
||||||
|
|
|
|
||||||
|
|
Code/Codes |
Optional(String/Array) |
||||||
|
|
|
Varies according to type. Send:
|
||||||
|
Enabled |
Optional(Boolean) |
|||||||
|
|
TRUE FALSE |
|||||||
|
ChannelType |
Optional(String) |
|||||||
|
|
Possible values:
|
|||||||
|
Type |
Optional(String) |
|||||||
|
|
REGULAR |
|||||||
|
Discount |
Optional(Object) |
|||||||
|
|
Type |
Optional(String) |
||||||
|
|
|
Discount type:
|
||||||
|
|
Value / Values |
Optional (Int / Array of 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) |
|||||||
|
|
|
|||||||
|
RecurringChargesNumber |
Optional(Int) |
|||||||
|
|
Offer discounts for a number of recurring billing charges beyond the initial purchase. |
|||||||
Response
| Parameters | Type/Description |
|---|---|
| Promotion | Object |
Request
<?php
function callRPC($Request, $host, $Debug = true) {
$curl = curl_init($host);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_VERBOSE, true);
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)) {
var_dump($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.avangate.com/rpc/3.1/';
$merchantCode = "YOUR_MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.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.avangate.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;
$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);
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 = 30;
$promotionObject->Discount = $discountObj;
$promotionObject->Products = [$productsObj1, $productsObj2, $productsObj3];
$promotionObject->Translations = [$translation1, $translation2];
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addPromotion',
'params' => array($sessionID, $promotionObject),
);
$result = callRPC((object)$jsonRpcRequest, $host);
var_dump($result);
SOAP Authentication
Overview
Use the login method for the authentication process in the 2Checkout system.
Parameters
| Parameters | Type/Description |
|---|---|
|
MerchantCode |
required (string) |
|
|
Your merchant identifier (received from 2Checkout).
|
|
Date |
required (string) |
|
|
GMT ISO Date format (e.g. 2010-01-01 12:13:14)
|
|
Hash |
required (Object) |
|
|
Calculated HMAC_SHA256 signature based on MerchantCode and Date, using your secret key (see example below). |
Response
|
Parameters |
Type/Description |
|---|---|
|
sessionID |
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. |
Request
To create the HMAC_SHA256 source string use your merchant code (available here) and the date of the request, prefixing them with the length in bytes of each respective value, along with your account’s secret key (for UTF-8 characters the length in bytes might be longer that the string length). For example:
|
Parameters |
Type/Description |
|---|---|
|
MerchantCode |
Avangate |
|
|
8AVANGATE
|
|
Date |
2010-05-13 12:12:12 |
|
|
192010-05-13 12:12:12
|
|
HMAC source string |
8AVANGATE192010-05-13 12:12:12
|
|
Secret key |
SECRET_KEY |
|
Calculated HMAC_SHA256 signature based on MerchantCode and Date, using your secret key: |
|
|
bf763db7d333e9c3038698cf59ada3e6 |
|
Request example
<?php
$host = "https://api.2checkout.com";
$merchantCode = "YOURCODE123";
//your account's merchant code available in the 'System settings' area of the cPanel:
//https://secure.2checkout.com/cpanel/account_settings.php
$key = "SECRET_KEY";
//your account's secret key available in the 'System settings' area of the cPanel:
//https://secure.2checkout.com/cpanel/account_settings.php
$now = gmdate('Y-m-d H:i:s'); //GMT date format)
$algo = "sha256";
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash = hash_hmac($algo, $string, $key);
try {
$client = new SoapClient($host . "/soap/3.0/?wsdl", array(
'location' => $host . "/soap/3.0/",
"stream_context" => stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
))
));
$sessionID = $client->login($merchantCode, $now, $hash, $algo);
echo("Auth token: {$sessionID}" . PHP_EOL);
}
catch (SoapFault $e) {
echo "Authentication: " . $e->getMessage() . PHP_EOL;
exit;
}Manage leads
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
];
$jsonRpcRequest = array (
'method' => 'markLeads',
'params' => array($sessionID, [$markLead]),
'id' => $i++,
'jsonrpc' => '2.0'
);
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
Response Parameters
Response Example
class stdClass#18 (2) {
public $Response =>
string(37) "1 leads have been marked successfully"
public $Errors =>
array(0) {
}
}
Remove products
Overview
Use deletePromotionProducts to remove products from an existing promotion.
Parameters
| Parameter | Type/Description | |
|---|---|---|
|
promotionCode |
Required (string) |
|
|
|
The code corresponding to the promotion that you want to remove products from. |
|
|
promotionProducts |
Required (object) |
|
|
|
Code |
Required (string) |
|
|
|
System generated product code. |
|
|
pricingConfigurationCode |
Required (string) |
|
|
|
System generated pricing configuration code. |
|
|
pricingOptionCodes |
Required (array of strings) |
|
|
|
Pricing option codes that you control. |
Response
| Parameter | Type/Description |
|---|---|
| Status | Boolean |
| True or False |
Request
<?php
require ('PATH_TO_AUTH');
// Define the first product to remove from the promotion
$newProduct1 = new stdClass;
$newProduct1->Code = '';
$newProduct1->PricingConfigurationCode = '';
$newProduct1->PricingOptionCodes = ['',''];
// Define another product to remove from the promotion
$newProduct2 = new stdClass;
$newProduct2->Code = '';
$newProduct2->PricingOptionCodes = [''];
$promotionProducts = [$newProduct1, $newProduct2];
try {
$updatedPromotion = $client->deletePromotionProducts ($promotionCode, $promotionProducts);
}
catch (SoapFault $e) {
echo "UpdatedPromotion: " . $e->getMessage();
exit;
}
var_dump("UpdatedPromotion", $updatedPromotion);
SOAP API Reference
This is a summary of the objects/classes and methods available.
Update usage
Overview
Use the updateSubscriptionUsage method via SOAP API 6.0 to update a specific usage entry.
Request Parameters
| Parameters | Type | Required | Description |
|---|---|---|---|
| merchantCode | String | Required | The system-generated merchant ID. |
| hash | String | Required | The MD5 hmac key for the request. |
| sessionID | String | Required | The system-generated code of the session. |
| UsageReference | String | Required | The system-generated reference code for the usage of the subscription. |
| SubscriptionReference | String | Required | The system-generated reference code for the subscription. |
| Units | Number | Optional (Optional if Description provided) | Number of units used. |
| Description | String | Optional (Optional if Units provided) | It can be used to store a short merchant comment of the usage being uploaded. This can be anything, from the source of usage (mobile, web, etc.), to why changes occurred, etc. Example: Subscription usage for September. |
Request Sample
<?php
require ('PATH_TO_AUTH'); // authentication call
$subscriptionReference = '4A1D733696';
$usageReference = 120010776516;
try {
$subscriptionUsageRequest = new stdClass();
$subscriptionUsageRequest->Units = 123;
$subscriptionUsageRequest->Description = 'Units 123';
$response = $client->updateSubscriptionUsage($sessionID, $subscriptionReference, $usageReference, $subscriptionUsageRequest);
var_dump($response);
} catch (SoapFault $ex) {
$faultname = (isset($ex->faultname)) ? " $faultname" : '';
echo "[$ex->faultcode]$faultname: $ex->faultstring" . PHP_EOL;
}
exit;
Response
The updateSubscriptionUsage method via SOAP APIv6 returns the Usage object if successful.
class stdClass#3 (8) {
public $UsageReference =>
120011112631
public $SubscriptionReference =>
"67F3AD6A32"
public $OptionCode =>
"USG_MN"
public $UsageStart =>
"2020-07-06 12:00:00"
public $UsageEnd =>
"2020-07-07 12:00:00"
public $Units =>
69
public $Description =>
""
public $RenewalOrderReference =>
0
}
Error Handling
If unsuccessful, the updateSubscriptionUsage method via SOAP APIv6 will return the error below.
| Error message description | Error code | Error message |
|---|---|---|
|
Provided parameters lack the required type or format. |
MALFORMED_PARAMETER | One or more parameters lack the required format: SubscriptionReference must be a string. |
| MALFORMED_PARAMETER | One or more parameters lack the required format: UsageReference must be a positive integer higher than or equal to 1. | |
| PARAMETER_MISSING | Please provide at least one of the following parameters: Units, Description. | |
| MALFORMED_PARAMETER | One or more parameters lack the required format: Units must be a positive integer higher than or equal to 1. | |
| MALFORMED_PARAMETER | One or more parameters lack the required format: Description must be a string. | |
|
Subscription or usage line are not found. |
NOT_FOUND | Subscription not found. |
| Usage line described does not exist. | ||
| Usage line is already billed. | ALREADY_BILLED | Usage was not updated as this usage was already billed. |
| The renewal process is in progress for this subscription. | RENEWAL_IN_PROGRESS | There is a renewal in progress for the provided usage line. |
| The usage was not changed after the update. | NOTHING_HAPPENED | The usage has not been updated, nothing to change. The provided values are identical to the existing ones. |
| An unexpected error happens. | GENERIC | There has been an error updating the usage line. Please try again later. |
