Skip to main content

Update upsell campaign

Overview

Use the updateUpSellCampaign method to update an upsell campaign via JSON-RPC API 6.0.

Request Parameters

Parameter Name Type Required/Optional Description
sessionId String Required Unique 2Checkout session ID code.
Code String Required The code of the upsell campaign in UUID format.
UpsellCampaign Object Required New upsell campaign definition.

Name

String

Required

Name of campaign, max 500 characters.

StartDate

String

Optional

The date when the up-sell campaign starts, in the YYYY-MM-DD format. Can be NULL (starts immediately after enabling).

EndDate

String

Optional

The date when the up-sell campaign ends, in the YYYY-MM-DD format. Can be NULL (ends immediately after disabling).

DisplayForManualRenewals

Boolean/Integer

Required

Flag to control if the campaign will be displayed for manual subscription renewal orders. Can be set as true/false/0/1.

Discount

Object

Required

Discount definition object, details below:

      Type

String

Required

Type of discount. Can be FIXED or PERCENT.

      Value

Integer

Required

Percentage discount value (PERCENT discount only).

      Values

Array of objects

Required

List of currency discounts (FIXED discount only), details below:

            Currency

String

Required

Code of Currency for the related amount.

            Amount

Integer

Required

Discount amount value for the related currency.

      DefaultCurrency

String

Required

Code of default Currency (FIXED discount only).

PrimaryProduct

Object

Required

Main (primary) product object, details below:

      Code

String

Required

The code of the product that the recommendation is made for.

      Quantity

Integer

Required

The quantity for the primary product. Can be 0 (standing for any quantity).

      PriceOptions

Array of objects

Optional

Price options list for the primary product, details below:

            Code

String

Required

Price option group code.

            Options

Array of objects

Optional

Price options list, details below:

                  Code

String

Required

Price option code.

                  Value

Integer

Optional

Price option value (for scale interval price option group only).

RecommendedProduct

Object

Required

Recommended product object, details below:

      Code

String

Required

The code of the recommended product.

      Quantity

Integer

Required

The quantity for the recommended product. Can be 0 (standing for “match quantity” setting).

      PriceOptions

Array of objects

Optional

Price options list for the recommended product, details below:

            Code

String

Required

Price option group code.

            Options

Array of objects

Optional

Price options list, details below:

                Code

String

Required

Price option code.

                Value

Integer

Optional

Price option value (for scale interval price options group only).

Enabled

Boolean/Integer

Required

Sets the campaign enabled or disabled. Can be set as true/false/0/1.

Description

Array of objects

Required

List of campaign language descriptions, details below:

      Language

String

Required

Code of the language.

      Text

String

Required

The text of the description in the associated language.

Request example

<?php
require ('PATH_TO_AUTH');

$upsell = new \stdClass();

$upsellCode = 'fc580e11-09e4-483f-b73e-cd0f460bcd9d';

$upsell->Name = 'December 2020 upsell campaign’;
$upsell->StartDate = '2020-12-21';
$upsell->EndDate = '2020-12-25';
$upsell->DisplayForManualRenewals = false;

// setup percent discount
$discountPercent = new \stdClass();
$discountPercent->Type = 'PERCENT';
$discountPercent->Value = 5;

// setup fixed discount
$discountFixed = new \stdClass();
$discountFixed->Type = 'FIXED';
$discountValues = [
    'USD' => 10,
    'EUR' => 8,
    'TRY' => 80,
    'RUB' => 1100,
];
$dv = [];
foreach ($discountValues as $curr => $amt) {
    $disc = new \stdClass();
    $disc->Currency = $curr;
    $disc->Amount = $amt;

    $dv[] = $disc;
}
$discountFixed->Values = $dv;

// assign discount
$upsell->Discount = $discountPercent;
# OR
# $upsell->Discount = $discountFixed;


