Skip to main content

Subscription import

Overview

Add/import subscriptions in the 2Checkout system.

 

Include card data with your subscription import only if you contacted 2Checkout to enable this functionality for your account. Otherwise, the import process results in a failure. Contact 2Checkout or your account manager directly for more details.

ATTRIBUTES

Parameters Type/Description

ExternalSubscriptionReference

Required (string)

 

Unique identifier for your subscription. Mandatory when importing subscription data.

StartDate

Required (string)

 

Subscription start date(YYYY-MM-DD) - StartDate is mandatory when importing subscription data. If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the StartDate you provide must be in accordance with your custom configuration.

ExpirationDate

Required (string)

 

Subscription expiration date(YYYY-MM-DD) - ExpirationDate is mandatory when importing subscription data. If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the ExpirationDate you provide must be in accordance with your custom configuration.

Product

Required (object)

 

The product for which 2Checkout generated the subscription. Details below.

 

ProductCode

String

 

 

Unique product identifier that you control.

 

ProductId

Int

 

 

Unique, system-generated product identifier.

 

ProductName

String

 

 

Product name.

 

ProductQuantity

Int

 

 

Ordered number of units.

 

ProductVersion

String

 

 

Product version.

 

PriceOptionCodes

Array

 

 

The product options codes the customer selected when acquiring the subscription. Pricing options codes are case sensitive.

EndUser

Required (object)

 

The end user of the subscription. Details below.

 

Person

Object

 

 

FirstName

String

 

 

 

End user's first name

 

 

LastName

String

 

 

 

End user's last name

 

 

CountryCode

String

 

 

 

End user country code [ISO3166-1 Alpha 2].

 

 

State

String

 

 

 

End user state.

 

 

City

String

 

 

 

End user city.

 

 

Address1

String

 

 

 

End user first address line.

 

 

Address2

String

 

 

 

End user second address line.

 

 

Zip

String

 

 

 

End user zip code.

 

 

Email

String

 

 

 

End user email address.

 

 

Phone

String

 

 

 

End user phone number.

 

 

Company

String

 

 

 

Company name.

 

Fax

String

 

 

End user fax.

 

Language

String

 

 

Language [ISO639-2] the 2Checkout system uses for communications.

DeliveryInfo

Optional (object)

 

The object contains information about the delivery/fulfillment made to the customer.

 

Description

String

 

 

Delivery description.

 

Codes

Array of objects

 

 

Code

String

 

 

 

Delivered activation key/code.

 

 

Description

String

 

 

 

Code description for dynamic lists from your key generator. 

 

 

ExtraInfo

Object

 

 

 

Info set by your key generator for dynamic lists only.

 

 

 

CodeExtraInfo

Object

 

 

 

Type

String

 

 

 

Label

String

 

 

 

Value

String

 

 

File

Array of objects

 

 

 

Content

String

 

 

 

 

Content of the file (base64 encoded).

 

 

 

ContentLength

Int

 

 

 

 

File size.

 

 

 

Filename

String

 

 

 

 

The name of the delivered file.

 

 

 

FileType

String

 

 

 

 

The type of the delivered file.

PartnerCode

Optional (string)

 

  • Empty: for ecommerce orders
  • Partner Code (mandatory)

ExternalCustomerReference

Optional (string)

 

Customer identifier you control.

SubscriptionValue

Optional (double)

 

Subscription value. The total costs incurred by the customer through the lifecycle of the subscription before you imported the item into the 2Checkout system.

When you send this parameter you must accompany it by ValueCurrency.

SubscriptionValueCurrency

Optional (string)

 

Mandatory when you also send the Value parameter. The currency associated to the subscription value.

AdditionalInfo

Optional (string)

 

Extra information that you can attach to a subscription, such as the source of the initial purchase.

NextRenewalPrice

Optional (double)

 

The future costs that subscribers would incur when their subscriptions are renewed. When provided, you must accompany it by NextRenewalPriceCurrency and CustomPriceBillingCyclesLeft.

NextRenewalPriceCurrency

Optional (string)

 

Mandatory when you send CustomPriceBillingCyclesLeft. The currency associated with the subscription next renewal price value.

