Skip to main content

Control myAccount UI display language

Overview

Use the setLanguageForMyAccount method before calling the getSingleSignOn or getSingleSignOnByCustomer methods to control the display language customers see when logged into their myAccount.

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.

isoLang

Required (string)

 

ISO 639-1 two-letter code.

Response

Parameters Type/Description

Boolean

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

Request

<?php

require ('PATH_TO_AUTH');

$isoLang = 'YOUR_LANGUAGE_ISO_CODE';

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

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

Retrieve a product’s cross-sell campaigns

Overview

Use the getProductCrossSellCampaigns method to extract information on all cross-sell campaigns triggered by the same primary product.

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.

ProductCode

Required (string)

 

The code of the primary product triggering cross-sell campaign that you can define for each of your offerings.

Request

<?php

require ('PATH_TO_AUTH');

$ProductCode = 'subscr1';

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

var_dump(" \n Cross-sell campaigns: \n", callRPC($jsonRpcRequest, $host));

?>

Response

Parameters Type/Description

CrossSellCampaign

Object

Validate order references as payment

Overview

Use the isValidOrderReference method to validate that you can use a previously placed order reference to pay for a new order.

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.

RefNo

Required (string)

 

Order reference number of older order, which is already approved/paid. The status of said order returned by getOrderStatus method should be AUTHRECEIVED or COMPLETE.

Response

Boolean

true or false depending on whether you can use the order reference to for the payment process of new orders or not.

Request


<?php
echo "<pre>";
$host   = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/3.0/?wsdl", array(
    'location' => $host . "/order/3.0/soap",
    "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 = "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 = "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;
}
$orderReference = '45452071';
try {
    $validOrderRef = $client->isValidOrderReference($sessionID, $orderReference);
}
catch (SoapFault $e) {
    echo "validOrderRef: " . $e->getMessage();
    exit;
}
var_dump("validOrderRef", $validOrderRef);

?>

 

Use Purchase order flow

Overview 

Place an order using catalog products, and collect the payment using the Purchase Order flow.

Requirements

Purchase order flow needs to be enabled on your account. Contact 2Checkout for activation.

You have to send the InternalPONumber and AutoApprove parameters to place a Purchase Order. The company name is mandatory when placing an order via PO.

Currency support 

Check with 2Checkout support for a list of currencies available for Purchase Order. 

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.

 

Workflow 

  1. The customer is placing the order using Purchase Order as the ordering flow, filling in the internal PO number as mandatory information.
  2. You are able to set the order to auto-approve as soon as the purchase order is submitted. Otherwise, you have to approve/cancel it manually from Control Panel.
  3. After the order is placed, the order confirmation e-mail is sent, including the payment instructions and payment terms agreed.
  4. The order is finalized as soon as the payment is confirmed.
  5. If payment is not received according to the terms, the order is canceled.

Response 

Parameters Type/Description

Order information

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]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'Test Cosmin API';
$Order->BillingDetails->LastName = 'Cosmin API';
$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 = 'cosmin.deftu@2checkout.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = 'ABC Company';
$Order->DeliveryDetails = NULL;


$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'PURCHASEORDER';
$Order->PaymentDetails->Currency = 'USD';
$Order->PaymentDetails->PaymentMethod = new stdClass();
$Order->PaymentDetails->PaymentMethod->AutoApprove = true;
$Order->PaymentDetails->PaymentMethod->InternalPONumber = 84864848;


$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

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

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

Retrieve the next renewal price for a subscription

Overview

Use the getNextRenewalPrice method to retrieve information on the costs customers incur on the next renewal for a subscription, per the recurring billing configuration.

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.

Currency

Required (string)

 

ISO 4217 code.

Response

Next renewal price

Object

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

 

Retrieve the next renewal price for a subscription

Overview

Use the getNextRenewalPrice method to retrieve information on the costs customers incur on the next renewal for a subscription, per the recurring billing configuration.

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.

Currency

Required (string)

 

ISO 4217 code.

Response

Next renewal price

Object

Request


