Skip to main content

Promotions

Overview

Use the Promotion object to create/update and update information on discounts/promotions you set up for your account.

Parameters

Parameters Type/Description

Promotion

Object

 

Name

String  / Required

 

 

Promotion name

 

Description

String  / Optional

 

 

Promotion description

 

StartDate

String  / Optional

 

 

Starting date. The date when you set the promotion to start. Is NULL for promotions that start immediately after they're created.

Format: Y-m-d

 

EndDate

String  / Optional

 

 

Ending date. The date when you set the promotion to end. Is NULL for promotions that you want active indefinitely.

Format: Y-m-d

 

MaximumOrdersNumber

Integer / Optional

 

 

2Checkout stops offering the discount when the promotion reaches the maximum number of orders. Can be NULL if you want the promotion to apply to an unlimited number of orders.

 

MaximumQuantity

Integer / Optional

 

 

Discount only applies to a specific number of products, smaller than the maximum quantity you defined. Can be NULL if you want the promotion to apply to an unlimited number of units. Any extra quantity added to the cart will be sold at full price.

 

InstantDiscount

Boolean / Optional

 

 

Selecting the instant discount option will auto-apply the discount for ALL the selected products for all shoppers, without the need to enter the discount coupon.

Coupon

Object / Required

 

Type

String  

 

 

  • SINGLE = one coupon code-shared by all shoppers
  • MULTIPLE = array of unique coupon codes, each designed for individual use

 

Code/Codes

Array of strings 

 

 

Varies according to type. Send:

  • Code = 'single_code'; when Type = 'SINGLE';
  • Codes = ['code1', 'code2']; when Type = 'MULTIPLE';

Enabled

Bolean / Optional

 

Possible values:

  • TRUE - promotion is active.
  • FALSE - promotion is inactive

ChannelType

String / Required

 

Possible values:

  • ECOMMERCE
  • CHANNEL_MANAGER
  • ALL

Type

String / Required

 

REGULAR

Discount

Object / Required

 

Type

String 

 

 

Discount type:

  • PERCENT, use in combination with Value
  • FIXED, use in combination with Values and DefaultCurrency

 

Value / Values

Array of objects

 

 

  • Value = Int, determines the discount percentage from 0 to 100
  • Values = Array of Value objects

 

 

Value

Object 

 

 

         Currency

String 

 

 

 

 

ISO currency code

 

 

          Amount

Integer 

 

 

 

 

Discount amount in the corresponding currency.

 

DefaultCurrency

String 

 

 

ISO code

Products

Object/ Optional

 

Code

Integer/ Optional

 

 

Unique product code that you control.

 

PricingConfigurationCode

String / Optional

 

 

Unique system generated pricing configuration code.

 

PricingOptionCodes

Array of strings / Optional

 

 

Array of pricing option codes controlled by you.

PriceThreshold

Object / Optional

 

Limits discount use only when total order value (taxes included) exceeds the threshold you configure.

 

Amount

Decimal / Optional

 

 

The minimum threshold you defined for the default currency.

 

Currency

String / Optional

 

 

Currency code available for the default currency of custom threshold settings.

Translations

Array of objects / Optional

 

PromotionTranslation

Object / Optional

 

 

Name

String / Optional

 

 

 

Localized name corresponding to translated language.

Name: Le product

Language: FR

 

 

Language

String / Optional

 

 

 

Language for localization.

Sources

StringArray / Optional

 

Array of strings defining the sale source through the SRC parameter.

PublishToAffiliatesNetwork

Integer / Optional

 

1 - make promotion available in the Affiliates Network

0 - keep promotion unavailable for the Affiliates Network

ApplyRecurring

String / Required

 

Choose whether to apply the discount to renewal orders. Possible values:

  • NONE
  • ALL
  • CUSTOM

RecurringChargesNumber

Integer / Optional

 

If ApplyRecurring is set to CUSTOM, you can offer discounts for a number of recurring billing charges beyond the initial purchase.

 

 

Search SKU codes

Overview

Use the searchSku method to perform product SKU search calls with the below parameters.

Request Parameters