CustomPriceBillingCyclesLeft

Optional (string)

 

Mandatory when you send NextRenewalPrice. 2Checkout applies the next renewal price to the number of billing cycles you define.

CardPayment

Optional (object)

 

Include payment (credit/debit card) information that 2Checkout uses for recurring billing to renew imported subscriptions. Importing subscriptions with payment data is available only to eligible 2Checkout accounts. Contact 2Checkout directly for additional details.

 Card payment

Add credit/debit card details when importing subscriptions. 2Checkout uses payment information in the recurring billing process.

For imports of test subscriptions, use the credit card information from this article.`

CardPayment Object

CardNumber

Required (string)

 

The credit/debit card number.

CardType

Required (string)

 

VISA, VISAELECTRON, MASTERCARD, MAESTRO, AMEX, DISCOVER, DANKORT, CARTEBLEUE, JCB.

ExpirationYear

Required (string)

 

The year in which the card expires.

ExpirationMonth

Required (string)

 

The month in which the card expires.

HolderName

Required (string)

 

Card holder name.

CCID

Required (string)

 

Credit Card Identification - an extra ID printed on the card, usually a 3-4 digit number, the CVC2/CVV2.

HolderNameTime

Required (int)

 

The interval of time in seconds in which shoppers enter their name in the HolderName field. An abnormally short interval is usually a red flag for fraud attempts.

AutoRenewal

Optional (bool)

 

True or false, depending on whether the customer or you enabled or disabled subscription auto-renewals.

CardNumberTime

Optional (int)

 

The interval of time in seconds in which shopper enter their card number in the CardNumber field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

 

Retrieve information on promotions

Overview

Use the searchPromotions method to extract information on promotions you set up for your account.

Parameters

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.

Types

StringArray

 

Discount type:

  • REGULAR
  • GLOBAL
  • RENEWAL

Channel

String

 

Channel:

  • ECOMMERCE
  • CHANNEL_MANAGER
  • ALL

ProductCode

String

 

Unique code that you set for each of your products.

Limit

Int

 

Number of results returned by the method.

Page

Int

 

Results pagination.

Response

Promotion

Array of objects

Request

<?php

$host   = "https://api.avangate.com";
$client = new SoapClient($host . "/soap/3.0/?wsdl", array(
    'location' => $host . "/soap/3.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));


function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}

$merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')

$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);

try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}

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

$SearchOptions              = new stdClass();
$SearchOptions->Types       = array();
$SearchOptions->Types[0]    = 'REGULAR';
$SearchOptions->Types[1]    = 'RENEWAL';
$SearchOptions->Channel     = 'ECOMMERCE';
$SearchOptions->ProductCode = 'my_subscription_1';
$SearchOptions->Limit       = 10;
$SearchOptions->Page        = 1;


try {
    $Discounts = $client->searchPromotions($sessionID, $SearchOptions);
}

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

var_dump("Discounts", $Discounts);


?>

Retrieve VAT or sales tax

Overview

Use the getContents method to calculate the tax charge based on current session contents. Follow the steps below to learn how you can retrieve the VAT or sales tax amount:

  1. Populate the Order object with information. 2Checkout needs the BillingDetails (object) information to calculate taxes. 
  2. Use the getContents method to get info on all the products added to cart by the shopper in the current session.
  3. The output of the getContents method is the Order session content object.
  4. Under the Price, access information including for each product purchased. Find value added tax and sales tax details under the VAT parameter. 
  5. Tax information is also available for the entire order object. Find value added tax and sales tax details under the VAT parameter.
  6. Calculate the VAT/sales tax rates using the VAT and NetPrice values

 

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

SessionContents

Object

Request

<?php

require ('PATH_TO_AUTH');

$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->AffiliateId = NULL;
$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->FirstName = 'FirstName';
$Order->BillingDetails->LastName = 'LastName';
$Order->BillingDetails->CountryCode = 'us';
$Order->BillingDetails->State = 'California';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'customer@email.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'TEST';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->CardType = 'visa';
$Order->PaymentDetails->PaymentMethod->ExpirationYear = '2019';
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = '12';
$Order->PaymentDetails->PaymentMethod->HolderName = 'John';
$Order->PaymentDetails->PaymentMethod->CCID = '123';
$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

try {
    $CartContents = $client->getContents    ($sessionID, $Order);
}
catch (SoapFault $e) {
    echo "CartContents: " . $e->getMessage();
    exit;
}
var_dump("CartContents", $CartContents

A/B testing campaigns for purchase flows

Overview

Use A/B testing campaigns to compare purchase flow variations and determine the highest converting purchasing funnel. Test between multiple purchase flow types:

  • Checkout with cart functionalities
  • One page checkout without review
  • One page checkout with review
  • Checkout page
  • Express Payments Checkout

Requirements & limitations

Parameters sent through buy links will overwrite campaigns variables. Campaigns will not start if the buy link has a parameter that overwrites an experiment variable.

Trial links generated without CART or CARD parameters are also taken into account by the A/B testing mechanism.

You can see in the table below that some links that you can generate via the Sales links area of the platform contain parameters such as CART=1, CARD=1 or CARD=2. Make sure to remove these parameters from the links your shoppers use. Otherwise, their interactions will not be taken into account by the purchase flows A/B test.

Important: 2Checkout updates the campaign results at hourly intervals. Please allow up to one hour for the statistics to completely refresh after running tests.

2Checkout recommends using simple links, such as https://secure.2checkout.com/order/checkout.php.

Purchase Flow Type Action Description
Checkout with cart functionalities
https://secure.2checkout.com/order/checkout.php?CART=1
The customers will land on the billing page having the shopping cart functionalities enabled. All marketing tools and extra delivery services are also available (cross-selling, etc).
One page checkout without review
https://secure.2checkout.com/order/checkout.php?CART=1&CARD=2
Customers will have an all-in-one page: shopping cart, billing form, marketing tools and the payment form (credit card and PayPal).
One page checkout with review
https://secure.2checkout.com/order/checkout.php?CART=1&CARD=1
Customers will have an all-in-one page: shopping cart, billing form, marketing tools and the credit card form. Plus a review page.
Checkout page
https://secure.2checkout.com/order/checkout.php
Customers will land on the billing page having the product options already added in their shopping cart. Select this option for a "quick checkout" scenario.

Purchase flows scenario variants

  • Include cart functionalities
  • Include payment details
  • Exclude review page

Shopping cart modifiers

  • Include compact shopping cart fields
  • Include express payments checkout

Note: The one page checkout without review and one page checkout with review flows have an identical behavior when the shopper uses PayPal for the payment.

By using these options, you can replicate the purchase flows available in the 2Checkout system.

  • Checkout with cart functionalities: shopping cart, billing info, review order, payment details
  • One page checkout without review: shopping cart, billing info, payment details, express payment checkout
  • One page checkout with review: shopping cart, billing info, payment details, review order, express payment checkout
  • Checkout page: cart content, billing info, review order, payment details

You can use all of the flows in conjunction with the Include compact shopping cart fields setting.

2Checkout allows you to compare the following purchase flow scenarios. The table below shows the scenarios that 2Checkout currently supports.

Purchase flows Options to replicate 2Checkout purchase flows Shopping cart modifiers
  Include cart functionalities Include payments details Exclude review page Include express payments checkout Include compact shopping cart fields
Checkout with cart functionalities YES NO NO
One page checkout without review YES YES YES
One page checkout with review YES YES NO
Checkout page NO NO NO

Example scenario 1

Let's say that you currently sell products/subscriptions using the One page checkout with review purchase flow, and you want to compare conversion rates with the One page checkout without review flow.

Requirements

Before kicking off an A/B test make sure that you create a comprehensive testing plan with clearly defined comparison scenarios and even clearer success metrics.

Setup

  1. Go to the A/B Testing page and click the Campaigns tab.
  2. Click Configure new campaign in the Purchase flows section. If you already have an existing campaign, click the Edit Campaign button.
  3. Fill in the details of the new campaign, such as the campaign name, maximum number of tests and the date when the campaign should end. Hit the Add campaign button to create an empty campaign. If you already have an existing campaign, proceed to the next step.
  4. For our example scenario, enable the Include cart functionalities and Include payments details options to define the One page checkout with reviewpurchase flow. This will act as the baseline control sample. Set 50% of the traffic to be redirected to this scenario - this means that 50% of all visitors that reach checkout will use the One page checkout with review flow.
  5. Click Add Scenario.
  6. Next, let's create the second scenario. Enable the Include cart functionalities, Include payments details and Exclude review page options to define the One page checkout without review purchase flow. This will act as our comparison version. Set the remaining 50% of traffic to be redirected to this scenario - this means that the remaining 50% of all visitors that reach checkout will use the One page checkout without review flow.
  7. Click Add Scenario.
  8. Click Save campaign.
  9. Return to the A/B testing dashboard and find your campaign in the list.
  10. Click Start Campaign to direct half of your shoppers to one scenario and half to the other.
  11. Calculate the A/B testing statistical confidence to know when you can stop the A/B testing campaign. When you have gathered enough relevant data you can easily decide on the winning scenario.

Note: Keep in mind that the example above is only a demonstrative one. You'll need to configure your own A/B tests based on your own individual testing needs.

Example scenario 2

Let's say that you currently sell products/subscriptions using the One page checkout without review purchase flow, and you want to compare conversion rates using the compact shopping cart fields and express payments checkout.

Setup

  1. Go to the A/B Testing page and click the Campaigns tab.
  2. Click Configure new campaign in the Purchase flows section. If you already have an existing campaign, click the Edit Campaign button.
  3. Fill in the details of the new campaign, such as the campaign name, maximum number of tests and the date when the campaign should end. Hit the Add campaign button to create an empty campaign. If you already have an existing campaign, proceed to the next step.
  4. For our example scenario, enable the Include cart functionalitiesInclude payments details and Exclude review page options to define the One page checkout without review purchase flow. This will act as the baseline control sample. Set 34% of the traffic to be redirected to this scenario - this means that 34% of all visitors that reach checkout will use the One page checkout without review flow.
  5. Click Add Scenario.
  6. Let's create the second scenario now. Enable the Include cart functionalities, Include payments detailsExclude review page and Include compact shopping cart fields options to define the One page checkout without review purchase flow with compact shopping cart fields. Set 33% of the remaining traffic to be redirected to this scenario - this means that another 33% of all visitors that reach checkout will use this flow.
  7. Click Add Scenario.
  8. Now for the third scenario. Enable the Include cart functionalities, Include payments detailsExclude review page and Include express payments checkout options to define the One page checkout without review purchase flow with express payments checkout. Set the remaining 33% of the remaining traffic to be redirected to this scenario.
  9. Click Add Scenario.
  10. Click Save campaign.
  11. Return to the A/B testing dashboard and find your campaign in the list.
  12. Click Start Campaign to start splitting your visitors between scenarios.

Use PayPal

Overview

Place an order using catalog products defined in your Control Panel, and collect the payment using PayPal.

Currency support

Check with Avangate support for a list of currencies available for PayPal. 

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.

Order

Required (Object)

 

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

To place an order with PayPal rather than PayPal Express, use PAYPAL as the type of the PaymentDetails object and send the shopper email and a return URL as part of the PaymentMethod object. See code sample. 

Workflow

  1. Create the order object. Use PAYPAL as the type of the PaymentDetails object and send the shopper email and a return URL as part of the PaymentMethod object. Place the order.
  2. Once you place the order, Avangate logs it into the system. At this point in time, the status of the order is PENDING. Avangate responds with the Order information object.
  3. Redirect shoppers to the RedirectURL from the Order information object you receive as response from Avangate.
  4. Once shoppers log into their PayPal account and complete the transaction, they're redirected to the ReturnURL you set in the order object. Avangate also authorizes the order and updates the status to AUTHRECEIVED. 

Response

Parameters Type/Description

Order information

Object

  Object containing order information.

Request example

<?php

require ('PATH_TO_AUTH');

$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->FirstName = 'FirstName';
$Order->BillingDetails->LastName = 'LastName';
$Order->BillingDetails->CountryCode = 'us';
$Order->BillingDetails->State = 'California';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'customer@email.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;

$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'PAYPAL';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '91.220.121.21';
$Order->PaymentDetails->PaymentMethod->ReturnURL = 'http://yoururl.com';
$Order->PaymentDetails->PaymentMethod->Email= 'email@avangate.com';
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

try {
    $newOrder = $client->placeOrder($sessionID, $Order);
}
catch (SoapFault $e) {
    echo "newOrder: " . $e->getMessage();
    exit;
}

var_dump("newOrder", $newOrder);

European Economic Area (EEA) Countries

Overview

This is a list of countries that are part of the European Economic Area (EEA). 

List of European Economic Area (EEA) Countries

Non-cross border Cross border

Austria

Bulgaria

Belgium

Croatia

Czech Republic

Cyprus

Denmark

Estonia

Finland

Hungary

France

Iceland

Germany

Latvia

Greece

Liechtenstein

Ireland

Lithuania

Italy

Malta

Luxembourg

Slovakia

Netherlands

Slovenia

Norway

 

Poland

 

Portugal

 

Romania

 

Spain

 

Sweden

 

Switzerland

 

United Kingdom  

 

Place orders with dynamic product information

Overview

Use this object to create new orders and collect payments from shoppers using products with dynamic information. 

Purchase types available are: PRODUCT, TAX, SHIPPING and COUPON. The surcharge defined in the pricing option is used for calculating the order renewal price, when applicable.

Supported payment methods

  1. Credit/Debit cards: Visa, Visaelectron, MasterCard, Maestro, Amex, Discover, Dankort, Cartebleue, JCB. 2Checkout supports local Brazilian cards.
  2. PayPal 
  3. Free orders (no payment information required).
  4. 2Pay.js

How to test?

Place test orders with dynamic product information by following the instructions from this article.

Requirements

Product code must be sent as null. The order currency must match with the payment currency, otherwise, an error is thrown. The isDynamic parameter of the Items object must be true.

Limitations

Placing an order with both catalog and dynamic product information is not possible. Recurring options can be set only for purchase type PRODUCT and TAX.

Parameters

Parameters Type/Description
Currency Optional (string)
  The currency ISO code for the payment - ISO 4217. Example: “usd.”
Country Optional (string)
  Shopper country. ISO 3166 two-letter code. Example: “us.”
Language Optional (string)
  ISO 639-1 two-letter code. Language used for the purchase process. Example: “en.”
ExternalReference Optional (string)
  Set external reference identifiers for orders. Enables you to replicate the functionality of the REF parameter included into Buy Links. Maximum 100 characters. If there is a need for longer references, you can apply an md5 hash for any string value, resulting in a 32 characters string. You can verify the hash after the order notification, on the client side.
Source Optional (string)
 

The link source for the sales. Enables you to replicate the functionality of the SRC (separate link identifier) parameter when included into Buy Links. Use the SRC parameter to track sale sources.

 

Maximum length 255 characters.

CustomerReference Optional (Int)
  System-generated 2Checkout customer reference. Aggregate subscriptions under the same Customer account by adding the AV_CUSTOMERID (case sensitive) parameter to buy links. The 2Checkout system generates default customer numerical (integer) IDs (AV_CUSTOMERID) automatically for all orders containing products that feature subscriptions.
MachineId Optional (string)
  Unique, system generated code for each unique customer, identifying returning customers.
Items Required (array of objects)

 

 

  Details below. 

 

 

Code Optional (string)

 

 

  Should be send as NULL. Any other value will be ignored.

 

 

Quantity Required (integer)

 

 

  Number of units
  isDynamic Required (bool)
    Send true for creating orders with dynamic order information.
  Tangible Required (bool)
    Send false for product delivered electronically.
  PurchaseType Required (string)
    Purchase types available are: PRODUCT, TAX, SHIPPING and COUPON.
  PriceOptions Optional (array of objects)
    Array of price option groups.
    Name Optional (string) 
      Name of the pricing option group. Mandatory for dynamic products.
    Options Optional (array of objects)
      Array of pricing options.
    Name Optional (string)
      Pricing option name. Mandatory for dynamic products.
    Value Optional (string)
      Pricing option code. Mandatory for catalog products. 
    Surcharge Optional (double)
      Surcharge of the pricing option. For renewal orders, the renewal price includes the pricing option surcharge from the initial order. Mandatory for dynamic products.
  RecurringOptions Optional (Object)
    Contains recurring options.
    CycleLength Optional (int)
      The length of the recurring billing cycle.
    CycleUnit Optional (string)
      Unit of measuring billing cycles (years, months).
    CycleAmount Optional (int)
      The amount to be billed on each renewal.
    ContractLength Optional (int)
      The contact length for which the recurring option will apply.
    ContractUnit Optional
      Unit of measuring contact length (years, months).

 

 

Price Required (Object)
    Details below.
    Amount Required (Int)
      Amount of the product.
    Type Optional (string)
      Send "CUSTOM" for dynamic pricing.
    Trial Optional (Object) – Can be NULL
      Details below. 
      Period Optional (integer)
        The length of the trial subscription lifetime in days.
      Price Optional (double)
        Total trial price in the payment currency before 2Checkout deducts any taxes, discounts, etc.
    AdditionalFields Optional (array of objects) – Can be NULL
      AdditionalFieldSet Optional (Object) – Can be NULL
        Details below
        Code Optional (string)
          Identifier code for the additional field.
        Text Optional (string)
          Text displayed in the additional field.
        Value Optional (string)
          Additional field value.
    SubscriptionStartDate Optional (string)
     

Specify the date time stamp when the subscription becomes active. Format 2016-07-02 22:22:22 (YYYY-MM-DD HH:mm:ss). Available for JSON-RPC and REST.

Send empty or NULL to activate subscriptions on the same date when customers purchase them.

You can exclude HH:mm:ss when sending the date and include only YYYY-MM-DD. In this case, 2Checkout uses 00:00:01. Default time zone GMT+02:00.

BillingDetails Required (Object)
  Details below. 
  Person Object
    Details below. 
    FirstName Required (string)
      Shopper name.
    LastName Required (string)
      Shopper surname.
    CountryCode Optional (string)
      Shopper country. ISO 3166 two-letter code.
    State String/Optional – Required for US, Canada, Brazil, Turkey, India and Romania
      The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two-letter code.
    City             Optional (string)
      Shopper city.
    Address1 Optional (string)
      Shopper address.
    Address2 Optional (string)
      Shopper address.
    Zip Optional (string)
      ZIP/ Postal code.
    Email Optional (string)
      Shopper email address.
    Phone Optional (string)
      Shopper phone number. Mandatory when you set Brazil as the Billing Country. Can be NULL.
    Company Optional (string)
      Company name. Can be null for end users. When present, you also need to provide the FiscalCode.
    TaxExemptionId  Optional (string)
      Tax Exempt Certification id used to deduct taxes for US orders
Example: 1b80eecc349v
  FiscalCode Optional (string) – Required for Brazil
   

• For companies, it needs to be the VAT ID. 2Checkout will validate the value provided and throw an error if the VAT ID is invalid/incorrect when calling setPaymentDetails. When present, you also need to provide the Company name.

• Mandatory when you set Brazil as the Billing Country. For Brazilian customers it represents the Fiscal Code (CPF/CNPJ).

Mandatory when you set India as the Billing Country, and purchase is made by a Company.

• Can be NULL for end users.

DeliveryDetails Required (Object)
  Details below. 
  Person Object
  Details below. 
    FirstName Required (string)
      Shopper name from the delivery details.
    LastName Required (string)
      Shopper surname from the delivery details.
    CountryCode Optional (string)
      Shopper country. ISO 3166 two-letter code from the delivery details.
    State String/Optional – Required for US, Canada, Brazil, Turkey, India and Romania
      The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two-letter code.
    City Optional (string)
      Shopper city from the delivery details.
    Address1 Optional (string)
      Shopper address from the delivery details.
    Address2 Optional (string)
      Shopper address from the delivery details.
    Zip Optional (string)
      ZIP/ Postal code from the delivery details.
    Email Optional (string)
      Shopper email address from the delivery details.
    Phone Optional (string)
      Shopper phone number from the delivery details. Mandatory when you set Brazil as the Billing Country. Can be NULL.
    Company Optional (string)
      Company name from the delivery details. Can be null for end users. When present, you also need to provide the FiscalCode.
PaymentDetails Required (Object)
  Adapt this object to the desired payment method.
  Type Required (string)
   

The payment method:

  • CC (credit/debit card - including local Brazilian cards).
  • ENCRYPTED_PAYMENT_DATA (client-side encryption)
  • PAYPAL
  • PAYPAL_EXPRESS
  • CCNOPCI(credit/debit card for non-PCI certified merchants).
  • TEST (for test orders).
  • PREVIOUS_ORDER(place new orders using the reference of a previous order).
  • EXISTING_PAYMENT_DATA  (use a card one of your customers already used to purchase from your account).
  • WIRE – the placeOrder response includes Wire payment details.
  • CHECK – the placeOrder response includes Check payment details.
  • WE_CHAT_PAY (for WeChat payments).
  • IDEAL (for iDEAL payments).
  • PURCHASEORDER - use for orders with POs.
  • FREE – for 0 value orders for which you’re not requiring customers to provide payment details.
  • EES_TOKEN_PAYMENT (2Pay.js)

 

  Currency Required (string)
    The currency ISO code for the payment - ISO 4217. Example: “usd.”
  RecurringEnabled Optional (boolean)
   

true – shopper checks the auto renewal checkbox and 2Checkout charges subscription renewals using a recurring billing process.

false – shopper doesn’t check the auto renewal checkbox.

  PaymentMethod Optional (object)
   

Object structure and parameters differ according to payment method selected and API method (placing orders (POST) vs. retrieving order data (GET)).

 

NULL for 0 value orders for which you’re not requiring customers to enter payment details.

      CardPayment Optional (object)
        Details below. 
        CardNumber Required (string)
          The credit/debit card number.
        CardType Required (string)
          visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb, hipercard, elo
        ExpirationYear Required (string)
          The year in which the card expires.
        ExpirationMonth Required (string)
          The month in which the card expires.
        HolderName Required (string)
          Card holder name.
        Vendor3DSReturnURL Required (string)
          URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.
        Vendor3DSCancelURL Required (string)
          URL address to which customers are redirected if the 3DS details were not validated or the order could not be authorized.
        CCID Optional (string)
          Credit Card Identification - an extra ID printed on the card, usually a 3-4 digit number, the CVC2/CVV2.
        HolderNameTime Optional (float)
         

The interval of time in seconds in which shoppers enter their name in the HolderName field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

        CardNumberTime Optional (float)
         

The interval of time in seconds in which shopper enter their card number in the CardNumber field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

        InstallmentsNumber  Optional (Int)
          Number of installments. Available only when customers un Brazil pay with Visa or MasterCard using Brazilian Real as the order currency. Use 1 or exclude the parameter for full payments. 
      PayPalExpress Optional (object)
        Details below. 
        Email Optional (string)
          Email address customers use for their PayPal account.
        ReturnURL Optional (string)
          The PayPal Express Checkout redirect URL returned by calling the getPayPalExpressCheckoutRedirectURL method. The return URL is the page on your website to which PayPal redirects your buyer's browser after the buyer logs in to PayPal and approves the payment. Typically, this is a secure page (https://...) on your site.
        CancelURL Optional (string)
          The cancel URL is the page on your website to which PayPal redirects your buyer's browser if the buyer does not approve the payment. Typically, this is the secure page (https://...) on your site from which you redirected the buyer to PayPal.
      PreviousOrder Optional (Object)
        Details below. 
        RefNo Optional (string)
         

Order reference a previous purchase that reached the Approved/Complete status. You can use order for which customers paid with credit/debit cards or with PayPal. The status of order should be AUTHRECEIVED or COMPLETE.

 

Check the validity of references with the isValidOrderReference method.

 

The 2Checkout system blocks you from using references for fraudulent or potentially fraudulent orders.

      PurchaseOrderPaymentDetails Optional (Object)
        Details below. 
        InternalPONumber Optional (string)
          Identifier that business customers use internally in their organization to track and manage Purchase Orders (PO). Can be NULL.
        AutoApprove Optional (boolean)
         

TRUE - requires activation of the PO AutoApprove package (If the package is inactive 2Checkout returns an error). Please contact 2Checkout. When AutoApprove is TRUE, 2Checkout no longer requires that business customers upload a PO document. As such, PO orders are automatically approved for your account, without a PO doc. 2Checkout sets the PURCHASE_PENDING status for auto-approved PO orders.

FALSE - Default. Send this if the PO AUtoApprove package is not available for your account. 2Checkout uses the same flow as cart purchases with Purchase Orders for business customers placing orders with POs via API. This means that customers receive the same emails as if they made the purchase using the cart and need to update the PO document, which is reviewed by 2Checkout and that you need to approve. 2Checkout sets the AVAITING_UPLOAD status for POs andUnfinished for their orders.

 

Can be NULL.

      WE_CHAT_PAY Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
      IDEAL Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
        BankCode Required (string)
          String contains the SWIFT code of the bank, the plus sign "+", and the first 3 characters from the bank name. E.q.: in the case of Rabobank, code parameter is "RABONL2U+RAB".
      EXISTING_PAYMENT_DATA Optional (Object)
        By using EXISTING_PAYMENT_DATA you no longer require shoppers to enter any payment details.
        TransientToken Optional (string)
          Returned as a part of the process of retrieving customer information by SSOToken.
  CustomerIP Optional (string)
    Shopper IP.
Promotions Optional (Array of strings)
  Array of promotion codes.
LocalTime Optional (string)
 

Local shopper time in the following format: Y-m-d H:i:s.

This parameter can impact the fraud score of an order when it's missing, NULL or incorrectly formatted.

Unassign a PricingOption Group

Overview

Use the unassignPricingConfigurationOptionGroup method to remove a PricingOptionGroup from a PricingConfiguration.

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.

pricingConfigurationCode

Required (string)

 

Unique, system-generated pricing configuration identifier.  

priceOptionsGroupAssigned

Required (Object)

 

Details below.

PriceOptionsGroupAssigned

Object

Code

Required (string)

 

PricingOption Group identifier.

Required

Required (Object)

 

True or false depending on whether the pricing options group is required during the purchase process or not.

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$pricingConfigurationCode = 'YOUR_PRICING_CONFIG_CODE';
$priceOptionsGroupAssigned = new stdClass();
$priceOptionsGroupAssigned->Code = 'STORAGE';
$priceOptionsGroupAssigned->Required = false;

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'unassignPricingConfigurationOptionGroup',
'params' => array($sessionID, $pricingConfigurationCode, $priceOptionsGroupAssigned)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

?>

Upgrade subscription

Overview

Use the setSubscriptionUpgrade method to upgrade a subscription. 

Requirements

You can only upgrade subscriptions with automatic renewal enabled.

   The upgrade will not work if the subscription has a refund request that was not yet processed.

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.

SubscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

ProductCode

Required (string)

 

Unique identifier of the target product for the subscription upgrade process. You control the product code and can set it up in the Control Panel.

Options

Optional (string)

 

Pricing options of the target product for the subscription upgrade process.

 

String - ';' separated list of 'OptionValue' returned by getProductUpgradeOptions function.

If the pricing options groups is "scale" (interval), the Options parameter should be sent like this: [option group unique code] + "=" + value

e.g. Users=7

CustomPrice

Optional (string)

 

The price you want to charge customers for the upgrade. The currency used by default is the same as in the previous payment customers made.

Response

Parameters Type/Description

Boolean

true or false depending on whether or not the operation succeeded.

Request


<?php
$host   = "https://api.avangate.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
    'location' => $host . "/soap/4.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));

function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}
$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
$now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);
try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}
catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage();
    exit;
}
$subscriptionReference = 'BE14FDCF37';
$ProductCode = 'my_subscription_123';
$Options = 'emailsupport;oneuser1';//case sensitive; include only price options codes (exclude spaces)
$customPrice = 1;
try {
    $upgradedSubscriptions = $client->setSubscriptionUpgrade($sessionID, $subscriptionReference, $ProductCode, $Options, $customPrice);
}
catch (SoapFault $e) {
    echo "upgradedSubscriptions: " . $e->getMessage();
    exit;
}
var_dump("upgradedSubscriptions", $upgradedSubscriptions);

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