// setup primary product
$primaryProduct = new \stdClass();
$primaryProduct->Code = $productCode;
$primaryProduct->Quantity = 1;
$ppPriceOptionGroup1 = new \stdClass();
$ppPriceOptionGroup1->Code = 'OPTGRP2';
$ppPriceOptionGroup1Option = new \stdClass();
$ppPriceOptionGroup1Option->Code = 'OptGrp2Code2';
$ppPriceOptionGroup1->Options = [$ppPriceOptionGroup1Option];

$ppPriceOptionGroup2 = new \stdClass();
$ppPriceOptionGroup2->Code = 'interval_scale_grp1';
$ppPriceOptionGroup2Option = new \stdClass();
$ppPriceOptionGroup2Option->Code = 'interval_scale_grp1-1-10';
$ppPriceOptionGroup2Option->Value = '6';
$ppPriceOptionGroup2->Options = [$ppPriceOptionGroup2Option];

$primaryProduct->PriceOptions = [$ppPriceOptionGroup1, $ppPriceOptionGroup2];
$upsell->PrimaryProduct = $primaryProduct;

// setup recommended product
$recommProduct = new \stdClass();
$recommProduct->Code = $recProductCode;
$recommProduct->Quantity = 0; // stands for “match quantity” 
$rpPriceOptionGroup1 = new \stdClass();
$rpPriceOptionGroup1->Code = 'CHECKB_LIST';
$rpPriceOptionGroup1Option1 = new \stdClass();
$rpPriceOptionGroup1Option1->Code = 'chk1';
$rpPriceOptionGroup1Option2 = new \stdClass();
$rpPriceOptionGroup1Option2->Code = 'chk3';
$rpPriceOptionGroup1->Options = [$rpPriceOptionGroup1Option1, $rpPriceOptionGroup1Option2];
$recommProduct->PriceOptions = [$rpPriceOptionGroup1];
$upsell->RecommendedProduct = $recommProduct;

$upsell->Enabled = true;

// setup languagte descriptions / texts
$enDescription = new \stdClass();
$enDescription->Language = 'EN';
$enDescription->Text = 'Buy <!--{RECOMMENDED_PRODUCT_NAME}--> for just <!--{RECOMMENDED_PRODUCT_PRICE}--> until Dec 25th';
$upsell->Description = [$enDescription];

$jsonRpcRequest = new \stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'updateUpsellCampaign';
$jsonRpcRequest->params = [$sessionID, $upsellCode, $upsell];
$jsonRpcRequest->id = $i++;

$upsellResponse = callRPC($jsonRpcRequest, $host);

Response

Parameters Type Description

UpSell

Object

Object containing information related to the upsell campaigns, including product information and discount settings.

 

Retrieve available currencies

Overview

Use the getAvailableCurrencies method via JSON-RPC API 6.0 to get the list of available currencies. If the countryCode parameter is added, the paymentMethod parameter also becomes mandatory (you need to use both parameters or none).

Request Parameters

Parameter Name Type Required/Optional Description
sessionId String Required 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.
countryCode String Required The ISO country code (two-letter code). If the countryCode parameter is used, the paymentMethod parameter must be used as well and both parameters are mandatory.
paymentMethod String Required The payment method for which you are retrieving the list of available currencies.

Request Example

<?php

include('Config.php');

// Grab Config Values
$config = new ConfigScripts();
$apiVersion = '6.0';
$i = 1;
$host = 'http://api.avangate.local:8081/rpc/' . $apiVersion . "/";

// Login to get the session id;
$sessionID = $config->rpcLogin($host);

$countryCode = 'ro';
$paymentMethod = 'CC';

$jsonRpcRequest = array (
  'jsonrpc' => '2.0',
  'id' => $i++,
  'method' => 'getAvailableCurrencies',
//  'params' => [$sessionID]
  'params' => [$sessionID, $countryCode, $paymentMethod]
);

$response = $config->callRPC($jsonRpcRequest, $host, true);

print_r(json_encode($response));


?>

Response

Parameter Name Type Description
currencies Array An array of currency objects.

Response Example

