Skip to main content

Renewal status

Overview

Use the getRenewalDetails method to retrieve information regarding subscription renewals based on 2Checkout 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.

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)

 

Unique, system-generated subscription identifier.

Response

Parameters Type/Description

recurringEnabled

Boolean

 

TRUE= automatic renewal (recurring billing) is enabled for the subscription.

FALSE= automatic renewal (recurring billing) is not enabled for the subscription.

manualRenewalLink

String

 

The manual renewal link customers can use to renew their subscription.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

try {
    $renewalDetails = $client->getRenewalDetails($sessionID, $subscriptionReference);
}
catch (SoapFault $e) {
    echo "renewalDetails: " . $e->getMessage();
    exit;
}
var_dump("renewalDetails", $renewalDetails);

Use Credit cards

Overview

Place an order with dynamic product information, and collect the payment using card-based payment methods.

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.

 

Requirements 

For credit card orders placed using API 5.0 or newer versions, you need to pass through additional parameters that support the 3D Secure flow. 3D Secure works by redirecting customers to pages provided by their banks, where they need to enter additional security tokens or password to trigger the completion of the charge. By using 3D Secure, you get additional protection from liability for fraudulent card payments, with customers having to go through an extra layer of authentication.

Send the following parameters as part of the PaymentMethod object:

Parameters Description
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.

Response 

Parameters Type/Description

Order information

Object

  Object containing order information.

Request

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->Currency = "USD";
$Order->Language = "EN";
$Order->Country = "US";
$Order->CustomerIP = '91.220.121.21';//"10.10.13.37";
$Order->Source = "sourceAPI.net";
$Order->LocalTime = date('Y-m-d H:i:s');
$Order->CustomerReference = 421820775;
$Order->Items = array();


/**
* 1st Product
*/
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = null;
$Order->Items[0]->Quantity = 2;
$Order->Items[0]->PurchaseType = 'PRODUCT';
$Order->Items[0]->Tangible = false; // physical
$Order->Items[0]->IsDynamic = true;

$Order->Items[0]->Price = new stdClass();
$Order->Items[0]->Price->Amount = 100;
$Order->Items[0]->Price->Type = 'CUSTOM';

$Order->Items[0]->Name = 'Dynamic Product 1 '. date("Y-m-d H:i:s");
$Order->Items[0]->Description = 'Description Produs OTF';

$Order->Items[0]->PriceOptions = [];
$priceOption = new stdClass();
$priceOption->Name = 'Name';
$priceOption->Value = 'Value';
$priceOption->Surcharge = 10;
$Order->Items[0]->PriceOptions[] = $priceOption;

$priceOption1 = new stdClass();
$priceOption1->Name = 'Name';
$priceOption1->Value = 'Value123';
$priceOption1->Surcharge = 11;
$Order->Items[0]->PriceOptions[] = $priceOption1;

$priceOption2 = new stdClass();
$priceOption2->Name = 'Name1';
$priceOption2->Value = 'Value1';
$priceOption2->Surcharge = 12;
$Order->Items[0]->PriceOptions[] = $priceOption2;

$Order->Items[0]->RecurringOptions = new stdClass();
$Order->Items[0]->RecurringOptions->CycleLength = 1;
$Order->Items[0]->RecurringOptions->CycleUnit = 'MONTH';
$Order->Items[0]->RecurringOptions->CycleAmount = 1234;
$Order->Items[0]->RecurringOptions->ContractLength = 3;
$Order->Items[0]->RecurringOptions->ContractUnit = 'YEaR';

//$Order->Items[0]->SubscriptionStartDate = '2017-10-22 12:34:56'; set a custom start date for the subscription

/**
* 3rd Product - SHIPPING
*/
$Order->Items[2] = new stdClass();
$Order->Items[2]->Name = 'Shipping Item '. date("Y-m-d H:i:s");
$Order->Items[2]->PurchaseType = 'SHIPPING';
$Order->Items[2]->Quantity = 1;
$Order->Items[2]->Price = new stdClass();
$Order->Items[2]->Price->Amount = 123;
$Order->Items[2]->IsDynamic = true;

