Skip to main content

Disable a subscription

Overview

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

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

SubscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

Response

Parameters Type/Description

Boolean

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

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

try {
    $disableSubscription = $client->cancelSubscription($sessionID, $subscriptionReference);
}
catch (SoapFault $e) {
    echo "disableSubscription: " . $e->getMessage();
    exit;
}
var_dump("disableSubscription", $disableSubscription);

 

Add a pricing configuration

Overview

Use the SOAP API 4 addPricingConfiguration method to add a new pricing configuration for your account.

Parameters

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.

PricingConfiguration

Required (object)

 

Use this object to add a new pricing configuration for your account.

ProductCode

Required (string)

 

The code of the product you assign the configuration to.

Response

bool(true)

Request

<?php

$host   = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
    'location' => $host . "/soap/4.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));


function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}

$merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.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'); //date_default_timezone_set('UTC')

$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);

try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}

catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage();
    exit;
}
$PricingConfiguration = new stdClass();
$PricingConfiguration->Default = True;
$PricingConfiguration->Name = 'New Pricing Configuration Through API';
$PricingConfiguration->BillingCountries = array();
$PricingConfiguration->BillingCountries[0] = 'RO';
$PricingConfiguration->BillingCountries[1] = 'DE';
$PricingConfiguration->PricingSchema = 'DYNAMIC';
$PricingConfiguration->PriceType = 'NET';
$PricingConfiguration->DefaultCurrency = 'USD';
$PricingConfiguration->Prices = new stdClass();
$PricingConfiguration->Prices->Regular = array();
$PricingConfiguration->Prices->Regular[0] = new stdClass();
$PricingConfiguration->Prices->Regular[0]->Amount = 69.09;
$PricingConfiguration->Prices->Regular[0]->Currency = 'USD';
$PricingConfiguration->Prices->Regular[0]->MinQuantity = 1;
$PricingConfiguration->Prices->Regular[0]->MaxQuantity = 35;
$PricingConfiguration->Prices->Regular[0]->OptionCodes = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Code = 'G77ICHEM1C';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[0] = 'zh5onfolw7';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[1] = '75rjldfcnz';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Code = 'BAWAQB8LZP';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[0] = 'r3oi06opvi';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[1] = '76gqbq4bhd';
$PricingConfiguration->Prices->Regular[1] = new stdClass();
$PricingConfiguration->Prices->Regular[1]->Amount = 64.66;
$PricingConfiguration->Prices->Regular[1]->Currency = 'USD';
$PricingConfiguration->Prices->Regular[1]->MinQuantity = 36;
$PricingConfiguration->Prices->Regular[1]->MaxQuantity = 83;
$PricingConfiguration->Prices->Regular[1]->OptionCodes = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Code = '8RNXV3T3RE';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[0] = 'rorqkqnd9p';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[1] = 'aeu89gqdg6';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Code = 'DJYD713MKC';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[0] = 'y2z2squ7c1';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[1] = 'g74qfskbjg';
$PricingConfiguration->Prices->Renewal = array();
$PricingConfiguration->Prices->Renewal[0] = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->Amount = 7.89;
$PricingConfiguration->Prices->Renewal[0]->Currency = 'USD';
$PricingConfiguration->Prices->Renewal[0]->MinQuantity = 84;
$PricingConfiguration->Prices->Renewal[0]->MaxQuantity = 100;
$PricingConfiguration->Prices->Renewal[0]->OptionCodes = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Code = '73QCSXYH0E';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[0] = '54xu7mngqm';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[1] = 'p6m8im2unl';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Code = '0QD0CF0OIE';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[0] = 'ytbac9wpmh';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[1] = 'lpkxxqsqxb';
$PricingConfiguration->Prices->Renewal[1] = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->Amount = 76.99;
$PricingConfiguration->Prices->Renewal[1]->Currency = 'USD';
$PricingConfiguration->Prices->Renewal[1]->MinQuantity = 101;
$PricingConfiguration->Prices->Renewal[1]->MaxQuantity = 544;
$PricingConfiguration->Prices->Renewal[1]->OptionCodes = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Code = '03APF0H4QF';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[0] = '15ce5uw2j6';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[1] = 'e88d5hk0tb';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Code = 'PT00TYI2VY';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[0] = '10c24smlbl';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[1] = '0ondbwdk3q';
$PricingConfiguration->PriceOptions = array();
$PricingConfiguration->PriceOptions[0] = new stdClass();
$PricingConfiguration->PriceOptions[0]->Code = 'FKQ8CFLYKM';
$PricingConfiguration->PriceOptions[0]->Required = false;
$PricingConfiguration->PriceOptions[1] = new stdClass();
$PricingConfiguration->PriceOptions[1]->Code = 'TH1HKFOTFR';
$PricingConfiguration->PriceOptions[1]->Required = true;
 
