Skip to main content

How to efficiently scale your affiliate program

Is your company at the point where How to Efficiently Scale Your Affiliate Program sales from your affiliate program are flat? Are you simply not satisfied with the growth rate? Or are you just starting the affiliate program and are wondering how to scale?

If you can identify with one of the above, watch our webinar and hear Cristian Miculi, 2Checkout's Senior Manager of Affiliate Services speak about how to efficiently scale your program and build it in such a manner so it'll be easy for you to add new opportunities on top of that.

Watch this webinar and you will find out:

  • When to expand your program
  • What to look at when choosing an in-house platform / 3rd party network to grow
  • What are recommended ways to grow depending on your affiliate revenue
  • How others did this successfully
Join Our Webinar

 

Add product

Overview

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

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

Product

Required (object)

 

Use this object to configure your subscription plans/products.

 

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

Mandatory parameters

 

ProductName
ProductCode
PricingConfigurations

Response

bool(true)

Sample request

<?php
 
require ('PATH_TO_AUTH'); // authentication call
 
$Product = new stdClass();
$Product->AvangateId = null;
$Product->ProductCode = 'API_Imported_Product_1';
$Product->ProductType = 'REGULAR';
$Product->ProductName = 'API_Subscription Imported New';
$Product->ProductVersion = '1.0';
 
$Product->GiftOption = false;
$Product->ShortDescription = 'Placeat cumque necessitatibus est minus praesentium ut non quibusdam. Molestias provident tempore eligendi mollitia quia.';
$Product->LongDescription = 'Corrupti inventore vitae nesciunt ab. Nemo cum non maiores. Non repudiandae est iste voluptatibus.';
$Product->SystemRequirements = null;
$Product->ProductCategory = null;
$Product->Platforms = array();
$Product->Platforms[0] = new stdClass();
$Product->Platforms[0]->PlatformName = null;
$Product->Platforms[0]->Category = null;
$Product->Platforms[1] = new stdClass();
$Product->Platforms[1]->PlatformName = null;
$Product->Platforms[1]->Category = null;
$Product->ProductImages = array();
$Product->ProductImages[0] = new stdClass();
$Product->ProductImages[0]->URL = null;
$Product->ProductImages[0]->Default = false;
$Product->ProductImages[1] = new stdClass();
$Product->ProductImages[1]->URL = null;
$Product->ProductImages[1]->Default = true;
$Product->TrialUrl = null;
$Product->TrialDescription = null;
$Product->Enabled = True;
 
//Product additional fields
 
/* $Product->AdditionalFields = array();
$Product->AdditionalFields[0] = new stdClass();
$Product->AdditionalFields[0]->Label = 'i44wak1dzp';
$Product->AdditionalFields[0]->Code = 'ITYAK0OEWJ';
$Product->AdditionalFields[0]->Enabled = false;
$Product->AdditionalFields[0]->Required = false;
$Product->AdditionalFields[0]->URLParameter = 'id1ktigl6d';
$Product->AdditionalFields[1] = new stdClass();
$Product->AdditionalFields[1]->Label = 'aig699lmo1';
$Product->AdditionalFields[1]->Code = 'V28TP07PQN';
$Product->AdditionalFields[1]->Enabled = false;
$Product->AdditionalFields[1]->Required = true;
$Product->AdditionalFields[1]->URLParameter = '8to9p6y54j'; */
 
//Product localization
 
