Skip to main content

Disable recurring billing

Overview

Use the disableRecurringBilling method to disable recurring billing for a subscription. When you disable recurring billing, the subscription status doesn’t change. Users continue to use subscriptions with recurring billing disabled until they expire, and 2Checkout provides them with the option to renew their subscription through manual payments.

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.

ChurnReasons Array
 

Possible values for this field are:
CHURN_REASON_NOT_SATISFIED_PRODUCT

CHURN_REASON_ENABLED_BY_MISTAKE

CHURN_REASON_PREFER_MANUAL

CHURN_REASON_ALREADY_RENEWED

CHURN_REASON_DONT_NEED

CHURN_REASON_WANT_PAUSE

CHURN_REASON_COVID

CHURN_REASON_HIGH_PRICE

CHURN_REASON_NOT_SATISFIED_SUPPORT

CHURN_REASON_EXTRAORDINARY

CHURN_REASON_OTHER

ChurnReasonOther String
  This field should have a value only if the ChurnReasons has the CHURN_REASON_EXTRAORDINARY or CHURN_REASON_OTHER values

Response

Parameters Type/Description

Boolean

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

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

try {
    $disabledRecurringBilling = $client->disableRecurringBilling($sessionID, $subscriptionReferenceTest);
}
catch (SoapFault $e) {
    echo "disabledRecurringBilling: " . $e->getMessage();
    exit;
}
var_dump("disabledRecurringBilling", $disabledRecurringBilling);

SOAP code samples

Overview

  1. Working code samples for JSON-RPC and SOAP are available in PHP for each documented method, including the clients you need to make API calls. You need to replace the dummy Merchant Code and Secret Key with those available in your Merchant Control Panel.
  2. Working code samples for REST are available for each documented scenario and method. Check out the REST reference for examples. To access code samples, select any scenario and click on the "Working example" link. Working code samples:

 

  • cURL
  • Java
  • JavaScript
  • Node.js
  • Perl
  • Python
  • PHP
  • Ruby
  • Go
  • C#
  • Visual Basic
  • Groovy
  • Objective-C
  • Swift

 

Use Trustly

Overview

Place an order for catalog products defined in your Merchant Control Panel and collect the payment using Trustly via SOAP API 6.0.

Request parameters

Parameter name Type Required/Optional Description
sessionID String Required Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes.
Order Object Required

Object designed to collect all data necessary for an order, including billing, product/subscription plan, and payment details. To place an order with Trustly, use TRUSTLY as the type of the PaymentDetails object and provide a ReturnURL and a CancelURL as part of the PaymentMethod object. See code sample.

Request example

<?php

    require ('PATH_TO_AUTH');

    $Order = new stdClass();
    $Order->RefNo = NULL;
    $Order->Currency = 'EUR';
    $Order->Country = 'SE';
    $Order->Language = 'en';
    $Order->CustomerIP = '91.220.121.21';
    $Order->ExternalReference = NULL;
    $Order->Source = NULL;
    $Order->Affiliate = new stdClass();
    $Order->Affiliate->AffiliateCode = 'Partner123'
    $Order->Affiliate->AffiliateSource = 'MobilePlatform'
    $Order->CustomerReference = NULL;
    $Order->Items = array();
    $Order->Items[0] = new stdClass();
    $Order->Items[0]->Code = 'my_subscription_1';
    $Order->Items[0]->Quantity = 1;
    $Order->Items[0]->PriceOptions = NULL;
    $Order->Items[0]->SKU = NULL;
    $Order->Items[0]->Price = NULL;
    $Order->Items[0]->CrossSell = NULL;
    $Order->Items[0]->Trial = false;
    $Order->Items[0]->AdditionalFields = NULL;
    $Order->Items[0]->Promotion = NULL;
    $Order->Items[0]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.

    $Order->BillingDetails = new stdClass();
    $Order->BillingDetails->FirstName = 'John';
    $Order->BillingDetails->LastName = 'Doe';
    $Order->BillingDetails->CountryCode = 'SE';
    $Order->BillingDetails->State = 'Beijing';
    $Order->BillingDetails->City = 'Beijing';
    $Order->BillingDetails->Address1 = 'Address example';
    $Order->BillingDetails->Address2 = NULL;
    $Order->BillingDetails->Zip = '90210';
    $Order->BillingDetails->Email = 'cosmin.deftu@avangate.com';
    $Order->BillingDetails->Phone = NULL;
    $Order->BillingDetails->Company = NULL;
    $Order->DeliveryDetails = NULL;

    $Order->PaymentDetails = new stdClass ();
    $Order->PaymentDetails->Type = 'TRUSTLY';
    $Order->PaymentDetails->Currency = 'EUR';
    $Order->PaymentDetails->PaymentMethod = new stdClass ();
    $Order->PaymentDetails->CustomerIP = '91.220.121.21';
    $Order->PaymentDetails->PaymentMethod->ReturnURL = 'http://yourreturnurl.com';
    $Order->PaymentDetails->PaymentMethod->CancelURL= 'http://yourcancelurl.com';

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

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

    $trustlyredirect = $newOrder->PaymentDetails->PaymentMethod->Authorize->Href."/?avng8apitoken=".$newOrder->PaymentDetails->PaymentMethod->Authorize->Params->avng8apitoken;

    header('Location:' . $trustlyredirect);

