Skip to main content

Cancel subscriptions

Cancellation

Once you cancel the subscription, you cannot perform any future refund or proration actions

You can reactivate canceled subscriptions. This action also enables actions such as proration, refunds, renewals and upgrades.

To cancel a subscription, click the Cancel immediately button from the subscription page. Choose whether to notify the customer about the subscription cancellation, by checking the "Send notification email to customer" checkbox. Leave the option unchecked in case you don't want your customers to be notified about the cancellation.

Unassign a PricingOption Group

Overview

Use the unassignPricingConfigurationOptionGroup method to remove a PricingOptionGroup from a PricingConfiguration.

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.

pricingConfigurationCode

Required (string)

 

Unique, system-generated pricing configuration identifier.  

priceOptionsGroupAssigned

Required (Object)

 

Details below.

PriceOptionsGroupAssigned

Object

Code

Required (string)

 

PricingOption Group identifier.

Required

Required (Object)

 

True or false depending on whether the pricing options group is required during the purchase process or not.

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$pricingConfigurationCode = 'YOUR_PRICING_CONFIG_CODE';
$priceOptionsGroupAssigned = new stdClass();
$priceOptionsGroupAssigned->Code = 'STORAGE';
$priceOptionsGroupAssigned->Required = false;

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

?>

Custom upgrade links

Overview

On-demand upgrade links allow you to create your own rules in terms of product upgrades, overriding existing upgrade settings through URL parameters. 

Custom upgrade links allow you to define:

  • The upgrade product
  • Upgrade price
  • Product quantity
  • Pricing options
  • Time interval to replace subscription lifetime  

Availability

All 2Checkout accounts.

Create the upgrade link

To build upgrade links you need the following two elements:

  1. The main upgrade link 
    https://secure.2checkout.com/order/upgrade.php?

    The unique subscription identifier from the 2Checkout system: LICENSE=ABC1D2E345. The simplest upgrade link you can build is:

    https://secure.2checkout.com/order/upgrade.php?LICENSE=ABC1D2E345

Query parameters

Build your upgrade links using the following parameters.

Parameter Required / Optional Type/Description
LICENSE Required

Specifies the subscription to be upgraded.

Example: https://secure.2checkout.com/order/upgrade.php?LICENSE=ABC1D2E345
PROD Required Product ID of the target product used in the upgrade process.
PRICES(ProductId)[CURRENCY] Required

Price and currency to be used in the custom upgrade process.

Example: PRICES4692644[USD]=999
QTY Optional

Set product quantity. It does not impact the total order price.

 

PERIOD Optional Period of time to replace the subscription lifetime. Starts when the order is finalized. Requires PRICES parameter.
PHASH Required if using PRICE, PERIOD, OPTIONS, and/or QTY HMAC_MD5 signature in order to prevent the request from being exploited. All custom upgrade links require digital signing, similar to current manual renewal links.
LICENSE Required

Specifies the subscription to be upgraded.

Example: https://secure.2checkout.com/order/upgrade.php?LICENSE=ABC1D2E345
LANG Optional

ISO country code of the language used for the order processing interface and shopper emails.

Default value: EN.

CURRENCY Optional Preselects the billing currency to be used in the transaction.
SHOPURL Optional Custom URL used for "Back to shopping" link.
OPTIONS(ProductID) Optional

Preselects the pricing options for the subscription, using the pricing options codes (the IDs you set for each option individually). You need to append the unique product identifier generated by the 2Checkout platform after the OPTIONS parameter. 

Example: OPTIONS1234567=5usr,2year.
UPGRADEPROD

Required in conjunction with UPGRADEOPT.

Optional otherwise.

Product ID of the target product used in the upgrade process.
UPGRADEOPT Optional Product option code of the target product used in the upgrade process. Can only be used in conjunction with UPGRADEPROD.
DESIGN_TYPE Optional Use DESIGN_TYPE=1 to change the layout of the shopping cart template interface, positioning the payment methods selector in a more prominent position, above the billing details area.
LAYOUT_TYPE Optional

Enables you to control which version of the shopping cart 2Checkout serves to shoppers.

Possible values:

  • CLASSIC - the desktop variant of the shopping cart (2Checkout serves the desktop version of the cart even to mobile device users.)
  • MOBILE - 2Checkout mobile cart (2Checkout serves the mobile version of the shopping cart, even to users of desktop browsers.)
REF Optional External order reference (string). Add a string identifier to every URL (less than 100 characters). 2Checkout saves the string at order-level, in addition to the system-generated order reference. If there is a need for longer references, use an md5 hash. To access external reference info navigate to the order details page.
SRC Optional Identifies the source of a sale by assigning a unique URL identifier. For instance, if there are two buy links on your website, one in the product page and another one in the download page, you can track the source page by entering the following parameters:
  • SRC=prodpage for the product page
  • SRC=dlpage for the link on the download page
COUPON Optional

Promotion coupon code applied to the order. Use commas (,) to separate multiple values.

Example: [...]&COUPON=voucher1,voucher2[...] 
CARD Optional

Possible values:

  • 1 to display the payment form in the selected landing page. Shoppers get to place orders from the Review page.
  • 2 to display the payment form in the selected landing page, and shoppers to place orders immediately after entering their payment data, excluding the Review page.
