Skip to main content

Subscription history

Overview

Retrieve information about a subscription.

Parameters

Parameters

Type/Description

ReferenceNo

String

 

Unique, system-generated order reference number.

Type

String

 

Purchase type:

  • SALE
  • RENEWAL
  • UPGRADE

SubscriptionReference

String

 

Unique, system-generated subscription reference.

StartDate

String

 

Subscription start date(YYYY-MM-DD) - StartDate is mandatory when importing subscription data. If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the StartDate you provide must be in accordance with your custom configuration.

ExpirationDate

String

 

Subscription expiration date(YYYY-MM-DD) - ExpirationDate is mandatory when importing subscription data. If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the ExpirationDate you provide must be in accordance with your custom configuration.

Lifetime

Boolean

 

Possible values:

  • True – the subscription is evergreen

False – the subscription has a recurring billing cycle less than or equal to three years.

SKU

String

 

Stock keeping unit you defined.

DeliveryInfo

Object

 

Object with information about the delivery made to the customer - structure described below

PartnerCode

String

 

Possible values:

  • Empty = ecommerce order
  • Partner Code

 

Retrieve iDEAL bank information

Overview

Use the getIdealIssuerBanks method to retrieve the information on the Avangate list of banks that support iDEAL payments for shoppers in the Netherlands. You will need banking information to place orders, enabling your shoppers to pay using iDEAL. Use the code parameter from the array returned by getIdealIssuerBanks, as a value of the BankCode parameter in the Order object, when you call placeOrder.

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.

Response

Method returns an array of objects, containing the bank code and bank name as parameters. The value of the Code parameter is used in the placeOrder call, in the BankCode parameter.

Parameters Type/Description

Code

String

  String contains the SWIFT code of the bank, the plus sign "+", and the first 3 characters from the bank name. E.q.: in the case of Rabobank, code parameter is "RABONL2U+RAB".
Name String
  String contains the full bank name. E.q.: "Rabobank".

Request


<?php

// authentication script: https://knowledgecenter.avangate.com/Integration/SOAP_API/API_4.0/02Authentication

require ('PATH_TO_AUTH');

try {
    $getIdealBanks = $client->getIdealIssuerBanks($sessionID);
} catch (SoapFault $e) {
    echo "Error getIdealIssuerBanks: " . $e->getMessage() . $e->faultcode;
    exit;
}

$bankCodes=("getIdealIssuerBanks", $getIdealBanks);

?>

Retrieve order information

Overview

Use this method to extract information about orders in the Avangate platform.

Parameters

Parameters Type/Description
sessionID String
  Session identifier string, output of the Login method. An exception is thrown if the values are incorrect.
refNo String
  Order reference number of an existing approved/paid order.

Response

Parameters Type/Description
Order Object

Request

<?php

require ('PATH_TO_AUTH');  // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication

$refNo = 'YOUR_ORDER_REFERENCE_NUMBER';

$jsonRpcRequest = array (
'method' => 'getOrder',
'params' => array($sessionID, $refNo),
'id' => $i++,
'jsonrpc' => '2.0'
);
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

Manage usage and usage billing

Overview

Manage all aspects of usage billing either from your Merchant Control Panel or via the 2Checkout API.

Read here more info on how to manage and upload usage billing

Upload usage for your subscriptions 

Timeframe to upload subscriptions usage  

You can upload usage data for the active billing cycle at any time throughout the billing cycle. However, not all usage might be available for billing by the time the subscription expires. That is why you should consider taking a few days buffer to allow usage to be uploaded for the current billing cycle for a subscription before any billing attempts are made.   

2Checkout will not attempt to automatically charge customers for recurring costs and additional metered usage fees (in arrears) during the “Usage billing interval”, thus allowing merchants time to upload any outstanding usage. Set the “Usage billing interval” to zero if you want to charge usage fees as soon as the subscription expires.

You can set a usage upload interval by editing the “Usage billing interval” settings: 

  • Across all your products from your Merchant Control Panel → Setup → Renewal → Global Renewal Settings tab OR  
  • For individual products from your Merchant Control Panel → Setup → Products → Renewal tab

These settings will impact only the subscriptions associated with the product you're configuring, and will override any global renewal settings. 

Changes in Usage upload interval settings also impact subscriptions created prior to the update of the setting. 

Because the usage upload interval cannot exceed the grace period, if you set the grace period value to a value smaller than the current usage billing interval, the usage billing interval setting will automatically be updated so that the new value does not exceed the grace period setting.  