/* $Product->Translations = array();
$Product->Translations[0] = new stdClass();
$Product->Translations[0]->Name = 'zsg7wtg4e5';
$Product->Translations[0]->Description = 'Voluptate iure ut quam omnis impedit. Deserunt facere id dolores doloribus quis. Minima nostrum ut possimus incidunt vel est sint. Odit tempora omnis iste nesciunt commodi accusantium placeat.';
$Product->Translations[0]->Language = 'pt';
$Product->Translations[0]->LongDescription = 'Pariatur molestiae sit dignissimos modi. Aut modi libero numquam repudiandae. Doloribus explicabo delectus fugiat amet. Excepturi quo consequatur sint adipisci.';
$Product->Translations[0]->SystemRequirements = 'c16tvyg88c';
$Product->Translations[0]->TrialUrl = 'UNCAUGHT TYPE: anyURI';
$Product->Translations[0]->TrialDescription = 'Voluptas rem sit ut voluptas molestias quidem ut. Maiores facilis tempora voluptates. Consequuntur illum recusandae hic magni iste.';
$Product->Translations[1] = new stdClass();
$Product->Translations[1]->Name = 'cv2sx15aby';
$Product->Translations[1]->Description = 'Ut distinctio asperiores et a placeat voluptatem et. Et eveniet temporibus aut vel. Nemo occaecati praesentium dolor fugiat rerum assumenda expedita.';
$Product->Translations[1]->Language = 'fr';
$Product->Translations[1]->LongDescription = 'Et ut nostrum molestiae voluptates soluta. Molestiae cum in ut qui. Voluptatem voluptates vero odit quia corporis. In impedit eligendi sed expedita nihil temporibus nobis.';
$Product->Translations[1]->SystemRequirements = 'cfv2amk25j';
$Product->Translations[1]->TrialUrl = 'UNCAUGHT TYPE: anyURI';
$Product->Translations[1]->TrialDescription = 'Voluptatem ut possimus consequatur iste. Recusandae id quia sed quibusdam aut debitis. Cupiditate harum architecto quod quia.'; */
 
 
$Product->PricingConfigurations = array();
$Product->PricingConfigurations[0] = new stdClass();
$Product->PricingConfigurations[0]->Default = false;
$Product->PricingConfigurations[0]->Code = null;
$Product->PricingConfigurations[0]->Name = 'API Pricing Configuration Test';
$Product->PricingConfigurations[0]->BillingCountries = array();
$Product->PricingConfigurations[0]->PricingSchema = 'DYNAMIC';
$Product->PricingConfigurations[0]->PriceType = 'NET';
$Product->PricingConfigurations[0]->DefaultCurrency = 'USD';
$Product->PricingConfigurations[0]->Prices = new stdClass();
$Product->PricingConfigurations[0]->Prices->Regular = array();
$Product->PricingConfigurations[0]->Prices->Regular[0] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Regular[0]->Amount = 100;
$Product->PricingConfigurations[0]->Prices->Regular[0]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Regular[0]->MinQuantity = 1;
$Product->PricingConfigurations[0]->Prices->Regular[0]->MaxQuantity = 10;
$Product->PricingConfigurations[0]->Prices->Regular[0]->OptionCodes = array();
$Product->PricingConfigurations[0]->Prices->Regular[1] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Regular[1]->Amount = 200;
$Product->PricingConfigurations[0]->Prices->Regular[1]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Regular[1]->MinQuantity = 11;
$Product->PricingConfigurations[0]->Prices->Regular[1]->MaxQuantity = 100;
$Product->PricingConfigurations[0]->Prices->Regular[1]->OptionCodes = array();
$Product->PricingConfigurations[0]->Prices->Renewal = array();
$Product->PricingConfigurations[0]->Prices->Renewal[0] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Renewal[0]->Amount = 50;
$Product->PricingConfigurations[0]->Prices->Renewal[0]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Renewal[0]->MinQuantity = 1;
$Product->PricingConfigurations[0]->Prices->Renewal[0]->MaxQuantity = 10;
$Product->PricingConfigurations[0]->Prices->Renewal[0]->OptionCodes = array();
$Product->PricingConfigurations[0]->Prices->Renewal[1] = new stdClass();
$Product->PricingConfigurations[0]->Prices->Renewal[1]->Amount = 60;
$Product->PricingConfigurations[0]->Prices->Renewal[1]->Currency = 'USD';
$Product->PricingConfigurations[0]->Prices->Renewal[1]->MinQuantity = 11;
$Product->PricingConfigurations[0]->Prices->Renewal[1]->MaxQuantity = 100;
$Product->PricingConfigurations[0]->Prices->Renewal[1]->OptionCodes = array();
$Product->PricingConfigurations[0]->PriceOptions = array();
 
/* $Product->BundleProducts = array();
$Product->BundleProducts[0] = new stdClass();
$Product->BundleProducts[0]->ProductCode = '540Q45PQBN';
$Product->BundleProducts[0]->ProductId = 48439;
$Product->BundleProducts[1] = new stdClass();
$Product->BundleProducts[1]->ProductCode = 'PA3JDB5SZ2';
$Product->BundleProducts[1]->ProductId = 46439;
 */
$Product->Fulfillment = 'NO_DELIVERY';
$Product->Prices = array();
 
