Skip to main content

Single sign-on (SSO)

Overview

Use this method to redirect and login users of the Channel Manager/Partner account automatically from your system into their CM/Partner account based on their email address. This method connects third-party systems with the 2Checkout Channel Manager/Partner Control Panel and enables your partners to seamlessly sign in to their Control Panel.

getPartnerSingleSignOn logs the partner users only into the Channel Manager account associated with your 2Checkout account. This method will not replicate the functionality of a full sign-in operation for users who partnered with multiple 2Checkout vendors and are leveraging connected partner accounts.

Requirements

This method requires you to set a specific partner using setPartner.

Parameters

Parameter Type/Description
sessionID Required (String)
  Session identifier, output of the Login method. An exception is thrown if the values are incorrect.
email Required (String)
  Channel Manager/Partner user account email address.
partnerCode Required (String)
  Unique partner identifier.
accessPage Required (String)
 

The specific Channel Manager / Partner control panel page you want the user to be redirected to.

Possible values:

You can use any URL in the Channel Manager/Partner Control Panel, including links to specific orders, subscriptions/licenses, and partner invoices.

validityTime Optional (Int)
  The time, in seconds, before the single sign-on URL returned by this method expires. By default, the URL expires after 10 seconds.
validationIP Optional (String)
  The IP address of the Channel Manager/Partner Control Panel user, required for security purposes. Can be an empty string or a valid IP, but cannot be NULL.

Response

Parameter Type/Description
Single sign-on URL String
 

The string is the complete single sign-on URL with a token to allow authentication into Channel Manager from external domains. Partner account users are logged in automatically to their Channel Manager accounts.

The URL can be used only once and only within the interval of time in which it's valid. Call this method again to generate a new single sign-on URL for a subsequent login action.

Request

<?php

require('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.2checkout.com/Integration/Channel_Manager_API/SOAP/02Authentication
require('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.2checkout.com/Integration/Channel_Manager_API/SOAP/06Reference/Partner/00Set_partner

$email = 'YOUR_PARTNER_EMAIL';
$partnerCode = 'YOUR_PARTNER_CODE';
$accessPage = 'YOUR_ACCESS_PAGE_URL';
$validityTime = VALIDITY_TIME;
$validationIP = 'VALIDATION_IP_ADDRESS';

try {
    $PartnerSingleSignon= $client-> getPartnerSingleSignOn ($sessionID, $email, $partnerCode , $accessPage, $validityTime, $validationIP);
} catch (SoapFault $e) {
    echo "SSO: " . $e->getMessage();
    exit;
}
var_dump ("SSO", $PartnerSingleSignon);

Errors

Error Description

INVALID_EMAIL

The email address is mandatory.

INVALID_EMAIL

Please specify a valid email address.

INVALID_PARTNER

The partner code is mandatory.

INVALID_PARTNER

Partner code provided is not associated to an active partner account.

INVALID_USER

Email address provided is not associated to a partner account user.

INVALID_URL

The page URL is mandatory.

INVALID_URL

The page URL provided is not valid.

INVALID_VALIDITY_TIME

Validity time needs to be a positive numeric value.

INTERNAL_ERROR

Cannot save security token. Please try again.

 

Turn on auto-advance feature

Overview

Use the Cart object to turn on the auto-advance feature (if mandatory fields are filled in) on the InLine checkout by calling the TwoCoInlineCart.cart.setAutoAdvance(true) method.

Use case

  1. Add an HTML link or button on your page like the one below.
  2. Create a JavaScript click handler to execute the InLine Client desired methods.
  3. Use the TwoCoInlineCart.products.add({code, quantity, options}) method to prepare your catalog product.
  4. Turn on the auto-advance feature by calling the TwoCoInlineCart.cart.setAutoAdvance(true) method.
  5. Set all the mandatory fields for billing.
TwoCoInlineCart.billing.setCountry('US');
TwoCoInlineCart.billing.setEmail('some@email.com');
TwoCoInlineCart.billing.setName('John Doe');

6. Use the TwoCoInlineCart.cart.checkout() method to show the cart on your page.

Request sample

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.setAutoAdvance(true);
      TwoCoInlineCart.billing.setCountry('US');
    TwoCoInlineCart.billing.setEmail('some@email.com');
    TwoCoInlineCart.billing.setName('John Doe');
    TwoCoInlineCart.cart.checkout();
});

Demo

After turning on the cart auto-advance feature using the above method, your cart should look like this:

 

 

Set cart lock in the InLine Cart

Overview

Use the Cart object to lock products by calling the TwoCoInlineCart.cart.setCartLockedFlag(true)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 currency use TwoCoInlineCart.cart.setCurrency(currency-code).
  5. To lock products use TwoCoInlineCart.cart.setCartLockedFlag(true)method.
  6. You can see below a signature token request payload for this example. A success response contains a JSON with the property “signature“ which needs to be used at the next step to set the signature using the TwoCoInlineCart method.
{
    "merchant": "AVLRNG",
    "currency": "USD",
    "lock": 1,
    "products": [
        {
            "code": "74B8E17CC0",
            "quantity": 3
        }
    ]
}

The above payload will generate the signature ba6ad53ac1cb699daad64bb1d3ef6ab72050787f62a3137d5090c96173a05e85.

7. Use the TwoCoInlineCart.cart.setSignature('ba6ad53ac1cb699daad64bb1d3ef6ab72050787f62a3137d5090c96173a05e85') method to set the signature.

8. 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.cart.setCurrency('USD');
  TwoCoInlineCart.products.add({
    code: "74B8E17CC0",
    quantity: 3
  });
  TwoCoInlineCart.cart.setSignature('ba6ad53ac1cb699daad64bb1d3ef6ab72050787f62a3137d5090c96173a05e85');
  TwoCoInlineCart.cart.setCartLockedFlag(true);
  TwoCoInlineCart.cart.checkout();
});

