Skip to main content

Create a lead

Overview

The lead management functionality that exists for the ConvertPlus cart can be also integrated with a self-hosted cart.

Use the addLead method to create a lead when a customer abandons the cart before placing an order.

Request Parameters

Parameters Required Type/Description
Items Required Purchased products.
BillingDetails Required Array of strings. Billing information for the order.
DeliveryDetails Required Array of strings. Delivery information for the order.

Request Example

<?php

require ('PATH_TO_AUTH');

$Lead = new stdClass();

$Lead->CartId = "CartIdValue";
$Lead->Currency = "EUR";
$Lead->Language = "EN";
$Lead->ExternalReference = "REST_API_2CHECKOUT";
$Lead->Source = "testAPI.com";
$Lead->CustomerReference = "asdf1";
$Lead->MachineId = "123asd";

$Lead->Items = [];

$Item = new stdClass();
$Item->Code = "04C26C50F8";
$Item->Quantity = 2;
$Item->IsDynamic = false;
$Item->Tangible = true;
$Item->PurchaseType = "PRODUCT";
$Item->PriceOptions = [];

$priceOption = new stdClass();
$priceOption->Name = "group name 1";
$priceOption->Required = false;
$option = new stdClass();
$option->Name = 'add25';
$option->Value = 'add25';
$option->Surcharge = 100;
$priceOption->Options[] = $option;

$Item->PriceOptions[] = $priceOption;

$recurringOptions = new stdClass();
$recurringOptions->CycleLength = 6;
$recurringOptions->CycleUnit = 'MONTH';
$recurringOptions->CycleAmount = 100;
$recurringOptions->ContractLength = 2;
$recurringOptions->ContractUnit = 'YEAR';
$Item->RecurringOptions = $recurringOptions;

$marketingCampaigns = new stdClass();
$marketingCampaigns->Type = 23;
$marketingCampaigns->ParentCode = "m";
$marketingCampaigns->CampaignCode = 23;
$Item->MarketingCampaigns = $marketingCampaigns;

$Item->Price = new stdClass();
$Item->Price->Amount = 20;
$Item->Price->Type = "CUSTOM";

$additionalFields = [];

$additionalField = new stdClass();
$additionalField->Code = "TestFieldOne";
$additionalField->Text = "test text";
$additionalField->Value = "test value";
$additionalFields[] = $additionalField;
$Item->AdditionalFields = $additionalFields;

$Item->SubscriptionStartDate = date("Y-m-d H:i:s");

$Lead->Items[] = $Item;

$billingDetails = new stdClass();
$billingDetails->FirstName = "Customer";
$billingDetails->LastName = "2Checkout";
$billingDetails->Phone = null;
$billingDetails->Company = null;
$billingDetails->FiscalCode = "32423423";
$billingDetails->Email = "customer@2checkout.com";
$billingDetails->Address1 = "Test Address";
$billingDetails->Address2 = null;
$billingDetails->City = "LA";
$billingDetails->Zip = "12345";
$billingDetails->CountryCode = "RO";
$billingDetails->State = "CA";

$Lead->BillingDetails = $billingDetails;
$Lead->DeliveryDetails = clone($billingDetails);

$Lead->DeliveryInformation = new stdClass();
$Lead->DeliveryInformation->ShippingMethod = new stdClass();
$Lead->DeliveryInformation->ShippingMethod->Code = "sdfsd";

$Lead->PaymentDetails = new stdClass();
$Lead->PaymentDetails->Type = "CC";
$Lead->PaymentDetails->Currency = "EUR";
$Lead->PaymentDetails->PaymentMethod = new stdClass();
$Lead->PaymentDetails->PaymentMethod->RecurringEnabled = false;
$Lead->PaymentDetails->PaymentMethod->CardPayment = new stdClass();
$Lead->PaymentDetails->PaymentMethod->CardPayment->InstallmentsNumber = 23;
$Lead->PaymentDetails->CustomerIP = "1.2.3.4";

$Lead->LocalTime = date("Y-m-d H:i:s");