[
  {
      "Code":"USD",
      "ISO3DigitCode":"840",
      "Label":"United States Dollar",
      "Symbol":"$",
      "SymbolPosition":"left",
      "DecimalSeparator":".",
      "UnitSeparator":",",
      "Decimals":"2"
   }
] 

 

One click (1-click) purchase

Overview 

2Checkout supports 1-click purchases for returning customers who paid for their previous orders with:

  • Credit/Debit cards
  • PayPal
  • iDEAL

How does this work? 

  1. Identify returning customers. 
  2. Access data on the previous purchases of returning customers.
  3. Validate previous order references for 1-click purchase scenarios using the isValidOrderReference method.
  4. Place a new order using a valid previous order reference as the payment method. 
  5. 2Checkout charges returning customers using their payment-on-file information, either a card or their PayPal account. 

Requirements 

  • Use only references of previous orders with one of the following statuses AUTHRECEIVED or COMPLETE.
  • The email address of the BillingDetails object is mandatory and it needs to match the email address used as a part of the billing details of the initial order whose reference you're now using to place a new order. 2Checkout checks whether the email addresses are identical, and throws an error if they're not, blocking the order placement process. Note: You need to provide only the email address of the shopper, and can ignore the rest of the required customer billing information. If you enter any billing details in addition to the email address, you'll have to provide all information required in the BillingDetails object.
  • For orders paid with PayPal, the original order must have automatic renewal enabled so that it can be reused for future 1-click purchases.

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.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

Response 

Parameters Type/Description

Order information

Object

  Object containing order information.

Validate previous order reference

<?php

require('PATH_TO_AUTH');

$orderReference = '670174996';
$jsonRpcRequest = array (
'method' => 'isValidOrderReference',
'params' => array($sessionID, $orderReference),
'id' => $i++,
'jsonrpc' => '2.0'
);

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

Place an order using previous order reference 

<?php

require('PATH_TO_AUTH');

$oldOrderExistent = callRPC((Object)$jsonRpcRequest, $host, true);
$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'usd';
$Order->Country = 'US';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;

$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1;
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false;
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->Promotion = NULL;

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->Email = $oldOrderExistent->BillingDetails->Email;;
$Order->DeliveryDetails = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'PREVIOUS_ORDER';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->RefNo = $orderReference;
$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

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

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

2Checkout API Upgrade Guide

Overview 

Use this guide to prepare and migrate your 2Checkout API implementation to our newest version. This document features deprecations, updates, and enhancements, providing guidance on how to upgrade your implementation to the latest version of the 2Checkout API.

New authentication flow

 To use the latest 2Checkout API version, you need to update your authentication process. The parameters included in the authentication flow are displayed below.

Parameters Type/Description
merchantCode Required (String)
  Your merchant identification code. Can be found in your Admin Area, in the System Setting section.
date Required (String)
  GMT ISO Date format (e.g. 2010-01-01 12:13:14)
hash Required (Object)
  Calculated HMAC_SHA signature based on merchantCode and date, using your secret key. Your secret key can be found in your System settings area.
algo Required (String)
  Hashing algorithms. Accepted values: sha256/sha3-256

API protocols

The latest 2Checkout version (API 6.0) is available via three API protocols: JSON-RPC, SOAP and REST. Check below the authentication method for each of them.

JSON-RPC SOAP REST
login login login

 2Checkout API methods status

2Checkout legacy method Status 2Checkout new API method
detail_sale  Updated. Use: getOrder
list_sales  Updated. Use: Instant Search Order Export
refund_invoice  Updated. Use: Instant Refund
refund_lineitem  Updated. Use: Instant Refund
stop_lineitem_recurring  Updated. Use: disableRecurringBilling 
reauth  Deprecated N/A
mark_shipped  Deprecated N/A
create_comment  Updated. Use: addSubscriptionAdditionalInformationField 
list_products  Updated. Use: searchProducts 
detail_product  Updated. Use: getProductById 
create_product  Updated. Use: addProduct 
update_product  Updated. Use: updateProduct
delete_product  Deprecated N/A
list_options  Updated. Use: getAssignedPriceOptionGroups 
detail_option  Updated. Use: getPriceOptionGroup 
create_option  Updated. Use: addPriceOptionGroup 
update_option  Updated. Use: updatePriceOptionGroup 
delete_option  Deprecated N/A
list_coupons  Updated, but for promotions. Use: searchPromotions 
detail_coupon  Updated, but for promotions. Use: getPromotion 
update_coupon  Updated. Use: updatePromotionCoupon 
delete_coupon  Updated. Use: deletePromotionCoupon 
detail_company_info  Deprecated N/A
detail_contact_info Deprecated N/A
detail_pending_payment  Updated. Use: getOrder
list_payments  Deprecated N/A