$Product->GeneratesSubscription = True;
$Product->SubscriptionInformation = new stdClass();
$Product->SubscriptionInformation->DeprecatedProducts = array();
$Product->SubscriptionInformation->BundleRenewalManagement = null;
$Product->SubscriptionInformation->BillingCycle = 1;
$Product->SubscriptionInformation->BillingCycleUnits = 'M';
$Product->SubscriptionInformation->IsOneTimeFee = false;
 
$Product->SubscriptionInformation->ContractPeriod = new stdClass();
$Product->SubscriptionInformation->ContractPeriod->Period = -1;
$Product->SubscriptionInformation->ContractPeriod->PeriodUnits = 'days';
$Product->SubscriptionInformation->ContractPeriod->IsUnlimited = TRUE;
$Product->SubscriptionInformation->ContractPeriod->Action = 'RESTART';
$Product->SubscriptionInformation->ContractPeriod->EmailsDuringContract = 'altenwerth.elise@gmail.com';
 
//$Product->SubscriptionInformation->UsageBilling = 77;
 
$Product->SubscriptionInformation->GracePeriod = new stdClass();
$Product->SubscriptionInformation->GracePeriod->Type = 'GLOBAL';
$Product->SubscriptionInformation->GracePeriod->Period = 14;
$Product->SubscriptionInformation->GracePeriod->PeriodUnits = 'D';
$Product->SubscriptionInformation->GracePeriod->IsUnlimited = false;
 
$Product->SubscriptionInformation->RenewalEmails = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Type = 'CUSTOM';
$Product->SubscriptionInformation->RenewalEmails->Settings = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before30Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before15Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before7Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->Before1Day = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->OnExpirationDate = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->After5Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->ManualRenewal->After15Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal = new stdClass();
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before30Days = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before15Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before7Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->Before1Day = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->OnExpirationDate = true;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->After5Days = false;
$Product->SubscriptionInformation->RenewalEmails->Settings->AutomaticRenewal->After15Days = true;
 
$Product->FulfillmentInformation = new stdClass();
$Product->FulfillmentInformation->IsStartAfterFulfillment = false;
$Product->FulfillmentInformation->IsElectronicCode = false;
$Product->FulfillmentInformation->IsDownloadLink = false;
$Product->FulfillmentInformation->IsBackupMedia = false;
$Product->FulfillmentInformation->IsDownloadInsuranceService = false;
$Product->FulfillmentInformation->IsInstantDeliveryThankYouPage = false;
$Product->FulfillmentInformation->IsDisplayInPartnersCPanel = false;
 
 

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addProduct',
'params' => array($sessionID, $Product)
);
 
$addedProduct = callRPC($jsonRpcRequest, $host);
var_dump ($addedProduct);

Configure order fulfillment/delivery

Overview

Enable customers to start using your services immediately after they finalize the purchase process and use electronic content delivery to distribute binary keys, activation codes, product files, etc. to your shoppers as soon as 2Checkout receives payment confirmation. 

Supported business models

If your business relies on electronic software distribution (ESD), Software as a Service (SaaS), Information Services, Service Contracts, and even on physical delivery, you can easily leverage the scalability of 2Checkout's platform built to support the software and SaaS markets.

Availability

All 2Checkout accounts. Contact 2Checkout directly to:

  • Access extra storage space for your product files. 
  • Inquire about physical delivery. 

Configure product delivery options

Define product delivery options along with general information, pricing schemes, renewal details and all additional info needed when configuring a product.

  1. Go to Setup -> Products.
  2. Click Add product.
  3. Enter the item's general information and click Add product when you're done.
  4. Enter the pricing, upgrade and renewal details on the next page.
  5. Three Product fulfillment categories are available:
    • Fulfillment made through 2Checkout delivery - You can opt to have 2Checkout deal with all aspects related to the delivery of your products, and serve binary keys, activation codes, product files and Download Insurance Service (DIS) to customers. Here you can also choose to manually confirm the delivery of the order. If you enable the Requires delivery confirmation option, 2Checkout puts the order processing on hold until you confirm delivery .
    • Fulfillment made by you - You are responsible with providing your customers with the necessary resources to start using purchased products. It's critical that you also send confirmation of order fulfillment to 2Checkout to finalize orders.
    • Fulfillment made immediately after payment confirmation - Use this if don't distribute products / keys to customers, but instead offer access to online services or subscriptions-based applications, to name a couple of examples.