Parameters Required Type Description
ProductCode Required String The product code that you can define for each of your offerings. Needs to be unique.
PricingConfigurations Required Array of objects  

Code

Required String  

Currencies

Required Array of Objects ISO currency code.

Code

Required String  

PurchaseTypes

Required Array of objects Purchase type identifier. Possible values:
  • NEW_PRODUCT
  • RENEWAL
  • UPGRADE

Code

Required String  

QuantityIntervals

Required Object Numeric identifier of product quantity.

MinQuantity

Required Int  

MaxQuantity

Required Int  

PriceOptionGroups

Required Array of objects  

Code

Required String  

Options

Required Array of objects  

OptionValue

Required String  
Pagination Required Object  

Page

Required Int  

Limit

Required Int  

Request Example

<?php

require ('PATH_TO_AUTH');

$inputSchema = new \stdClass();
$inputSchema->ProductCode= '6B3CB17DDA_COPY1';

$pricingConfiguration = new \stdClass();
$pricingConfiguration->Code = 'E684EC99B0';

$currency = new \stdClass();
$currency->Code = 'EUR';
$pricingConfiguration->Currencies = [$currency];

$purchaseType = new \stdClass();
$purchaseType->Code = 'RENEWAL';
$pricingConfiguration->PurchaseTypes = [$purchaseType];

$quantityIntervals = new \stdClass();
$quantityIntervals->MinQuantity= 1;
$quantityIntervals->MaxQuantity= 10;
$pricingConfiguration->QuantityIntervals = [$quantityIntervals];

$pagination = new \stdClass();
$pagination->Page = 1;
$pagination->Limit = 10;

$inputSchema->PricingConfigurations = [$pricingConfiguration];
$inputSchema->Pagination = $pagination;


try {
    $skuData = $client->searchSku($sessionID, $inputSchema);
} catch (SoapFault $e) {
    echo "searchSku: " . $e->getMessage();
    exit;
}

var_dump("searchSku", $skuData);

Response Parameters

Parameters Type/Description
Items Object

{ProductCode}

Object. This element will be replaced by the code of the product.

SkuPricingOptions

Array of strings

Code

String

Details

Array

ProductSKU

String

Currency

String

FromQty

Int

ToQty

Int

PurchaseTypes

String

Groups

Array

GroupCode

String

Options

Array

               Name

String
                                                                                Value String

Errors

Array
Pagination Object

Limit

Int

Page

Int

Count

Int

Response Example

object(stdClass)#22 (2) {
    public $Items" =>
    object(stdClass)#21 (1) {
      public $6B3CB17DDA_COPY1 =>
      object(stdClass)#4 (2) {
        public $ProductCode =>
        string(18) "6B3CB17DDA_COPY1"
        public $SkuPricingOptions =>
        array(1) {
          [0]=>
          object(stdClass)#5 (3) {
            public $Code =>
            string(10) "E684EC99B0"
            public $Details =>
            array(5) {
              [0]=>
              object(stdClass)#6 (7) {
                public $ProductSKU =>
                string(4) "Product_Test_SKU_008899"
                public $Currency =>
                string(4) "EUR"
                public $FromQty =>
                int(1)
                public $ToQty =>
                int(10)
                public $PurchaseType =>
                string(11) "RENEWAL"
                public $Groups =>
                array(1) {
                  [0]=>
                  object(stdClass)#7 (2) {
                    public $GroupCode =>
                    string(7) "GRUP_2"
                    public $Options =>
                    array(1) {
                      [0]=>
                      object(stdClass)#8 (2) {
                        public $Name =>
                        string(7) "grup 2"
                        public $Value =>
                        string(4) "option_code_4"
                      }
                    }
                  }
                }
                public $Options =>
                string(32) "a:1:{i:16885;a:1:{i:0;i:78164;}}"
              }
              [1]=>
              object(stdClass)#9 (7) {
                public $ProductSKU =>
                string(4) "Product_Test_SKU_008902"
                public $Currency =>
                string(4) "EUR"
                public $FromQty =>
                int(1)
                public $ToQty =>
                int(10)
                public $PurchaseType =>
                string(11) "RENEWAL"
                public $Groups =>
                array(1) {
                  [0]=>
                  object(stdClass)#10 (2) {
                    public $GroupCode =>
                    string(7) "GRUP_2"
                    public $Options =>
                    array(1) {
                      [0]=>
                      object(stdClass)#11 (2) {
                        public $Name =>
                        string(6) "grup 2"
                        public $Value =>
                        string(13) "option_code_4"
                      }
                    }
                  }
                }
                public $Options =>
                string(6) "a:0:{}"
              }
            public $Errors =>
            array(0) {
            }
          }
        }
      }
    }
    public $Pagination =>
    object(stdClass)#23 (3) {
      public $Limit =>
      int(10)
      public $Page =>
      int(1)
      public $Count =>
      int(5)
    }