Create a new customer

Overview

Use the createCustomer method to add the details of a customer entity into the Avangate system. By default, customer status is Inactive until you assign a specific subscription to the customer. Following that action, customer status reflects the status of the attached subscription(s).

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

Customer

Object

Request

<?php

require ('PATH_TO_AUTH');

$newCustomer = new stdClass();
$newCustomer->AvangateCustomerReference = null;
$newCustomer->ExternalCustomerReference = 'ThisIsATestReference123456';
$newCustomer->FirstName = 'NewCustomer';
$newCustomer->LastName = 'NewCustomerLastName';
$newCustomer->Company = null;
$newCustomer->FiscalCode = null;
$newCustomer->Address1 = 'Address';
$newCustomer->Address2 = null;
$newCustomer->City = 'LA';
$newCustomer->Zip = '90210';
$newCustomer->CountryCode = 'us';
$newCustomer->Phone = null;
$newCustomer->Fax = null;
$newCustomer->Email = 'newcustomer@email.com';
$newCustomer->ExistingCards = null;
$newCustomer->Enabled = null;
$newCustomer->Trial = null;
$newCustomer->Language = 'en';

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

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

Response

Parameters Type/Description

AvangateCustomerReference

Int

 

System-generated customer reference.

Remove translations

Overview

Use the deletePromotionTranslations method to remove all localized texts from an existing promotion.

Parameters

Parameter Type/Description

sessionID

Required (string)

 

Output of the Login method.

promotionCode

Required (string)

 

The code corresponding to the promotion that you want to add translations to.

Response

Parameters Type/Description

Status

Boolean

  True or false.

Request

<?php

require ('PATH_TO_AUTH');

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

try {
    $updatedPromotion = $client->deletePromotionTranslations($promotionCode);
}

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

var_dump("UpdatedPromotion", $updatedPromotion);

 

One page checkout without review

Overview

One Page Checkout without Review is an optimized purchase flow designed to support fast and streamlined shopping experiences. It combines ease of use with speed, bringing together all key stages of the purchase process onto a single page. 

Generate link

Use the One page checkout without review flow by following the steps below.

  1. Log in to your 2Checkout Merchant Control Panel account.
  2. Navigate to Setup → Generate links.
  3. Click on the Checkout Links tab. 
  4. Select Default Flows.
  5. In the Link options section, you can see a list with all available 2Checkout purchase flows.
  6. Click One page checkout without review to select this purchase flow.
  7. Choose one or more products from the Select products drop-down list to have the single page checkout flow associated with the experience offered to your users, ahead of generating buy-links for your offerings.

Purchase flow

tempsnip.png

After shoppers add a product to the cart and move to the next stage of the purchase process, 2Checkout redirects them to the one page checkout experience.

One page checkout without review comes with full cart functionality, enabling shoppers to:

  • Modify quantity
  • Add and remove products from the cart
  • Enter discount coupons
  • Change the display currency, language, and country
  • Purchase backup media and download software insurance
  • Purchase cross-sell products

Shoppers need only provide their billing information and preferred payment method. 

One page checkout without review doesn't include a review stage or require shoppers to go through any additional steps ahead of placing the order.

This is why under the Payment Options area, the cart highlights the amount to be charged. Once they're done adding products to the cart and entering their billing and payment info, shoppers get to place the order directly.