ORDERSTYLE Optional Allows you to set the desired ordering interface template, overriding the default template assigned to the product group. Each template defined in the Interface Templates area of the Control Panel has a unique identifier associated which is visible in the browser address bar when previewing the shopping cart.
AUTO_PREFILL=1 Optional

Requires 2Checkout activation before using.

 

Use AUTO_PREFILL=1 to set the ZIP code and country fields as mandatory. Address, City and State details are calculated automatically by the 2Checkout system. The address can be excluded completely. Using the AUTO_PREFILL=1 parameter without the feature being enabled for your account will result in shoppers following the classic purchase flow, where all billing address data is mandatory. 

Upgrade a subscription with a specific price and period of time

For this example, let's assume that we need a custom on-demand upgrade link for Subscription A (monthly subscription expiring on June 30th, 2019 with the reference ABC1D2E345) associated with Product A with the ID 1234567.

Product A is offered to customers in two versions:

  • 1 user (code: 1user) - $99.99; (the customer using Subscription A opted for this particular pricing option).
  • 2 users (code: 2users) - $149.99.

You're looking to prolong the subscription lifetime with 30 days, and charge the customer $50. For this example, the parameters must have the following values:

  • LICENSE=ABC1D2E345
  • PROD=1234567
  • OPTIONS1234567=1user
  • PRICES1234567[USD]=50
  • QTY=4
  • PERIOD=30

The resulting upgrade link (excluding PHASH) is:

https://secure.2checkout.com/order/upgrade.php?LICENSE=ABC1D2E345&PROD=1234567&OPTIONS1234567=1user&PRICES1234567[USD]=50&QTY=4&PERIOD=30

Secure upgrade links

Use a HMAC_MD5 signature to prevent links from being exploited. To calculate the HMAC_MD5 signature, you need to build a string from the query parameters of the Buy Link prefixed by the length of the sequence of parameters in tandem with the 2Checkout-generated SECRET KEY for your account (view secret key). 

  1. Using the parameters above, you get the following sequence: 
    LICENSE=ABC1D2E345&PROD=1234567&OPTIONS1234567=1user&PRICES1234567[USD]=50&QTY=4&PERIOD=30
  2. You need to add the length of the character sequence at its beginning, to calculate the hash, namely 90. The resulting base string is
    90LICENSE=ABC1D2E345&PROD=1234567&OPTIONS1234567=1user&PRICES1234567[USD]=50&QTY=4&PERIOD=30
  3. For the purpose of this demo, let's assume that your secret key is SECRET_KEY.
  4. Use the secret key and the base string to calculate the HMAC-MD5 HASH. The result should be: 54e7d22d741f3ceacfe80586ba5d55a7 (valid exclusively for this example).
  5. The final upgrade link:
https://secure.2checkout.com/order/upgrade.php?LICENSE=ABC1D2E345&PROD=1234567&OPTIONS1234567=1user&PRICES1234567[USD]=50&QTY=4&PERIOD=30&PHASH=54e7d22d741f3ceacfe80586ba5d55a7

Domain use

  1. secure.2checkout.com. If your account is using the 2Checkout's secure.2checkout.com domain, then your custom on-demand renewal links would look like this: https://secure.2checkout.com/order/upgrade.php?
  2. Custom domains such as store.YourDomain.com. If your account is using a custom domain such as store.YourDomain.com, then your custom on-demand renewal links would look like this: https://store.YourDomain.com /order/upgrade.php?

Add special price promotion

Overview

Use the AddSpecialPricePromotion method via SOAP API 6.0 to create a promotion with a special price.

Request parameters 

Parameters Type Required Description
Promotion Object Required Contains all details of the promotion.
PriceMatrix Array of Objects Required Only for this type of promotion; is generated by getPriceMatrix and used to set promotion special prices.
Coupon Object Required Type of coupon applied to the promotion.

Request sample

<?php

require('PATH_TO_AUTH');

$promotionObject = new stdClass;
$promotionObject->Name = 'YOUR_PROMOTION_TITLE';
$promotionObject->Description = 'YOUR_PROMOTION_DESCRIPTION';
$promotionObject->DefaultCurrency = "EUR";
$promotionObject->StartDate = date('Y-m-d', strtotime('1 month ago'));
$promotionObject->EndDate = date('Y-m-d', strtotime('+1 month'));
$promotionObject->Type = 'SPECIAL_PRICE';
$promotionObject->Enabled = 1;
$promotionObject->MaximumOrdersNumber = 0;
$promotionObject->MaximumQuantity = 0;
$promotionObject->InstantDiscount = false;
$promotionObject->ApplyRecurring = 'NONE';
$promotionObject->RecurringChargesNumber = 3;
$promotionObject->InstantDiscount = 0;

$couponObject = new stdClass;
$couponObject->Type = 'SINGLE';
$couponObject->Code = 'single_code';
$promotionObject->Coupon = $couponObject;

$productsObj1 = new stdClass;
$productsObj1->Code = 'test';
$promotionObject->Products = [$productsObj1];


$priceMatrixDefinition1 = new stdClass;
$priceMatrixDefinition1->ProductCode = "test";
$priceMatrixDefinition1->PricingConfigurationCode = "738C6A2049";
$priceMatrixDefinition1->OptionHash = "708e43960c4edc42f14cf388bcb24bde";