After the expiration date of one billing cycle, you can start uploading usage for the upcoming billing cycle, as long as the subscription is in Past Due status, and not Expired.  

Usage upload notifications 

For subscriptions with a usage billing price options group, the 2Checkout system will start notifying you via email that usage is due 5 days before the usage upload interval of the subscription. 2Checkout will continue to send notifications daily for the following 10 days, or until usage was uploaded for the subscription or the subscription expires.  

Example of the timeframe for uploading usage 

Assuming a subscription expires on August 31st, and there’s a usage billing interval of 2 days and a grace period of 5 days, this is the usage you can upload and when: 

 

<= Aug 31st 

Sep 1st 

Sep 2nd  

Sep 3rd  

Sep 4th  

Sep 5th  

>=Sep 6th  

Ability to upload usage from August 

Yes 

Yes 

Yes 

No (usage billing interval exceeded) 

Ability to upload usage from September 

No (outside of billing cycle) 

Yes 

Yes 

Yes 

Yes 

Yes 

Yes, if August cycle was paid.  

Otherwise no.

Upload and manage usage records

There are a few ways you can upload and manage usage records in the 2Checkout platform.

Add, edit, delete and read usage records via API  

2Checkout provides an extensive set of API methods aimed to automate the management of usage without the use of physical files, all without rate limits. Read more about these in the API documentation

How to upload itemized, maximum or average usage  

2Checkout does not limit the number of usage records you can upload, which means that you can upload usage immediately after it happens, or with a certain frequency, or all usage together at the end of the billing cycle.  

2Checkout will sum up all your usage records in the billing cycle before billing it. The timeliness of when you upload usage may be impacted by how you want to bill usage. For example: 

  • If you want to bill a sum of all usage, you can upload usage immediately as it happens, or upload an intermediate sum for a specific timeframe, or upload a sum of all usage throughout the billing cycle at the end of the cycle.  
  • If you want to bill based on the usage peak in that bill cycle or an average usage throughout the billing cycle, you should ensure you perform this calculation outside of 2Checkout and have only one usage record uploaded for the entire billing cycle of the subscription

Import usage from a CSV file via your Merchant Control Panel  

You can upload usage from a CSV (comma-separated values) file by using the usage import tool located in your Merchant Control Panel → Setup → Renewal → Usage tab. To build your CSV file you can use the sample file provided, or you can create a file from scratch as long as you make sure it has the following structure, with the columns in this order:

Column name

Type 

Description

LicenseUniqueId 

string (250) 

Your unique identifier for the subscription which is generated outside of 2Checkout but stored in 2Checkout so that it can subsequently be used for management tasks impacting subscriptions. If provided, it must match the external identifier associated with a subscription present in 2Checkout. Can be empty only when LicenceCode is populated . If both LicenceUniqueID and LicenceCode are provided, the combination must match a valid subscription for the merchant.

LicenceCode 

string 

2Checkout generated unique subscription reference which is stored in 2Checkout so that it can subsequently be used for management tasks impacting subscriptions. If provided, it must match the reference of a subscription present in 2Checkout. Can be empty only when LicenceUniqueId is populated. If both LicenceUniqueID and LicenceCode are provided, the combination must match a valid subscription for the merchant.

OptionCode 

string 

Unique code provided in the definition of the pay per usage price option group for the product associated with the subscription. Must match a valid pay per usage price option group associated with the product on the subscription. 

Units 

numeric 

The number of units of the metered resources consumed on the subscription in the time interval mentioned. 

Cannot be empty or negative, but you can upload 0 (zero) units.

StartDate 

date

 

YYYY-MM-DD 

Defines the beginning of the usage interval (for example, when the subscriber logged into your application). Cannot be empty, and has to be equal to or greater than the subscription Purchase date and less than EndDate on the same row. Date interval on one usage record cannot overlap with the date interval on another usage record.

EndDate 

date

 

YYYY-MM-DD

Defines the end of the usage interval (for example, when the subscriber logged out of your application). Cannot be empty, has to be greater than the purchase date of the subscription, greater than the StartDate on the same row, and cannot be a date in the future. Date interval on one usage record cannot overlap with the date interval on another usage record.

2Checkout uploads CSV files and processes the usage data successfully only if no errors are encountered during the upload. Processing of usage uploaded via CSV files is done hourly, on the 17th minute of each hour.