$ProductCode = 'API_Imported_123456';
try {
    $NewPricingConfiguration = $client->addPricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
}

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

var_dump("NewPricingConfiguration", $NewPricingConfiguration);


?>

 

Add translations

Overview

Use the addPromotionTranslations method to add localized texts to existing promotions.

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 translations to.

promotions

Required (array of PromotionTranslations objects)

PromotionTranslations  Object

 

language

Required (string)

 

 

ISO country code corresponding to the country you want to set the translation for.

 

name

Required (string)

 

 

Localized promotion name applicable to the selected country.

Response

Parameters Type/Description

promotionTranslation

Object

Request

<?php

require ('PATH_TO_AUTH');

// Promotion code corresponding to the promotion you want to add translations to
$promotionCode = '';

// Defining a translation for German shoppers
$promotionTranslation1 = new stdClass;
$promotionTranslation1->Language = 'de'; 
$promotionTranslation1->Name = 'YOUR_GERMAN_PROMOTION_NAME';

// Defining a translation for Bulgarian shoppers
$promotionTranslation2 = new stdClass;
$promotionTranslation2->Language = 'bg'; 
$promotionTranslation2->Name = 'YOUR_BULGARIAN_PROMOTION_NAME';

$translations = [$promotionTranslation1, $promotionTranslation2];

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

 

Order flow in 2Checkout API

Overview

Order flow in the 2Checkout system is complex no matter what type of integration you choose. Find out more information below on order lifecycle, order statuses, chargeback flow, and user interfaces.

Order lifecycle

Diagram #1 order flow.png

Order statuses

Order status

The overall status of an order in the 2Checkout systems.

Status value Description

PENDING

2Checkout has yet to block the amount corresponding to the transaction or shoppers used an offline payment method like a wire transfer.

AUTHRECEIVED

2Checkout blocks the amount corresponding to the transaction, but the process of collecting funds is incomplete.

COMPLETE

 The shopper completed the transaction for the purchase and 2Checkout or you fulfilled the order (when required).

REVERSED

Payment authorization has been reversed due to being flagged as potentially fraudulent but the order has not been canceled. The shopper can retry payment in order to complete the order.

REFUND

2Checkout refunds orders only after they reach the Complete/Finished stage and returns the funds collected to shoppers.

 

CANCELED

Order has been canceled by the merchant (for partner orders) or by 2Checkout (order not paid when offline payment methods are used).

PENDING

2Checkout has yet to block the amount corresponding to the transaction or shoppers used an offline payment method like a wire transfer.

Merchant Approve Status

Shows if the merchant has approved or not a partner order. 

Merchant approve status Description

OK

Order approved.

WAITING

Order is awaiting a decision. While it depends on the load on the Fraud flow, orders get approved within a matter of minutes.

REJECTED

Order canceled.

Approve Status

The status of the order resulted from the evaluation by the 2Checkout anti-fraud system or by a member of the anti-fraud department. This status varies for new purchases and for orders requiring customers to make manual payments.

Usually, an order will be approved anywhere between a few seconds to a couple of minutes. The approval time depends on a few factors, like the data provided by the shopper (that is used to calculate the risk score), as well as the “age” of the merchant. In the first month, the orders of a new merchant will take a little longer to be authorized by the Risk team.

Approve Status Values Description

WAITING

The 2Checkout Anti-Fraud System or a member of the Anti-Fraud Department has yet to approve the order.

INVALIDATA

Shopper-supplied data is invalid – 2Checkout did not approve the order.

FRAUD

The 2Checkout Anti-Fraud System or a member of the Anti-Fraud Department has flagged the order as being fraudulent.

Usually, there is nothing the merchant can do. The 2Checkout Risk department will contact the shopper in order to confirm the order.

If the shopper confirms the order, then the status is updated to OK.

OK

The 2Checkout Anti-Fraud System or a member of the Anti-Fraud Department approved the order.

Chargeback flow 