try {
    $leadData = $client->addLead($sessionID, $Lead);
} catch (SoapFault $e) {
    echo "addLead: " . $e->getMessage();
    exit;
}

var_dump("addLead", $leadData);

Response Example

class stdClass#18 (3) {
  public $LeadCode =>
  string(10) "60E6C4B574"
  public $CreatedAt =>
  string(19) "2019-11-05T16:39:36"
  public $Errors =>
  array(0) {
  }
}

 

Cloud GUI (Government Uniform Invoice) for Taiwan Shoppers

Overview

Offshore electronic service providers without a fixed place of business in Taiwan (referred to as foreign eCommerce operators - FECOs) selling digital services to Taiwanese consumers are required to issue Cloud Government Uniform Invoices (GUI) starting January 1st, 2020. These are a form of government pre-approved e-invoices.

Digital or electronic services include for example: Streaming or download media, desktop or mobile apps, e-books, e-learning, online journals, SaaS, and membership to online sites, etc.

The issuance of the cloud GUI (Government Uniform Invoice) is made by 2Checkout using an approved third-party provider integrated with the Taiwan Tax Authorities system.

Availability

The feature is automatically applied for all orders placed using an address in Taiwan, on reseller accounts (2Monetize), without any additional cost for merchants or shoppers.

Key Features

Starting January 1st, 2020, all Taiwan shoppers will receive two invoices:

  • The invoice issued by 2Checkout or any of its subsidiaries, as per the actual flow
  • The e-invoice (cloud GUI) issued by the authorized third-party provider within 48 hours upon payment

2Checkout will send the billing email address of the shopper to the Taiwanese Government as a requirement of the Cloud GUI integration.

Shopper Flow

Shoppers will receive a notification from the authorized third-party provider, including some important e-GUI information: Invoice date, invoice number, random number, sales amount.