Do conversion optimization like the pros

Your web visitors are your most valuable marketing asset. Are you wasting precious traffic with the wrong conversion optimization strategy?

Most companies start their conversion optimization on the wrong footing. They unknowingly adopt so-called 'best practices' that haven't been properly tested. If you don't have a proven A/B testing process, you could be making big marketing mistakes and not know it.

Learn how to get the best CRO results from WiderFunnel's thousands of experiments on hundreds of websites.

In this webinar, you'll learn:

  • A proven process for optimizing any marketing touchpoint
  • The six factors that are hurting your conversion rate right now - and how to fix them
  • The one best way to discover what motivates your customer to buy from you
  • Surprising A/B test results from leading optimizing companies
Join Our Webinar

 

Delete SKU codes

Overview

Use the deleteSku method to remove product SKU codes through an API call using the below parameters.

Request Parameters

Parameters Required Type/Description
ProductCode Required String. The product code that you can define for each of your offerings. Needs to be unique.
PriceConfigurations Required String.
PriceConfigurationCode Required String. Unique identifier of the pricing configuration.
SkuCode Required String. Unique identifier of the SKU schema.

Request Example

<?php

require ('PATH_TO_AUTH');

$product = new \stdClass();
$product->ProductCode= '6B3CB17DDA_COPY1';

$pricingConfiguration = new \stdClass();
$pricingConfiguration->PriceConfigurationCode = 'E684EC99B0';
$pricingConfiguration->SKUs = ['Product_Test_SKU_001050', 'Product_Test_SKU_001053'];

$product->PriceConfigurations = [$pricingConfiguration];


try {
    $skuOutput = $client->deleteSku($sessionID, [$product]);
} catch (SoapFault $e) {
    echo "deleteSku: " . $e->getMessage();
    exit;
}

var_dump("deleteSku", $skuOutput);

Response Parameters

Parameters Type/Description
ProductCode String
PriceConfigurations String
PriceConfigurationCode String

Response Example

array(1) {
  [0] =>
  class stdClass#5 (4) {
    public $ProductCode =>
    string(16) "6B3CB17DDA_COPY1"
    public $PriceConfigurations =>
    array(1) {
      [0] =>
      class stdClass#6 (3) {
        public $PriceConfigurationCode =>
        string(10) "E684EC99B0"
        public $SKUs =>
        array(2) {
          [0] =>
          string(23) "Product_Test_SKU_001050"
          [1] =>
          string(23) "Product_Test_SKU_001053"
        }
        public $Errors =>
        array(0) {
        }
      }
    }
    public $SKUs =>
    array(0) {
    }
    public $Errors =>
    array(0) {
    }
  }
}

Search proposals

Overview

Use the searchProposals method via JSON-RPC APIv6 to find a specific proposal or quote.

Request parameters

Request parameters for the searchProposal method via JSON-RPC APIv6
Parameters Type Required/Optional Description
sessionId String Required Unique 2Checkout session ID code.
Name String Optional Proposal name.
Email String Optional The bill to or sell to email.
CreatedBy String Optional The unique external system user identifier.
ModifiedBy String Optional The unique external system user identifier.
Source String Optional The source from where the proposal was created.
CreatedAfter String Optional The UTC date and time in ISO 8601 format.
CreatedBefore String Optional The UTC date and time in ISO 8601 format.
ModifiedAfter String Optional The UTC date and time in ISO 8601 format.
ModifiedBefore String Optional The UTC date and time in ISO 8601 format.
Locked Boolean Optional

