Skip to main content

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

?>

Create proposal

Overview

Use the createProposal method via JSON-RPC API 6.0 to add/create a new quote.

Request Parameters

Parameters Type Required/Optional Description
proposal Object Required  
proposalContent Object Required  
lineItems Object Required  
sessionId String Required Unique 2Checkout session ID code.

Request Sample

<?php

require ('PATH_TO_AUTH');

$proposal = new stdClass();
$proposal->Type = "acquisition";
$proposal->BillTo = new stdClass();
$proposal->BillTo->Company = "Billing company";
$proposal->Content = new stdClass();
$proposal->Content->Language = "EN";
$proposal->Content->Currency = "USD";
$proposal->Content->LineItems =  array();
$lineItem = new stdClass();
$lineItem->ProductName = "My Product Name";
$lineItem->ProductCode = "5DCB30C6B0";
$lineItem->Quantity = 1;
$lineItem->Price = 54.2;
$lineItem->DiscountedPrice = 50;
$lineItem->PriceType = "net";
$lineItem->ContractPeriod = 0;
$proposal->Content->LineItems[0] = $lineItem;
$proposal->tac = new stdClass();
$proposal->tac->content = "Lorem ipsum.";
$proposal->SellTo = new stdClass();
$proposal->SellTo->Company = "End user company";

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

try {
    $result = callRPC($jsonRpcRequest, $host);
    echo "Proposal: </br>", 
    var_dump($result);
}
catch (SoapFault $e) {
    echo "Could not fetch proposal: " . $e->getMessage();
    exit;
}

Request sample with prorationDate

<?php


        require('PATH_TO_AUTH');

        $proposal = new stdClass();
        $proposal->Type = "amendment";
        $proposal->BillTo = new stdClass();
        $proposal->BillTo->Company = "Billing company";
        $proposal->Content = new stdClass();
        $proposal->Content->Language = "EN";
        $proposal->Content->Currency = "USD";
        $proposal->Content->Terms = 30;
        $proposal->Content->LineItems = array();
        $lineItem = new stdClass();
        $lineItem->ProductName = "My Product Name";
        $lineItem->ProductCode = "5DCB30C6B0";
        $lineItem->Quantity = 1;
        $lineItem->Price = 54.2;
        $lineItem->DiscountedPrice = 50;
        $lineItem->PriceType = "net";
        $lineItem->ContractPeriod = 0;
        $lineItem->ProrationDate = "2020-11-14T15:28:56+00:00";
        $lineItem->subscriptionReference ="1234567890";
        $proposal->Content->LineItems[0] = $lineItem;
        $proposal->tac = new stdClass();
        $proposal->tac->content = "Lorem ipsum.";
        $proposal->SellTo = new stdClass();
        $proposal->SellTo->Company = "End user company";

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

        try {
            $result = callRPC($jsonRpcRequest, $host);
            echo "Proposal: </br>",
            var_dump($result);
        } catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

Request sample with vatCode