Chargebacks are shopper requests for funds reversal made directly to the bank/PayPal, possible only if the payment was made using a credit/debit card or PayPal. As a rule of thumb, buyers contact their credit card bank/issuer or PayPal directly to initiate a chargeback. You can read more on chargebacks here.

Diagram #2.png

Chargeback Resolution

Chargeback Resolution Status Description

OPEN

A chargeback has been raised on the order and is in progress.

WON

The chargeback raised on the order has been won by the merchant.

LOST

The chargeback raised on the order has been won by the shopper.

ACCEPTED

The chargeback process has been closed. The merchant agreed to repay the value of the order to the customer

User Interfaces

Merchant Control Panel

The Merchant Control Panel Dashboard acts as a homepage and comes with a wide array of functionalities that allow live monitoring of the main business metrics, customization, and extended reporting capabilities.

While working on your integration, the Merchant Control Panel offers an easy-to-use interface for debugging and testing your integration.

Shopping Carts

Several cart options are available, based on the required use cases needed and desired behavior.

ConvertPlus is the newest and main cart in the 2Checkout system. ConvertPlus simplifies the process of collecting payments from shoppers using major credit/debit cards as well as localized payment methods and can be used in sync with the API for managing the product catalog, fetching order information, and more. 

The InLine Checkout acts as an iframe that opens on your website, enabling you to receive payments without redirecting your customers to a third-party checkout. Inline Checkout integrates ideally with shopping cart applications that collect customer billing and shipping information, allowing you to pass that information over to the cart and minimize customer's efforts during the payment process.

API

The 2Checkout Public API is the main interface for interacting with the 2Checkout systems in a programmatic way. Offering a wide range of functionality, the API is available in a number of protocols and versions.     

Webhooks 

2Checkout generates automatic notifications for transaction and subscription/license change events which it sends to a location on your server you control via Webhooks. 

Using these webhooks, you can perform backend tasks including provisioning, entitlement, customer, and subscription lifecycle management.

The available webhooks are:

Depending on the order status, approval status, and order flow, there are different ways these map to the IPN status:

IPN Message Type Merchant Control Panel Trigger Order Status Description

PENDING

Pending orders.

PENDING

The shopper places the order. 2Checkout is waiting for bank authorization.

PENDING

Pending orders.

PURCHASE_PENDING

Shopper places the order using a Purchase Order (PO). 2Checkout approves the PO document and you also approve the PO document. The shopper has yet to finalize the payment.

 

Alternatively, you use the AutoApprove API flow and do not require a PO document but the shopper has yet to finalize the payment.

PROCESSING

Orders waiting to be processed by the 2Checkout system.

PENDING_APPROVAL

Order is waiting for the 2Checkout system to process it or for anti-fraud review.

APPROVED

Authorized and approved orders (sent before electronic delivery).

PAYMENT_AUTHORIZED

The bank authorized the payment.

APPROVED

Authorized and approved orders (sent before electronic delivery).

PAYMENT_RECEIVED

2Checkout sends a notification when it receives payments for offline orders (e.g. Bank/Wire transfer) but only before fulfillment/delivery.

APPROVED

Authorized and approved orders (sent before electronic delivery).

PENDING_ORDER_APPROVAL

2Checkout sends this status for products/subscriptions configured with the “Requires delivery confirmation” setting.

AUTH

Authorized and approved orders (sent after electronic delivery).

PAYMENT_AUTHORIZED

The bank authorized the payment.

AUTH

Authorized and approved orders (sent after electronic delivery).

COMPLETE

2Checkout marks the order as finished and fulfilled.

APPROVED_DELIVERY

Order approved for delivery.

PAYMENT_AUTHORIZED

You approved an order for fulfillment/delivery.

COMPLETE

Completed orders.

COMPLETE

2Checkout marks the order as finished and fulfilled.

 

2Checkout can resend this notification when it generates invoices.

COMPLETE

Completed orders.

COMPLETE

The customer pays the PO.

ORDER_UNDER_REVIEW

Orders under 2Checkout review.

PENDING_APPROVAL

Order is waiting for the 2Checkout system to process it or for anti-fraud review.

SHOPPER_INVOICE

Invoice generated.

COMPLETE

2Checkout marks the order as finished and fulfilled.

 

2Checkout can resend this notification when it generates invoices.

SUSPECT

Fraud suspect.

SUSPECT

The 2Checkout Risk department is reviewing the order for possible fraud. (Not available by default, contact 2Checkout directly to enable it)

CANCELED

Canceled orders.

CANCELED

The 2Checkout system can send out notifications for:

eStore orders canceled by 2Checkout representatives (only for orders that are not authorized/paid, otherwise a reverse or refund action is required).

Partner (Channel Manager) orders canceled by you.

Purchase Orders not approved/submitted in due time

CHARGEBACK_OPEN

Chargeback open.

COMPLETE

ORDERSTATUS is COMPLETE for chargebacks. 2Checkout details information about disputes in the CHARGEBACK_RESOLUTION and CHARGEBACK_REASON_CODE fields.

CHARGEBACK_CLOSED

Chargeback closed.

COMPLETE

ORDERSTATUS is COMPLETE for chargebacks. 2Checkout details information about disputes in the CHARGEBACK_RESOLUTION and CHARGEBACK_REASON_CODE fields.

 

2Checkout can resend this notification when it generates chargeback invoices.

REFUND

Reversed and refund orders.

REVERSED

2Checkout reverses transactions and releases funds back to shoppers for Authorized payments that never reach the Complete status.

REFUND

Reversed and refund orders.

REFUND

2Checkout repays funds back to shoppers for Complete orders.

 

2Checkout can resend this notification when it generates refund invoices.

PURCHASE_PENDING

Approved

PURCHASE_PENDING

You approve the PO document.

PURCHASE_REJECTED_BY_VENDOR

Rejected

CANCELED

You reject the PO document.

PURCHASE_COMPLETE

Completed

COMPLETE

The customer pays the PO.

PURCHASE_EXPIRED_NOT_PAID

Expired, not paid

CANCELED

You don’t approve nor reject the PO within a time interval.

PURCHASE_CANCELED_TIMEOUT

Canceled

CANCELED

You cancel the PO or 2Checkout cancels the order.

PENDING_APPROVAL_ORDER_FOR_PARTNER

Pending approval orders from partners.

PENDING

Resellers place orders that await your approval.

VENDOR_APPROVED

Approved orders from partners.

PENDING

You approve partner orders.

DELIVERED_ORDER_FOR_PARTNER

Delivered orders from partners.

PENDING

2Checkout fulfills partner orders.

ORDER_SHIPPED

Order shipped (only for tangible products)

PAYMENT_AUTHORIZED

You marked the order as shipped, and the delivery process has started.

2Checkout sends a notification to customers once orders are marked as shipped.

INVALID

Invalid orders

INVALID

Shopper provides invalid billing and/or delivery information. (Not available by default, contact 2Checkout directly to enable it)

2Checkout also provides the following webhooks:

You can read the complete information about webhooks here.

Create a product group

Overview

Use the addProductGroup method to create product groups for your account:

  • Send null for product group Code. Avangate ignores any values you send for Code and generates identifiers itself. 
  • Use unique product group names. 
  • Send true or null for the Enabled property.
  • Avangate throws an exception if you send a blank product group.
  • If you send only the name of the product group Avangate creates the new product group entity. 

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.

Name

Required (string)

 

The name of the product group.  

Response

bool(true)

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)) {
//        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.0/';
 
$merchantCode = "YOURCODE12345";//your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key = "SECRET_KEY";//your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
 
$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 the login method for authentication
 
$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);
 
$ProductGroup = new stdClass();
$ProductGroup->Name = 'New Product Group from API';
$ProductGroup->Code = null;//Send null for the Code. Avangate generates unique product group code identifiers. 
$ProductGroup->TemplateName = 'Default Template';//'001 - Two Column Billing'; //the name of the cart template you want to associate with the product group
$ProductGroup->Description = 'This is a generic description';
$ProductGroup->Enabled = true;
 
 
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addProductGroup',
'params' => array($sessionID, $ProductGroup)
);
 
var_dump (callRPC($jsonRpcRequest, $host));
 
 ?>

Interactive Voice Response system

Overview

The Interactive Voice Response system is geared towards helping your customers better manage their subscriptions.

Through the Interactive Voice Response system subscribers can:

  1. Check the auto-renewal and recurring billing status of their subscriptions. To do this, they need to provide the last four digits of the card number used during the acquisition process.
  2. Request that 2Checkout re-deliver the license codes to the end-user. 2Checkout sends the license codes to the email address associated with the subscription.

Benefits

Through the Interactive Voice Response system, you empower your customers to take more control of their subscriptions through easy to use self-service capabilities that they can access directly from their mobile phone, significantly shortening the time needed to resolve requests such as the ones mentioned above.

Retrieve price option groups

Overview