To check the cloud GUI, a shopper needs to navigate to "The E-Invoice Platform of Ministry of Finance" (https://einvoice.nat.gov.tw) and use the email address that was used when placing the orders.

Additionally, these invoices can be verified using the Taiwanese Ministry of Finance’s “Claiming Reward App”.

Shoppers will need to log in to their 2Checkout MyAccount to check order details and access the invoice issued by 2Checkout or any of its subsidiaries.

Key Benefits 

The cloud GUI issuance is compliant with the Taiwan tax legislation and provides all Taiwan shoppers with the opportunity of participating in the Taiwan receipt lottery.

To claim any potential rewards, shoppers need to navigate to "The E-Invoice Platform of Ministry of Finance" (https://einvoice.nat.gov.tw) and input the email address that was used to place the orders.

Activate payment methods

Overview

Use this feature to control the availability of your payment methods. Additionally, you can configure what payment methods are available to your shoppers, based on the country they place orders from.

Availability

Payment method management is available for all 2Checkout accounts. The availability of specific payment methods may vary depending on your account and contractual agreements. Payment methods activation takes place instantly, except for those that require a special request, such as domestic cards.

Requirements

Before activating or modifying payment method settings, make sure that you are authorized by your company to perform these changes, and agree with any special conditions implied.

Activate a payment method

Follow the steps below to activate a payment method from your Merchant Control Panel.

  1. Log in to your Merchant Control Panel.
  2. Go to Setup → Ordering options.
  3. Click on the Payment Methods tab.
  4. Locate the payment method you want to edit in the list of payment methods and click on the Activate button in the Status column.
  5. Click on the Activate button again, once you're prompted with the iframe window showing details about the commissions applied to that payment method.

Restrict a payment method

Follow the steps below to restrict a payment method for specific countries.

  1. Log in to your Merchant Control Panel.
  2. Go to Setup → Ordering options.
  3. Click on the Payment Methods tab.
  4. Locate the payment method you want to restrict for specific countries and click on the Edit button.
  5. Select the countries you want to restrict from the left side column and move them to the list on the right, in the Restricted countries list.
  6. Click on Save settings.

Restricting all countries for a payment method triggers its deactivation.

You cannot edit the availability of the following payment methods:

  • Visa/MasterCard
  • American Express
  • Discover/Novus
  • PayPal

Deactivate/disable a payment method

Follow the steps below to disable a payment method.

  1. Log in to your Merchant Control Panel.
  2. Go to Setup → Ordering options.
  3. Click on the Payment Methods tab.
  4. Locate the payment method you want to deactivate and click on Edit in the Status column.
  5. Click on the Disable this payment method link below the Restricted countries list.
  6. When prompted with the iframe window, click on the Deactivate button.

Alternatively, you can disable a payment method by restricting all of its available countries.

You cannot disable the following payment methods:

  • Visa/MasterCard
  • American Express
  • Discover/Novus
  • PayPal

Restrict billing countries

Follow the steps below to restrict purchases coming from specific billing countries.

  1. Log in to your Merchant Control Panel.
  2. Go to Setup → Ordering options.
  3. Click on the General tab.
  4. Locate the Billing Countries section.
  5. Select the countries you want to restrict from the left side column and move them to the list on the right.

Shoppers won't be able to select restricted countries for the billing address in the cart.

Local processing activation

Domestic cards with installments

2Checkout’s local processing support in Turkey and Brazil provides shoppers with the choice to pay for their purchases with local cards that allow installments. Cards such as:

  • Visa and MasterCard in Turkey
  • Visa, MasterCard, American Express, Elo, HiperCard in Brazil.

Follow the steps below to enable this payment method.

  1. Go to Setup -> Ordering options.
  2. Click the Payment Methods tab.
  3. Locate the Credit cards with installments payment method and click Activate. The activation window notifies you of the applicable commissions for both Brazil and Turkey for eCommerce and affiliate orders.
  4. Choose the countries for which you want to enable the payment method.
    • Brazil. You need to enable domestic cards without installments separately for Brazilian shoppers. 
    • Turkey. This action also enables domestic cards without installments for Turkish shoppers. 
  5. Click Activate.

Domestic cards without installments

Domestic cards without installments are available in Turkey (Visa/MasterCard) and Brazil (Visa/MasterCard and American Express). Payment without installments is not enabled by default. To enable local cards without installments, follow the steps below.

  1. Go to Setup -> Ordering options.
  2. Click the Payment Methods tab.
  3. Locate the Visa/MasterCard payment method and click Edit.
  4. Click Send request to notify 2Checkout to enable this payment method. The activation window notifies you of the applicable commissions for both Brazil and Turkey for eCommerce and affiliate orders. 

Risk assessment

Activation of domestic credit cards requires 2Checkout risk assessment and can take up to 2 business days.

OFAC country restrictions

2Checkout is fully compliant with OFAC regulations, restricting shoppers from the OFAC countries from placing orders. Read more about OFAC regulations here.

Payment failed (instant payment methods)

Overview

Use the variables in the list below to customize the Payment failed (instant payment methods) shopper email according to your needs.

Check the Mandatory column to see the variables that are required in your customized version of the e-mail.

Variable name Description Test value Mandatory

2CHECKOUT_COMPANY_NAME

2Checkout company name

2Checkout

No
2CHECKOUT_LOGO 2Checkout logo URL https://secure.2checkout.com/images/e...endor_logo.png Yes

2CHECKOUT_OPERATIONAL_EMAIL

2Checkout operational email address

0

No

2CHECKOUT_OPERATIONAL_FAX

2Checkout operational fax number

0

No
2CHECKOUT_RESELLER_ROLE This is mandatory content you need to keep in your emails, given 2Checkout acts as Reseller / Merchant of Record for online purchases on your website. 2Checkout acts as an authorized reseller of #Merchant commercial name online products and services. Yes

2CHECKOUT_SUPPORT_EMAIL

2Checkout support email address

support@2checkout.com

Yes

2CHECKOUT_SUPPORT_PHONE

2Checkout support phone

0

No

2CHECKOUT_SUPPORT_PHONE_US

2Checkout US hotline number

0

No

2CHECKOUT_WEBSITE

2Checkout website

http://www.2checkout.com

Yes

BUSINESS_COMPANY

2Checkout company name

2Checkout No

BUSINESS_HOTLINE

2Checkout support phone

0

No

BUSINESS_HOTLINEUS

2Checkout US hotline number

0

No

BUSINESS_OPEMAIL

2Checkout operational email address

0

No

BUSINESS_OPFAX

2Checkout operational fax number

0

No

BUSINESS_SUPEMAIL

2Checkout support email address

support@2checkout.com

No

CARD_LAST_DIGITS

Last 4 digits of the card used to perform the payment

0

No

COMMERCIALNAME

Merchant's commercial name

0

No

CONVERTED_ORDER_AMOUNT

Order amount converted in all vendor currencies

0

No

CURRENCY

Order billing currency

USD

Yes

CURRENCY_ORIGINAL

Original order currency (applicable to refunds)

0

No

ENCRYPTED_MERCHANT_CODE

Encrypted merchant code

0

No

FIRSTNAME

Shopper's first name used on the billing information

John

No

FIRST_NAME_BILLING

Shopper's first name used on the billing information

John

No
GATEWAY_ERROR_CODE Gateway error code

GW_PROCESSING_ERROR 

See the full list of Possible Values

No
GATEWAY_ERROR_MESSAGE

Reason why the transaction failed. (e.g. Invalid card, insufficient funds)

 

Error processing the card transaction. The card account has not been debited. Card data is invalid or incomplete. No

GENERALTOTAL

Total order price

56.5

No

HAS_RENEWAL_PRODUCTS

Flag that indicates whether at least one product has renewal settings

1

No

HOTLINE_NUMBERS

Array of attributes for 2Checkout hotline numbers

0

No

IS_RENEWAL

Flag that indicates whether at least one product has renewal settings

1

No

LASTNAME

Shopper's last name used on the billing information

Doe

No

LAST_NAME_BILLING

Shopper's last name used on the billing information

Doe

No

MERCHANT_COMMERCIAL_NAME

Merchant's commercial name

Software Company Name

No

MYACCOUNT_URL_UPDATE_CC

URL for updating credit card information in myAccount

0

No

MY_ACCOUNT_LOGIN_URL

2Checkout myAccount login/sign-up URL

https://secure.2checkout.com/myaccoun...m&k=xxxxxxxxxx

Yes

MY_ACCOUNT_URL_UPDATE_CC

URL for updating credit card information in myAccount

0

No

NAMES_OF_PRODUCTS

Names of all products in the order, comma-separated

My product name

Yes

ORDERDATE

Order placement date

42515

No

ORDER_AMOUNT

Total order price

56.5

No

ORDER_AMOUNT_ORIGINAL

Original order value (applicable to refunds)

0

No

ORDER_DATE

Order placement date

42515

No

ORDER_DATE_STANDARD_FORMAT

Standard format used for the order placement date

42515

Yes

ORDER_FLOW

Purchase flow used to place the order

0

No

ORDER_REFERENCE_NUMBER

Order reference number

9xxxxx

Yes

ORDER_STATUS

Order status

0

No

ORDER_WEBSITE

Website where the shopper placed the order

http://www.software-company-website.com

Yes

PAYABLE_TO

Payee name (applicable to wire transfer)

0

No

PAYMENT_METHOD

English name for the payment method used

Visa/MasterCard/Eurocard - 1234

No

PAYMENT_TYPE_INFO

English payment method name. Includes last four card digits (if applicable).

Visa - 1234

No

PAYMETHOD

English name for the payment method used

0

Yes

PAYTYPE

Identification number for the payment method selected during the ordering process

1

No

PAY_TYPE

Identification number for the payment method selected during the ordering process

1

No

PRODUCTS

Products data.

0

No

PRODUCTS[index1].BILLING_CYCLE

Indicates how many renewals have been successfully performed so far (on the subscription)

11

No
PRODUCTS[index1].CODE Product code. P_CODE No

PRODUCTS[index1].DISCOUNT

Product discount value per product line

1

No

PRODUCTS[index1].INFO

Additional product information defined by merchant when generating buy links

Product info 1

No

PRODUCTS[index1].LICENSE_TYPE

Type of purchased subscription

0

No

PRODUCTS[index1].PCODE

Product code.

P_CODE_1

No

PRODUCTS[index1].PID

Product ID number

1234

No

PRODUCTS[index1].PNAME

Product name

Test

No

PRODUCTS[index1].PRICE

Product unit price

20

No

PRODUCTS[index1].PRODUCT_OPTIONS

0

0

No

PRODUCTS[index1].PRODUCT_OPTIONS[index2].OptionText

Ignore internal var.

0

No

PRODUCTS[index1].PROMONAME

Name of the promotion applied to the product

Some promotion

No

PRODUCTS[index1].QUANTITY

Purchased product quantity

2

No

PRODUCTS[index1].SHORT_DESCRIPTION

Short product description

0

No
PRODUCTS[index1].SKU Product SKU SKU1234 No

PRODUCTS[index1].TOTAL

Total gross price per product line (before applying discounts)

45.6

No

PRODUCTS[index1].VAT

VAT/Sales tax value per product line

3.8

No

PRODUCTS_DATA[index1].IdProduct

Product ID number

0

No

PRODUCTS_DATA[index1].PRODUCT_SHORT_DESCRIPTION

Short product description

0

No

PRODUCTS_NO

Number of products in cart

0

No

QR_CODE_SRC

The QR code URL to be used for payments with bank/wire transfer

0

No

REFNO

Order reference number

9xxxxx

No

RETRY_LINK

Payment retry link

https://secure.2checkout.com/order/fi...?id=xxxxxxxxxx

Yes

SELLERCOMPANY

Merchant's company name

Software Company Name

No

TOTALEQUIV

The order amount converted to all the merchant's currencies

0

No

UPLOADLINK

File upload link

0

No

UPLOAD_LINK

File upload link

0

No

WEBSITE

Website where the shopper placed the order

http://www.software-company-website.com

No

Create fixed discount

Overview

Use setPromotionDiscount to set a fixed promotion discount.

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 set the discount for.

promotionDiscount

Required(Object)

 

Type

Required (String)

 

 

Discount type:

  • PERCENT, use in combination with Value
  • FIXED, use in combination with Values and DefaultCurrency

 

Value / Values

Required (Int / Array of objects)

 

 

  • Value = Int, determines the discount percentage from 0 to 100
  • Values = Array of Value objects

 

 

Value

Required (Object)

 

 

 

Currency

Required (String)

 

 

 

 

Discount currency ISO code (ISO 4217).

 

 

 

Amount

Required (Int)

 

 

 

 

Discount amount in corresponding currency.

 

DefaultCurrency

Required (String)

 

 

Default discount currency ISO code (ISO 4217).

Response

Parameter Type/Description
promotionDiscount Object

Request

<?php

function callRPC($Request, $host, $Debug = true) {
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
    if ($Debug) {
        $RequestString;
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        $ResponseString;
    }
    if (!empty($ResponseString)) {
        var_dump($ResponseString);
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}

$host = 'https://api.avangate.com/rpc/3.1/';

$merchantCode = "YOUR_MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key = "YOUR_SECRET_KEY"; // your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php

$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$hash = hash_hmac('md5', $string, $key);

$i = 1;

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;

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

// Promotion code assigned to the promotion you want to update
$promotionCode = '';

$promotionDiscount = new stdClass;
$promotionDiscount->Type = 'FIXED';
$promotionDiscount->DefaultCurrency = 'USD';

// Define the first discount object for a specific currency
$discount1 = new stdClass;
$discount1->Currency = 'USD';
$discount1->Amount = 22;

// Define the second discount object for a specific currency
$discount2 = new stdClass;
$discount2->Currency = 'EUR';
$discount2->Amount = 50;

$promotionDiscount->Values = [$discount1, $discount2];

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'setPromotionDiscount',
'params' => array($sessionID, $promotionCode, $promotionDiscount)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

How do invoices work?

Overview

2Checkout sends PDF invoices via email to both business customers and shoppers after finalizing payment (when the order's status switches to Finished).

Important: The system sends Purchase Order invoices immediately after you've confirmed the Purchase Orders, before the order's status switches to Finished.

Customizing invoices

We offer the possibility of customizing the invoices sent to your shoppers via our Professional Services team. Depending on your needs, we can help you customize details such as additional order and product fields, to better suit your preferences and offer relevant information to your shoppers.

Availability

The invoice customization service is available only to eligible accounts.

For any kind of invoice customization requests, feel free to contact us.

Retrive upsell settings

Overview

Use the getDisplayType method to extract information for upselling display type for your campaigns.

Request parameters

Parameter 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.

Response

The getDisplayType method will return the UpsellingDisplayType value with one of "overlay" or "interstitial".

Request sample

<?php

        require ('PATH_TO_AUTH');

        $jsonRpcRequest = new stdClass();
        $jsonRpcRequest->jsonrpc = '2.0';
        $jsonRpcRequest->method = 'getDisplayType';
        $jsonRpcRequest->params = array($sessionID);
        $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;
        }

Add promotion coupon

Overview

Use the addPromotionCoupon method to add single or multiple coupons to a 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 coupons to.

promotionCoupon

Required (object)

 

type

Required (string)

 

 

Coupon type. Available values:

  • SINGLE, use in conjunction with Code
  • MULTIPLE, use in conjunction with Codes

 

Code/Codes

Required (string / array of strings)

 

 

Coupon code (for SINGLE) or array of coupon codes (for MULTIPLE).

Response

Parameter Type/Description
promotionCoupon Object

Request

<?php

function callRPC($Request, $host, $Debug = true) {
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
    if ($Debug) {
        $RequestString;
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        $ResponseString;
    }
    if (!empty($ResponseString)) {
        var_dump($ResponseString);
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}

$host = 'https://api.avangate.com/rpc/3.1/';

$merchantCode = "YOUR_MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key = "YOUR_SECRET_KEY"; // your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php

$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$hash = hash_hmac('md5', $string, $key);

$i = 1;

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;

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

// Promotion code corresponding to the promotion you want to add coupons to
$promotionCode = '';

// Define single coupon object
$promotionCoupon = new stdClass;
$promotionCoupon->Type = 'SINGLE';
$promotionCoupon->Code = 'YOUR_CODE_HERE';

// Define multiple coupon object
$promotionCoupon = new stdClass;
$promotionCoupon->Type = 'MULTIPLE';
$promotionCoupon->Codes = ['YOUR_CODE_1', 'YOUR_CODE_2'];

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addPromotionCoupon',
'params' => array($sessionID, $promotionCode, $promotionCoupon)
);
var_dump (callRPC($jsonRpcRequest, $host));

Set SKU codes

Overview

Use the setSku method to create a valid combination of elements (code) for a specific product. 

In case there is an active SKU schema available for that Product Code and Pricing Configuration Code, when setting new SKUs the entire existing schema will be overwritten with the new values. The same validations that are applied to the CSV file import in the Merchant Control Panel are applicable to the API as well.

Product SKUs created via API will also be available in the Merchant Control Panel for manual update (Dashboard → Setup → Products → Edit product → Information → SKU Manager (SKU list Tab).

Request Parameters

Parameters Required Type/Description
     
     
     
     

Request

<?php

require ('PATH_TO_AUTH');

$product = new \stdClass();
$product->ProductCode = "6B3CB17DDA_COPY1";

$skuPricingOption1 = new \stdClass();
$skuPricingOption1->Code = "E684EC99B0";

$skuDetail1 = new \stdClass();
$skuDetail1->ProductSKU = "Product_Test_SKU_001022";
$skuDetail1->Currency = "USD";
$skuDetail1->FromQty = 1;
$skuDetail1->ToQty = 3
$skuDetail1->PurchaseType = "NEW_PRODUCT";

$skuGroup = new \stdClass();
$skuGroup->GroupCode = "GRUP_1";

$skuGroupOption = new \stdClass();
$skuGroupOption->Name = "option name 1";
$skuGroupOption->Value = "option_code_1";

$skuGroup->Options = [$skuGroupOption];

$skuDetail1->Groups = [$skuGroup];
$skuDetail1->Options = "eJwBLADT/6G10uOW07exk6mNk7KvrpaSc4l1lbXToqi5sriTcbOXseWu3ZGrlXauuZOojh8cww==";

$skuDetail2 = new \stdClass();
$skuDetail2->ProductSKU = "Product_Test_SKU_001023";
$skuDetail2->Currency = "USD";
$skuDetail2->FromQty = 1;
$skuDetail2->ToQty = 3
$skuDetail2->PurchaseType = "NEW_PRODUCT";

$skuGroup = new \stdClass();
$skuGroup->GroupCode = "GRUP_1";

$skuGroupOption = new \stdClass();
$skuGroupOption->Name = "option name 2";
$skuGroupOption->Value = "option_code_2";

$skuGroup->Options = [$skuGroupOption];

$skuDetail2->Groups = [$skuGroup];
$skuDetail2->Options = "eJwBLADT/6G10uOW07exk6mNk7KvrpaSc4l1lbXToqi5sriTcbOXseWu3ZGrmXauuZOojjccxw==";

$skuPricingOption1->Details = [$skuDetail1, $skuDetail2];

$product->SkuPricingOptions = [$skuPricingOption1];

$jsonRpcRequest = array (
    'method' => 'setSku',
    'params' => array($sessionID, [$product]),
    'id' => $i++,
    'jsonrpc' => '2.0'
);

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

Response Parameters

Parameters Required Type/Description
     
     
     
     
     

Response

class stdClass#7 (3) {
  public $ProductCode =>
  string(16) "6B3CB17DDA_COPY1"
  public $PricingConfigurations =>
  array(1) {
    [0] =>
    class stdClass#8 (6) {
      public $Code =>
      string(10) "E684EC99B0"
      public $Currencies =>
      array(1) {
        [0] =>
        class stdClass#9 (1) {
          public $Code =>
          string(3) "EUR"
        }
      }
      public $PurchaseTypes =>
      array(1) {
        [0] =>
        class stdClass#10 (1) {
          public $Code =>
          string(7) "RENEWAL"
        }
      }
      public $QuantityIntervals =>
      array(0) {
      }
      public $PriceOptionGroups =>
      array(0) {
      }
      public $SkuCollection =>
      array(1) {
        [0] =>
        class stdClass#11 (2) {
          public $ProductCode =>
          string(16) "6B3CB17DDA_COPY1"
          public $SkuPricingOptions =>
          array(1) {
            [0] =>
            class stdClass#12 (3) {
              public $Code =>
              string(10) "E684EC99B0"
              public $Details =>
              array(8) {
                [0] =>
                class stdClass#13 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008899"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(1)
                  public $ToQty =>
                  int(3)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#14 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#15 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(32) "a:1:{i:16885;a:1:{i:0;i:78164;}}"
                }
                [1] =>
                class stdClass#16 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008902"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(1)
                  public $ToQty =>
                  int(3)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#17 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#18 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(6) "a:0:{}"
                }
                [2] =>
                class stdClass#19 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008900"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(1)
                  public $ToQty =>
                  int(3)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#20 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#21 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(32) "a:1:{i:16885;a:1:{i:0;i:78165;}}"
                }
                [3] =>
                class stdClass#22 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008901"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(1)
                  public $ToQty =>
                  int(3)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#23 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#24 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(32) "a:1:{i:16885;a:1:{i:0;i:78166;}}"
                }
                [4] =>
                class stdClass#25 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008907"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(4)
                  public $ToQty =>
                  int(7)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#26 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#27 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(32) "a:1:{i:16885;a:1:{i:0;i:78164;}}"
                }
                [5] =>
                class stdClass#28 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008910"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(4)
                  public $ToQty =>
                  int(7)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#29 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#30 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(6) "a:0:{}"
                }
                [6] =>
                class stdClass#31 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008908"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(4)
                  public $ToQty =>
                  int(7)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#32 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#33 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(32) "a:1:{i:16885;a:1:{i:0;i:78165;}}"
                }
                [7] =>
                class stdClass#34 (7) {
                  public $ProductSKU =>
                  string(23) "Product_Test_SKU_008909"
                  public $Currency =>
                  string(3) "EUR"
                  public $FromQty =>
                  int(4)
                  public $ToQty =>
                  int(7)
                  public $PurchaseType =>
                  string(7) "RENEWAL"
                  public $Groups =>
                  array(1) {
                    [0] =>
                    class stdClass#35 (2) {
                      public $GroupCode =>
                      string(6) "GRUP_2"
                      public $Options =>
                      array(1) {
                        [0] =>
                        class stdClass#36 (2) {
                          public $Name =>
                          string(6) "grup 2"
                          public $Value =>
                          string(13) "option_code_4"
                        }
                      }
                    }
                  }
                  public $Options =>
                  string(32) "a:1:{i:16885;a:1:{i:0;i:78166;}}"
                }
              }
              public $Errors =>
              array(0) {
              }
            }
          }
        }
      }
    }
  }
  public $Errors =>
  array(0) {
  }
}

