Delete upsell campaign
Overview
Use the deleteUpSellCampaign method via JSON-RPC API 6.0 to permanently delete an upsell campaign in any status (active, disabled, expired).
Request parameters
| Parameters | Type | Required/Optional | Description |
|---|---|---|---|
| upSellCampaignCode | String | Required | The identifying code of the upsell campaign. |
Request sample
<?php
declare(strict_types=1);
class Configuration
{
public const MERCHANT_CODE = '';
public const MERCHANT_KEY = '';
public const URL = 'http://api.2checkout.com/rpc/6.0';
public const ACTION = 'deleteUpsellCampaign';
public const ADDITIONAL_OPTIONS = null;
public const PAYLOAD = "72937a15-1ffd-43b9-90b2-210d03dcd754";
}
class Client
{
private const LOGIN_METHOD = 'login';
private $calls = 1;
private $sessionId;
private function generateAuth(): array
{
$merchantCode = Configuration::MERCHANT_CODE;
$key = Configuration::MERCHANT_KEY;
$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);
return compact('merchantCode', 'date', 'hash');
}
public function login(string $url)
{
$payload = $this->generateAuth();
$response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
$this->sessionId = $response['result'];
}
public function call(
string $url = Configuration::URL,
$payload = Configuration::PAYLOAD,
string $action = Configuration::ACTION
): ?array {
if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
$this->login($url);
}
if (!empty($this->sessionId)) {
$payload = [$this->sessionId, $payload, Configuration::ADDITIONAL_OPTIONS];
}
$payload = array_filter($payload);
$request = json_encode([
'jsonrpc' => '2.0',
'method' => $action,
'params' => $payload,
'id' => $this->calls++,
]);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSLVERSION, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($curl);
if(empty($response)) {
die('Server unavailable');
}
echo $response . '</br>';
return json_decode($response, true);;
}
}
$client = new Client();
$result = $client->call();
var_dump($result);
Response
- 204 - 'No content' if SUCCESS
- 4xx if FAILED with distinct error messages
Error handling
| Error code | Message |
|---|---|
| UPSELL_CAMPAIGN_NOT_FOUND | Upsell campaign with code test was not found. |
| UPSELL_CAMPAIGN_CODE_EMPTY | Code is not set |
| UPSELL_CAMPAIGN_CODE_TOO_LONG | Code exceeds allowed max length (255) |
Search products
Overview
Use the searchProducts method to extract information about the subscription plan/products you configured for your account.
Pagination
Use pagination to decrease the request loading time, while better handling the returning responses.
Pagination works on all the search methods existing on 2Checkout API 5.0. The default pagination behavior is to display page 1 with 10 results. The maximum number of items displayed on a single page is 200.
To use pagination, include the Pagination object inside the search method call, using the parameters below:
| Parameters | Type/Description | |
|---|---|---|
| Pagination | Object | |
| Details below. | ||
| Page | Int | |
| Set the number of pages that should be returned. | ||
| Limit | Int | |
| Set a limit for the number of results that should be returned. | ||
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. |
||
|
SearchOptions |
Object |
||
|
Name |
Optional (string) |
||
|
|
Product name. Can be NULL. |
||
|
|
Codes |
Optional (StringArray) |
|
|
|
Array of product codes. |
||
|
Types |
Optional (StringArray) |
||
|
|
Array of the values representing the type of products. Possible values:
Leave empty to have all product types returned to the search. Can be NULL. If NULL, 2Checkout returns both regular and bundle products. |
||
|
Enabled |
Optional (boolean) |
||
|
|
True or false. Can be NULL. |
||
|
GroupName |
Optional (string) |
||
|
|
The name of the group that the product is associated with. Can be NULL. |
||
|
Limit |
Optional (integer) |
||
|
|
Number of results (products) displayed per page. Default value is 10. Can be NULL. |
||
|
Page |
Optional (integer) |
||
|
|
A specific page of search results. Default value is 1. Can be NULL. |
||
|
|
OrderBy |
Object |
|
|
|
Defines the order of the returned results. |
||
|
|
Field |
Optional (string) |
|
|
|
The name of the field to order the results by. Allowed values: 'ProductStatus', 'ProductName', 'ProductCode', 'UpdateDatetime', 'AvangateId'. Can be NULL. |
||
|
|
Direction |
Optional (string) |
|
|
|
Sort results ascending or descending. Allowed values:
Can be NULL (defaults to desc).
|
||
Response
| Parameter | Type/Description |
|---|---|
|
Object |
Request
<?php
require ('PATH_TO_AUTH');
$SearchOptions = new stdClass();
$SearchOptions->Name = '2Checkout Subscription'; //Product name
$SearchOptions->Types = array ('REGULAR', 'BUNDLE'); //product type (standalone), regular or bundle
$SearchOptions->Enabled = True;
//$SearchOptions->GroupName = '';
$SearchOptions->Limit = '10';
$SearchOptions->Page = '10';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'searchProducts',
'params' => array($sessionID, $SearchOptions)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
?>Products and subscriptions listing query parameters
Overview
2Checkout offers query parameters to enable you to manage the listing of products/subscriptions in the My Products page of your shoppers' myAccount.
Availability
All 2Checkout accounts. myAccount users can apply filters to manage the listing of their products/subscriptions.
Parameters
| Parameter | Description |
|---|---|
| SubscriptionType |
|
| OrderBy | ExpirationDate. Used in combination with the OrderByType parameter. |
| OrderByType | Possible values: asc or desc. Used in combination with the OrderBy parameter. 2Checkout displays either last subscriptions to expire first, or the first to expire at the top of the page. |
Example
https://secure.2checkout.com/myaccount/my_products/?OrderBy=ExpirationDate&SubscriptionType=all&OrderByType=asc
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) |
||||||
|
|
|
|
||||||
|
|
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
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:
- Checkout with cart functionalities
- One page checkout without review
- One page checkout with review
- Add to Shopping Cart
- Checkout page
- Product page
- 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));