$option1 = new stdClass;
$option1->GroupName = "Units";
$option1->OptionText = "1 - maximum";

$price1 = new stdClass;
$price1->Value = 10;
$price1->Currency = "USD";
$price2 = new stdClass;
$price2->Value = 15;
$price2->Currency = "EUR";

$priceMatrixDefinition1->Options = [$option1];
$priceMatrixDefinition1->Prices = [$price1, $price2];

$promotionObject->PriceMatrix = [$priceMatrixDefinition1];


try {
    $newPromotion = $client->addPromotion($sessionID, $promotionObject);
} catch (SoapFault $e) {
    echo "NewPromotion: " . $e->getMessage();
    exit;
}

var_dump("Promotion", $newPromotion);

Response

{
   "@encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/",
   "Body": {
      "addPromotionResponse": {
         "addPromotionReturn": {
            "@type": "ns2:Promotion",
            "Code": {
               "@type": "xsd:string",
               "#text": "6GR7JU369E"
            },
            "Name": {
               "@type": "xsd:string",
               "#text": "Promo percentage REST"
            },
            "Description": {
               "@type": "xsd:string",
               "#text": "Promo description1"
            },
            "StartDate": {
               "@type": "xsd:string",
               "#text": "2019-11-30"
            },
            "EndDate": {
               "@type": "xsd:string",
               "#text": "2100-12-31"
            },
            "MaximumOrdersNumber": {
               "@type": "xsd:int",
               "#text": "-1"
            },
            "MaximumQuantity": {
               "@type": "xsd:int",
               "#text": "1"
            },
            "InstantDiscount": {
               "@type": "xsd:boolean",
               "#text": "false"
            },
            "Coupon": {
               "@type": "ns2:PromotionCouponSingleOrMultiple",
               "Type": {
                  "@type": "xsd:string",
                  "#text": "MULTIPLE"
               },
               "Codes": {
                  "@arrayType": "xsd:string[2]",
                  "@type": "ns2:StringArray",
                  "item": [
                     {
                        "@type": "xsd:string",
                        "#text": "code1"
                     },
                     {
                        "@type": "xsd:string",
                        "#text": "code2"
                     }
                  ]
               }
            },
            "Enabled": {
               "@type": "xsd:boolean",
               "#text": "true"
            },
            "ChannelType": {
               "@nil": "true"
            },
            "Type": {
               "@type": "xsd:string",
               "#text": "SPECIAL_PRICE"
            },
            "Discount": {
               "@nil": "true"
            },
            "Products": {
               "@arrayType": "ns2:PromotionProduct[1]",
               "@type": "ns2:PromotionProductsArray",
               "item": {
                  "@type": "ns2:PromotionProduct",
                  "Code": {
                     "@type": "xsd:string",
                     "#text": "test"
                  },
                  "PricingOptionCodes": {
                     "@nil": "true"
                  },
                  "PricingConfigurationCode": {
                     "@nil": "true"
                  }
               }
            },
            "PriceThreshold": {
               "@nil": "true"
            },
            "Translations": {
               "@arrayType": "ns2:PromotionTranslation[1]",
               "@type": "ns2:PromotionTranslationsArray",
               "item": {
                  "@type": "ns2:PromotionTranslation",
                  "Name": {
                     "@type": "xsd:string",
                     "#text": "Promo percentage REST"
                  },
                  "Language": {
                     "@type": "xsd:string",
                     "#text": "EN"
                  }
               }
            },
            "Sources": {
               "@arrayType": "xsd:string[0]",
               "@type": "ns2:SourcesArray"
            },
            "PublishToAffiliatesNetwork": {
               "@nil": "true"
            },
            "ApplyRecurring": {
               "@type": "xsd:string",
               "#text": "NONE"
            },
            "RecurringChargesNumber": {
               "@type": "xsd:int",
               "#text": "0"
            },
            "DefaultCurrency": {
               "@type": "xsd:string",
               "#text": "EUR"
            },
            "PriceMatrix": {
               "@arrayType": "ns2:PromotionPriceMatrix[1]",
               "@type": "ns2:PromotionPriceMatrixArray",
               "item": {
                  "@type": "ns2:PromotionPriceMatrix",
                  "ProductCode": {
                     "@type": "xsd:string",
                     "#text": "test"
                  },
                  "PricingConfigurationCode": {
                     "@type": "xsd:string",
                     "#text": "738C6A2049"
                  },
                  "OptionHash": {
                     "@type": "xsd:string",
                     "#text": "708e43960c4edc42f14cf388bcb24bde"
                  },
                  "Options": {
                     "@arrayType": "ns2:PromotionPriceMatrixOptions[1]",
                     "@type": "ns2:PromotionPriceMatrixOptionsArray",
                     "item": {
                        "@type": "ns2:PromotionPriceMatrixOptions",
                        "GroupName": {
                           "@type": "xsd:string",
                           "#text": "Units"
                        },
                        "OptionText": {
                           "@type": "xsd:string",
                           "#text": "1 - maximum"
                        }
                     }
                  },
                  "Prices": {
                     "@arrayType": "ns2:PromotionPriceMatrixPrices[12]",
                     "@type": "ns2:PromotionPriceMatrixPricesArray",
                     "item": [
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "31.156"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "CAD"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "20"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "EUR"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "40"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "USD"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "1587.5251590698"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "ARS"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "18541.12858627"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "CLP"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "18.1324"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "GBP"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "2447.2"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "JPY"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "499.518"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "MXN"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "97.536"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "RON"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "1846.05"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "RUB"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "601.82854437393"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "UAH"
                           }
                        },
                        {
                           "@type": "ns2:PromotionPriceMatrixPrices",
                           "Value": {
                              "@type": "xsd:double",
                              "#text": "384.374"
                           },
                           "Currency": {
                              "@type": "xsd:string",
                              "#text": "ZAR"
                           }
                        }
                     ]
                  }
               }
            }
         }
      }
   }
} 