Search upsell campaigns

Overview

Use the searchUpsellCampaigns method via JSON-RPC API 6.0 to find and filter specific upsell campaigns.

Request Parameters

Parameter Name Type Required/Optional Description

SessionId

String

Required

Unique 2Checkout session ID code.

Name

String

String

Title of the campaign.

PrimaryProductCodes

Array of Strings

Optional

Array of product codes used as primary products you want to filter by.

 PrimaryProductCode

String

Optional

Unique product code.

RecommendedProductCodes

Array of Strings

Optional

Array of product codes used as recommended products you want to filter by.

 RecommendedProductCode

String

Optional

Unique product code.

Statuses

Array of Strings

Optional

Array of statuses you want to filter by.

 Status

String

Optional

Status of the upsell campaign. Enum can be one of:

 

  • Enabled
  • Disabled
  • Expired

StartsAfter

String

Optional

Date in ‘Y-m-d’ format after which campaigns start.

StartsBefore

String

Optional

Date in ‘Y-m-d’ before campaigns start.

EndsAfter

String

Optional

Date in ‘Y-m-d’ after which campaigns are ending.

EndsBefore

String

Optional

Date in ‘Y-m-d’ before campaigns end.

EnabledForRenewals

Boolean

Optional

Filter campaigns enabled for renewal.