2Checkout matches the display currency with the billing currency for the One page checkout without review purchase flow, and as such, shoppers no longer get the option to select a different standalone billing currency. In scenarios where shoppers choose a different country, the final price will be updated automatically, taxes included, taking into consideration the taxation details of the locale. The page will need to refresh itself in order to present the new details.

Limitations

One page checkout without review does not support scenarios for products in the following categories:

  • The products price is zero
  • Products with physical delivery

Some orders require shoppers to enter additional information on top of the billing and payment areas of the One page checkout without review shopping cart support.

Consequently, there are a number of exceptions when the One page checkout without review purchase process is swapped for the One page checkout with review flow:

  • Payment settings active for your account do not support the billing currency.
  • The delivery address is different than the billing address.

One page trials

One page checkout with review works with:

  • Free trials with payment details
  • Paid trials

Streamline the ordering process of free trials with payment details and of paid trials, by using the One page checkout without review flow.

When you generated the trial link, add the &CARD=2 parameter manually.

For example, this download link:

https://secure.2checkout.com/order/trial.php?PRODS=123445566&QTY=1&PRICES4552060[EUR]=0&TPERIOD=30&PHASH=43684afcfe81388878b9612793bfdb51

needs to become:

https://secure.2checkout.com/order/trial.php?PRODS=123445566&QTY=1&PRICES4552060[EUR]=0&TPERIOD=30&PHASH=43684afcfe81388878b9612793bfdb51&CARD=2

for the users accessing the trial to go through the One page checkout without review flow.

For free trials with payment details, customers receive trial information in the Payment Options area of the shopping cart.

For paid trials, shoppers are provided not only with relevant trial details, but also a notification of the charge they'll incur. 2Checkout only charges the amount you set as the cost of the trial and not the full value of the product/subscription.

Single Sign On (SSO)

Overview

Redirect and login shoppers automatically from your user portal into their 2Checkout myAccount based on subscription or customer information.

Requirements

You need a custom domain to use Single Sign-On. Contact 2Checkout directly for guidance on how to set up a custom domain.

 

Automatic subscription cancelation

Overview

Choose to automatically cancel subscriptions whenever 2Checkout registers an open chargeback request or a total refund request.

  1. Go to Setup -> Ordering options.
  2. Scroll down to the following settings:
    • Cancel subscriptions for open chargebacks
      • 2Checkout automatically sends shoppers a subscription cancelation email upon opening a chargeback.
    • Cancel subscriptions for processed total refunds
      • This also impacts refunds made via IRN. Subscription will be canceled once the refund is processed by 2Checkout.
  3. Toggle them on or off according to your preferences.

Important: These settings reflect in the default state of the Cancel subscription option when you request refunds from the 2Checkout Control Panel.

The subscription gets reactivated when the chargeback is won.

If the subscription is in past due, it'll be reactivated and automatic renewal will be attempted.

If the expiry date of the subscription has passed and there is no grace period defined for this, the subscription will not be reactivated.

The time for which a subscription was disabled will not be added to the subscription lifetime to extend its expiry date.

2Checkout does not send a notification 7 days prior to the subscription renewal (since the subscription is disabled due to the chargeback).

Orders with installments

Overview

Avangate supports local Brazilian Visa, MasterCard and AMEX credit / debit cards limited to national purchases in the local currency BRL (Brazilian Real)

Requirements

  1. Installments are available only for:
    • Brazilian customers
    • Local Visa, MasterCard and AMEX cards
    • Non-recurring transactions
  2. Minimum installment threshold is 5 BRL. Maximum number of installments is 6.
  3. Mandatory information for payments also includes shopper phone number and  Fiscal Code (CPF/CNPJ).

Do local BR cards with / without installments require an addendum to my contract?

Yes. Please contact Avangate for activation.

How does it work?

  1. Create the Order object.
  2. Validate the number of installments available based on total order value. 
  3. Place the order specifying the number of installments. 

Funds collection for installment payments

Avangate pays you in full, regardless of the number of installments (this is covered directly by the banks). 

 

 

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