/**
* 4th Product - TAX
*/
$Order->Items[3] = new stdClass();
$Order->Items[3]->Name = 'Tax Item '. date("Y-m-d H:i:s");
$Order->Items[3]->PurchaseType = 'TAX';
$Order->Items[3]->Quantity = 1;
$Order->Items[3]->Price = new stdClass();
$Order->Items[3]->Price->Amount = 456;
$Order->Items[3]->IsDynamic = true;
$Order->Items[3]->RecurringOptions = new stdClass();
$Order->Items[3]->RecurringOptions->CycleLength = 1;
$Order->Items[3]->RecurringOptions->CycleUnit = 'MONTH';
$Order->Items[3]->RecurringOptions->CycleAmount = 10.2;
$Order->Items[3]->RecurringOptions->ContractLength = 3;
$Order->Items[3]->RecurringOptions->ContractUnit = 'YEaR';

/**
* 5th Product - COUPON
*/
$Order->Items[4] = new stdClass();
$Order->Items[4]->Name = 'Coupon Item '. date("Y-m-d H:i:s");
$Order->Items[4]->PurchaseType = 'COUPON';
$Order->Items[4]->Quantity = 1;
$Order->Items[4]->Price = new stdClass();
$Order->Items[4]->Price->Amount = 234;
$Order->Items[4]->IsDynamic = true;

/**/
$additionalField1 = new stdClass();
$additionalField1->Code = "additional_field_order_1";
$additionalField1->Text = "REST";
$additionalField1->Value = "1";

$additionalField2 = new stdClass();
$additionalField2->Code = "additional_field_order_2";
$additionalField2->Text = "REST";
$additionalField2->Value = "a";

$additionalField3 = new stdClass();
$additionalField3->Code = "additional_field_order_3";
$additionalField3->Text = "REST";
$additionalField3->Value = "a";

$Order->AdditionalFields = array();
$Order->AdditionalFields[0] = $additionalField1;
$Order->AdditionalFields[1] = $additionalField2;
$Order->AdditionalFields[2] = $additionalField3;

$additionalField1 = new stdClass();
$additionalField1->Code = "REST";
$additionalField1->Text = "REST";
$additionalField1->Value = "REST";



$Order->MachineId = 'machineIdTestDan';
$Order->Discount = null;
$Order->ExternalReference = null;

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->Address1 = 'API BILL';
$Order->BillingDetails->Address2 = 'API BILL2';
$Order->BillingDetails->City = 'London';
$Order->BillingDetails->State = 'Greater London';
$Order->BillingDetails->CountryCode = 'UK';
$Order->BillingDetails->Phone = 12345;
$Order->BillingDetails->Email = 'shopper@2checkout.com';//"mail463@aPpLe.com";//
$Order->BillingDetails->FirstName = 'First Name Bil';
$Order->BillingDetails->LastName = 'Last Name Bil';
$Order->BillingDetails->Company = 'Api Company';
$Order->BillingDetails->Zip = '12345';
$Order->BillingDetails->FiscalCode = 13205628845;

/**/
$Order->DeliveryDetails = new stdClass();
$Order->DeliveryDetails->Address1 = 'Api Del';
$Order->DeliveryDetails->Address2 = 'Api Del2';
$Order->DeliveryDetails->City = 'Api City Del';
$Order->DeliveryDetails->State = 'Paris';
$Order->DeliveryDetails->CountryCode = 'US';
$Order->DeliveryDetails->Phone = '12345';
$Order->DeliveryDetails->Email = 'deli@email.com';
$Order->DeliveryDetails->FirstName = 'Api First Name Del';
$Order->DeliveryDetails->LastName = 'Api Last Name Del';
$Order->DeliveryDetails->Zip = 12345;
/**/

$Order->PaymentDetails = new stdClass();
$Order->PaymentDetails->Type = "CC";

$Order->PaymentDetails->Currency = "USD";
$Order->PaymentDetails->CustomerIP = '91.220.121.21';//"10.10.13.37";

$Order->PaymentDetails->PaymentMethod = new stdClass();


/**/
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";//4222222222222 //4111111111111111 //4984123412341234 - Installments
$Order->PaymentDetails->PaymentMethod->CardType = "VISA";/**/

