Skip to main content

Import usage from CSV

Overview

Upload usage data through the 2Checkout API from a CSV (comma-separated values) file for active and trial subscriptions. Usage data uploaded via JSON-RPC APIv6 will be used to charge subscribers for the metered resources they consume. Metered billing allows for usage fees in arrears to be added to recurring subscription costs.

2Checkout will capture the parameters sent via JSON-RPC APIv6 and import the usage data into the system. Once the upload process is complete, you'll be able to access the uploaded file in the Usage area of the Merchant Control Panel.

Set the DATE parameter to GMT+2 time zone, when making the API call to the Usage Upload endpoint.

Method and URL

POSThttps://api.2checkout.com/subscription/payperusage/receiver/index.php

Parameters

Parameters

Type

Required/Optional

Description

Used in HASH validation*

merchant

String

Required

Your unique 2Checkout merchant code. View merchant code.

YES

secret_key

String

Required

The secret key associated to your account. View secret key.

YES

file_MD5

String

Required

The md5 hash of the CSV file used to upload usage.

YES

hash

String

Required

The MD5 hmac key for the request.

N/A

UsageStart Datetime Required The datetime when the usage started; can be the same as UsageEnd. For existing records, this will be updated to time 00:00:00. N/A
UsageEnd Datetime Required The datetime when the usage ended and was recorded.  For existing records this will be updated to time 23:59:59, this will be enforced in the CSV upload as well. N/A
OptionCode String Required Unique codes you provided as identifiers of specific Pricing Options in the Usage Scale Pricing Options Group scheme. Example: metered pricing.   N/A
Description String Optional It can be used to store a short merchant comment of the usage being uploaded. This can be anything, from the source of usage (mobile, web, etc.), to why changes occurred, etc. Example: Subscription usage for September. N/A
SubscriptionRef String Required Unique code that represents a subscription. Example: 83FE4FEF2. N/A

Request Example

<?php
//hmac
$date             = date("Y-m-d");
$fileReceived_md5 = md5_file("[Path to the CSV file used for usage upload]");
$merchantCode     = "";
/* 2Checkout Code */
$merchantKey      = "";
/* Merchant Secret Key */
$hashParams       = "MERCHANT={$merchantCode}&FILE={$fileReceived_md5}&DATE={$date}";
$hmac             = hash_hmac('md5', $hashParams, $merchantKey);
?>

<html>
<body>
<form method="post" action="https://api.2checkout.com/subscription/payperusage/receiver/index.php" enctype="multipart/form-data">
<input type="text" name="MERCHANT" value="<?php
echo $merchantCode;
?>" /><br />
<input type="text" name="HASH" value="<?php
echo $hmac;
?>" /><br />
<input type="file" name="OPTIONS" /><br />
<input type="hidden" name="FILE_MD5" value="<?php
echo $fileReceived_md5;
?>" />
<input type="hidden" name="DATE" value="<?php
echo $date;
?>" />
<input type="submit" /><br />
</form>
</body>
</html>

Error handling

Message code

Message description

Resolution

1

The upload operation completed successfully.

N/A

Invalid account!

The merchant code provided does not belong to a vendor in the 2Checkout system.

Please check your merchant code and make sure you're using the correct version. View merchant code.

Bad signature on the received file!

The upload CSV file's md5 signature is different than the one sent as a parameter.

Please make sure that you're using the correct md5 signature for the CSV file, or that you're uploading the CSV file for which the signature was generated.

Invalid signature

The HMAC calculated by the 2Checkout system is different from the one you're sending.

Please make sure that all parameters use correct values.

Add a subscription plan/product

Overview

Use the addProduct method to create subscription plans/products for your 2Checkout account. 

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

Product

Required (object)

 

Use this object to configure your subscription plans/products.

 

You can set all Product parameters except AvangateID. The 2Checkout system sets the unique product ID. The AvangateID is not editable.

Mandatory parameters

 

ProductName
ProductCode
PricingConfigurations

Response

bool(true)

Request

<?php
 
require ('PATH_TO_AUTH');
 
$Product = new stdClass();
$Product->AvangateId = null;
$Product->ProductCode = 'API_Imported_1234567899';
$Product->ProductType = 'REGULAR';
$Product->ProductName = 'API_Subscription Imported New';
$Product->ProductVersion = '1.0';
$Product->GroupName = 'General';
 
//Shipping classes
 
/* $Product->ShippingClass = new stdClass();
$Product->ShippingClass->Name = '2o9rlujkvg';
$Product->ShippingClass->Amount = 89.40;
$Product->ShippingClass->Currency = 'GBP';
$Product->ShippingClass->ApplyTo = 'ct29dr3fj4';
$Product->ShippingClass->Type = 'bii521vp6k'; */
 