CampaignCodes

Array of Strings

Optional

Array of campaign codes to filter by.

 CampaignCode

String

 

Unique code for an upsell campaign.

Page

Integer

Optional

Page you want to retrieve.

Limit

Integer

Optional

Maximum number of campaigns per page.

Request Example

<?php
 
require ('PATH_TO_AUTH');
 
$filters = new \stdClass();
$filters->Name = 'op_2';
$filters->PrimaryProductCodes = ['A59VUKFMA2', 'JN2GSQ184L'];
$filters->RecommendedProductCodes = ['XI2MNQ41MNH'];
$filters->Statuses = ['DISABLED', 'EXPIRED'];
$filters->StartsBefore = '2020-10-01';
$filters->StartsAfter = '2019-11-05';
$filters->EndsBefore = '2022-11-10';
$filters->EndsAfter = '2020-10-02';
//$filters->EnabledForRenewals = true;
//$filters->CampaignCodes = ['8050a1b7-338e-45bd-9936-17f98b01349e'];
$filters->Page = 1;
$filters->Limit = 10;
 
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'searchUpsellCampaigns';
$jsonRpcRequest->params = array($sessionID, $filters);
$jsonRpcRequest->id = $i++;
 
try {
    $result = callRPC($jsonRpcRequest, $host);
    echo "Campaigns: </br>",
    var_dump($result);
}
catch (SoapFault $e) {
    echo "Could not fetch upsell campaigns: " . $e->getMessage();
    exit;
}

Response

Parameter Name Type Required/Optional Description

Page

Integer

Required

The Search page you are on.

Limit

Integer

Required

Maximum number of campaigns per page.

Upsells

Array of Strings

Required

Array of Upsell Campaigns.

   UpsellCampaign

Object

Required

 

UpsellsCount

Integer

Required

Total number of Upsells that fit your search criteria.

PagesCount

Integer

Required

Total number of pages with Upsells that fit your criteria.

 

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