Instant Refund Notification (IRN)

Overview

Use Instant Refund/Reverse Notifications (IRN) to automate the process of requesting: 

  • Transaction reversals
  • Full refunds
  • Partial refunds

The IRNs let you send refund and reversal requests directly from your own management interface/platform into the 2Checkout system. 

Once 2Checkout approves the REVERSE/REFUND procedure, we send you an email and an IPN notification containing the status corresponding to the canceled transaction, REVERSE or REFUND respectively. We display the total canceled amount as a negative value.

Reversal

A reversal involves 2Checkout unblocking the shopper's balance corresponding to the transaction that we authorized for future capture immediately after payment confirmation, following approval from the financial department. Reversals happen before 2Checkout captures the authorized amount and also precedes order fulfillment/delivery. 2Checkout does not charge transaction processing commissions for orders that we reverse. Such orders feature the REVERSED status in the 2Checkout Control Panel as well as in all notifications regarding the reversal.

REFUND

2Checkout can only refund completed transactions associated with finalized orders (fulfilled/delivered). 

Method and URL

POST: https://secure.2checkout.com/order/irn.php

Authentication

You're required to validate each request with a HASH (HMAC_SHA256 signature). To build the HMAC_SHA256 source string, prepend each required value with its own length in bytes.

  • Use 0 for null or empty values without prepending their length. However, when the value is 0 (zero), you do need to prepend its length (1).
  • Note that for UTF-8 characters the length in bytes can be longer than the string length.

IRN HASH example

For the purposes of this example, we assume that the values of the secret key are 123456789!@#$%^&*. Your secret key is available in the Account Settings area of your account. 

Field name

Length

Field value

MERCHANT

8

MERCCODE

ORDER_REF

8

12345678

ORDER_AMOUNT

5

39.99

ORDER_CURRENCY

3

USD

IRN_DATE

19

2012-12-12 12:12:12

PRODUCTS_IDS

35386 and 35387 in an array

PRODUCTS_QTY

1 and 2 in an array

REGENERATE_CODES

19

1234-5678-9012-3456

LICENSE_HANDLING

6

CANCEL

Parameters to be included in the HASH signature

$params = array(
'MERCHANT' => 'MERCCODE',
'ORDER_REF' => 12345678,
'ORDER_AMOUNT' => 39.99,
'ORDER_CURRENCY' => 'USD',
'IRN_DATE' => '2012-12-12 12:12:12',
'PRODUCTS_IDS' => array(35386, 35387),
'PRODUCTS_QTY' => array(1, 2),
'REGENERATE_CODES' => array('1234-5678-9012-3456'),
'LICENSE_HANDLING' => array('CANCEL')
);

Serialized string for hash 

8MERCCODE812345678539.993USD192012-12-12 12:12:125353865353871112191234-5678-9012-34566CANCEL
Hash: e24fe2f3a2fadcd375be2fc9410d48fe

Parameters

Include parameters in the request in the exact order featured below. 

Field Type/Required Description Used in HASH calculation

MERCHANT

String/Required

Merchant ID. This is available in the "Account administration" / "Account settings" section of the Control Panel

YES

ORDER_REF

String/Required

The unique reference number of the order from the 2Checkout system for which you’re initiating a refund request.

YES

ORDER_AMOUNT

Double/Required

The total value of the order (total costs customers incurred for the order) for which you’re requesting a reverse/refund.

You can refund a different amount and not necessarily the entire value of the order, and you would specify the funds using the AMOUNT parameter.

YES

ORDER_CURRENCY

String/Required

The currency used for the order.

YES

IRN_DATE

String/Required

The date of the refund request in the following format: Y-m-d H:i:s (2008-05-10 17:30:56).

If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then calculate the IRN_DATE according to your custom configuration. 2Checkout uses your custom time zone for the IRN_DATE when calculating the HASH, and it's important that you also use the same datetime stamp, also per the custom time zone. 

 The default 2Checkout API time zone is GMT+02:00 (EET).

YES

ORDER_HASH

String/Required

The HMAC_SHA256 signature for the transmitted data.

-

SIGNATURE_ALG String/Required The hashing algorithm used to authenticate the request. In order to use SHA2 or SHA3 for auth, simply pass SHA2 or SHA3 as value for the SIGNATURE_ALG parameter NO

REF_URL 

String/Optional