$Product->GiftOption = false;
$Product->ShortDescription = 'Placeat cumque necessitatibus est minus praesentium ut non quibusdam. Molestias provident tempore eligendi mollitia quia.';
$Product->LongDescription = 'Corrupti inventore vitae nesciunt ab. Nemo cum non maiores. Non repudiandae est iste voluptatibus.';
$Product->SystemRequirements = null;
$Product->ProductCategory = null;
$Product->Platforms = array();
$Product->Platforms[0] = new stdClass();
$Product->Platforms[0]->PlatformName = null;
$Product->Platforms[0]->Category = null;
$Product->Platforms[1] = new stdClass();
$Product->Platforms[1]->PlatformName = null;
$Product->Platforms[1]->Category = null;
$Product->ProductImages = array();
$Product->ProductImages[0] = new stdClass();
$Product->ProductImages[0]->URL = null;
$Product->ProductImages[0]->Default = false;
$Product->ProductImages[1] = new stdClass();
$Product->ProductImages[1]->URL = null;
$Product->ProductImages[1]->Default = true;
$Product->TrialUrl = null;
$Product->TrialDescription = null;
$Product->Enabled = True;
 
//Product additional fields
 
/* $Product->AdditionalFields = array();
$Product->AdditionalFields[0] = new stdClass();
$Product->AdditionalFields[0]->Label = 'i44wak1dzp';
$Product->AdditionalFields[0]->Code = 'ITYAK0OEWJ';
$Product->AdditionalFields[0]->Enabled = false;
$Product->AdditionalFields[0]->Required = false;
$Product->AdditionalFields[0]->URLParameter = 'id1ktigl6d';
$Product->AdditionalFields[1] = new stdClass();
$Product->AdditionalFields[1]->Label = 'aig699lmo1';
$Product->AdditionalFields[1]->Code = 'V28TP07PQN';
$Product->AdditionalFields[1]->Enabled = false;
$Product->AdditionalFields[1]->Required = true;
$Product->AdditionalFields[1]->URLParameter = '8to9p6y54j'; */
 
//Product localization
 
/* $Product->Translations = array();
$Product->Translations[0] = new stdClass();
$Product->Translations[0]->Name = 'zsg7wtg4e5';
$Product->Translations[0]->Description = 'Voluptate iure ut quam omnis impedit. Deserunt facere id dolores doloribus quis. Minima nostrum ut possimus incidunt vel est sint. Odit tempora omnis iste nesciunt commodi accusantium placeat.';
$Product->Translations[0]->Language = 'pt';
$Product->Translations[0]->LongDescription = 'Pariatur molestiae sit dignissimos modi. Aut modi libero numquam repudiandae. Doloribus explicabo delectus fugiat amet. Excepturi quo consequatur sint adipisci.';
$Product->Translations[0]->SystemRequirements = 'c16tvyg88c';
$Product->Translations[0]->TrialUrl = 'UNCAUGHT TYPE: anyURI';
$Product->Translations[0]->TrialDescription = 'Voluptas rem sit ut voluptas molestias quidem ut. Maiores facilis tempora voluptates. Consequuntur illum recusandae hic magni iste.';
$Product->Translations[1] = new stdClass();
$Product->Translations[1]->Name = 'cv2sx15aby';
$Product->Translations[1]->Description = 'Ut distinctio asperiores et a placeat voluptatem et. Et eveniet temporibus aut vel. Nemo occaecati praesentium dolor fugiat rerum assumenda expedita.';
$Product->Translations[1]->Language = 'fr';
$Product->Translations[1]->LongDescription = 'Et ut nostrum molestiae voluptates soluta. Molestiae cum in ut qui. Voluptatem voluptates vero odit quia corporis. In impedit eligendi sed expedita nihil temporibus nobis.';
$Product->Translations[1]->SystemRequirements = 'cfv2amk25j';
$Product->Translations[1]->TrialUrl = 'UNCAUGHT TYPE: anyURI';
$Product->Translations[1]->TrialDescription = 'Voluptatem ut possimus consequatur iste. Recusandae id quia sed quibusdam aut debitis. Cupiditate harum architecto quod quia.'; */
 
 
$Product->PricingConfigurations = array();
$Product->PricingConfigurations[0] = new stdClass();
$Product->PricingConfigurations[0]->Default = false;
$Product->PricingConfigurations[0]->Code = null;
$Product->PricingConfigurations[0]->Name = 'API Pricing Configuration Test';
$Product->PricingConfigurations[0]->BillingCountries = array();
$Product->PricingConfigurations[0]->PricingSchema = 'DYNAMIC';
$Product->PricingConfigurations[0]->PriceType = 'NET';
$Product->PricingConfigurations[0]->DefaultCurrency = 'USD';
$Product->PricingConfigurations[0]->Prices = new stdClass();
$Product->PricingConfigurations[0]->Prices->Regular = array();
$Product->PricingConfigurations[0]->Prices->Regular[0] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Regular[0]->Amount = 100;
$Product->PricingConfigurations[0]->Prices->Regular[0]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Regular[0]->MinQuantity = 1;
$Product->PricingConfigurations[0]->Prices->Regular[0]->MaxQuantity = 10;
$Product->PricingConfigurations[0]->Prices->Regular[0]->OptionCodes = array();
$Product->PricingConfigurations[0]->Prices->Regular[1] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Regular[1]->Amount = 200;
$Product->PricingConfigurations[0]->Prices->Regular[1]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Regular[1]->MinQuantity = 11;
$Product->PricingConfigurations[0]->Prices->Regular[1]->MaxQuantity = 100;
$Product->PricingConfigurations[0]->Prices->Regular[1]->OptionCodes = array();
$Product->PricingConfigurations[0]->Prices->Renewal = array();
$Product->PricingConfigurations[0]->Prices->Renewal[0] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Renewal[0]->Amount = 50;
$Product->PricingConfigurations[0]->Prices->Renewal[0]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Renewal[0]->MinQuantity = 1;
$Product->PricingConfigurations[0]->Prices->Renewal[0]->MaxQuantity = 10;
$Product->PricingConfigurations[0]->Prices->Renewal[0]->OptionCodes = array();
$Product->PricingConfigurations[0]->Prices->Renewal[1] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Renewal[1]->Amount = 60;
$Product->PricingConfigurations[0]->Prices->Renewal[1]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Renewal[1]->MinQuantity = 11;
$Product->PricingConfigurations[0]->Prices->Renewal[1]->MaxQuantity = 100;
$Product->PricingConfigurations[0]->Prices->Renewal[1]->OptionCodes = array();
$Product->PricingConfigurations[0]->PriceOptions = array();
 