Retrieve proposals that are locked or not.

Possible values:

  • True
  • False
Offset Integer Required The offset at which the proposals should be returned. Default value: 0.
Limit Integer Required The maximum number of proposals to return. Default value: 10.
LinkId String Optional The link id for any status.

Request sample

<?php

require ('PATH_TO_AUTH');

$searchParameters = new stdClass();
$searchParameters->Name = "My Proposal Name";
$searchParameters->Email = "example@email.com";
$searchParameters->CreatedBy = "createUser";
$searchParameters->ModifiedBy = "modifyUser";
$searchParameters->Source = "MERCHANT_API";
$searchParameters->CreatedAfter = "2020-01-01T00:00:00+00:00";
$searchParameters->CreatedBefore = "2020-12-31T23:59:59+00:00";
$searchParameters->ModifiedAfter = "2020-01-01T00:00:00+00:00";
$searchParameters->ModifiedBefore = "2020-12-31T23:59:59+00:00";
$searchParameters->Locked = false;
$searchParameters->Offset = 0;
$searchParameters->Limit = 10;

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

try {
    $result = callRPC($jsonRpcRequest, $host);
    echo "Proposal: </br>", 
    var_dump($result);
}
catch (SoapFault $e) {
    echo "Could not fetch proposal: " . $e->getMessage();
    exit;
}

Response

The searchProposals call via JSON-RPC APIv6 returns a list of proposal objects.

Expose merchant information for 2CO shopping cart

Overview

Disclaimer: the following method is intended for internal purposes only.

Use the getMerchantInformation method for retrieving vendor information required by the 2CO shopping cart into a single call.

This API method is protected through a special authentication header that the 2CO cart should sent. Click here to learn more about the X - header authentication.

Requirements

Authenticate using the special authentication header.

Response

Info Description
Company name Merchant company name.
Commercial name Merchant commercial name.
Demo flag Y if the vendor status is Pending, else P if the vendor has the "test orders" package active, otherwise N.
Forced currency code 3-letter code.
Shopping cart customization Shows possible cart customizations.
Payment methods Merchant available payment options.
Override line item limit -
Order auth time Minutes into days (how long it takes for the order to become complete).
3DS status true if vendor has Use3DSecure = NO, false otherwise.
Currencies Merchant available currencies.
Countries Merchant available ordering countries.
Languages Merchant available ordering languages.
Promotions

Promotions defined on merchant account.

Secret key Merchant account secret key.
Shipping methods Shipping methods defined on merchant account.

Request

<?php

function callRPC($Request, $hostUrl, $Debug = false) {
    $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_HTTPPROXYTUNNEL, false);
    curl_setopt($curl, CURLOPT_PROXY, '');
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Accept: application/json',
        'X-Avangate-Authentication: type="private" ver="2" app="2co-shopping-cart" merchant="RDGM" date="2018-01-31T13:57:44+00:00" hash="0m3ULy6dZ2xUI8CFtU0ersCootdf6wz8Z1qxN28FdXI="'
    ));

    curl_setopt($curl, CURLOPT_COOKIE, '');
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);

    if ($Debug) {
        var_dump($RequestString);
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        var_dump($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;
    }

    return null;
}

$host = 'http://api.avangate.com/rpc/5.0';

$jsonRpcRequest = array (
    'jsonrpc' => '2.0',
    'id' => 1,
    'method' => 'getMerchantInformation',
    'params' => []
);

echo json_encode(callRPC((Object)$jsonRpcRequest, $host));

 

Create a cross-sell campaign

Overview

Use the createCrossSellCampaign method to create a cross-sell campaign for your 2Checkout account.

Request parameters

Parameters Type Required Description

MasterProducts 

Array of strings 

Required

Array of product codes to apply to this campaign. 

DisplayType 

String 

Required

The display type of the campaign; Can be cart, review, finish.

DisplayInEmail 

Boolean 

Required

Determines if the campaign will be displayed in payment receipt emails.

Products 

Array of objects 

Required