You have the option of setting a URL where 2Checkout sends the response to your IRN request using GET. Make sure to host a listener capable of interpreting the response. (http://www.my-site.com/irn.php)

If you do not use this parameter, 2Checkout displays the answer inline.

NO

PRODUCTS_IDS

 

Array/Optional for full refund/Required for partial refunds

When included, it cannot be empty. Array with the product(s) ID for which you send the reverse/refund request. Number of PRODUCTS_IDS array elements much match those of the PRODUCTS_QTY array.

For total refunds, 2Checkout validates product identifiers, and they need to belong to the products purchased in the same order. Include identifiers for all products in the order.

For partial refunds, include only the IDs for the products that you want to refund.

YES only if included in the request

PRODUCTS_QTY 

 

Array/Optional/Required when you use PRODUCTS_IDS

When included, it cannot be empty. Array with corresponding quantities for product(s) mentioned in PRODUCTS_IDS. Number of PRODUCTS_QTY array elements much match those of the PRODUCTS_IDS array. Quantities cannot exceed those of items purchased as part of the order you’re refunding.

For example, let's assume Customer A purchased 2 units of Product A at $1000. To refund $500 for 1 unit of product A, the value of PRODUCTS_QTY needs to be 1.

For total refunds, match the value of PRODUCTS_QTY to the total number of units per product purchased with that order.

YES only if included in the request

REGENERATE_CODES

String/Optional

Array with codes you want 2Checkout to reallocate to the static list associated with the product. Ignore if you use dynamic lists.

For dynamic lists of activation codes/keys, 2Checkout does not generate an error if you include the parameter. This applies to HASH calculation as well.

YES only if included in the request.

LICENSE_HANDLING

Array/Optional

For regular products: array containing the action that 2Checkout should carry out regarding the subscriptions/licenses generated with the customer’s purchase.

For bundles set to generate subscriptions/licenses for each bundled product, LICENSE_HANDLING should be an array of an array.

Possible values:

  • CANCEL - cancels the subscription/license immediately. No future actions can be performed for canceled items, including renewals or upgrades.
    • Note:  License will be canceled only if you enabled from cPanel the option of canceling subscriptions for total refunds. Find more information here.
  • NONE - left the subscription/license unchanged.

If LICENSE_HANDLING is empty, the 2Checkout system interprets the value as NONE.

2Checkout correlates impact on subscriptions based on the values you send using LICENSE_HANDLING with the product identifiers you set using PRODUCTS_IDS. For example, let's assume that you're trying to refund

  • Product 1 (regular product): unique ID (1234567), that generated a subscription that you want to cancel with the reference 1A234567B89.
  • Product 2 (bundle product): unique ID (1122334), that generated 2 subscriptions, one you want to cancel, with the reference 9X234567X00 and one you wish to leave untouched 5Z234567Z11.

Then you will need to send:

  • 'PRODUCTS_IDS' => array(1234567, 1122334)
  • 'LICENSE_HANDLING' => array('CANCEL', array(9X234567X00=>CANCEL, 5Z234567Z11=>NONE))

YES only if included in the request

AMOUNT

Double or Array/Required

Double (Float) - a single value for total refunds. 'AMOUNT' => '150.00'- in this case AMOUNT (equal to ORDER_AMOUNT) needs to match the total value of the order.

Or, array with the specific amounts that will be refunded to customers only for partial refunds. When issuing partial refunds, PRODUCTS_IDS is mandatory.

 

The amounts reimbursed to customers must match the products for which the refund/reverse is made.

  • When the amount of money paid back to customers is smaller than the value of the initial order (ORDER_AMOUNT), specify the value of the refund using AMOUNT.
  • If AMOUNT is missing, then the entire value of the order (ORDER_AMOUNT) will be refunded.

For example, Customer A purchased 3 units of Product A (ID=1234567) at $300 and 5 units of Product B (ID=1112223)at $500. You want to issue partial refunds of $150 for Product A and $250 for Product B.

'PRODUCTS_IDS' => array('1234567', '1112223'),

'PRODUCTS_QTY' => array(2,3),

'AMOUNT' => array ('150.00', '250.00'),

For the same example, if you want to refund only $150 for Product A:

'PRODUCTS_IDS' => array('1234567'),

'PRODUCTS_QTY' => array(1),

'AMOUNT' => array ('150.00'),

You can issue a partial refund through IRN even for orders that contain only a single unit of a product. For example, let's assume Customer A purchased 2 units of Product A at $150. You will be able to refund a part of the full $150 for 1 unit of product A (the value of PRODUCTS_QTY needs to be 1). In this case, you also need to use the following format:

 

'PRODUCTS_IDS' => array('1234567'),

'PRODUCTS_QTY' => array(2),

'AMOUNT' => array ('300.00'),

For the same example, if you want to refund only $50 for Product A:

'PRODUCTS_IDS' => array('1234567'),

'PRODUCTS_QTY' => array(1),

'AMOUNT' => array ('150.00'),

YES

REFUND_REASON String/Optional

Refund reason.

Include one of the refund reasons predefined by in our platform:

  • Chargeback
  • Duplicate order
  • Not satisfied with the product
  • Product not received
  • Unwanted auto-renewal
  • Technical issue with the product
  • Other
  • No reason

If you have set your own refund reasons, you can include one of your custom reasons defined.

Click here to learn how to customize your refund reasons.

An error is thrown if you send a refund reason which is not part of the list predefined by 2Checkout, or a reason customized by you.

Can be null.

YES only if included in the request

Response

2Checkout validates your request by showing a response in the page that receives the information, under the following format:

<EPAYMENT>ORDER_REF|RESPONSE_CODE|RESPONSE_MSG|IRN_DATE|ORDER_HASH </EPAYMENT>

The parameters in the validation signature 2Checkout sends:

ORDER_REF

The order reference in the 2Checkout system, received through IRN

RESPONSE_CODE

The answer code for the order reverse request

RESPONSE_MSG

The answer to the order reverse request

IRN_DATE

The date of the answer to the order reverse request, in the following format: YYYY-MM-DD HH:mm:ss (24 hour format)

(Ex: 2009-01-30 11:33:37)

If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the IRN_DATE will be calculated according to your custom configuration. 2Checkout will use your custom set time zone for the IRN_DATE when calculating the HASH, and it's important that you also use the same datetime stamp, also per the custom time zone. Note: The default 2Checkout API time zone is GMT+02:00

ORDER_HASH

The HMAC_SHA256 data validation signature



If the 2Checkout response is set to be sent to a specific URL (the REF_URL parameter contains a valid URL), the reply will be sent as follows:

REF_URL = http://www.mysite.com/callback.php

http://www.mysite.com/callback.php?ORDER_REF=value&RESPONSE_CODE=value&RESPONSE_MSG=value&IRN_DATE=value&ORDER_HASH=value
Secret key: 123456789!@#$%^&*
<EPAYMENT>12345678|1|OK|2012-12-12 12:12:12</EPAYMENT>
Serialized string for hash: 812345678112OK192012-12-12 12:12:12
Hash: e8324511d50f0f78a0a20aca28295290

IRN response codes and messages

Response code

Response message

1

OK

2

ORDER_REF missing or format incorrect

3

ORDER_AMOUNT missing or format incorrect

4

ORDER_CURRENCY is missing or format incorrect

5

IRN_DATE is not in the correct format

6

Error canceling order

7

Order already canceled

8

Unknown error

9

Invalid ORDER_REF

10

Invalid ORDER_AMOUNT

11

Invalid ORDER_CURRENCY

12

PRODUCTS_IDS missing or format incorrect

13

PRODUCTS_QTY missing or format incorrect

14

Invalid PRODUCTS_QTY

15

Invalid REGENERATE_CODES

16

Invalid LICENSE_HANDLING

17

AMOUNT missing or format incorrect

18

Invalid AMOUNT

19

You have already placed a Total refund for this order.

20

You have already placed a refund for this order.

21

You already have a pending refund request.

22

The maximum refundable amount for this order has been exceeded.

23

You cannot place a refund request due to the order's current status.

24

You cannot place a refund request due to the order's payment details.

25

The allowed period to request a new refund for this order has expired.

26

Multiple refunds are not supported by this order's payment type.

27

Refunding not supported for this Cross Vendor Sale order.

28

Order total is negative.

29

You cannot place a refund request due to the order's approval status.

30

Multiple refunds are not supported by this order's terminal.

31

Partial reverse is not supported.

32

Invalid product type. Refunds are available only for the following product types: REGULAR / BUNDLE / MEDIA / DOWNLOAD_INSURANCE, but not for DISCOUNT / SHIPPING.

33

You cannot request a refund because a chargeback dispute was open for the order.

34 Invalid REFUND_REASON
* Access not permitted!
 

*In some cases “Response message” does not have a “Response code”.

Batch refunds/reversals

Batch processing is not supported. You need to send standalone requests for every reverse or total/partial refund.

PHP code samples

Total refund

<?php

function SerializeArray($myarray, $strip_slashes = true, $elementsToProcess = null)
{
    $retvalue = "";
    if ($elementsToProcess !== null && is_array($elementsToProcess)) {
        $_myarray = $myarray;
        $myarray = array();

        foreach ($elementsToProcess as $key) {
            if (!isset($_myarray[$key])) {
                continue;
            }
            $myarray[$key] = $_myarray[$key];
        }
    }
    foreach ($myarray as $val) {
        if (is_array($val)) {
            $retvalue .= SerializeArray($val, $strip_slashes);
        } else {
            $size = ($strip_slashes) ? strlen(StripSlashes($val)) : strlen($val);
            $retvalue .= ($strip_slashes) ? $size . StripSlashes($val) : $size . $val;
        }
    }

    return $retvalue;
}

$key = "SECRET_KEY";

$algo = "sha256"; // or sha3-256

$irn = array(
    'MERCHANT'       => 'MERCHANT',
    'ORDER_REF'      => 12345678,
    'ORDER_AMOUNT'   => 11.00,
    'ORDER_CURRENCY' => 'USD',
    'IRN_DATE'       => date('Y-m-d H:i:s'),
    'SIGNATURE_ALG'  => $algo,
    'REFUND_REASON'  => 'Other' // send one of the 2Checkout predefined reasons, or your customized reason
);

$process = array(
    'MERCHANT',
    'ORDER_REF',
    'ORDER_AMOUNT',
    'ORDER_CURRENCY',
    'IRN_DATE',
    'PRODUCTS_IDS',
    'PRODUCTS_QTY',
    'REGENERATE_CODES',
    'LICENSE_HANDLING',
    'AMOUNT'
);
$string = SerializeArray($irn, true, $process);

$hash = hash_hmac($algo, $string, $key);

$irn['ORDER_HASH'] = $hash;

$dataels = array();

$data = http_build_query($irn); $curl = curl_init("https://secure.2checkout.com/order/irn.php");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_SSLVERSION, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_PROXY, '');
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$responseString = curl_exec($curl);