Fulfillment made through 2Checkout delivery

2Checkout handles the delivery of your products, but you control the content served to customers as well as the distribution method, and can even add extra services to increase the value of your offerings.

Selecting Fulfillment made through 2Checkout delivery brings up the Content & methods box, enabling you to configure the delivery process of a product. The Fulfillment area tailors itself dynamically to the options you select under Product fulfillment type and Content & methods. Options available:

  • Delivery content
  • Delivery methods
  • Extra delivery services

Delivery content

When 2Checkout handles the delivery of products on your behalf, it's mandatory that you check at least one of the boxes for the two Delivery content options:

Electronic code / key / binary file 

Makes it mandatory to also select a list of codes from the drop down menu under the Activation codes settings area that is brought up. If none exists, you need to create a new code list and associate it with the product.

Product file download links

2Checkout can deliver your digital product files to shoppers immediately after they successfully placed an order.

In the product Fulfillment page, set the files you want to deliver from the Assign product files list under the Product file area. You need to upload and set up product files, if you haven't done so already. Click here to learn how to manage product files.

Assign multiple product files in case your delivery requires separate installation files for one product in the download page. For example, if your product has support for multiple operating systems: Windows, MAC OSX, etc., your shoppers can receive and download the product files for all supported versions. You can add multiple product files at once by checking all the files you want to assign from the list. The list contains all the product files uploaded by you that have a clean status, including the ones currently assign to your product. Keep in mind that when assigning a product file you have to check the extra delivery services involved: download link, download insurance service (DIS), and partner (channel manager).

Shoppers are able to download the product files from:

  • Thank you page - If you have checked the delivery method of Instant delivery (in the Thank you page). This delivery option is available for payment methods with instant payment confirmation like credit cards, PayPal, etc.
Note that HTML tags are not supported in the ConvertPlus and InLine Checkout flows when using additional fulfillment information in 'Thank you' page .  Plain text can be used instead.
  • myAccount - Your shoppers can download the product files by logging into their 2Checkout customer account. The product files are available on the product history page, after clicking on the "Download product" button.
  • Download page - The electronic delivery e-mail sent to your customers contains a "Download your product" button. By accessing it, customers are redirected to the download page where they can download all the product files belonging to the product ordered.

You can select both delivery options (product files / electronic code), in accordance with the distribution model of the product you're setting up. At least one of these options needs to be enabled for your offering to benefit from 2Checkout delivery. It's entirely up to you to offer the electronic code/key/binary file to your customers, a link to download the product file, or both.

Requirements

You can only assign clean files to your products. 2Checkout scans the files uploaded for malware, and only files in clean status can be delivered to shoppers. 

Delivery methods

By Email & in 2Checkout myAccount 

Default - cannot be disabled. Ensures that customers who acquire your products receive at least the electronic code / key / binary file or a link to download the product file, if not both, via email and in their myAccount, from 2Checkout. Consider customizing the email message sent to your customers using the Additional delivery information - by email field

Instant delivery (in the Thank you page) 

Have 2Checkout instantly deliver product files and keys in the Thank you page displayed once a purchase is finalized. 2Checkout displays the Thank you page to customers if the payment method they use supports instant confirmation (credit cards, debit cards, PayPal, etc.) and automatically approved by the system/anti-fraud team, otherwise the instant electronic delivery can be delayed or even canceled altogether. You cannot use Instant delivery together with the Requires delivery confirmation feature.

The delivery content, also available in Email and in 2Checkout myAccount, is included in the Thank you page that you customize.

Instant delivery works for authorized and approved purchases. If the transaction fails or if the 2Checkout system flags an order as potentially fraudulent, 2Checkout does not display the instant delivery content in the "Thank You Page". In such scenarios, the delivery takes place over email once the order is authorized and approved.

Regardless if you checked the Instant delivery option or not, you can personalize the Additional delivery information - "Thank you" page with details according to your preferences in the field which is found at the bottom of the page.

Extra delivery services

DIS (Download insurance service) is an optional service that you can charge extra for, providing you with an easy tool to increase Average Order Value (AOV) while also offering a richer set of shopping cart options to customers.

DIS (Download insurance service)

By enabling the DIS (Download insurance service), customers get the option to pay to extend the life span of the product file download link for a total of two (2) years, but also to download the item an unlimited number of times. Make sure to associate a downloadable file associated with the product in the Product file area.