Response parameters

Parameter name Type Description
Order Object Object containing order information.

 

 

 

Copy payment info

Overview

Copy card-on-file data available in the 2Checkout system from a source subscription to an imported target subscription. 2Checkout uses the existing payment information to charge customers as a part of the recurring billing (renewal) process.

Use the copyPaymentInfo method.

Requirements

The imported target subscription and the source subscription must belong to the same customer. The 2Checkout system checks to make sure that the 2Checkout Customer Reference (internal identifier) coincides for the customer accounts associated with the target and source subscriptions.

Availability

Please contact 2Checkout directly if you wish to take advantage of this feature.

How does this method work?

  1. Customer A purchases Subscription A using a VISA credit card and you import Subscription B for the same customer with no data or with an AMEX card.
  2. When 2Checkout renews Subscription A, it charges Customer A using the VISA, while using the AMEX (if the data was provided) for Subscription B charges.
  3. When you copy the payment data from Subscription A to Subscription B, the 2Checkout system uses the VISA credit card to renew both subscriptions according to their respective recurring billing cycles. 2Checkout charges customers during the recurring billing process for the imported target subscription using the payment method they used to purchase the source 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.

TargetSubscriptionReference

Required (string)

 

The 2Checkout Subscription Reference of the imported target subscription, to which 2Checkout copies the payment on file data associated with the source subscription.

SubscriptionReference

Required (string)

 

The 2Checkout Subscription Reference of the source subscription whose attached payment on file data 2Checkout copies to the target subscription.

Response

Boolean

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

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;
}
$TargetSubscription = '559338F092';
$SourceSubscription = '9F4154733C';
try {
    $payInfo = $client->copyPaymentInfo($sessionID, $TargetSubscription, $SourceSubscription);
}
catch (SoapFault $e) {
    echo "payInfo: " . $e->getMessage();
    exit;
}
var_dump("payInfo", $payInfo);

 

Disable recurring billing

Overview

Use the disableRecurringBilling method to disable recurring billing for a subscription. When you disable recurring billing, the subscription status doesn’t change. Users continue to use subscriptions with recurring billing disabled until they expire, and Avangate provides them with the option to renew their subscription through manual payments.

Parameters

Parameters Type/Description

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.

Response

Parameters Type/Description

Boolean

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

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

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

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

Retrieve account balance

Overview

Use getPendingPayout to retrieve a detailed estimation of the amount that 2Checkout owes you, based on the sales from your current payout period.

The amounts returned by this API method are approximations, and may not represent the final amount that 2Checkout will pay you at the end of the billing period.

Parameters

Parameters Type/Description
inputParameters

Object (Optional)

Details below

  Currency String (Optional)
   

Use this parameter to show the balance only for a single order currency. Example: 'USD'.

If not sent, or sent as NULL, 2Checkout sends the balance for all order currencies.

  TotalCurrency String (Optional)
   

Use this parameter to show the total account balance in the preferred currency. Example: 'EUR'.

If not sent, or sent as NULL, 2Checkout sends the total balance in the default account currency.

Request

<?php

require('PATH_TO_AUTH');

$inputParameters = new StdClass();
$inputParameters->Currency = 'USD';
$inputParameters->TotalCurrency = 'EUR';

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

echo "<pre>";

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

Response

Pending Payout Object

Parameters   Type/Description
Currencies

Array of objects

Details below

  CurrencyObject

Object

Details below

    Currency

String

      Order currency.
    OrdersTotal

Object

Total order amounts, divided per order source.

                        estore Float
      eStore order amounts from the current payout cycle.
                       affiliates Float
      Amounts from your affiliates orders, during the current payout cycle.
                       partner Float
      Amounts from your partner sales, during the current payout cycle.
                        total Float
      Total sales amount made in the order currency from this object, during the current payout cycle.
  RetainedToDisputesBalance Float
      Amounts retained to your dispute balance reports, in the object order currency.
  ReleasedFromDisputesBalance Float
      Amounts released from your dispute balance reports, in the object order currency.
  RetainedToRollingReserveBalance Float
      Amounts retained to your rolling reserve, in the object order currency.
  ReleasedFromRollingReserveBalance Float
      Amounts retained to your rolling reserve, in the object order currency
  ChargebackFees Float
      Chargeback fees retained in the object order currency.
  ProcessingFees Float
      Processing fees retained by 2Checkout in the object order currency.
  AffiliatesCommission Float
      Affiliate commissions paid by 2Checkout in the object order currency.
  TaxCollected Float
      Tax collected by 2Checkout in the object order currency.
  EstimatedTotalRevenue Float
      The estimated total revenue for the object order currency.
Total    

Object

Total account balance amount

  Currency  

String

      Currency used for expressing the account balance.. If not sent in the API call, 2Checkout uses the account default currency.
  OrdersTotal

 

Object