<?php

        require ('PATH_TO_AUTH');

        $proposal = new stdClass();
        $proposal->Type = "acquisition";
        $proposal->BillTo = new stdClass();
        $proposal->BillTo->Company = "Billing company";
        $proposal->Content = new stdClass();
        $proposal->Content->Language = "EN";
        $proposal->Content->Currency = "USD";
        $proposal->Content->LineItems =  array();
        $lineItem = new stdClass();
        $lineItem->ProductName = "My Product Name";
        $lineItem->ProductCode = "5DCB30C6B0";
        $lineItem->Quantity = 1;
        $lineItem->Price = 54.2;
        $lineItem->DiscountedPrice = 50;
        $lineItem->PriceType = "net";
        $lineItem->ContractPeriod = 0;
        $proposal->Content->LineItems[0] = $lineItem;
        $proposal->tac = new stdClass();
        $proposal->tac->content = "Lorem ipsum.";
        $proposal->SellTo = new stdClass();
        $proposal->SellTo->Company = "End user company";
        $proposal->SellTo->VatCode = "854234564";

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

        try {
            $result = callRPC($jsonRpcRequest, $host);
            echo "Proposal: </br>", 
            var_dump($result);
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

Request sample with TaxExemptionId

<?php

        require ('PATH_TO_AUTH');

        $proposal = new stdClass();
        $proposal->Type = "acquisition";
        $proposal->BillTo = new stdClass();
        $proposal->BillTo->Company = "Billing company";
        $proposal->Content = new stdClass();
        $proposal->Content->Language = "EN";
        $proposal->Content->Currency = "USD";
        $proposal->Content->LineItems =  array();
        $lineItem = new stdClass();
        $lineItem->ProductName = "My Product Name";
        $lineItem->ProductCode = "5DCB30C6B0";
        $lineItem->Quantity = 1;
        $lineItem->Price = 54.2;
        $lineItem->DiscountedPrice = 50;
        $lineItem->PriceType = "net";
        $lineItem->ContractPeriod = 0;
        $proposal->Content->LineItems[0] = $lineItem;
        $proposal->tac = new stdClass();
        $proposal->tac->content = "Lorem ipsum.";
        $proposal->SellTo = new stdClass();
        $proposal->SellTo->Company = "End user company";
        $proposal->SellTo->TaxExemptionId = "854234564";

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

        try {
            $result = callRPC($jsonRpcRequest, $host);
            echo "Proposal: </br>", 
            var_dump($result);
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

Response

The createProposal API call returns Proposal object.

Cross-sell

Overview

Use this object to retrieve information about the cross-sell campaigns you configured for your account. 

Parameters

CrossSellCampaign

Object

MasterProducts

Array

 

Array of product codes for the items you set to trigger the cross-sell campaign.

DisplayType

String

 

  • cart – Shopping cart
  • review – Review page
  • finish – Thank you page

DisplayInEmail

Boolean

 

True or false depending on whether you set the cross-sell campaign to display in payment receipt emails or not.

Products

Array of objects

 

Details below

 

ProductCode

String

 

 

Product code for the item you set as recommended for the cross-sell campaign.

 

Discount

String

 

 

Value of the discount. This is a percentage.

 

DiscountType

String

 

 

PERCENT – you can only set discounts as a percentage from the product price.

CampaignCode

String

 

Unique, system-generated cross-sell campaign code.

Name

String

 

Campaign name.

StartDate

String

 

YYYY-MM-DD. The start date you set for the cross-sell campaign.

EndDate

String

 

YYYY-MM-DD. The end date you set for the cross-sell campaign.

 

InLine Checkout methods and parameters

Overview

Minimize your customers' effort by collecting their order/billing information and passing it to InLine Checkout. Simplify the checkout experience and enable your customers to place orders only by confirming their payment information.

 

Related links

Advanced InLine Checkout experience

InLine Checkout offers you advanced control over the ordering process, for minimizing the customer's effort during the purchase. You can send the billing and delivery information directly to the cart if they are collected on your website by a shopping cart application. InLine Checkout enables you to:

  • Place test orders
  • Set coupons codes in cart
  • Set the cart language
  • Set the cart currency
  • Set a redirect URL after a finalized purchase

We recently improved the perceived loading time for the InLine checkout ordering engine by pre-loading the cart iframe. Faster loading time for the InLine cart means an enhanced shopping experience and helps you to increase conversion rates with no other effort on your side. See more details below in the Cart methods table.

Send information to InLine Checkout

After you integrate the InLine Checkout JavaScript code in your website application, you get access to the library that allows you to add products, control billing and shipping details, and start the checkout process. Follow the instructions below to control the information displayed by InLine Checkout.

Handling products

Products are handled by the products' service. This service allows you to retrieve the list of added products, add products to cart, remove individual products, or remove all the products from the cart.

Use the methods and product attributes listed below to add/remove products from the cart.

Product attributes

Attributes Type/Description
code

String

Product code assigned by you when creating the product. Required for catalog products.

type

String

Product type. Required only for dynamic products. Possible values:

[PRODUCT, SHIPPING, TAX]. Default value is PRODUCT.

name

String

Product name. Required for dynamic products.

price

String - for dynamic products

Product price. It is required for dynamic products.

 

Object - for catalog products with on-the-fly pricing

Product price. It is required for catalog products with on-the-fly pricing and includes value and currency.

tangible

String

Product tangible flag. Required only for dynamic products. Default value is FALSE.

quantity

String

Product quantity. Default value is 1. Required for catalog products with on-the-fly pricing.

options

Array

The product price options. It is supported for both catalog and dynamic products. Required for catalog products with on-the-fly pricing.

 

Product price options structure for dynamic products:

  • Name (String)- The price option name
  • Value (String, Number, Array of strings or numbers) - The price option value
  • Surcharge (string) - The price option surcharge - applicable only for dynamic products

Product price options structure for catalog products:

  • Name (String) – The unique code of the pricing OPTION GROUP
  • Value (String) – The unique code of the pricing OPTION
recurrence

Object

Required for dynamic products.

Possible values:

  • DAY
  • WEEK
  • MONTH
  • YEAR
  • FOREVER (available only for duration)

This parameter is conditioned by two other parameters: duration and renewalPrice.

duration

Object

Sets the duration of the recurrence. Required for dynamic products.

renewalPrice

Integer

Sets the price to be applied to the renewal order. Required for dynamic products.

Product methods

Methods Description
add Adds a single product to the list. Use the above list of parameters to add a product to cart.
remove Removes a product from the list.
addMany

Adds an array of product objects to the main list.

removeAll

Removes all products from the list.

getAll

Retrieves the products list.

HANDLING billing details

Billing details are handled by the billing service. Each billing information is controlled by a setter method.

Use the attributes and methods listed below to control the billing information displayed in the cart. Customers are able to fill in their billing information in the overlay provided by InLine Checkout. In case your shopping cart application collects customer's billing information, use the attributes and methods listed below to pass that information over to the cart.

Billing details attributes

Attributes Type/Description
name

String

Customer billing name. Example: "John Doe". 

email

String

Customer billing email. Example: "john.doe@email.com".

phone

String

Customer billing phone number. Example: "403940281923".

country

String

Customer billing country. Example: "US".

city

String

Customer billing city. Example: "Los Angeles".

state

String

Customer billing state. Example: "California".

zip

String

Customer billing zip code. Example: "90078".

address

String

Customer billing address. Example: "1093 Rodeo Drive".

address2

String

Customer billing additional address information. "293 Postal Box".

company-name

String
CompanyName

When sending the Company name the Company checkout flow will be triggered. Otherwise, the default checkout flow for InLine cart is the individual flow.

fiscal-code

String
fiscalCode

When sending the Fiscal code, the Company checkout flow will be triggered only if also another company flow relevant parameter will be also sent (Company name and/or Tax office). Otherwise, the default checkout flow for InLine cart is the individual flow.

tax-office

String
taxOffice

When sending the Tax office the Company checkout flow will be triggered. Otherwise, the default checkout flow for InLine cart is the individual flow.

Billing details methods

Methods Description
setData

Sets the entire billing data.

setName Sets the billing name.
setEmail Sets the billing email.
setPhone

Sets the billing phone.

setCountry Sets the billing country.
setCity Sets the billing city.
setState Sets the billing state.
setZip

Sets the billing zip code.

setAddress Sets the billing address.
setAddress2 Sets additional billing address information.
reset Resets the billing data.

setCompanyName

Sets the billing Company name

setFiscalCode

Sets the billing Fiscal code

setTaxCode

Sets the billing Tax code

Handle shipping details 

Shipping details are handled by the shipping service. Each shipping information is controlled by a setter method.

Use the attributes and methods listed below to control the shipping information displayed in the cart. In case you use a shopping cart application that collects the shipping information, use the attributes and methods listed below to pass that information over to the cart.

Shipping details attributes

Attributes Type/Description
name

String

Customer shipping name. Example: "John Doe". 

email

String

Customer shipping email. Example: "john.doe@email.com".

phone

String

Customer shipping phone number. Example: "403940281923".

country

String

Customer shipping country. Example: "United States of America".

city

String

Customer shipping city. Example: "Los Angeles".

state

String

Customer shipping state. Example: "California".

zip

String

Customer shipping zip code. Example: "90078".

address

String

Customer shipping address. Example: "1093 Rodeo Drive".

address2

String

Customer shipping additional address information. "293 Postal Box".

Shipping details methods

Methods Description
setData

Sets the entire shipping data.

setName Sets the shipping name.
setEmail Sets the shipping email.
setPhone

Sets the shipping phone.

setCountry Sets the shipping country.
setCity Sets the shipping city.
setState Sets the shipping state.
setZip

Sets the shipping zip code.

setAddress Sets the shipping address.
setAddress Sets additional shipping address information.
reset Resets the shipping data.

HANDLE the Checkout process 

Control the cart behavior by using the cart service. Use the checkout method to start the InLine Checkout experience.

Cart attributes

Attributes Type/Description
source

String

Sale originating source. Example: "YouTube Channel".

language

String

Cart language code. Example: "FR".

currency

String

Cart currency code. Example: "USD".

test

Boolean

Test order flag. Possible values:

  • true for test orders
  • false for real orders
setReturnMethod

String

Sets the ReturnMethod object. 

URL to which customer is redirected after a successful payment. Example: https://www.merchant-website.com.

coupon

String

Order promotion coupon. Example: "50%off".

token

String

Token for the authorization code.

expiration

String

The expiration date for the authorization.

orderExternalRef

String

The unique identifier of an order placed in the 2Checkout system, mirroring the reference you're using to manage order data in your system.

CustomerReference Integer. The 2Checkout system generates default customer numerical (integer) IDs automatically for all orders containing products that feature subscriptions. Can be used for new acquisitions aggregating new subscriptions under an existing Customer account.
ExternalCustomerReference String. The external customer reference.
autoAdvance

Boolean. Auto-advanced flag.

 

Possible values:

  • true for auto-advance
  • false for cart flow without auto-advance

Cart methods

Methods Description
register*

Makes the products, billing, shipping, cart and formParser services available.

These services are unavailable unless this method is called.

checkout

Starts the cart service which displays the overlay payment form.

addCoupon

Adds a coupon to the coupons list.

addCoupons Adds coupons in the cart from a list array.
removeCoupon

Removes a coupon from the coupons list.

removeCoupons

Clears all coupons from the cart instance.

setSource

Sets the order source.

setCurrency

Sets the currency on the cart instance.

setLanguage

Sets the language code for the order.

setReturnMethod

Sets the ReturnMethod object by calling TwoCoInlineCart.cart.setReturnMethod({url, type}). 

URL to which customer is redirected after a successful payment. Example: https://www.merchant-website.com.

setTest

Send true for placing a test order.

setLoaderState Handles the overlay window visibility.
setIframeState

Handles the loader visibility.

reloadCart

Reloads the cart instance.

setOrderExternalRef Sets the order external reference.
setCustomerReference Sets 2Checkout customer reference.
setExternalCustomerReference Sets external customer reference.
setCartLockedFlag

Boolean

Lock cart flag. Possible values:

  • true 
  • false

setIframeLoad

One string parameter: 'immediate' or 'delayed'. Additionally, the InLine cart can also be set by using TwoCoInlineCart',{"app":{"merchant":"MERCHANT_CODE", "iframeLoad": "immediate"} instead of TwoCoInlineCart.setup.setIframeLoad.

setIframeLoadDelay

One number parameter; sets the time in milliseconds. Modify the pre-loading time of the cart iframe by adding a delay using the TwoCoInlineCart.setup.setIframeLoadDelay method. 

setReset

Boolean

Erases all previous cart sessions from the customer's browser upon opening a new cart to avoid overlapping of the buy-link parameters. Possible values:

  • true 
  • false 
cart.setAutoAdvance

Sets the auto-advanced cart behavior. If all mandatory checkout parameters are prefilled, the shopper is advanced to the payment details page. 

addAdditionalField Sets an additional field for your account.

Retrieve cart attributes from InLine Checkout by using get methods: getTest, getLanguage, getCurrency, getSource, getCoupons, getSuccessURL, getCustomerReference, getExternalCustomerReference, getCartLockedFlag.

*When inserting the JavaScript code snippet from your Control Panel into your e-commerce website, you will get access to the library that allows you to add products, control billing and shipping details, and start the checkout process, without having to call the register() method.

Subscribe to shopping cart events

To subscribe to shopping cart events you need to call the events service 'subscribe' method with the event name as the first argument and a callback function as the second argument.

Below you can find a list of events that are supported by the shopping cart and you can subscribe to:

1. 'cart:opened' - triggers when the shopping cart is opened.
2. 'cart:closed' - triggers when the shopping cart is closed.
3. 'payment:finalized' - triggers when the payment has finalized.
4. 'fulfillment:finalized' - triggers when the fulfillment is completed.

TwoCoInLineCart.events.subscribe('cart:opened', function () {
    console.log('cart:opened triggered');
});

Sample request for catalog products

TwoCoInlineCart.setup.setMerchant('merchantCode'); // your Merchant code
TwoCoInlineCart.register();

TwoCoInlineCart.billing.setCountry('US'); // customer billing country
TwoCoInlineCart.billing.setName('John Doe'); // customer billing Name
TwoCoInlineCart.billing.setEmail('john.doe@email.com'); // customer email address
TwoCoInlineCart.billing.setCompanyName('<company name>')
TwoCoInlineCart.billing.setFiscalCode('<fiscal code>')
TwoCoInlineCart.billing.setTaxOffice('<tax office>')
TwoCoInlineCart.cart.setReset(true); // erase previous cart sessions

TwoCoInlineCart.shipping.setName('Jane Doe'); // customer Delivery name
TwoCoInlineCart.shipping.setEmail('jane.doe@email.com'); // customer Delivery email

TwoCoInlineCart.products.add({
    code: 'the-2co-product-code',
    quantity: 3
    options: [{
       name: 'color',
       value: 'red'
   }]
});

TwoCoInlineCart.products.addMany([
    {
        type: 'PRODUCT', 
        name: 'product 1', 
        price: 10, 
        tangible: true, 
        quantity: 1, 
    },
    {
        type: 'PRODUCT', 
        name: 'product 2', 
        price: 30, 
        tangible: true, 
        quantity: 1, 
    }                
]);

TwoCoInlineCart.cart.addCoupon('50%OFF'); // discount code
TwoCoInlineCart.cart.setCurrency('GBP'); // order currency
TwoCoInlineCart.cart.setLanguage('fr'); // language code
TwoCoInlineCart.cart.setOrderExternalRef('1231231'); // order external reference
TwoCoInlineCart.cart.setExternalCustomerReference('ID123extern'); // external customer reference 
TwoCoInlineCart.cart.checkout(); // start checkout process

Sample request for dynamic products

TwoCoInlineCart.setup.setMerchant('merchantCode'); // your merchant code
TwoCoInlineCart.setup.setMode('DYNAMIC'); // product type
TwoCoInlineCart.register();

TwoCoInlineCart.cart.setCurrency('USD'); // order currency

TwoCoInlineCart.products.add({
name        : 'A test dynamic product',
recurrence:{
    unit: 'WEEK',
    length: 2
},
duration: {
    unit: 'YEAR',
    length: 1
},
renewalPrice: 100.99
});
TwoCoInlineCart.cart.checkout(); //start checkout process

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