var_dump($responseString); 

Multiple partial refunds

<?php

function SerializeArray($myarray, $strip_slashes = true, $elementsToProcess = null)
{
    $retvalue = "";
    if ($elementsToProcess !== null && is_array($elementsToProcess)) {
        $_myarray = $myarray;
        $myarray = array();

        foreach ($elementsToProcess as $key) {
            if (!isset($_myarray[$key])) {
                continue;
            }
            $myarray[$key] = $_myarray[$key];
        }
    }
    foreach ($myarray as $val) {
        if (is_array($val)) {
            $retvalue .= SerializeArray($val, $strip_slashes);
        } else {
            $size = ($strip_slashes) ? strlen(StripSlashes($val)) : strlen($val);
            $retvalue .= ($strip_slashes) ? $size . StripSlashes($val) : $size . $val;
        }
    }

    return $retvalue;
}

$key = "SECRET_KEY";

$algo = "sha256"; // or sha3-256

$irn = array(
    'MERCHANT'       => 'MERCHANT',
    'ORDER_REF'      => 12345678,
    'ORDER_AMOUNT'   => 11.00,
    'ORDER_CURRENCY' => 'USD',
    'IRN_DATE'       => date('Y-m-d H:i:s'),
    'PRODUCTS_IDS'   => array(1119321, 2225673),
    'PRODUCTS_QTY'   => array(1, 1),
    'SIGNATURE_ALG'  => $algo,
    'AMOUNT'         => array('1.00', '5.00')
);