Use the searchPriceOptionGroups to extract information on the price option groups you configured. 

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.

PriceOptionGroupSearch

Optional (object)

 

Details below.

 

PriceOptionGroupSearch

Object

Name

Optional (string)

 

The name of the pricing options groups configured in the Avangate system.

Can be NULL.

Types

Optional (array)

 

Possible values:

· RADIO

· CHECKBOX

· INTERVAL

· COMBO

Can be NULL.

Limit

Optional (int)

 

Number of results displayed per page. Default maximum value is 10.

Can be NULL.

Page

Optional (int)

 

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

Can be NULL.

 

Response

PriceOptionGroup

Array of objects

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)) {
//        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.0/';
 
$merchantCode = "YOURCODE12345";//your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key = "SECRET_KEY";//your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
 
$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 the login method for authentication
 
$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);
 
$GroupCode = 'USERS';
 
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getPriceOptionGroup',
'params' => array($sessionID, $GroupCode)
);
 
var_dump (callRPC((Object)$jsonRpcRequest, $host));
 
?>

Retrieve cross-sell campaigns

Overview

Use the searchCrossSellCampaigns method to extract information about the cross-sell campaigns you configured.

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.

Request

<?php

require ('PATH_TO_AUTH');

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'searchCrossSellCampaigns';
$jsonRpcRequest->params = array($sessionID);
$jsonRpcRequest->id = $i++;

var_dump(" \n Cross-sell campaigns: \n", callRPC($jsonRpcRequest, $host));
?>

Response

Parameters Type/Description

CrossSellCampaign

Object

Create percentage discount

Overview

Use setPromotionDiscount via SOAP API 4.0 to set a percentage-based 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 

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

Client::setBaseUrl('https://api.avangate.com/soap/3.1/');
Client::setCredentials('YOUR_MERCHANT_CODE', 'YOUR_SECRET_KEY');
Client::login();

// create discount object
$discountObj = new stdClass;
$discountObj->Type = 'PERCENT';
$discountObj->Value = 30;

$promotionCode = 'YOUR_PROMO_CODE'; // code of the promotion that you want to update
$response = Client::setPromotionDiscount($promotionCode,$discountObj); // Set the promotion discount to the existing promotion
var_dump($response);

 

How to configure churn prevention campaigns

Overview

Configure churn prevention campaigns for your shoppers and offer them discounts for keeping their subscription auto-renewals active. 2Checkout offers an easy way to configure churn prevention campaigns so that you can:

  • Solidify your recurring revenue by offering discounts to customers who want to cancel recurring billing, incentivizing them to keep auto-renewal enabled for their subscriptions.
  • Engage and collect feedback from your customers to optimize your products, marketing campaigns, and business operations.

Set up a new churn prevention campaign

  1. In your Merchant Control Panel, navigate to DashboardMarketing toolsRetention toolsChurn prevention and click on Add campaign.
    add a churn prevention campaign_1.png
  2. Fill in the details of the campaign: name and running interval. You can also choose whether or not to apply this campaign to subscriptions with custom price by checking or unchecking the Apply for subscriptions that are using product catalog pricing only option.
    add a churn prevention campaign_2.png
  3. Select the campaign settings that will be displayed to the shopper:
    • Create a message to display to your shoppers when they try to stop the subscription auto-renewal for products that you've selected in the campaign. The default message is mandatory but can be customized from the Edit campaign message section, as shown below. You can customize the default message for each shopper language to make it as personalized as you wish.
      add a churn prevention campaign_default message.png
      add a churn prevention campaign_default message_1.png
    • You can also request shoppers to give you a cancelation reason (optional).

       
      Cancellation reasons can be customized, as described in the How to configure cancellation reasons section.

      add a churn prevention campaign_request cancelation reason.png

    • Allow your shoppers to pause a subscription when they try to stop auto-renewal for products that you've selected in the campaign.
      add a churn prevention campaign_allow pause.png
    • Provide a discount incentive (this step is optional, but recommended) for your customers to keep auto-renewal enabled for their subscriptions and customize the discount message that you want shoppers to see during their cancelation attempts. This message is only displayed if you have set a campaign discount.
      add a churn prevention campaign_add discount.png
      add a churn prevention campaign_customize discount message.png
  4. Select the products that you want the campaign to be applied to from the Available products list and add them to the Selected products list. You can add products to a campaign after it starts running.
    add a churn prevention campaign_add products.png
  5. Click on the Save campaign button at the bottom of the page.
  6. The campaign is now created and displayed as Ready. Click Start campaign to start it.
    add a churn prevention campaign_start campaign.png
    You can see the status of your campaign in the Retention toolsChurn prevention page. A churn prevention campaign can have the following statuses:

    • Scheduled - a campaign that didn't reach Running status yet. You can edit or stop it from running in the future.
    • Ready - a campaign that you have not started or one that you've stopped before its start date. You can edit it.
    • Running - a campaign that is currently running. You can stop it or view its settings. You can still add products to a running campaign.
    • Finished - a campaign that passed its end date. You can view its settings but you cannot edit it.

    If the campaign is Scheduled, click Edit if you want to modify its settings.