/* $Product->BundleProducts = array();
$Product->BundleProducts[0] = new stdClass();
$Product->BundleProducts[0]->ProductCode = '540Q45PQBN';
$Product->BundleProducts[0]->ProductId = 48439;
$Product->BundleProducts[1] = new stdClass();
$Product->BundleProducts[1]->ProductCode = 'PA3JDB5SZ2';
$Product->BundleProducts[1]->ProductId = 46439;
 */
$Product->Fulfillment = 'NO_DELIVERY';
$Product->Prices = array();
 
$Product->GeneratesSubscription = True;
$Product->SubscriptionInformation = new stdClass();
$Product->SubscriptionInformation->DeprecatedProducts = array();
$Product->SubscriptionInformation->BundleRenewalManagement = null;
$Product->SubscriptionInformation->BillingCycle = 1;
$Product->SubscriptionInformation->BillingCycleUnits = 'M';
$Product->SubscriptionInformation->IsOneTimeFee = false;
 
$Product->SubscriptionInformation->ContractPeriod = new stdClass();
$Product->SubscriptionInformation->ContractPeriod->Period = -1;
$Product->SubscriptionInformation->ContractPeriod->PeriodUnits = 'days';
$Product->SubscriptionInformation->ContractPeriod->IsUnlimited = TRUE;
$Product->SubscriptionInformation->ContractPeriod->Action = 'RESTART';
$Product->SubscriptionInformation->ContractPeriod->EmailsDuringContract = 'altenwerth.elise@gmail.com';
 
//$Product->SubscriptionInformation->UsageBilling = 77;
 
$Product->SubscriptionInformation->GracePeriod = new stdClass();
$Product->SubscriptionInformation->GracePeriod->Type = 'GLOBAL';
$Product->SubscriptionInformation->GracePeriod->Period = 14;
$Product->SubscriptionInformation->GracePeriod->PeriodUnits = 'D';
$Product->SubscriptionInformation->GracePeriod->IsUnlimited = false;
 
$Product->SubscriptionInformation->RenewalEmails = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Type = 'CUSTOM';
$Product->SubscriptionInformation->RenewalEmails->Settings = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before30Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before15Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before7Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before1Day = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->OnExpirationDate = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->After5Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->After15Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before30Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before15Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before7Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before1Day = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->OnExpirationDate = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->After5Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->After15Days = true;
 
$Product->FulfillmentInformation = new stdClass();
$Product->FulfillmentInformation->IsStartAfterFulfillment = false;
$Product->FulfillmentInformation->IsElectronicCode = false;
$Product->FulfillmentInformation->IsDownloadLink = false;
$Product->FulfillmentInformation->IsBackupMedia = false;
$Product->FulfillmentInformation->IsDownloadInsuranceService = false;
$Product->FulfillmentInformation->IsInstantDeliveryThankYouPage = false;
$Product->FulfillmentInformation->IsDisplayInPartnersCPanel = false;
 
/* $Product->FulfillmentInformation->CodeList = new stdClass();
$Product->FulfillmentInformation->CodeList->Code = '5C6F821DA1';
$Product->FulfillmentInformation->CodeList->Name = 'General delivery';
$Product->FulfillmentInformation->CodeList->Type = 'STATIC';  */
 
//$Product->FulfillmentInformation->BackupMedia = new stdClass();
 
//$Product->FulfillmentInformation->ProductFile = new stdClass();
 