The 2Checkout system sends out notifications if the usage upload process completed successfully, and when the processing of the CSV file with the usage data uploaded fails. Emails are sent automatically to the address under Customers Support Email (set in Account Information → Account Settings), specifying the lines in the CSV file for which usage processing was unsuccessful. If the process fails, correct the errors reported on the specific lines and re-upload the CSV file entirely for the data to be processed. 

As long as the usage uploaded in the file has not been processed, you can always delete the uploaded CSV files. Once the usage was processed by the 2Checkout system, you will only be able to download the CSV files, but not to remove them or the uploaded data.  

Importing usage from a CSV file via API  

You can automate the upload of the CSV file already mentioned in this documentation by using the 2Checkout API to upload the file. Read more about this in the API documentation.

Use the GMT+2 time zone for the StartDate and EndDatec columns when making the API call to the Usage Upload endpoint. 

    Billing of subscriptions with a pay-per-usage price option  

    Initial purchase 

    Pay-per-usage pricing does not impact new acquisition costs, but only their renewal price. When first purchasing products with usage pricing components, shoppers pay the costs of the first billing cycle in advance. 2Checkout charges metered resources consumed in arrears at the start of a new billing cycle when the subscription expires/renews for the previous billing cycle. 

    Renewal billing 

    Renewal notifications  

    The 2Checkout system sends out renewal notifications to your customers according to the global or product-specific renewal notification settings on your account. For subscriptions with usage billing price option groups, the timing of the notification is calculated based on the expiration date + usage billing interval. This means that in some cases renewal notifications might be sent out before the usage billing period interval is over, and full usage is received for the subscription.

    Billing amount calculation 

    2Checkout charges the customer the recurring costs of the upcoming billing cycle and the fees for the unbilled metered resources consumed in the previous billing cycles together. To determine what the fees for the metered resources are, 2Checkout performs the following actions: 

    1. Filters for the usage records which need to be billed for the Subscription and the billing cycle. These are all unbilled usage records where the record’s EndDate is less than or equal to the bill cycle Expiration Date. 
    • If no usage is found, then Usage costs will be zero. 
    • Any unbilled usage before the active billing cycle is going to be billed as part of the active billing cycle.

    2. Sums up all usage records for the Subscription, Price Option Code, and the Billing Cycle. 

    3. Looks up what the price of each usage unit is, in the Price Option setup of the product.  

    • If the “Impact on price per unit” set-up on the scale is set to “Add” prices to the price per unit, then the unit price will be calculated by adding all values for all the previous scales, including the one usage falls in.  
    • If the unit price is zero on any of the scales, then zero is what will be used in the calculations.  

    4. Multiplies the units with the Price per unit to determine the usage costs.

    Automatic billing of usage 

    The first billing attempt for an automatic renewal usage billing subscription is set at Subscription Expiration Date + Usage Upload Interval. You can also mark that all usage for the subscription’s current billing cycle was received before the usage upload interval and trigger immediate billing of the subscription costs via API.

    After the first attempt, retries are scheduled only within the Grace Period according to the 2Checkout retry logic, depending on your account settings and if you have activated the 2Recover add-on. Retries are as follows: 

    • Without 2Recover add-on, 2Checkout will retry to bill usage up to 2 times, up to 9 days after the Usage upload interval has ended, but only within Grace Period 
    • With 2Recover add-on, 2Checkout will retry to bill usage up to 6 times, up to 14 days after the Usage upload interval has ended, but only within Grace Period 

    Manual billing of usage 

    Subscribers can manually renew their pay-per-usage subscriptions only after the Usage Upload Interval has passed, or after the merchant has marked that all usage for the subscription’s current billing cycle was received via API. As is with all subscriptions, subscribers can only renew their pay-per-usage subscriptions within the subscription’s grace period. 

    Report usage 

    The number of usage units consumed, their cost and the status of their billing is visible in your Merchant Control Panel, in the Subscription Details page available for each subscription.  

    Usage records can also be read via API. Read more about this in the dedicated API documentation.

    FAQ

    1. Do discounts apply to the entire value of renewal orders? 

    Yes. Discounts apply to the entire value of the renewal order, usage costs included. 

    2. Is there a maximum number of usage billing units that can be uploaded? 

    The maximum limit for usage units is 999,999,999 units. 

    3. What if the data for only a few subscriptions or a single item was incorrect? Will the rest of the usage data be processed? 

    No. Please make sure that you deal with the errors reported by the 2Checkout system and re-upload the full CSV file. 

    4. Can usage be updated once it is uploaded?

    Yes, usage can be updated via API using the updateUsage method.

    Total refund

    Overview

    Use the issueRefund method to issue a total refund for an order processed by 2Checkout.

    Requirements 

    The payment for the refundable order needs to be collected.

    You cannot issue a refund for an amount higher than the total order amount.

    We recommend you to create a new order with placeOrder to have one that can be refunded.

    The order’s status must be ’COMPLETE’ and it should have a Total price.

    The order’s date cannot be older than a year from the current date.

    To obtain LineItemReference, use the getOrder method: https://knowledgecenter.2checkout.com/API-Integration/JSON-RPC_API_6.0/Reference/14Retrieve-an-order

    Request

    <?php
    
    /**
     * @throws JsonException
     */
    function callRPC($Request, $host) {
        $curl = curl_init($host);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
        curl_setopt($curl, CURLOPT_VERBOSE, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        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, JSON_THROW_ON_ERROR);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
    
        $ResponseString = curl_exec($curl);
    
        if (!empty($ResponseString)) {
            echo($ResponseString);
            $Response = json_decode($ResponseString, false, 512, JSON_THROW_ON_ERROR);
            if (isset($Response->result)) {
                return $Response->result;
            }
            if (!is_null($Response->error)) {
                echo("Method: {$Request->method}" . PHP_EOL);
                echo("Error: {$Request->error}" . PHP_EOL);
            }
        } else {
            return null;
        }
        return null;
    }
    
    $host = 'https://api.avangate.com/rpc/6.0/';
    
    $merchantCode = "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 = "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');
    $algo = "sha256";
    $hash = hash_hmac($algo, $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, $algo);
    $jsonRpcRequest->id = $i++;
    
    try {
        $sessionID = callRPC($jsonRpcRequest, $host);
        echo("Auth token: {$sessionID}" . PHP_EOL);
    } catch (JsonException $e) {
        echo("Error: {$e->getMessage()}" . PHP_EOL);
    }
    
    $orderReference = "73152871";
    
    $items = [];
    
    $amount = '241.49';
    $comment = "This is a comment";
    $reason = "Fraud";
    
    $jsonRpcRequest          = new stdClass();
    $jsonRpcRequest->jsonrpc = '2.0';
    $jsonRpcRequest->method  = 'issueRefund';
    $jsonRpcRequest->params  = array($sessionID, $orderReference, $amount, $items, $comment, $reason);
    $jsonRpcRequest->id      = $i++;
    
    $totalRefund = callRPC($jsonRpcRequest, $host);
    
    var_dump ($totalRefund ); 

    Response

    Response Type/Description
    Boolean

    TRUE is the refund was processed successfully

    FALSE otherwise

     

    Retrieve account time zone

    Overview

    Use the getTimezone method to retrieve information on the time zone used by your account for the 2Checkout API.

    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.

    Response

    Parameters Type/Description

    Timezone

    String

     

    The time zone you selected or the default GMT+02:00 time zone of the 2Checkout system.

    Request

    <?php
    
    require ('PATH_TO_AUTH');
    
    $jsonRpcRequest = array (
    'method' => 'getTimezone',
    'params' => array($sessionID),
    'id' => $i++,
    'jsonrpc' => '2.0');
    
    var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
    

     

    Assign additional fields

    Overview

    Use the assignAdditionalField method to assign additional fields to 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.

    FieldCode

    Required (string)

     

    Field identifier. Alpha-numeric chars, underscores and dashes.

    Required

    Boolean

     

    True or False depending on whether you want make the field mandatory or not.

    ProductCode

    Required (string)

     

    The unique product code that you control, not the system-generated product identifier.

    Response

    bool(true)

    Request

    <?php
    
    require ('PATH_TO_AUTH');
    
    $ProductCode = 'YOUR_PRODUCT_CODE';
    $FieldCode = 'YOUR_FIELD_CODE';
    $Required = true;
    
    try {
        $AssignedAdditionalField = $client->assignAdditionalField($sessionID, $FieldCode, $Required, $ProductCode);
    }
    
    catch (SoapFault $e) {
        echo "AssignedAdditionalField: " . $e->getMessage();
        exit;
    }
    
    var_dump("AssignedAdditionalField", $AssignedAdditionalField);
    
    ?>
    

    Update additional fields

    Overview

    Use the updateAdditionalField method to update additional fields for your account.

    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.

    AdditionalField

    Object

     

    Additional field object.

    Response

    bool(true)
    

    Request

    <?php
    
    require ('PATH_TO_AUTH');
    
    $AdditionalField                             = new stdClass();
    $AdditionalField->Label                      = 'Do you agree with the new newsletter policy 2015?';
    $AdditionalField->Type                       = 'LISTBOX';
    $AdditionalField->Code                       = 'NewsletterPolicy1234576';
    $AdditionalField->ApplyTo                    = 'ORDER';
    $AdditionalField->Values                     = array();
    $AdditionalField->Values[0]                  = 'YES';
    $AdditionalField->Values[1]                  = 'NO';
    $AdditionalField->ValidationRule             = null;
    $AdditionalField->Translations               = array();
    $AdditionalField->Translations[0]            = new stdClass();
    $AdditionalField->Translations[0]->Label     = "Êtes-vous d'accord avec la politique de la newsletter?";
    $AdditionalField->Translations[0]->Values    = array();
    $AdditionalField->Translations[0]->Values[0] = 'Oui';
    $AdditionalField->Translations[0]->Values[1] = 'Non';
    $AdditionalField->Translations[0]->Language  = 'fr';
    $AdditionalField->Translations[1]            = new stdClass();
    $AdditionalField->Translations[1]->Label     = 'Haben Sie mit dem Newsletter Politik zu?';
    $AdditionalField->Translations[1]->Values    = array();
    $AdditionalField->Translations[1]->Values[0] = 'Ja';
    $AdditionalField->Translations[1]->Values[1] = 'Nein';
    $AdditionalField->Translations[1]->Language  = 'de';
    
    try {
        $UpdateAdditionalField = $client->updateAdditionalField($sessionID, $FieldCode, $AdditionalField);
    }
    
    catch (SoapFault $e) {
        echo "UpdateAdditionalField: " . $e->getMessage();
        exit;
    }
    
    var_dump("UpdateAdditionalField", $UpdateAdditionalField);
    
    

     

    Retrieve price matrix for product

    Overview

    Use the GetPriceMatrix API call to retrieve details that are used to add or update a special price promotion.

    Request parameters

    Paremeters Type Required Description
    sessionID String Required The unique identifier of the session.
    PriceMatrixRequest Array of Objects Required Contains details that are used to add or update a special price promotion.

    PriceMatrixRequestObject

    Object Required  

    ProductCode

    String Required Product code for the price matrix.

    PricingConfigurationCode

    String Required Pricing configuration code for the price matrix, must be related to the product.

    Response

    Parameters Type Description
    PriceMatrix Array of Objects Only for this type of promotion. It is generated by getPriceMatrix and used to set promotion special prices.
    ProductCode String Product code for the price matrix.
    PricingConfigurationCode String Pricing configuration code for the price matrix, must be related to the product.
    OptionHash String Unique identifier of one combination of price configuration options.
    Options Array of objects Describes price configuration options identified by OptionHash.

    GroupName

    String  

    OptionText

    String  
    Prices Array of Objects Promotion prices by currency, price for default currency is required.

    Value

    Int Decimal.

    Currency

    String ISO currency code.

    Request sample 

    <?php
    
    require('PATH_TO_AUTH');
    
    
    $priceMatrixRequestObject1 = new stdClass;
    $priceMatrixRequestObject1->productCode = "474FF7C0FD"
    $priceMatrixRequestObject1->pricingConfigurationCode = "514EE48419"
    
    $requestBody = [
        $priceMatrixRequestObject1
    ]
    
    $promotionObject->PriceMatrix = [$priceMatrixDefinition1];
    
    
    $jsonRpcRequest = array (
    'jsonrpc' => '2.0',
    'id' => $i++,
    'method' => 'getPriceMatrix',
    'params' => array($sessionID, $requestBody),
    );
    
    $result = callRPC((object)$jsonRpcRequest, $host);
    var_dump($result);
    

    Affiliate marketing: 5 myths debunked

    The performance marketing industry started in 1994 when 3rd party "affiliates" joined the marketing mix advertising pioneers of eCommerce on a pay-for-performance basis. There's been a lot of changes over the last 20 years and affiliate marketing has created a reputation for itself - for better or worse. 

    Hear Rick Gardiner, CEO of Affiliate Management as he highlights some of the major changes in affiliate marketing and shares insight on 5 common misconceptions around working with affiliates including forecasting, cross-channel cannibalization, and more. 

    Join Our Webinar

    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