Orders and payments are confirmed via email when this option is selected with 2Checkout also delivering product keys / codes and download links through email. Order deliveries are confirmed automatically causing 2Checkout to execute the money transfer from the customer.

Fulfillment made by you

Distribute binary keys, activation codes, and product files, as well as additional files yourself by selecting Fulfillment made by you. You're required to confirm  fulfillment of all orders before 2Checkout can move their status to Finished.

You can confirm delivery in two ways:

  1. Go to Orders & customers and Fulfillment confirmations to access a list of all incomplete orders that need fulfillment confirmation. Select he check box on the left hand side of an order you want to finalize and click Confirm fulfillment.
  2. Use Instant Delivery Notification (IDN). IDN helps you automate the order finalization process. Use scripts and rely on Instant Delivery Notification to facilitate automatic delivery confirmations from your system directly to 2Checkout servers..

2Checkout puts orders on hold until you confirm fulfillment, and finalizes them only after receiving confirmation from you or your system. Fulfillment made by you offers the possibility to have 2Checkout handle the distribution of products to customers on your behalf. 

The Additional information - "Thank you" page functionality enables you to serve a custom message to your customers along with the "thank you" for their purchase.

Please note that the responsibility of providing customers with electronic deliveries for your offerings rests solely with you, and not with 2Checkout. For products which you configured with Fulfillment made by you, order fulfillment confirmation is mandatory as 2Checkout keeps track of the product distribution process for all orders, with the system setting order status to Finished only after the fulfillment was made and confirmed manually or through IDN by you.

2Checkout confirms order and payments via email when you select this option but does not deliver product keys / codes and download links. Once you confirm order fulfillment, 2Checkout executes the money transfer from the customer.

Fulfillment made immediately after payment confirmation

Designed with SaaS in mind, this feature enables you to sell services, without delivering binary keys, activation codes, product file, or DIS to customers. 

Use Fulfillment made immediately after payment confirmation if your business model does not rely on electronic content delivery, and instead involves selling subscriptions or access to online services, etc.

Fulfillment made immediately after payment confirmation comes with the option to have 2Checkout handle the distribution of products to customers on your behalf. 

The Additional information - "Thank you" field allows you to customize the message for your shoppers as you wish.

For products that you configured with Fulfillment made immediately after payment confirmation, 2Checkout confirms orders automatically, with their status updated to Finished after payment goes through. 2Checkout does not keep track of deliveries when you use this option, and you need to provide customers with access/subscriptions to your service/platform or additional delivery options.

2Checkout confirms orders and payments via email but does not deliver product keys/codes and download links through email. Order fulfillment is confirmed automatically causing 2Checkout to execute the money transfer from the customer.

Enable delivery confirmation

If you want to manually approve or reject orders after the 2Checkout performs the risk assessment, you can do so after you enable the vendor delivery confirmation feature.

Availability

Before you can use this feature, get in contact with your Customer Success Manager and ask for the activation of this option on your 2Checkout account.

Requirements

Follow these steps to enable it.

  1. Log in to the 2Checkout Control Panel
  2. Go to the Account Settings page
  3. Click Manage user access
  4. Go to the View roles tab and click Edit on the role that you want to enable the delivery confirmation feature.
  5. Under the Orders & Reports roles section, check the Enable delivery confirmation approval checkbox and click Save role at the bottom of the page.

How do I confirm orders?

When a shopper places an order, you now have the option to either manually confirm or reject the order from the order's status page in the Control Panel. If you don't confirm or reject the order for 14 days, 2Checkout automatically reverses it.

We also notify you about the order requiring confirmation in the Control Panel dashboard on the Last orders tab. Shoppers see their order marked with a Pending status in myAccount until you confirm the delivery.

2Checkout also notifies them that the order is waiting for your approval through a message in the Order lookup section.

How to activate delivery confirmation IPN

You can configure 2Checkout to send an IPN when you confirm the delivery of an order by following the steps below.

  1. Log in to the 2Checkout Control Panel.
  2. Go to the Account Settings page.
  3. Click Edit sytem settings.
  4. Go to the IPN settings tab.
  5. Check the the order was approved for delivery option under Notification settings. 
  6. Click Save.

Retrieve subscription payment information

Overview