/* $Product->FulfillmentInformation->AdditionalInformationByEmail = 'arlene03@hotmail.com';
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations = array();
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[0] = new stdClass();
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[0]->Name = 'kbaa1aj7po';
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[0]->Description = 'Velit delectus sed amet sunt. Sunt deserunt quos recusandae consequuntur est. Velit aut optio error eius rerum. Nihil ipsam possimus ipsum dolores consequatur adipisci.';
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[0]->Language = 'fr';
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[1] = new stdClass();
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[1]->Name = 'l4ocvz9wwa';
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[1]->Description = 'Esse voluptatem delectus officiis eos quas asperiores. Quas non hic reiciendis enim. Consequatur similique recusandae laboriosam et autem.';
$Product->FulfillmentInformation->AdditionalInformationEmailTranslations[1]->Language = 'pt';
$Product->FulfillmentInformation->AdditionalThankYouPage = 'rvlhvkmxkp';
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations = array();
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[0] = new stdClass();
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[0]->Name = 'rl981w4nua';
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[0]->Description = 'Qui explicabo molestiae dolorem consequuntur. Ullam maiores temporibus vitae. Totam eos et consequatur. Est sit minima animi nam ut aut.';
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[0]->Language = 'en';
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[1] = new stdClass();
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[1]->Name = 'qye8hlwz3e';
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[1]->Description = 'Id est rerum deserunt non et quia magnam. Minus aut nostrum dicta est officiis quia. Commodi nobis sit porro accusamus rerum quis. Fugit et asperiores eum.';
$Product->FulfillmentInformation->AdditionalThankYouPageTranslations[1]->Language = 'fr';
 */
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addProduct',
'params' => array($sessionID, $Product)
);
 
$addedProduct = callRPC($jsonRpcRequest, $host);
var_dump ($addedProduct);

Track affiliates via affiliate ID URL parameters

Overview

2Checkout has expanded affiliate tracking capabilities with the introduction of support for the inclusion of Affiliate ID parameters ?AVGAFFILIATE=[affiliate identifier] in certain URLs pointing to your web properties.

Availability

This feature is available on-demand. Please contact 2Checkout directly if you'd like to take advantage of Affiliate ID URL Parameters,

Affiliate ID URL Parameters are available in concert with two types of Product Links that your affiliates can generate, namely links to:

  • Your website (vendor website): when clicking on this type of links, shoppers from your affiliates are sent to the homepage of your website. Affiliates using this type of links get credited for sales no matter what products are purchased by shoppers during the validity period of the cookie set on their machines by 2Checkout (30 to 180 days, according to vendor preferences).
  • Custom URL: affiliates create these types of links themselves, redirecting shoppers to a URL of their choice, such as special landing pages on your website.

How it works

When shoppers click on links on the affiliates' site such as the ones described above, pointing to your website they're taken to 2Checkout server (page loader), where affiliate cookies are set, and then redirected to your website. The redirect process involves adding the AVGAFFILIATE parameter to the link automatically.

For example, the following link:

http://wwww.yourwebsite.com/shop.html

becomes

http://wwww.yourwebsite.com/shop.html?AVGAFFILIATE=12345

(for an affiliate with the 12345 affiliate ID).

By including affiliate ID parameters in redirects to your website, 2Checkout enables you to better monitor the traffic generated by your affiliates.

Use case

AVGAFFILIATE functionality needs to be enabled for your account.

  1. Affiliates create vendor website or custom URL links and place them on their websites.
  2. AVGAFFILIATE is included automatically into links.
  3. Customers click the links to access a free trial of your service.
  4. Customers are taken to the 2Checkout server (page loader), where affiliate cookies are set (this stage of the process is invisible to end users) and then redirected to your website when they access the free trial of the service.
  5. Customers visit your site directly to buy the full product at a later date, or send the link to the financial department in a B2B scenario to purchase the service on their behalf.
  6. Because of the presence of the AVGAFFILIATE, the member of the 2Checkout Affiliate Network who provided the initial referral is credited for the sale and paid the appropriate commission.

Update a cross-sell campaign

Overview

Use the updateCrossSellCampaign method to update a cross-sell campaign for your 2Checkout account. 

Request parameters

Parameters Type Required Description

CampaignCode 

 String 

Required

The campaign code that can be used when placing orders. 

MasterProducts 

Array of strings 

Required

Array of product codes to apply to this campaign. 

DisplayType 

String 

Required

The display type of the campaign; Can be cart, review, finish.

DisplayInEmail 

Boolean 

Required

Determines if the campaign will be displayed in payment receipt emails.

Products 

Array of objects 

Required

Array of objects containing the product codes pointing to the promoted products when tied to each master product, the discount value, and the discount type (can only be percent).

ProductCode 

String 

Required

Product code of the product to be recommended to the shopper.

Discount 

Float 

Required

Value of the discount.

DiscountType 

String 

Required

Can only be 'PERCENT'.

Name 

String 

Required

Name of the campaign.

CampaignStatus

String 

Optional 

The status of the cross-sell campaign.

StartDate 

String 

Optional 

The date when the cross-sell campaign starts, formatted as YYYY-MM-DD.

EndDate 

String 

Optional 

The date when the cross-sell campaign ends, formatted as YYYY-MM-DD.

Response parameters

Parameters Type Required Description

CampaignCode 

 String 

Required

The campaign code that can be used when placing orders. 

MasterProducts 

Array of strings 

Required

Array of product codes to apply to this campaign. 

DisplayType 

String 

Required

The display type of the campaign; Can be cart, review, finish.

DisplayInEmail 

Boolean 

Required

Determines if the campaign will be displayed in payment receipt emails. Can be 'true' or 'false'.

Products 

Array of objects 

Required

Array of objects containing the product codes pointing to the promoted products when tied to each master product, the discount value, and the discount type (can only be percent).

ProductCode 

String 

Required

Product code of the product to be recommended to the shopper.

Discount 

Float 

Required

Value of the discount.

DiscountType 

String 

Required

Can only be 'PERCENT'.

Name 

String 

Required

Name of the campaign.

CampaignStatus

String 

Optional 

The status of the cross-sell campaign.

StartDate 

String 

Optional 

The date when the cross-sell campaign starts, formatted as YYYY-MM-DD.

EndDate 

String 

Optional 

The date when the cross-sell campaign ends, formatted as YYYY-MM-DD.

Request sample

<?php 
$require ('PATH_TO_AUTH'); 
 
$csCampaign = new stdClass(); 
$csCampaign->CampaignCode = '2Xrl85eSkemBv3G3ea+9fg=='; 
$csCampaign->MasterProducts = ['C8851A5BC9']; 
$csCampaign->DisplayType = 'review'; 
$csCampaign->DisplayInEmail = true; 
$csCampaign->Name = 'testingSoap'; 
$csCampaign->StartDate = '2019-10-21'; 
$csCampaign->EndDate = '2021-10-21'; 
$csCampaign->CampaignStatus = 'ACTIVE'; 
$csCampaign->Products = []; 
$csCampaign->Products[0] = new stdClass(); 
$csCampaign->Products[0]->ProductCode = '512712FA53'; 
$csCampaign->Products[0]->Discount = 19; 
$csCampaign->Products[0]->DiscountType = 'PERCENT'; 
 
try { 
    $csCampaignResponse = $client->updateCrossSellCampaign($sessionID, $csCampaign); 
} catch (SoapFault $e) { 
    echo  $e->getMessage(); 
} 

Cross-sell

Overview

Use this section to retrieve information about the cross-sell campaigns configured on your account.

 

Order field

Overview

Use this object to retrieve information about additional order/product fields. 

Parameters

Parameters Type/Description

AdditionalField

Object

Label

String

 

Field text.

Code

String

 

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

Type

String

 

Field type:

  • LISTBOX
  • CHECKBOX
  • TEXTBOX
  • HIDDEN

ApplyTo

Sting

 

  • ORDER
  • PRODUCT

Values

Array of values

 

Custom values you control.

ValidationRule

String

 

The validation rule restricting the type of information shoppers can enter in the additional field during the purchase process.

Translations

Array of objects

 

Details below.

Translation

Object

Label

String

 

Field text translated in the language of the Translations object.

Values

Object

 

Custom values you control translated in the language of the Translations object.

Language

String

 

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

 

 

Proposal Object-Level Mapping

Overview

Use this object structure to create and send a proposal via the 2Checkout API 6.0.

Object-Level Mapping

Proposal Object 

Proposal Object-Level Mapping

Parameter name

Type

Required

Description

proposalId

String

 Required

The unique system-generated merchant proposal ID.

name

String Required

The name of the proposal

version

Integer

 

Internal version of the proposal (incremented on each modification)

createDate

String

 

The creation date of the proposal; date-time ISO 8601 format

updateDate

String

 

The update  date of the proposal; date-time ISO 8601 format; populated by the userId

createdBy

String

 

The unique external system user identifier of the user that created the proposal; populated by the userId

updatedBy

String

 

The unique external system user identifier of the user that last updated the proposal

locked

Boolean

 

Signals if the proposal is locked or not for updates in order to restrict modifications

source

String, Enum

 

Source of the proposal, used for reporting purposes; Can be: [ MERCHANT_CPANEL, MERCHANT_API, QUOTE_INTERFACE, SALESFORCE_CPQ ]

content

Object (Proposal Content)

Required

The content of the proposal 

billTo/billingDetails

Object (billTo/billingDetails)

Required

The billing details associated with the proposal

tac

Object (tac)

 

Terms and conditions applied to the proposal

type

String, enum

Required

The type of proposal that defines the way it will be processed onwards; Can be [ renewal, upgrade, acquisition ]

sentBy

Object (sentBy)

 