<?php
$host   = "https://api.2checkout.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.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;
}
$subscriptionReference = '30E47F8699';
$Currency = 'eur';
try {
    $renewalDetails = $client->getNextRenewalPrice($sessionID, $subscriptionReference, $Currency);
}
catch (SoapFault $e) {
    echo "renewalDetails: " . $e->getMessage();
    exit;
}
var_dump("renewalDetails", $renewalDetails);

 

Single Sign On by subscription reference

Overview

Use the getSingleSignOn method to redirect and login shoppers automatically from your user portal into their Avangate myAccount based on subscription information. This method connects third-party user hubs with the Avangate myAccount, and allows your shoppers to seamlessly sign in to manage their information and perform tasks such as updating/changing credit card details.

Parameters

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

email

Optional (string)

 

End user email address belonging to the customers associated with the subscription.

validityTime

Optional (int)

 

The time, in seconds, before the single sign-on URL expires. By default, the URL expires after 10 seconds. (optional)

accessPage

Optional (string)

 

The specific myAccount page you want the user to be redirected to.

Possible values: view_order, my_license, change_card, my_products, user_data, order_lookup, faq - default: index page

view_order - based on the SubscriptionReference, redirects shoppers to the myAccount page for the initial order that served to purchase the subscription. The Avangate system will match the subscription to the order automatically, displaying its associated myAccount view_order page.

my_license - redirect shoppers to the subscription's page of myAccount based on the SubscriptionReference you provide.

change_card - redirects shoppers to the subscription page of myAccount and opens up the change credit card pop-up window designed to update the payment details associated with a subscription.

my_products - redirects shoppers to the myAccount page designed to list all products purchased from Avangate.

https://store.YourCustomDomain.com/m...t/my_products/?

user_data - redirects shoppers to the Personal Information page in myAccount

https://store.YourCustomDomain.com/m...unt/user_data/?

order_lookup - redirects shoppers to the Order Lookup page of myAccount.

https://store.YourCustomDomain.com/m.../order_lookup/?

faq - redirects shoppers to the Support page of myAccount

https://store.YourCustomDomain.com/support/

default: index page - redirects shoppers to myAccount homepage

https://store.YourCustomDomain.com/myaccount/?

validationIp

Optional (string)

 

The IP address of the shopper, necessary for security purposes. Can be an empty string or a valid IP, or null.

Response

Parameter Type/Description

Single sign-on URL

String

 

The string generated is the complete single sign-on URL pointing to Avangate myAccount, containing the unique URL. Shoppers using it log into their Avangate myAccount automatically.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$email = 'EMAIL@EXAMPLE.COM';
$validityTime = 50;
$accessPage = 'my_license';
$validationIp = null;

$jsonRpcRequest = array (
'method' => 'getSingleSignOn',
'params' => array($sessionID, $subscriptionReference, $email, $validityTime, $accessPage, $validationIp),
'id' => $i++,
'jsonrpc' => '2.0');

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

Retrieve assigned additional fields

Overview

Use the getAssignedAdditionalFields method to extract information about the additional fields assigned to a specific 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.

Response

Parameters Type/Description

AdditionalField

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$productCode = 'YOUR_PRODUCT_CODE';

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


Retrieve price based on specific options

Overview

Use getPrice to extract cost information for a product/subscription plan, based on a specific list of options. 

Parameters

Parameters Type/Description

Item

Required (Object)

 

Code

Required (string)

 

 

Unique product identifier your control. Max length 256 characters.

 

Quantity

Required (String)

 

 

Number of units.

 

PriceOptions

Optional (Array)

 

 

Array of price option codes.

Billing details

Required (Object)

 

Details below. Can be null. 

 

FirstName

Required (string)

 

 

Shopper name.

 

LastName

Required (string)

 

 

Shopper surname.

 

CountryCode

Optional (string)

 

 

Shopper country. ISO 3166 two-letter code. Include CountryCode in your request in combination with a null value for Currency, to receive the price in the default currency of the country you set. 

 

State

Optional (string) – Required for US, Brazil and Romania

 

 

The state in the shopper's country. Mandatory when you set the Billing Country to US, Brazil 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.

 

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

• Can be NULL for end users.

Currency

Required (string)

 