/**/
$Order->PaymentDetails->PaymentMethod->ExpirationYear = "2020";
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = "12";
$Order->PaymentDetails->PaymentMethod->CCID = "123";
$Order->PaymentDetails->PaymentMethod->HolderName = "John Doe";
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumberTime = 83.21; // can be null - high value in seconds is a red flag for fraud attempts.
$Order->PaymentDetails->PaymentMethod->HolderNameTime = 13.35; // can be null - high value in seconds is a red flag for fraud attempts.
$Order->PaymentDetails->PaymentMethod->Vendor3DSReturnURL = "http://www.success.ro"; 
$Order->PaymentDetails->PaymentMethod->Vendor3DSCancelURL = "http://www.error.ro"; 

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

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

var_dump($order);

Retrieve configuration by name

Overview

Use the getPricingConfigurationByName method to extract information on a specific pricing configuration you set for a product.

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.

productCode

Required (string)

 

The editable code that you control at product-level, not the unique, system-generated product ID.

pricingConfigurationName

Required (string)

 

The name of the pricing configuration.

schemaType

Required (string)

 

  • FLAT (without Base Price)
  • DYNAMIC (with Base Price)

priceType

Optional (string)

 

Possible values: NET or GROSS

Response

Parameters Type/Description

PricingConfiguration

Object

Request

<?php

require ('PATH_TO_AUTH');

$productCode = 'subscr1';
$pricingConfigurationName = 'EU prices';
$schemaType = 'DYNAMIC';// FLAT or DYNAMIC
$priceType = 'NET'; // or GROSS

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getPricingConfigurationByName',
'params' => array($sessionID, $productCode, $pricingConfigurationName, $schemaType, $priceType)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

?>

Retrieve configuration by code

Overview

Use the getPricingConfigurationByCode method to extract information on a specific pricing configuration you set for a product.

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.

productCode

Required (string)

 

The editable code that you control at product-level, not the unique, system-generated product ID.

pricingConfigurationCode

Required (string)

 

The code of the pricing configuration.

 

Response

Parameters Type/Description

PricingConfiguration

Object

Request

<?php

require ('PATH_TO_AUTH');

$productCode = 'YOUR_PRODUCT_CODE';
$pricingConfigurationCode = 'YOUR_PRICING_CONFIGURATION_CODE';

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

?>

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.

 

Collect payment data for free orders

Overview

Configure 2Checkout to collect payment details for full discount/zero value orders, and charge shoppers for all subsequent renewals at full price. Take advantage of this feature to incentivize potential customers to start using your software/service by providing it free of charge initially.

Drive shoppers to use your service by offering it completely free of charge for the first month, or the first billing cycle, whatever it might be. Set zero value prices via On-the-fly-pricing when configuring the purchase flow for your products. Alternatively, you can define 100% discounts for specific products/services, applying solely to the first transaction. Note: Discounts need to be equal to the value of the product or larger.

SaaS businesses can benefit from the increased appeal added to services through promotions, but this feature can also contribute to increasing your customer base and revenue even if you're selling subscription-based software.

Free or paid trials with payment details are also a viable alternative to offering customers the chance to try out your software/service free of charge or for minimal costs. To kick-off the trial, users need to first provide valid payment information, ensuring that you'll be able to charge for usage once the trial period expires, provided that no cancelations occur.

Availability

All 2Checkout accounts.

If you are using ConvertPlus and InLine shopping carts, keep in mind that zero value orders are obtained using regular (product level) promotions, generating 100% discount. For the moment, order level promotions are not supported on ConvertPlus and InLine carts.

Requirements

For the billing information to be requested from the shopper the following criteria must be met:

  • The service/product needs to have a renewal interval defined.
  • The purchase flow needs to be Checkout with cart functionalities. When a different purchase flow is selected, the system automatically defaults to Checkout with cart functionalities (the same as for the trial process).
  • Supported payment methods: VISA/MasterCard/Eurocard, American Express, JCB, PayPal, Discover/Novus, Direct Debit, Dankort.

Usage

After we've activated the Collect payment data for free orders feature for your account, follow the steps below to enable it.

  1. Log into your Merchant Control Panel.
  2. Go to Setup -> Ordering options
  3. Enable the Collect Payment details for full discount or orders with zero value option.

Collect payment details for full discount or orders with zero value.PNG

3. Save the settings.

Note: If unchecked, shoppers that already benefited from the discount will not be affected. New customers attempting to purchase a service/product for which you offer a full discount but do not require payment information, will not need to enter their billing details to complete the order.