Demo

After locking the product page using the above method, your cart should look like this:

 

Product Upgrade Schema

Overview

Use the setProductUpgradeSchema method to set a product’s upgrade schema via API.

Parameters

Parameter Type Required Description
UpgradeSettings Object Required Details below.

          PricingScheme

Integer Required

The Upgrade pricing scheme.

1 – Shopper pays the full upgrade product price;

2 – Shopper pays the difference between the original subscription and the upgraded product;

3 - Shopper pays a prorated upgrade price calculated using the most recent costs incurred by the customer;

4 – Shopper pays prorated upgrade price calculated using the product's pricing set up at the time of the order.

          OptionPriceOperator String Optional The operator that specifies how is the upgrade price impacted (not used for prorated upgrade pricing schemes):

- ADD – the value set as OptionPricePercentage is added to the  upgrade price;

- SUBTRACT – the value set as OptionPricePercentage is subtracted from the upgrade price.
          OptionPricePercentage Integer Optional The percentage of the upgrade price to be added/subtracted from this one (not used for pro-rated upgrade pricing schemes).
          UseProductCatalogPricing Boolean Optional When true, it enables the usage of product catalog pricing. Removing custom prices also disables any existing retention campaigns for the selected subscriptions.
          ProrateIgnoreGracePeriod Boolean Optional When true, it makes the grace period be ignored when calculating Upgrade. Use this option to ignore the grace period set in your Renewal Settings when computing the prorated price for the upgrade.
          SubscriptionUpgradeType Integer Required Determines the Subscription period option for the upgrade:

1 - Create a new subscription (disable the existing one);

2 - Prolong the subscription from the upgrade purchase date;

3 - The upgrade does not affect the original subscription duration. If you upgrade a lifetime subscription to a product that has recurring options, the subscription will remain lifetime, as its duration is not affected by the upgrade process.
AllowUpgradeFrom Array of Strings Required List of product codes corresponding to the products that can be upgraded to the product of reference.

Request sample

<?php

//require_once(realpath(__DIR__ . '/../../../../../') . "/lib/api/v6.0/vendor/autoload.php");
require_once("/srv/www/app/live/htdocs/lib/api/v6.0/vendor/autoload.php");

$apiVersion = '6.0';
$domain = 'api.avangate.local:8081';
$host = "http://{$domain}/soap/{$apiVersion}/";

$client = new SoapClient($host . "?wsdl", array('location' => $host, 'cache_wsdl' => WSDL_CACHE_NONE));
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

// AlexB Inc account #21478
$merchantCode = "120000589445";
$key = "i9u2+w8%s4^5#8%t)A8?";
$productCode = "ADEV17962UPGRADE";            // main upgrade product offered as upgrade for other products
$upgradeFromProductCode1 = "ADEV17962UPOPT1"; // product that can be upgraded #1
$upgradeFromProductCode2 = "ADEV17962UPOPT12"; // product that can be upgraded #2

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

try {
    $sessionID = $client->login($merchantCode, $date, $hash);
} catch (SoapFault $e) {
    echo  $e->getMessage();

}
echo "SessionID: " . $sessionID . PHP_EOL;

$upgradeSchema = new stdClass();

/** @var \Api\Resources\Product\Assets\UpgradeSettings $upgradeSettings */
$upgradeSettings = new stdClass();
$upgradeSettings->PricingScheme = \Api\Resources\Product\Assets\UpgradeSettings::PRICING_SCHEME_PRICE_DIFFERENCE;
$upgradeSettings->OptionPriceOperator = \Api\Resources\Product\Assets\UpgradeSettings::OPTION_PRICE_OPERATOR_SUBSTRACT;
$upgradeSettings->OptionPricePercentage = 2;
$upgradeSettings->SubscriptionUpgradeType = \Api\Resources\Product\Assets\UpgradeSettings::SUBSCRIPTION_UPGRADE_TYPE_PROLONG_SUBSCRIPTION;
#$upgradeSettings->SubscriptionUpgradeType = 8; // invalid value
$upgradeSettings->UseProductCatalogPricing = true;
#$upgradeSettings->UseProductCatalogPricing = new SoapVar(5, XSD_INTEGER); // integer value 5 => will trigger exception
$upgradeSettings->ProrateIgnoreGracePeriod = false;

$upgradeSchema->UpgradeSettings = $upgradeSettings;
$upgradeSchema->AllowUpgradeFrom = [$upgradeFromProductCode1, $upgradeFromProductCode2];

$payload = json_encode($upgradeSchema, JSON_PRETTY_PRINT);

echo PHP_EOL . 'Calling ' . $host . ' with productCode: ' . $productCode . ' and payload: ' . PHP_EOL . $payload . PHP_EOL;

try {
    $resp = $client->setProductUpgradeSchema($sessionID, $productCode, $upgradeSchema);
} catch (SoapFault $e) {
    echo  '(SoapFault) Exception caught: ' . $e->getMessage() . PHP_EOL;
    die();
}

echo PHP_EOL . 'SetUpgradeSchema response:' . PHP_EOL . var_export($resp, true) . PHP_EOL;

Response

{
    "UpgradeSettings": {
        "PricingScheme": 1,
        "OptionPriceOperator": "ADD",
        "OptionPricePercentage": 3,
        "SubscriptionUpgradeType": 2,
        "UseProductCatalogPricing": false,
        "ProrateIgnoreGracePeriod": false
    },
    "AllowUpgradeFrom": [
        "ADEV17962UPOPT12"
    ]
}

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.

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