The currency ISO code for the payment - ISO 4217. Example: “usd.”

CouponCode

Optional (string)

 

Promotion coupon/voucher.

PayType

Optional (string)

 

The payment method:

  • CC (credit/debit card - including local Brazilian cards).
  • ENCRYPTED_PAYMENT_DATA (client-side encryption)
  • PAYPAL
  • PAYPAL_EXPRESS
  • 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.
  • PURCHASEORDER - use for orders with POs.
  • FREE – for 0 value orders for which you’re not requiring customers to provide payment details.

Response

Parameters Type/Description
ItemPrice Object

UnitNetPrice

Optional (double)

 

The value per product unit, excluding sales tax/VAT expressed in the payment currency.

UnitGrossPrice

Optional (double)

 

Total value per product unit, including sales tax/VAT expressed in the payment currency. UnitGrossPricedoes not reflect any discounts.

UnitVAT

Optional (double)

 

Sales tax/VAT per product unit expressed in the payment currency.

UnitDiscount

Optional (double)

 

Value of the discount per product unit expressed in the payment currency.

UnitNetDiscountedPrice

Optional (double)

 

The value per product unit, expressed in the payment currency, excluding sales tax/VAT, from which 2Checkout deducts the unit discount.

UnitGrossDiscountedPrice

Optional (double)

 

Total costs shoppers incur per product unit, expressed in the payment currency. This value includes sales tax/VAT, 2Checkout and affiliate commissions, but 2Checkout deducts the value of any discounts.

UnitAffiliateCommission

Optional (double)

 

Value of the affiliate commission per product unit calculated expressed in the payment currency.

 

2Checkout deducts discounts from the costs incurred by shoppers before calculating affiliate commissions.

 

2Checkout does not take into account shipping costs when calculating affiliate commissions.

 

NULL when 2Checkout does not apply an affiliate commission.

AffiliateCommission Optional (double)
  Value of the affiliate commission for the order calculated from the NetDiscountedPrice expressed in the payment currency. Or NULL. 2Checkout does not take into account shipping costs when calculating affiliate commissions.
Currency Optional (string)
  The currency ISO code for the payment - ISO 4217. Example: “usd.” Use null as value when you include CountryCode in your request, to receive the price in the default currency of the country you set. 
Discount Optional (double)
  Value of the discounts for an order expressed in the payment currency.
GrossDiscountedPrice Optional (double)
  Total costs shoppers incurexpressed in the payment currencyThis value includes sales tax/VAT, 2Checkout and affiliate commissions, but 2Checkout deducts the value of any discounts.
GrossPrice Optional (double)
  Total order value, including sales tax/VAT expressed in the payment currency. GrossPrice does not reflect any discounts.
NetDiscountedPrice Optional (double)
  The NetPrice order value excluding sales tax/VAT, from which 2Checkout deducts discounts. NetDiscountedPriceis expressed in the payment currency.
NetPrice Optional (double)
  Order value excluding sales tax/VAT expressed in the payment currency.
VAT Optional (double)
  Value of sales tax/VAT expressed in the payment currency.

 

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 = 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);

$CartItem = new stdClass();
 
$CartItem->Code = 'my_subscription_1';
$CartItem->Quantity = 1; 
$CartItem->PriceOptions = array();

/* $CartItem->Trial = new stdClass(); 
$CartItem->Trial->Period = 8;
$CartItem->Trial->Price = 999; */

$BillingDetails = NULL;
$Currency = 'USD';
$CouponCode = '123';
$PayType = 'CC';

try {
    $itemPrice = $client->getPrice($sessionID, $CartItem, $BillingDetails, $Currency, $CouponCode, $PayType);
}
catch (SoapFault $e) {
    echo "itemPrice: " . $e->getMessage();
    exit;
}
var_dump("itemPrice", $itemPrice);

 

Manual renewal link and recurring billing status

Overview

Use the getRenewalDetails method to retrieve information regarding subscription renewals based on 2Checkout Subscription References:

  • Information on automatic renewal (recurring billing) status (enabled or disabled).
  • The link that customers access to renew the subscription through 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

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

 

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