Use the getSubscriptionPaymentInformation method to retrieve information related to the payment made for a subscription.

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.
subscriptionReference Required (String)
  The reference of the subscription you want to retrieve payment information for.

Response

Parameters Type/Description

Type

String

 

Payment method type.

Currency

String

 

ISO code of the order currency.

PaymentMethod

Object

 

FirstDigits

String

 

 

First 4 digits of the card used on the order.

 

LastDigits

String

 

 

Last 4 digits of the card used on the order.

 

CardType

String

 

 

Type of card used on the order.

  ExpirationMonth String
    Card expiration month.
  ExpirationYear String
    Card expiration year.
  CardUpdated Boolean
    The card updated by our internal account updater.
  Authorize3DSUrl String
    URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.

Response sample

{
    "Type": "CC",
    "Currency": "USD",
    "PaymentMethod": {
        "FirstDigits": "4111",
        "LastDigits": "1111",
        "ExpirationMonth": null,
        "ExpirationYear": null,
        "CardUpdated": false,
        "Authorize3DSUrl": null,
        "CardType": "Visa"
    }
}

Request

<?php
require ('PATH_TO_AUTH');

$subscriptionReference = "YOUR_SUBSCRIPTION_REFERENCE";

try {
    $paymentInformation = $client->getSubscriptionPaymentInformation($sessionID, $subscriptionReference);
} catch (SoapFault $e) {
    echo  $e->getMessage();
}
var_dump($paymentInformation);

Search methods pagination

Overview

Starting with 2Checkout API 5.0, search methods are including the option of pagination. Pagination has been developed for decreasing the request loading time, while allowing you to better handle the returning responses.

How it works?

Pagination works on all the search methods existing on 2Checkout API 5.0. The default pagination behavior is to display page 1 with 10 results. The maximum number of items displayed on a single page is 200.

Parameters

To use pagination, include the Pagination object inside the search method call, using the parameters below:

Parameters Type/Description
Pagination Object
  Details below.
  Page Int
    Set the number of pages that should be returned.
  Limit Int
    Set a limit for the number of results that should be returned.

Response

The response of search methods that are including pagination will contain a new object, with the following parameters:

Parameters Type/Description
Pagination Object
  Details below
  Page Int
    Set the number of pages that should be returned.
  Limit Int
    Set a limit for the number of results that should be returned.
  Count Int
    Number of total results returned

Sample request

The below PHP sample includes a search method for subscriptions.

<?php

require('PATH_TO_AUTH');

$SubscriptionSearch = new stdClass();
$SubscriptionSearch->CustomerEmail  = 'email@avangate.com';
$SubscriptionSearch->DeliveredCode = null;
$SubscriptionSearch->AvangateCustomerReference = null;
$SubscriptionSearch->ExternalCustomerReference = null;
$SubscriptionSearch->Aggregate = false;
$SubscriptionSearch->SubscriptionEnabled = null; //true false null
$SubscriptionSearch->RecurringEnabled = null; // true - autorenewal, false - manual renewal, null = both(default)
$SubscriptionSearch->ProductCodes = null; //array('Product_Code1', 'Product_Code2');
$SubscriptionSearch->CountryCodes = null;//array ('au')
$SubscriptionSearch->PurchasedAfter = null;
$SubscriptionSearch->PurchasedBefore = null;
$SubscriptionSearch->ExpireAfter = null;
$SubscriptionSearch->ExpireBefore = null;
$SubscriptionSearch->LifetimeSubscription = null;
$SubscriptionSearch->Type = 'regular'; //'trial', 'regular', 'regularfromtrial'
$SubscriptionSearch->TestSubscription = null; // true, false, null = both(default)
$SubscriptionSearch->Pagination = new stdClass();
$SubscriptionSearch->Pagination->Page = 1; // set the number of pages for the response
$SubscriptionSearch->Pagination->Limit = 200; // set the limit for the values from the response

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

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


Subscription additional information fields

Overview

Use this object to create, update and retrieve additional information fields from your subscriptions.

Attributes

Parameters Type/Description

fieldName

String

 

The name of the additional information field. Used for identifying additional information fields.

fieldValue

String

 

The value of the additional information field.

 

Assign a subscription to another customer

Overview

Use the setSubscriptionCustomer method. Avangate moves subscription under the customer for which you provide the Avangate customer reference or the External customer reference during the subscription update process.

json_diagram.png

Requirements