Array of objects containing the product codes pointing to the promoted products when tied to each master product, the discount value, and the discount type (can only be percent).

ProductCode 

String 

Required

Product code of the product to be recommended to the shopper.

Discount 

Float 

Required

Value of the discount.

DiscountType 

String 

Required

Can only be 'PERCENT'.

Name 

String 

Required

Name of the campaign.

StartDate 

String 

Optional 

The date when the cross-sell campaign starts, formatted as YYYY-MM-DD.

EndDate 

String 

Optional 

The date when the cross-sell campaign ends, formatted as YYYY-MM-DD.

Response parameters

Parameters Type Required Description

CampaignCode 

 String 

Required

The campaign code that can be used when placing orders. 

MasterProducts 

Array of strings 

Required

Array of product codes to apply to this campaign. 

DisplayType 

String 

Required

The display type of the campaign; Can be cart, review, finish.

DisplayInEmail 

Boolean 

Required

Determines if the campaign will be displayed in payment receipt emails. Can be 'true' or 'false'.

Products 

Array of objects 

Required

Array of objects containing the product codes pointing to the promoted products when tied to each master product, the discount value, and the discount type (can only be percent).

ProductCode 

String 

Required

Product code of the product to be recommended to the shopper.

Discount 

Float 

Required

Value of the discount.

DiscountType 

String 

Required

Can only be 'PERCENT'.

Name 

String 

Required

Name of the campaign.

CampaignStatus

String 

Optional 

The status of the cross-sell campaign.

StartDate 

String 

Optional 

The date when the cross-sell campaign starts, formatted as YYYY-MM-DD.

EndDate 

String 

Optional 

The date when the cross-sell campaign ends, formatted as YYYY-MM-DD.

Request sample

<?php 

require ('PATH_TO_AUTH'); 

$csCampaign = new stdClass(); 

$csCampaign->MasterProducts = ['C8851A5BC9']; 
$csCampaign->DisplayType = 'cart'; 
$csCampaign->DisplayInEmail = true; 
$csCampaign->Name = 'testing'; 
$csCampaign->StartDate = '2019-09-20'; 
$csCampaign->EndDate = '2020-10-21'; 
$csCampaign->Products = []; 
$csCampaign->Products[0] = new stdClass(); 
$csCampaign->Products[0]->ProductCode = '512712FA53'; 
$csCampaign->Products[0]->Discount = 20; 
$csCampaign->Products[0]->DiscountType = 'PERCENT'; 

try { 

    $csCampaignResponse = $client->createCrossSellCampaign($sessionID, $csCampaign); 

} catch (SoapFault $e) { 

    echo  $e->getMessage(); 

Convert a trial

Overview

Use the convertTrial method to convert a trial to a paid subscription. In the eventuality of a conversion failure, you can use convertTrial again for the same trial subscription only after you let 24 hours pass since the initial attempt. The 2Checkout system attempts to automatically convert trials before they expire to full subscriptions unless you made an attempt that failed less than 24 hours before the scheduled expiration deadline.

In case the trial conversion fails due to a transaction issue, the 2Checkout system sends unfinished payment follow-up emails to customers, provided that you set up lead management for your 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.

SubscriptionReference

Required (string)

 

Unique, system-generated subscription identifier of the trial that you convert to a paid subscription. The unique identifier from the 2Checkout system:

  • Must belong to an active trial subscription with the recurring billing system (auto-renewal) enabled.
  • The initial order placed to access the trial subscription must be finalized (status Finished).

Note: This method does not work for cancelled and/or expired trial subscriptions.

 

2Checkout charges customers using the payment data attached to the trial subscription. 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.

ExtendSubscriptionFromPaymentDate

Optional (boolean)

 

true = Set the moment of the conversion as the start date of the full subscription. 

Example: A 7 day trial purchased on October 29 for a monthly subscription converted on October 30 with $ExtendSubscriptionFromPaymentDate = true; features the following Billing cycle expiration: Nov 30, 2013 and Avangate scraps the initial trial expiration date November 5.

 

false = Set initial trial expiration deadline as the fhe full subscription start date. 

Example: A 10 day trial purchased on October 29 for a monthly subscription converted on October 30 with $ExtendSubscriptionFromPaymentDate = false; features the following Billing cycle expiration: December 9, with the first month period of the subscription added to the trial lifetime stretching until November 8.

 

Can be NULL. If not sent, the default value is false.

Response

Boolean

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

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.avangate.com/rpc/3.0/';
 
$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
 
$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);
$SubscriptionReference = 'BF44555C6C';
$ExtendSubscriptionFromPaymentDate = true; //false can also be used if you want the subscription start date to be the moment when the trial was set to initially expire.