You can only edit Ready and Scheduled campaigns. You cannot edit campaigns that reached the Running status.

What shoppers see in their 2Checkout myAccount platform

Once you've started the campaign, your shoppers are notified in myAccount whenever they try to stop the subscription auto-renewal for the products that you've selected in the campaign.

  1. The first pop-up displays either the default message (in the screenshot below) or the message that you customized before.
  2. The next pop-up asks for the cancelation reason (if you've checked the Request cancelation reason box) while setting up the campaign. Cancelation reasons are listed in the image below and they cannot be customized. After selecting the cancelation reason shoppers can provide additional comments/feedback in the Comment text box.
    cancelation reason
  3. The next pop-up asks the shopper to select the date until they want to pause the subscription and the reason for pausing the subscription. Note that a subscription cannot be paused for a period longer than 3 years.
    image.png
  4. The last pop-up shows the discount that you offered your shoppers for keeping the auto-renewal. You can customize this message by changing the discount message while configuring the campaign.

How to search for existing churn prevention campaigns

Use the churn prevention search filters to find specific campaigns that you have previously set. You can search for campaigns by:

  • Name
  • Status
  • Starting date
  • Product applied to
 
Searching campaigns by the starting date returns all the campaigns that had started in the specified time interval.

Click Search when you're done configuring the filters. You'll see the search results in the table at the bottom of the page along with possible actions that you can take on the campaigns. You can edit Ready and Scheduled campaigns, and view details of Finished campaigns.

How to configure cancellation reasons

You can configure your own churn cancellation reasons in Control Panel, by:

  • Adding or editing your own custom reasons;
    Go to Setup > Renewal > Cancellation reasons and select the Add reason option. Fill in the cancellation reason label in English (and in any other languages you're using).
    If you have multiple accounts and want to reuse an existing cancellation reason, copy the cancellation reason code from an account where you've previously defined it. This helps ensure consistency in reporting across all your accounts.
    After completing all fields, click Add reason.

     
    English is the first language displayed in the list, and it is always required.

    Add reason.
    When you add a cancellation reason, you can edit it by clicking on the Edit button. Once all changes are done, select the Apply changes button.
    Apply changes

  • Reordering and/or showing/hiding the pre-defined cancellation reasons;
    Reorder reasons
    Go to Setup > Renewal > Cancellation reasons and select the needed reason, that needs to be moved.
    Reorder reasons
    Drag and drop the reasons to arrange them in your preferred order. When you're finished, click Save all changes. After clicking this button, the reasons will be displayed to shoppers in the updated order.
    Reorder reasons - save changes
    Show/hide reason
    Go to Setup > Renewal > Cancellation reasons and click on the show/hide button.
    Show/hide reason
    After you've finished making changes, click Save all changes. Once clicked, the selected reason(s) will no longer be visible to your shoppers.

     
    At least three cancellation reasons should be visible for shoppers to choose from.

    Show/hide reason - save changes

How to run churn prevention campaign reports

You can find the Cancelation statistics reports in the Main reports section of the Reports center menu.

  1. Open the Reports center menu and click Main reports.
  2. Click the Churn prevention report, under Marketing reports to access the reports page.
    churn prevention report.JPG
  3. Use the filters in the Report settings section to define the campaigns that you want to include in the report. Click Build report when you're done.

The report shows the top 10 churn prevention campaigns, filtered by the Orders value column, in descending order. The rest of the campaigns are aggregated under the Others entry. The data included in the report comes from campaigns that ran in the selected interval.

You can also export the full report as CSV by clicking Export as CSV. The exported report contains details about all of your campaigns.

Additionally, you can download a CSV report of the feedback collected from your customers during the cancelation prevention campaigns in the selected time interval by clicking Download feedback.

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