To move a subscription from a source customer to a target customer:

  • Use Avangate customer references or External customer references belonging to the target customer. Avangate re-assigns the subscription to the target customer. 
  • Customer references must be valid and associated to the target customer entity under which you move the subscription.
  • If you provide both the Avangate customer reference and External customer reference they need to belong to the same target customer entity.

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.

AvangateCustomerReference

Required (int)

 

System-generated customer reference. Required unless you prefer to use ExternalCustomerReference.

ExternalCustomerReference

Optional (string)

 

External customer reference that you control. Optional when you use AvangateCustomerReference. If you include it, it needs to belong to the same customer as the AvangateCustomerReference.

Response

Boolean

true or false depending on whether the changes were successful or not.

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 = '30E47F8699';
$customerReference = 220531648;
try {
    $newCustomerInfo = $client->setSubscriptionCustomer($sessionID, $subscriptionReference, $customerReference);
}
catch (SoapFault $e) {
    echo "newCustomerInfo: " . $e->getMessage();
    exit;
}
var_dump("newCustomerInfo", $newCustomerInfo);

One click (1-click) subscription renewal

Overview

Avangate supports 1-click manual subscription renewals for returning customers who paid for their previous orders with Credit/Debit cards.

In this scenario, you can facilitate subscription renewals for subscribers who opted out of auto-renewal (recurring billing).

How does this work? 

  1. Identify returning customers. 
  2. Generate the manual renewal link.
  3. Create a tokenized manual subscription renewal link and serve it to the returning customer.
  4. Customers using the link land on a hosted shopping cart, then chose a credit card they previously used for purchases from your account/store and place the order.

Availability

Please contact Avangate to start using one-click (1-click) subscription renewals.

Requirements 

  • Make sure that the subscription is eligible:
    • Status needs to be Active or Past Due
    • Subscriptions cannot be evergreen​
  • The email address must match that of the initial order. If shoppers change the email they need to re-enter the payment details.

Flow comparison

  • Longer purchase funnel
  • Complex flow
  • Unused subscriber and payment on file info
  • High risk of churn
  • Shorter purchase funnel
  • Streamlined flow
  • Uses both customer and payment on file information
  • Lower risk of churn
  • Increase Customer Lifetime Value (CLTV) and recurring revenue

Detailed 1-click subscription renewal flow

Identify returning customers

You particularly need either the Avangate customer reference or the external customer reference you control.

Use customer information

getCustomerSubscriptions 

 

If customers log into your system and you’ve mapped unique identifiers into the Avangate platform you can easily extract their subscription information.

 

Use subscription information

searchSubscriptions 

 

You can also use subscription information to extract customer references, based on a set of filters. Validate the status of the subscription (needs to be Active or Past Due).

  • Customer email
  • Delivered codes/activation keys
  • Avangate customer reference
  • External customer reference
  • Subscription status
  • Recurring billing status
  • Product code
  • Customer country
  • Purchased date
  • Expiration/Renewal deadline
  • Subscription type

 

Create the manual renewal link

getRenewalDetails 

Retrieve information regarding subscription renewals based on Avangate Subscription References:

  • Information on the automatic renewal (recurring billing) status (enabled or disabled).
  • The link that customers access to renew the subscription though a manual payment.

 

Attach the payment token to the manual renewal link

getSingleSignOnInCart

 

Avangate attaches a unique token to links, designed to identify the returning shoppers and support the automatic extraction of payment data and billing information from the Avangate system.

 

Example



<?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 = "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          = date('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;
}
 