$jsonRpcRequest = array (
'method' => 'convertTrial',
'params' => array($sessionID, $SubscriptionReference, $ExtendSubscriptionFromPaymentDate),
'id' => $i++,
'jsonrpc' => '2.0');

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

 

Retrieve product by code

Overview

Use getProductByCode to extract product information using the unique identifier you assign to subscription plans/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

String

 

The product code that you control.

Response

Parameters Type/Description
Product Object

Request

<?php

require ('PATH_TO_AUTH');

$ProductCode = "subscr1";

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

?>

Place a renewal order

Overview

Renew a subscription by using the Avangate Subscription Reference. Collect recurring revenue with one of the following payment methods:

  • Credit cards
  • PayPal
  • WeChat Pay
  • iDEAL
  • Purchase Order
  • Wire

Use the PaymentDetails object to control the payment method used in the renewal process.

Requirements

To place a renewal order, you need to provide a valid subscription reference number.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

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

Order

Required (Object)

 

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

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

SubscriptionReference

Required (String)

Avangate generated subscription reference number. E.q. A8C5671BFE.

Response

Edit section 
Parameters Type/Description

Order information

Object

Request

<?php

require ('PATH_TO_AUTH');

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

/**/
$Order->Items[0]->RenewalInformation = new stdClass();
$Order->Items[0]->RenewalInformation->SubscriptionReference = 'A8C5671BFE'; //subscription used in the renewal process
$Order->Items[0]->Price = new stdClass();
$Order->Items[0]->Price->Type = 'CUSTOM';
$Order->Items[0]->Price->Amount = '10';
$Order->Items[0]->PriceOptions = array('uniqscale1=4');//

$Order->MachineId = "MachineID";

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->Address1 = 'Bil1ing address';
$Order->BillingDetails->Address2 = 'Billing address 2';
$Order->BillingDetails->City = 'Billing City';
$Order->BillingDetails->State = 'Billing State';
$Order->BillingDetails->CountryCode = 'US';
$Order->BillingDetails->Phone = 1231232123;
$Order->BillingDetails->Email = 'customer_details@test.com';
$Order->BillingDetails->FirstName = 'First';
$Order->BillingDetails->LastName = 'Customer';
$Order->BillingDetails->Company = 'Billing Company';
$Order->BillingDetails->Zip = '55104';

$Order->DeliveryDetails = new stdClass();
$Order->DeliveryDetails->Address1 = 'Bil1ing address';
$Order->DeliveryDetails->Address2 = 'Billing address 2';
$Order->DeliveryDetails->City = 'Billing City';
$Order->DeliveryDetails->State = 'Billing State';
$Order->DeliveryDetails->CountryCode = 'US';
$Order->DeliveryDetails->Phone = '12345';
$Order->DeliveryDetails->Email = 'customer_details@test.com';
$Order->DeliveryDetails->FirstName = 'First';
$Order->DeliveryDetails->LastName = 'Customer';
$Order->DeliveryDetails->Zip = "55104";

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

$Order->PaymentDetails->PaymentMethod = new stdClass();
/**/
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->CardType = "VISA";
$Order->PaymentDetails->PaymentMethod->ExpirationYear = "2019";
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = "12";
$Order->PaymentDetails->PaymentMethod->CCID = "123";
$Order->PaymentDetails->PaymentMethod->HolderName = "John Doe";
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = TRUE;
$Order->PaymentDetails->PaymentMethod->HolderNameTime = 1;
$Order->PaymentDetails->PaymentMethod->CardNumberTime = 1;
/**/


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

var_dump("newOrder", $Order);
Edit section
 

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