$process = array(
    'MERCHANT',
    'ORDER_REF',
    'ORDER_AMOUNT',
    'ORDER_CURRENCY',
    'IRN_DATE',
    'PRODUCTS_IDS',
    'PRODUCTS_QTY',
    'REGENERATE_CODES',
    'LICENSE_HANDLING',
    'AMOUNT'
);
$string = SerializeArray($irn, true, $process);

$hash = hash_hmac($algo, $string, $key);

$irn['ORDER_HASH'] = $hash;

$dataels = array();

$data = http_build_query($irn);  

$curl = curl_init("https://secure.2checkout.com/order/irn.php"); curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_SSLVERSION, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_PROXY, '');
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$responseString = curl_exec($curl);

var_dump($responseString); 

Account identity verification

Overview

2Checkout complies with regulatory obligations worldwide and is committed to providing a secure platform for all our customers. This is why we are asking you to confirm your identify and provide proof of ownership of your company.

Account identity verification is a process referred to as "Know Your Customer" (KYC). We have simplified the process of supplying all valid, relevant documents, which should take you only a few minutes, and we appreciate your cooperation when it comes to verifying your information and reducing risk.

Requirements

Provide scanned copies of valid, relevant documents (i.e., do not include expired documents).

Workflow

For new accounts

1. Sign-up for a 2Checkout account.

2. Navigate to the Know your customer area and upload scanned copies of relevant documents from the checklist in this article. This will accelerate the review process and you can start selling and accepting transactions from customers worldwide.

3. Newly created 2Checkout accounts undergo a review.

4. Work with the 2Checkout underwriting team to help validate your information.

For existing accounts

1. Log in to your Merchant Control Panel account.

2. Navigate to Settings in the upper right corner of your Dashboard, as shown below.

account_verification1.png

3. In the Account Settings window, scroll down to the Account Information section and click on the Business Details link, as the image below shows.

account_verification2.png

4. In the Know your customer documents window, scroll down to the Upload documents field and select the type/types of documents you want to upload. 

account_verification3.png

5. After adding your scanned copies of documents, click on the Upload button.

account_verification4.png

As regulatory and compliance obligations change over time, 2Checkout can request additional valid, relevant documents to verify your identity and proof of ownership of your company.

KYC Documents Checklist

The document checklist is different for individuals and for businesses/companies.

Individuals

  • Valid government-issued ID such as a passport or national identity card
  • Valid address proof, such as electricity bill, telephone bill (no older than two months from the date when you upload the scanned copies)
  • Any other valid, relevant documents that can prove your identity (in addition to the government-issued ID)

Companies/Business Entities

  • Company ownership documents (such as Articles of Incorporation or Organization, showing beneficial ownership)
  • Tax identification documents
    • Europe - TIN or other relevant documentation
    • US - SSN / TIN / PTIN or other relevant documentation
  • Valid government-issued ID such as a passport or national identity card. Include DOB, for anybody with 10% or more ownership in the company
  • Any other valid, relevant documents that can prove your identity and offer proof of ownership for your company.

Retrieve campaign texts

Overview

Use the getCrossSellTexts method to extract information on all cross-sell campaigns texts.

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.

LanguageCode

Required (string)

 

ISO language code. (ISO 639-1 two-letter code).

Response

Parameters Type/Description

Title

String

 

Cross-selling message title. Set here.

Description

String

 

Cross-selling message description. Set here.

Language

String

Request

<?php

require ('PATH_TO_AUTH');

$LanguageCode = 'de'; //returns title and description texts you set under https://secure.2checkout.com/cpanel/network_cross_selling_settings.php

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

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