Represents the account manager from the vendor

links

Object (links)

 

The proposal links details

status

String, Enum

 

The status of the proposal; can be [ opened, sent, in_review, reviewed, closed_won, closed_lost, declined, expired, accepted ]

statusComment

String

 

Free text comment that can accompaniate a status

expirationDate

String

 

The date at which the proposal expires; date-time ISO 8601 format

sellTo

Object (sellTo)

Required

Represents the entity using the service. Used for tax calculation.

BillTo Object 

BillTo Object Mapping

Parameter name

Type

Required

Description

company

String

Required

End-user company name.

email

String Required

Contact email address.

vatCode

String Required

For companies, it needs to be the VAT ID. 

phone

String Required

Contact phone number.

country

String Required

The country for the address. Represents the country code as specified by ISO 3166-1 alpha-2.

state

String Required

The country state for the address.

city

String Required

The city for the address.

zip

String Required

The address zip code.

address

String Required

The street address.

SellTo Object 

SellTo Object Mapping

Parameter name

Type

Required

Description

company

String

Required

End-user company name.

email

String Required

Contact email address.

vatCode

String Required

For companies, it needs to be the VAT ID. 

phone

String Required

Contact phone number.

country

String Required

The country for the address. Represents the country code as specified by ISO 3166-1 alpha-2.

state

String Required

The country state for the address.

city

String Required

The city for the address.

zip

String Required

The address zip code.

address

String Required

The street address.

Terms and conditions Object 

Tac Object Mapping

Parameter name

Type

Required

Description

content

String

 Optional

The terms and conditions of the proposal

acceptedDate

String

 Optional

The UTC date when the proposal terms and conditions were accepted in ISO 8601 format

SentBy Object 

SentBy Object Mapping

Parameter name

Type

Required

Description

firstName

 String

 Optional

The first name for the email sender

lastName

 String Optional

The last name for the email sender

email

 String Optional

The email address of the email sender

Content Object 

Content Object Mapping

Parameter name

Type

Required

Description

language

String

Required

The ISO 639-1 language code used to display the content of the proposal.

currency

String

Required

The ISO 4217 currency code used to display the product and order values.

lineItems

Array of Objects (lineItem)

Required

The list of products & associated custom values for the proposal.

LineItem Object 

LineItem Object Mapping

Parameter name

Type

Required

Description

productName

String

Required

Name of the product

productCode

String Required

2Checkout product code

quantity

Float

Required

The quantity of the product 

price

Float Required

The list price of the product

discountPrice

Float Required

The discounted price of the product

priceType

String, enum

Required

The price type, can be gross or net

subscriptionReference

String

 Optional

The subscription reference for upgrade of renewal

contractPeriod

Integer

Optional

The number of billing cycles. A zero value means a lifetime contract period and billingCycle is not needed in this case.

immediateAction

String

Optional

Defines if the contract starts now or at the end of current billing cycle or contract period [ now, end_of_billing_cycle, end_of_contract ]

billingCycle

Object (billingCycle)

Optional

The billing cycle configuration

priceOptions

Array of priceOption Objects

Optional

Array of selected price options.

additionalFields

Array of additionalFields Object

Optional

Array of Product additional fields

PriceOption Object

PriceOption Object Mapping

Parameter name

Type

Required

Description

groupCode

String

 Optional

The price options group code.

groupOptions

Array of Strings

 Optional

Selected group option code.

BillingCycle Object

BillingCycle Object Mapping

Parameter name

Type

Required

Description

unit

String, Enum

 Optional

The unit for the billing cycle, can be [day, month].

value

Integer

 Optional

The number of days or months. Minimum for a day unit is 7.
 

Link Object

Link Object Mapping

Parameter name

Type

Required

Description

linkId 

String

 Optional

The unique link id.

url

String Optional

The link URL for viewing.

status

String, Enum

Optional

The status of the proposal.

pdf

String Optional

The link URL for downloading the PDF.

AdditionalFields Object

AdditionalFields Object Mapping

Parameter name

Type

Required

Description

code

String

 Optional

The alpha-numeric characters, underscores and dashes that are set as the field identifier.

value

String

 Optional

Selected field value.

Errors

Parameter name

Type

Description

code

Integer

Internal error code.

detail

String

The details of the error associated with the code.

status

Integer

HTTP error code.

Proposal Object Sample 

{
    "updatedDate": "20120-03-20 20:12:11Z",
    "locked": true,
    "status": "sent",
    "expirationDate": "20120-10-20 20:12:11Z",
    "billTo": {
      "company": "Randcomp",
      "email": "y2hzhca4pc@groupbuff.com",
      "vatCode": "85421564",
      "phone": "12172196850",
      "country": "US",
      "state": "Illinois",
      "city": "Carthage",
      "zip": "62321",
      "address": "1849  Cardinal Lane"
    },
    "content": {
      "language": "ro",
      "currency": "ron",
      "terms": 30,    
      "lineItems": [
        {
          "productName": "Antivirus",
          "productCode": "FP10",
          "quantity": 2,
          "subscriptionReference": "FDG223",
          "contractPeriod": 12,
          "immediateAction": false,
          "billingCycle": {
            "unit": "month",{
    "proposal": {
        "updatedDate": "2020-05-11 10:14:24",
        "locked": false,
        "status": "sent",
        "billTo": {
            "company": "vgvhW98CiP",
            "firstName": "NbNlhZaw0m",
            "lastName": "GSPTiT8hUz",
            "email": "JwhQwQseHu@2checkout.com",
            "vatCode": "sxHuDDdwLu",
            "phone": "0744444445",
            "country": "ro",
            "state": "Yd0d97R44a",
            "city": "YyHln6KZdf",
            "zip": "02179000",
            "address": "E2LyqFKFXX"
        },
        "content": {
            "language": "ro",
            "currency": "usd",
            "lineItems": [
                {
                    "productName": "G2e8AESWBF",
                    "productCode": "KL1171S",
                    "quantity": 10,
                    "price": 80.29,
                    "discountedPrice": 20,
                    "priceType": "net",
                    "contractPeriod": 12,
                    "shortDescription": "<p>scurta descriere in romana</p>\r\n",
                    "priceOptions": [
                        {
                            "option": "License Duration ro",
                            "selections": [
                                "1 an ",
                                "2 ani"
                            ]
                        },
                        {
                            "option": "Numar calculatoare",
                            "selections": [
                                "2 calculatoare"
                            ]
                        }
                    ],
                    "subscriptionReference": "8B48958B24",
                    "subscriptionExpirationDate": "2020-02-03T05:13:16-04:00",
                    "immediateAction": "now",
                    "unitVat": 0,
                    "vatPercent": 0,
                    "vat": 0,
                    "grossPrice": 1902.27,
                    "grossDiscountedPrice": 1902.27,
                    "netPrice": 1902.27,
                    "netDiscountedPrice": 0,
                    "billingCycle": {
                        "unit": "day",
                        "value": "12"
                    }
                },
                {
                    "productName": "qc9zgm10eh",
                    "productCode": "KL1091S",
                    "quantity": 4,
                    "price": 80.85,
                    "discountedPrice": 76,
                    "priceType": "net",
                    "contractPeriod": 12,
                    "shortDescription": "",
                    "priceOptions": [],
                    "immediateAction": "now",
                    "unitVat": 0,
                    "vatPercent": 0,
                    "vat": 0,
                    "grossPrice": 71.57,
                    "grossDiscountedPrice": 71.57,
                    "netPrice": 71.57,
                    "netDiscountedPrice": 0,
                    "billingCycle": {
                        "unit": "day",
                        "value": "8"
                    }
                }
            ]
        },
        "tac": {
            "content": "7hxl1gZoMH"
        },
        "link": {
            "url": "https://proposal.2checkout.com/AlexB/7fe96d63-f287-4e2d-9302-71bd89ad4955",
            "status": "accepted"
        },
        "type": "upgrade",
        "sentBy": {
            "firstName": "7cnCFntR46",
            "lastName": "ZMUxWvHtd1",
            "email": "GijBj_test@2checkout.com"
        },
        "sellTo": {
            "company": "WanT1TjuiK",
            "firstName": "Ec4WUxhvGb",
            "lastName": "wF36GumR0e",
            "email": "CoFq5_test@2checkout.com",
            "vatCode": "w2SWzM4xqw",
            "phone": "0744444480",
            "country": "ro",
            "state": "KFNK1PgNr1",
            "city": "31CeVIrfB2",
            "zip": "02179000",
            "address": "gjIyFInjot"
        },
        "taxes": {
            "netPrice": 1973.84,
            "grossPrice": 1973.84,
            "netDiscountedPrice": 1973.84,
            "grossDiscountedPrice": 1973.84,
            "discount": 0,
            "vat": 0,
            "dueNow": 1973.84,
            "totalContractValue": 23686.079999999998
        },
        "pdfFileName": "1ed46260-4cb0-43d0-b2a0-afc1aad9f6be.pdf",
        "expirationDate": "2020-06-11 10:14:24"
    },
    "merchant": {
        "merchantCode": "AlexB",
        "companyName": "AlexB CompanyName",
        "commercialName": "AlexB CommercialName",
        "logoSrc": "AlexB"
    }
}

Error Handling

Proposal UI Error Handling
Error text Error message Error code

Unauthorized

ERR_UNAUTHORIZED

401

Route not found

ERR_NOT_FOUND

404

Internal Error

ERR_INTERNAL_ERROR

500

Bad Request

ERR_BAD_REQUEST

400

Proposal has terms

ERR_PROPOSAL_HAS_TERMS

400

error accepting proposal

PROPOSAL_SERVICE_ERROR

400

Invalid proposal

ERR_INVALID_PROPOSAL

400

Missing request parameters

ERR_MISSING_PARAMETER

404

Proposal not found

ERR_PROPOSALID_INVALID

404

Proposal not found

ERR_PROPOSAL_NOT_FOUND

404

Error accepting proposal

ERR_PROPOSAL_ACCEPT

400

Error declining proposal

ERR_PROPOSAL_DECLINE

400

Invalid payment method

ERR_INVALID_PAYMENT_METHOD

400

Retry payment

ERR_ORDER_RETRY_PAYMENT

417

Retry payment invalid payment data

ERR_ORDER_RETRY_PAYMENT_INVALID

402

Error creating order

ERR_ORDER_CREATE

400

Unauthorized

ERR_UNAUTHORIZED

401

 

Search partners

Overview

Search partners using their company name or contact email. If a generic string is provided, the system searches for matches in company names and contact emails for all your partners.

Parameters

Parameters Type/Description
sessionID Required (string)
  Session identifier, output by the Login method. An exception will be thrown if the values are incorrect.
searchString Required (string)
  Can be either the company name or contact email of the partner. The system searches generic strings in both the names of the companies as well as the contact email addresses.

Response

Parameters Type/Description
Partner Array of objects

Request

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

$searchString = "YOUR_SEARCH_STRING";

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

$response = callRPC((Object)$jsonRpcRequest, $host);

Errors

Error Description

INVALID_SEARCH

Invalid value. Please use a string to search.

 

Set the cart currency for InLine Cart

Overview

Use the Cart object to set the currency of the InLine Cart by calling theTwoCoInlineCart.cart.setCurrency(currency-code)method.

Use case

  1. Add an HTML link or button in your page like the one below.
  2. Create a JavaScript click handler to execute the Inline Client desired methods.
  3. Use theTwoCoInlineCart.products.add({code, quantity, options})method to prepare your catalog product.
  4. In order to set the currency use theTwoCoInlineCart.cart.setCurrency('RON')method.
  5. Use theTwoCoInlineCart.cart.checkout()method to show the cart on your page.

Sample request

HTML

<a href="#" class="btn btn-success" id="buy-button">Buy now!</a>

JavaScript

window.document.getElementById('buy-button').addEventListener('click', function() {
  TwoCoInlineCart.products.add({
    code: "74B8E17CC0"
  });
  TwoCoInlineCart.cart.setCurrency('GBP');
  TwoCoInlineCart.cart.checkout();
});

Demo

After setting the cart currency using the above method, your cart should look like this:

See more details on the 2Checkout order interface currencies and their symbols here.

Promotions

Overview

Use the Promotion object via SOAP API 3.0 to retrieve information on discounts/promotions you set up for your account.

Parameters

Parameters Type/Description

Promotion

Object

CouponCodes

Array of strings

 

Array of coupon/Voucher codes when Coupon / Voucher type is Multiple. Otherwise, empty array.

ChannelType

String

 

Possible values:

  • ECOMMERCE
  • CHANNEL_MANAGER
  • ALL

CouponType

String

 

Possible values:

  • SINGLE
  • MULTIPLE

DiscountType

String

 

Possible values:

  • FIXED
  • PERCENT

Type

String

 

REGULAR

Discount

Int

 

The value of the discount. Example, for a $30 USD discount Avangate returns the value 30 and for a 25% price cut, Avangate returns 25.

Products

Array

 

Array of product codes for the products impacted by the promotion.

Name

String

 

Promotion name

Description

String

 

Promotion description

StartDate

String

 

Starting date. The date when you set the promotion to start. Is NULL for promotions that start immediately after they're created.

EndDate

String

 

Ending date. The date when you set the promotion to end. Is NULL for promotions that you want active indefinitely.

MaximumOrdersNumber

Int

 

When the maximum number of orders is reached the promotion stops. Can be NULL if you want the promotion to apply to an unlimited number of orders.

MaximumQuantity

Int

 

Discount only applies to a specific number of product, smaller than the maximum quantity you defined. Can be NULL if you want the promotion to apply to an unlimited number units. Any extra quantity added to the cart will be sold at full price.

InstantDiscount

Boolean

 

Selecting the instant discount option will auto-apply the discount for ALL the selected products for all shoppers, without the need to enter the discount coupon.

Coupon

String

 

The promotion coupon/voucher you’re extracting information for.

DiscountLabel

String

 

Discounts can be set as a percentage from the product price or as a fixed amount in the chosen currenc

Enabled

Boolean

 

TRUE

FALSE

Currency

String

 

Currency code available for the default currency of FIXED promotions. Missing for PERCENT promotions.

Code

String

 

Unique, system-generated identifier Avangate associates with promotion campaigns.

PriceThreshold

Object

 

Limits discount use only when total order value (taxes included) exceeds the threshold you configure.

 

Amount

 Decimal

 

 

The minimum threshold you defined for the default currency.

 

Currency

String

 

 

Currency code available for the default currency of custom threshold settings.

 

 

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