When your shoppers provide payment details they're informed that no charges will be made and that a transaction will be done only for authorization purposes. Once the initial subscription period, which you offer for free, runs out, the 2Checkout system will use the payment data collected in order to charge customers the sum you set when configuring the pricing scheme of your service/product. Similarly, charges will continue to be made with every new renewal.

Why use Full discount/zero value orders with payment details and not Free trials with payment details?

It's really a matter of preference since the two options are somewhat similar in nature. However, there are a number of key differences that make Full discount/zero value orders with payment details a superior strategy for onboarding new shoppers compared to Free trials with payment details.

Full discount orders with payment details

Free trials with payment details

Customers actually acquire services/products.

Users only start a trial.

Shoppers feel more comfortable providing you with their billing information since they're purchasing offerings while taking advantage of a full discount for the initial subscription interval.

Since they're accessing a free trial, potential customers might be reluctant to hand over their sensitive payment details.

Discounts impact all sales of the product they're associated with, regardless of the buy links that your shoppers will use.

Free trials with payment details need to be configured for each buy link for the products you want your shoppers to try. Buy links are different from free trial links, and different pricing strategies might apply.

 

Renew a subscription

Overview

Renew a subscription in the 2Checkout system on-demand, controlling the number of days, price, and currency of the extension. Use the renewSubscription method to renew 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)

 

Unique, system-generated subscription identifier.

 

2Checkout charges customers using the payment data attached to subscriptions. In the case of credit/debit cards, if customers update their payment information in myAccount or if you update these details on behalf of your subscribers, the 2Checkout system uses the latest card info provided to charge subscription renewals.

Days

Required  (int)

 

The number of days the 2Checkout system extends the lifetime of the subscription.

Price

Required (double)

 

The price that 2Checkout charges the customer for the renewal. The type of price, Gross or Net, is decided by the product setting in the Merchant Control Panel.

Currency

Required (string)

 

The currency associated with the renewal price - ISO 4217 code.

Response

Boolean

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

Request

<?php


function callRPC($Request, $hostUrl, $Debug = true) {
    $curl = curl_init($hostUrl);
    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'));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);


    if ($Debug) {
        $RequestString;
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        $ResponseString;
    }

    if (!empty($ResponseString)) {
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}

$host = 'https://api.2Checkout.com/rpc/3.0/';

$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

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

$i = 1; // counter for api calls

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

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

var_dump($sessionID);

var_dump($sessionID);
$subscriptionReference = 'AF168DD240';
$Days = 4;
$Price = 50;
$Currency = 'eur';

$jsonRpcRequest = array (
'method' => 'renewSubscription',
'params' => array($sessionID, $subscriptionReference, $Days, $Price, $Currency),
'id' => $i++,
'jsonrpc' => '2.0');

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

Retrieve information on promotions

Overview

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

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.

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

Request

<?php

require ('PATH_TO_AUTH');

$searchOptions = new stdClass();
$searchOptions->Types = array ('REGULAR');
$searchOptions->Channel = 'ECOMMERCE';
$searchOptions->ProductCode = 'Product_Code_1';
$searchOptions->Enabled = TRUE;
$searchOptions->Limit = 99;
$searchOptions->Page = 1;

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'searchPromotions',
'params' => array($sessionID, $searchOptions)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
?>

Retrieve assigned price option groups

Overview

Use the getAssignedPriceOptionGroups method to extract information about the price option groups you assigned to one of your products.

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.

ProductCode

Required (string)

 

The editable code that you control at product-level, not the unique, system-generated product ID.

Response

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');
 
$productCode = 'YOUR_PRODUCT_CODE';
 
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getAssignedPriceOptionGroups',
'params' => array($sessionID, $productCode)
);

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

Upgrade a subscription

Overview

Use the setSubscriptionUpgrade method to upgrade a subscription.

Requirements

You can only upgrade subscriptions with automatic renewal enabled.

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

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$productCode = 'YOUR_PRODUCT_CODE';
$options = 'YOUR_PRICE_CODES'; //case sensitive; include only price options codes (exclude spaces)
$customPrice = 1;

$jsonRpcRequest = array (
'method' => 'setSubscriptionUpgrade',
'params' => array($sessionID, $subscriptionReference, $productCode, $options, $customPrice),
'id' => $i++,
'jsonrpc' => '2.0');

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

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