var_dump($sessionID);
$SubscriptionSearch = new stdClass();
$SubscriptionSearch->CustomerEmail  = null;
$SubscriptionSearch->DeliveredCode = '___TEST___CODE____123';
$SubscriptionSearch->AvangateCustomerReference = '123456789';
$SubscriptionSearch->ExternalCustomerReference = null;
$SubscriptionSearch->Aggregate = false;
$SubscriptionSearch->SubscriptionEnabled = null; //true false null
$SubscriptionSearch->RecurringEnabled = null; // true - autorenewal, false - manual renewal, null = both(default) 
$SubscriptionSearch->ProductCodes = null; //array('Product_Code1', 'Product_Code2');
$SubscriptionSearch->CountryCodes = null;//array ('au')
$SubscriptionSearch->PurchasedAfter = null;
$SubscriptionSearch->PurchasedBefore = null;
$SubscriptionSearch->ExpireAfter = null;
$SubscriptionSearch->ExpireBefore = null;
$SubscriptionSearch->RenewedAfter = null;
$SubscriptionSearch->RenewedBefore = null;
$SubscriptionSearch->NotificationAfter = null;
$SubscriptionSearch->NotificationBefore = null;
$SubscriptionSearch->LifetimeSubscription = null;
$SubscriptionSearch->Type = 'regular'; //'trial', 'regular', 'regularfromtrial'
$SubscriptionSearch->TestSubscription = null; // true, false, null = both(default) 
$SubscriptionSearch->Page = 1;
$SubscriptionSearch->Limit = 10;
try {
    $allsubscriptions = $client->searchSubscriptions($sessionID, $SubscriptionSearch);
}
catch (SoapFault $e) {
    echo "allsubscriptions: " . $e->getMessage();
    exit;
}
var_dump("allsubscriptions", $allsubscriptions);
$subscriptionReference = $allsubscriptions[0]->SubscriptionReference;
 
try {
    $manualrenewallink = $client->getRenewalDetails($sessionID, $subscriptionReference);
}
catch (SoapFault $e) {
    echo "manualrenewallink: " . $e->getMessage();
    exit;
}
var_dump("manualrenewallink", $manualrenewallink);

$IdCustomer = $allsubscriptions[0]->AvangateCustomerReference;
$CustomerType = 'AvangateCustomerReference';
$Url = $manualrenewallink->ManualRenewalLink;
$ValidityTime = 10;
$ValidationIp = null;
try {
    $ssoLINK = $client->getSingleSignOnInCart($sessionID, $IdCustomer, $CustomerType, $Url, $ValidityTime, $ValidationIp);
}
catch (SoapFault $e) {
    echo "ssoLINK: " . $e->getMessage();
    exit;
}
var_dump("ssoLINK", $ssoLINK);

 

Retrieve a specific proposal version

Overview

Use the getProposalVersion method via JSON-RPC API 6.0 to retrieve a specific proposal version.

Request Parameters

Parameters Type Required/Optional Description
proposalId String Required The proposal identifier.
proposalVersion Integer Required The proposal version.

Request Sample

<?php
declare(strict_types=1);

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.2checkout.com/rpc/6.0';
    public const ACTION = 'getProposalVersion';
    public const ADDITIONAL_OPTIONS = null;
    //array or JSON
    public const PAYLOAD = [
        "7ee02473-b60a-415b-90ae-87c6c443f684",
        3
    ];
}

class Client
{
    private const LOGIN_METHOD = 'login';
    private $calls = 1;
    private $sessionId;


    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $hash = hash_hmac('md5', $string, $key);

        return compact('merchantCode', 'date', 'hash');
    }


    public function login(string $url)
    {
        $payload = $this->generateAuth();
        $response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
        $this->sessionId = $response['result'];
    }


    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?array {
        if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
            $this->login($url);
        }
        if(is_string($payload)) {
            $payload = json_decode($payload, true);
        }
        if (!empty($this->sessionId)) {
            $payload = [$this->sessionId, $payload[0], $payload[1]];
        }
        $payload = array_filter($payload);

        $request = json_encode([
            'jsonrpc' => '2.0',
            'method' => $action,
            'params' => $payload,
            'id' => $this->calls++,
        ]);
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        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', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if(empty($response)) {
            die('Server unavailable');
        }
        echo $response . '</br>';
        return json_decode($response, true);;
    }
}
$client = new Client();
$result = $client->call();
var_dump($result);

Response

The getProposalVersion call via JSON-RPC API 6.0 returns the Proposal object.

Create a new customer

Overview

Use the createCustomer method to add the details of a customer entity into the 2Checkout 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. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

Customer

Object

Response

2CheckoutCustomerReference

Int

 

System-generated customer reference.

Request


<?php
$host   = "https://api.2checkout.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.2checkout.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.2checkout.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;
}
$newCustomer = new stdClass();
$newCustomer->2CheckoutCustomerReference = 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';
try {
    $newCustomerInfo = $client->createCustomer($sessionID, $newCustomer);
}
catch (SoapFault $e) {
    echo "newCustomerInfo: " . $e->getMessage();
    exit;
}
var_dump("newCustomerInfo", $newCustomerInfo);

 

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