Total order amounts, divided per order source.

    estore Float
      Amounts from total eStore orders during the currency payout cycle.
                      affiliates Float
      Amounts from total affiliates orders during the currency payout cycle.
                      partner Float
      Amounts from total partner orders during the currency payout cycle.
                      total Float
      Total sales amount during the currency payout cycle.
  RetainedToDisputesBalance Float
      Total amounts retained to your dispute balance during the current payout cycle.
  RetainedFromDisputesBalance Float
      Total amounts released from your dispute balance during the current payout cycle.
  RetainedToRollingReserveBalance Float
      Total amounts retained to your rolling reserve during the current payout cycle.
  RetainedFromRollingReserveBalance Float
      Total amounts released from your rolling reserve during the current payout cycle.
  ChargebackFees Float
      Total chargeback fees retained from your account during the currency payout cycle.
  ProcessingFees Float
      Total processing fees retained by 2Checkout during the current payout cycle.
  AffiliatesCommission Float
      Total affiliates commissions paid by 2Checkout during the current payout cycle.
  TaxCollected Float
      Total tax amount collected by 2Checkout during the current payout cycle.
  EstimatedTotalRevenue Float
      Total estimated revenue for the current payout cycle.

 

Set partner invoice (card payment)

Overview

Use this method to mark the partner invoice that the partner will pay. setProforma works in conjunction with setPaymentDetails and is a prerequisite for payProforma. Call setProforma, then setPaymentDetails and payProforma in this specific order to pay for a Partner Invoice.

You can pay only a single partner invoice at a time.

Requirements

This method requires that a specific partner be set using setPartner.

Parameters

Parameters Type/Description
sessionID Required (String)
  Session identifier, output of the Login method. An exception is thrown if the values are incorrect.
proformaNumber Required (String)
  The unique number of the partner invoice associated with one or more orders.

Response

Request

<?php

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

$proformaNumber = 'YOUR_PROFORMA_NUMBER';

try {
    $Proforma= $client->getProforma ($sessionID, $proformaNumber);
} catch (SoapFault $e) {
    echo "ProformaOutput: " . $e->getMessage();
    exit;
}
var_dump ("ProformaOutput", $Proforma);

 

Errors

Error Description

INVALID_PARTNER

No partner is set.

PAYMENT_PROFORMA

You have to use setPaymentDetails first.

PAYMENT_PROFORMA

This is a paid partner invoice.

PAYMENT_ERROR

Authorization error.

 

SOAP code samples

Overview 

  1. Working code samples for JSON-RPC and SOAP are available in PHP for each documented method, including the clients you need to make API calls. You need to replace the dummy Merchant Code and Secret Key with those available in your Merchant Control Panel.
  2. Working code samples for REST are available for each documented scenario and method. Check out the REST reference for examples. To access code samples, select any scenario and click on the "Working example" link. Working code samples:

 

  • cURL
  • Java
  • JavaScript
  • Node.js
  • Perl
  • Python
  • PHP
  • Ruby
  • Go
  • C#
  • Visual Basic
  • Groovy
  • Objective-C
  • Swift

 

Copy payment info

Overview

Copy card-on-file data available in the 2Checkout system from a source subscription to an imported target subscription. 2Checkout uses the existing payment information to charge customers as a part of the recurring billing (renewal) process.

Use the copyPaymentInfo method.

Requirements

The imported target subscription and the source subscription must belong to the same customer. The 2Checkout system checks to make sure that the 2Checkout Customer Reference (an internal identifier) coincides with the customer accounts associated with the target and source subscriptions.

Availability

Please contact 2Checkout directly if you wish to take advantage of this feature.

How does this method work?

  1. Customer A purchases Subscription A using a VISA credit card and you import Subscription B for the same customer with no data or with an AMEX card.
  2. When 2Checkout renews Subscription A, it charges Customer A using the VISA, while using the AMEX (if the data was provided) for Subscription B charges.
  3. When you copy the payment data from Subscription A to Subscription B, the 2Checkout system uses the VISA credit card to renew both subscriptions according to their respective recurring billing cycles. 2Checkout charges customers during the recurring billing process for the imported target subscription using the payment method they used to purchase the source 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.

TargetSubscriptionReference

Required (string)

 

The 2Checkout Subscription Reference of the imported target subscription, to which 2Checkout copies the payment on file data associated with the source subscription.

SubscriptionReference

Required (string)

 

The 2Checkout Subscription Reference of the source subscription whose attached payment on file data 2Checkout copies to the target subscription.

Response

Parameter Type/Description

Boolean

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

Request

<?php

require ('PATH_TO_AUTH');

$TargetSubscription = 'FFAE3C9429';
$SourceSubscription = '9F4154733C';

try {
    $payInfo = $client->copyPaymentInfo($sessionID, $TargetSubscription, $SourceSubscription);
}
catch (SoapFault $e) {
    echo "payInfo: " . $e->getMessage();
    exit;
}
var_dump("payInfo", $payInfo);

 

Account Payouts

Overview

Retrieve the account balance from your current payout period, detailed for each billing currency.

You can also search for the historical transfers issued by 2Checkout for your account, and filter the results based on the payment date, method or invoice paid.

 

 

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