Subscription details

Subscription details

After logging in to your Merchant Control Panel account, navigate to Orders & Customers → Subscriptions, and use the Subscription search filters to see subscriptions of a certain type and/or from a specific time period.

Click the View button in the Subscription details column to see more details.

Main subscription details page area

At the top of the page you can see some general details of the subscription:

  • Subscription status;
    • Subscription details: An upgraded label will be applicable only to the upgraded subscriptions with disable option
  • 2Checkout Subscription Reference;
  • Customer (the shopper who made the purchase);
  • Product name

Subscription info

This area centralizes details on:

  • Start date;
  • Expiration date;
  • Billing cycle value;
  • Automatic billing status;
  • Payment Method and the four last digits of the credit/debit card used for payments;
  • Next billing date;
  • Current billing amount.

Statistics

This area shows an overview of the subscription value expressed in your account's default settlement currency.

The statistics offer a quick overview of the evolution of a subscription, helping you to keep track of renewals, upgrades, and notifications.

Manual renewal and upgrade

Access manual renewal and upgrade links for subscriptions. 

Subscription history

This area centralizes information on orders (including unfinished renewals), notifications and changes impacting a specific subscription. You can see if one of your customers chose to opt-out from renewal e-mails using the unsubscribe link from the reminder e-mails, or from his 2Checkout account. The actions of subscribing to renewal e-mails are also captured in the subscription history.

Expiration notification

For expired subscriptions, you can send a renewal reminder to your customers directly from the Subscription page. Click the Send expiration email and choose whether the expired card instructions should also be included in the email notification.

End-user 

This area shows details of the subscription's end user. The data is identical to the delivery details the customer entered when placing the initial order and can be identical to the billing information.

Subscription renewal billing following the initial purchase will be done using the end-user details, and not the original billing information supplied by the customer when the product was first purchased.

You can edit this data by clicking the Edit button.

How to generate a JSON Web Token (JWT) for the Signature Generation API endpoint

Overview

In order to pass the identity of the merchant to the 2Checkout Signature Generation API endpoint, you need to generate a valid JSON Web Token (JWT). This is an Internet standard for creating JSON-based access tokens that assert some number of claims.

The https://jwt.io/ website allows you to decode, verify, and generate JSON Web Tokens.

Recommended resources

JWTs are credentials, which can grant access to resources. Be careful where you paste them! 

Generate a merchant JWT

To generate a merchant JWT, follow the steps below:

1. Before generating a JWT, you need to copy the Buy-link Secret Word from your Merchant Control Panel. Log in to your Control Panel and navigate to Integrations → Webhooks & APISecret word section.

2. Copy the string from the Buy-link Secret Word field to the clipboard.

3. Navigate to the https://jwt.io website and start generating the JWT token.

  • In the Debugger section, you need to input data into the sections highlighted in this image.

jwt_io.png

 

  • The data in the HEADER section identifies which algorithm and token type are used to generate the signature. For your JWT token, use HMAC-SHA-512 (HS512) and token type JWT:
    • alg: HS512 (string, required) - encryption algorithm;

    • typ: JWT (string, required) - token type;

{
 "alg" : "HS512",
 "typ" : "JWT"
}
  • The PAYLOAD section contains a set of claims. The JWT specification defines seven Registered Claim Names which are the standard fields commonly included in tokens. For your JWT, use the following claims:
    • sub: MERCH_CODE (string, required) - subject, the merchant code whom the token refers;

    • iat: 1580915730 (string, required) - issued at, must be current timestamp since the UNIX epoch;

    • exp: 1580915730 (string, optional) - expiration time, must be in UNIX timestamp format from future.

If the expiration time (exp) is not provided, the JWT token expiration time will be calculated from iat + 30 minutes.

All the other fields/claims will be ignored.

 {
  "sub": "MERCH_CODE",
  "iat": 1580912768,
  "exp": 1580916205
}
  • In the VERIFY SIGNATURE section, you calculate the signature. This is calculated by encoding the header and payload using Base64url encoding and concatenating the two values with a period separator. Then run the resulting string through the cryptographic algorithm specified in the header, which in this case is HMAC-SHA512.
  • For your JWT token, replace the <Buy link secret word> from the example below with your Buy-link Secret Word from step 1.
HMACSHA512(
  base64UrlEncode(header) + "." +
  base64UrlEncode(payload),
  <Buy link secret word>
)
  •  You will get the JWT token:
eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJz...z0ZY6L6T1GvlOHiptgOQ

4. Use this JWT token in the future to pass your identity as a merchant to the 2Checkout Signature Generation API endpoint. 

Create product group

Overview

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

  • Send null for product group Code. 2Checkout ignores any values you send for Code and generates identifiers itself. 
  • Use unique product group names. 
  • 2Checkout throws an exception if you send a blank product group.
  • If you send only the name of the product group 2Checkout 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. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

ProductGroup

Required (object)

 

Use this object to create product groups. Send null for the Code. 2Checkout generates unique product group code identifiers. 

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$ProductGroup = new stdClass();
$ProductGroup->Name = 'New Product Group from API';
$ProductGroup->Code = null;//Send null for the Code. 2Checkout 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';

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addProductGroup',
'params' => array($sessionID, $ProductGroup)
);

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

?>

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo