Skip to main content

Remove promotion coupon

Overview

Use the deletePromotionCoupon method to remove single or multiple coupons from a promotion.

Parameters

Parameter Type/Description

sessionID

Required (string)

 

Output of the Login method.

promotionCode

Required (string)

 

The code corresponding to the promotion that you want to remove coupons from.

promotionCoupon

Required (object)

 

type

Required (string)

 

 

Coupon type. Available values:

  • SINGLE, use in conjunction with Code
  • MULTIPLE, use in conjunction with Codes

 

Code/Codes

Required (string / array of strings)

 

 

Coupon code (for SINGLE) or array of coupon codes (for MULTIPLE).

Response

Parameter Type/Description
promotionCoupon Object

Request

<?php

function callRPC($Request, $host, $Debug = true) {
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    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)) {
        var_dump($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.1/';

$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;

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

// Promotion code corresponding to the promotion you want to remove coupons from
$promotionCode = '';

// Define single coupon object
$promotionCoupon = new stdClass;
$promotionCoupon->Type = 'SINGLE';
$promotionCoupon->Code = 'YOUR_CODE_HERE';

// Define multiple coupon object
$promotionCoupon = new stdClass;
$promotionCoupon->Type = 'MULTIPLE';
$promotionCoupon->Codes = ['YOUR_CODE_1', 'YOUR_CODE_2'];

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'deletePromotionCoupon',
'params' => array($sessionID, $promotionCode, $promotionCoupon)
);
var_dump (callRPC($jsonRpcRequest, $host));

Retrieve campaign texts

Overview

Use the getCrossSellTexts method to extract information on all cross-sell campaigns texts.

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.

LanguageCode

Required (string)

 

ISO language code. (ISO 639-1 two-letter code).

Response

Parameters Type/Description

Title

String

 

Cross-selling message title. Set here.

Description

String

 

Cross-selling message description. Set here.

Language

String

Request

<?php

require ('PATH_TO_AUTH');

$LanguageCode = 'de'; //returns title and description texts you set under https://secure.2checkout.com/cpanel/network_cross_selling_settings.php

try {
    $CrossSellCampaignsTexts = $client->getCrossSellTexts($sessionID, $LanguageCode);
}

catch (SoapFault $e) {
    echo "CrossSellCampaignsTexts: " . $e->getMessage();
    exit;
}

var_dump("CrossSellCampaignsTexts", $CrossSellCampaignsTexts);
?>

Search price option groups

Overview

Use the searchPriceOptionGroups to extract information on the price option groups you configured.

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.

PriceOptionGroupSearch

Optional (object)

 

Details below.

PriceOptionGroupSearch

Object

Name

Optional (string)

 

The name of the pricing options groups configured in the 2Checkout system.

Can be NULL.

Types

Optional (array)

 

Possible values:

· RADIO

· CHECKBOX

· INTERVAL

· COMBO

Can be NULL.

Limit

Optional (int)

 

Number of results displayed per page. Default maximum value is 10.

Can be NULL.

Page

Optional (int)

 

A specific page of search results. Default value is 1.

Can be NULL.

Response

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$SearchOptions = new \stdClass();
//$searchObject->Name = 'optionGroupA';
$SearchOptions->Types = ["RADIO"];
$SearchOptions->Pagination = new stdClass();
$SearchOptions->Pagination->Page = 1;
$SearchOptions->Pagination->Limit = 200;

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

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

?>

Product Upgrade Schema

Overview

Use the setProductUpgradeSchema method to set a product’s upgrade schema via API.

Parameters

Parameter Type Required Description
UpgradeSettings Object Required Details below.

          PricingScheme

Integer Required

The Upgrade pricing scheme.
1 – Shopper pays the full upgrade product price;
2 – Shopper pays the difference between the original subscription and the upgraded product;
3 - Shopper pays a prorated upgrade price calculated using the most recent costs incurred by the customer;
4 – Shopper pays prorated upgrade price calculated using the product's pricing set up at the time of the order.

          OptionPriceOperator String Optional The operator that specifies how is the upgrade price impacted (not used for prorated upgrade pricing schemes):
- ADD – the value set as OptionPricePercentage is added to the  upgrade price;
- SUBTRACT – the value set as OptionPricePercentage is subtracted from the upgrade price.
          OptionPricePercentage Integer Optional The percentage of the upgrade price to be added/subtracted from this one (not used for pro-rated upgrade pricing schemes).
          UseProductCatalogPricing Boolean Optional When true, it enables the usage of product catalog pricing. Removing custom prices also disables any existing retention campaigns for the selected subscriptions.
          ProrateIgnoreGracePeriod Boolean Optional When true, it makes the grace period be ignored when calculating Upgrade. Use this option to ignore the grace period set in your Renewal Settings when computing the prorated price for the upgrade.
          SubscriptionUpgradeType Integer Required Determines the Subscription period option for the upgrade:
1 - Create a new subscription (disable the existing one);
2 - Prolong the subscription from the upgrade purchase date;
3 - The upgrade does not affect the original subscription duration. If you upgrade a lifetime subscription to a product that has recurring options, the subscription will remain lifetime, as its duration is not affected by the upgrade process.
AllowUpgradeFrom Array of Strings Required List of product codes corresponding to the products that can be upgraded to the product of reference.

Request Sample

<?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_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
    $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;
        }
        var_dump($Response);

        if (!empty($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}

//require_once(realpath(__DIR__ . '/../../../../../') . "/lib/api/v6.0/vendor/autoload.php");
require_once("/srv/www/app/live/htdocs/lib/api/v6.0/vendor/autoload.php");

$apiVersion = '6.0';
$domain = 'api.avangate.local:8081';
$host = "http://{$domain}/rpc/{$apiVersion}/";

// AlexB Inc account #21478
$merchantCode = "120000589445";
$key = "i9u2+w8%s4^5#8%t)A8?";
$productCode = "ADEV17962UPGRADE";            // main upgrade product offered as upgrade for other products
$upgradeFromProductCode1 = "ADEV17962UPOPT1"; // product that can be upgraded #1
$upgradeFromProductCode2 = "ADEV17962UPOPT12"; // product that can be upgraded #2

$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$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 = [$merchantCode, $date, $hash];
$jsonRpcRequest->id = $i++;

$sessionID = callRPC($jsonRpcRequest, $host);
echo PHP_EOL . 'SessionID -> ' . $sessionID . PHP_EOL;

$upgradeSchema = new stdClass();

/** @var \Api\Resources\Product\Assets\UpgradeSettings $upgradeSettings */
$upgradeSettings = new stdClass();
$upgradeSettings->PricingScheme = \Api\Resources\Product\Assets\UpgradeSettings::PRICING_SCHEME_PRICE_DIFFERENCE;
$upgradeSettings->OptionPriceOperator = \Api\Resources\Product\Assets\UpgradeSettings::OPTION_PRICE_OPERATOR_SUBSTRACT;
$upgradeSettings->OptionPricePercentage = 3;
$upgradeSettings->SubscriptionUpgradeType = \Api\Resources\Product\Assets\UpgradeSettings::SUBSCRIPTION_UPGRADE_TYPE_PROLONG_SUBSCRIPTION;
#$upgradeSettings->SubscriptionUpgradeType = 8; // invalid value
$upgradeSettings->UseProductCatalogPricing = true;
#$upgradeSettings->UseProductCatalogPricing = 'yes'; // should be rejected
$upgradeSettings->ProrateIgnoreGracePeriod = false;

$upgradeSchema->UpgradeSettings = $upgradeSettings;
#$upgradeSchema->AllowUpgradeFrom = [$upgradeFromProductCode1, $upgradeFromProductCode2];
$upgradeSchema->AllowUpgradeFrom = [$upgradeFromProductCode1];

$payload = json_encode($upgradeSchema, JSON_PRETTY_PRINT);

echo PHP_EOL . 'Calling ' . $host . ' with productCode: ' . $productCode . ' and payload: ' . PHP_EOL . $payload . PHP_EOL;

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'setProductUpgradeSchema';
$jsonRpcRequest->params = [$sessionID, $productCode, $upgradeSchema];
$jsonRpcRequest->id = $i++;

$resp = callRPC($jsonRpcRequest, $host);
$response = json_encode($resp, JSON_PRETTY_PRINT);
echo PHP_EOL . 'SetUpgradeSchema response:' . PHP_EOL . var_export($resp, true) . PHP_EOL;

Response

{
    "UpgradeSettings": {
        "PricingScheme": 1,
        "OptionPriceOperator": "ADD",
        "OptionPricePercentage": 3,
        "SubscriptionUpgradeType": 2,
        "UseProductCatalogPricing": false,
        "ProrateIgnoreGracePeriod": false
    },
    "AllowUpgradeFrom": [
        "ADEV17962UPOPT12"
    ]
}

Update price options

Overview

Use the updatePriceOptionGroup method to update/edit an existing price options group you configured for your account. Price options intervals cannot overlap. 

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.

PriceOptionsGroup

Required (object)

 

Use this object to update/edit a new price option group for your account.

You cannot update the Code and Required parameters of the price options group.

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$SearchOptions = new stdClass ();
$SearchOptions->Name = 'New Users from API';
$SearchOptions->Types = array('INTERVAL', 'RADIO'); //RADIO, CHECKBOX, INTERVAL, COMBO

$SearchOptions->Pagination = new stdClass ();
$SearchOptions->Pagination->Limit = 10;
$SearchOptions->Pagination->Page = 1;

try {
$existentPriceOptions = $client->searchPriceOptionGroups($sessionID, $SearchOptions);
}

catch (SoapFault $e) {
    echo "existentPriceOptions: " . $e->getMessage();
    exit;
}

var_dump ($existentPriceOptions);

$updatedPriceOptions = $existentPriceOptions->Items[0]; //assigning pricing option into a new variable
$updatedPriceOptions->Translations[0]->Name = 'New Users from API3';
$updatedPriceOptions->Translations[0]->Language = 'EN';

echo ($updatedPriceOptions->Name);

try {
    $NewPriceOptionGroup = $client->updatePriceOptionGroup($sessionID, $updatedPriceOptions);
}

catch (SoapFault $e) {
    echo "NewPriceOptionGroup: " . $e->getMessage();
    exit;
}

var_dump("NewPriceOptionGroup", $NewPriceOptionGroup);


?>

Set grace period

Overview

Use the setSubscriptionGracePeriod method to set a custom grace period for an Active or Past Due subscription. This method changes per-subscription end user data and not customer details.

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. Needs to belong to an Active or Past Due subscription.

SubscriptionGracePeriod

Required (int)

 

The number of days for the grace period, during which time, customers can still renew/upgrade expired subscriptions. During the grace period, subscriptions feature the Past Due status.

 

Can be NULL. When NULL, the grace period for a subscription is the same as that you defined in the per-product or per-account grace period settings. You can use this to set a custom grace period for a subscription.

 

Use 0 to remove the grace period of a subscription.

Response

Boolean

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

Request


<?php
$host   = "https://api.avangate.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
    'location' => $host . "/soap/4.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));

function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}
$merchantCode = "YOUR_MERCHANT_CODE";// your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key = "YOUR_SECRET_KEY";// your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);
try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}
catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage();
    exit;
}
$subscriptionReference = 'DC47E143FA';
$gracePeriod = 14;
try {
    $customGracePeriod = $client->setSubscriptionGracePeriod($sessionID, $subscriptionReference, $gracePeriod);
}
catch (SoapFault $e) {
    echo "customGracePeriod: " . $e->getMessage();
    exit;
}
var_dump("customGracePeriod", $customGracePeriod);

Retrieve a lead

Overview

Use the getLead method to retrieve leads created in the 2Checkout systems by fetching the lead code.

Request Parameters

Parameters Required Type/Description

LeadCode

Optional

String/Array of strings. Retrieves all leads based on their unique identification code (system-generated).

 

 

Email

Optional

String. A valid email address used by the customer

Type

Optional String. Must be one of the existing types of leads:
  • New
  • Used
  • UsedSuccess
  • Stopped
  • NotStopped

StartDate

Optional String. The start date of the interval; format must be yyyy-mm-dd.

EndDate

Optional String. The end date of the interval; format must be yyyy-mm-dd.

ProductCode 

Optional

String/Array of strings. Searches for all leads containing the product code.

Language

Optional String. The language of the shopper cart; ISO 639-1 two-letter code.

Country

Optional String. The customers billing country; ISO 3166 two-letter code.

GeneratedFrom 

Optional String. API, shopping cart, ConvertPlus. Display the leads based on the source where they were created – via API or via the 2Checkout ordering engines.

Request Example

<?php

require ('PATH_TO_AUTH');

try {
    $leadData = $client->getLead($sessionID, '60E6C4B574');
} catch (SoapFault $e) {
    echo "getLead: " . $e->getMessage();
    exit;
}

var_dump("getLead", $leadData);

Response Example

class stdClass#18 (14) {
  public $LeadCode =>
  string(10) "60E6C4B574"
  public $GeneratedFrom =>
  string(3) "API"
  public $CartId =>
  string(11) "CartIdValue"
  public $Currency =>
  string(3) "EUR"
  public $Language =>
  string(2) "BG"
  public $ExternalReference =>
  string(18) "REST_API_3CHECKOUT"
  public $MachineId =>
  string(6) "123asd"
  public $LocalTime =>
  string(19) "2019-11-05 16:48:28"
  public $Items =>
  class stdClass#19 (1) {
    public $0 =>
    class stdClass#20 (15) {
      public $Code =>
      string(10) "04C26C50F8"
      public $Quantity =>
      string(1) "2"
      public $SKU =>
      NULL
      public $Name =>
      string(5) "softy"
      public $Description =>
      NULL
      public $IsDynamic =>
      bool(false)
      public $Tangible =>
      bool(false)
      public $PurchaseType =>
      string(7) "PRODUCT"
      public $PriceOptions =>
      NULL
      public $RecurringOptions =>
      class stdClass#21 (5) {
        public $CycleLength =>
        NULL
        public $CycleUnit =>
        NULL
        public $CycleAmount =>
        NULL
        public $ContractLength =>
        NULL
        public $ContractUnit =>
        NULL
      }
      public $RenewalInformation =>
      class stdClass#22 (1) {
        public $SubscriptionReference =>
        NULL
      }
      public $MarketingCampaigns =>
      class stdClass#23 (3) {
        public $Type =>
        string(2) "23"
        public $ParentCode =>
        string(1) "m"
        public $CampaignCode =>
        string(2) "23"
      }
      public $Price =>
      class stdClass#24 (2) {
        public $Amount =>
        string(2) "20"
        public $Type =>
        string(6) "CUSTOM"
      }
      public $AdditionalFields =>
      NULL
      public $SubscriptionStartDate =>
      string(19) "2019-11-05 16:48:28"
    }
  }
  public $BillingDetails =>
  class stdClass#25 (12) {
    public $FirstName =>
    string(8) "Customer"
    public $LastName =>
    string(9) "2Checkout"
    public $Phone =>
    NULL
    public $Company =>
    NULL
    public $FiscalCode =>
    string(8) "32423423"
    public $Email =>
    string(22) "customer@2checkout.com"
    public $Address1 =>
    string(12) "Test Address"
    public $Address2 =>
    NULL
    public $City =>
    string(2) "LA"
    public $Zip =>
    string(5) "12345"
    public $CountryCode =>
    string(2) "RO"
    public $State =>
    string(2) "CA"
  }
  public $DeliveryDetails =>
  class stdClass#26 (12) {
    public $FirstName =>
    string(8) "Customer"
    public $LastName =>
    string(9) "2Checkout"
    public $Phone =>
    NULL
    public $Company =>
    NULL
    public $FiscalCode =>
    string(8) "32423423"
    public $Email =>
    string(22) "customer@2checkout.com"
    public $Address1 =>
    string(12) "Test Address"
    public $Address2 =>
    NULL
    public $City =>
    string(2) "LA"
    public $Zip =>
    string(5) "12345"
    public $CountryCode =>
    string(2) "RO"
    public $State =>
    string(2) "CA"
  }
  public $DeliveryInformation =>
  class stdClass#27 (1) {
    public $ShippingMethod =>
    class stdClass#28 (1) {
      public $Code =>
      string(5) "sdfsd"
    }
  }
  public $PaymentDetails =>
  class stdClass#29 (4) {
    public $Type =>
    string(2) "CC"
    public $Currency =>
    string(3) "EUR"
    public $PaymentMethod =>
    class stdClass#30 (2) {
      public $RecurringEnabled =>
      bool(false)
      public $CardPayment =>
      class stdClass#31 (1) {
        public $InstallmentsNumber =>
        string(2) "23"
      }
    }
    public $CustomerIP =>
    string(7) "1.2.3.4"
  }
  public $Promotions =>
  array(1) {
    [0] =>
    string(0) ""
  }
}

Update proposal

Overview

Use the updateProposal method via SOAP API 6.0 to update the details of a proposal or quote.

Request parameters

Request parameters for the updateProposal method via SOAP APIv6
Parameters Type Required/Optional Description
proposalId String Required The unique merchant proposal ID generated by the 2Checkout system.
sessionId String Required Unique 2Checkout session ID code.
Name String Optional Proposal name.
UserId String Optional The unique user ID generated by the 2Checkout system.
BillTo Object Optional  The billing details associated with the proposal.
SellTo Object Optional Represents the entity using the service. Used for tax calculation.

Request sample

<?php

require ('PATH_TO_AUTH');

$proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

try {
    $result = $soapClient->getProposalById($sessionID, $proposalID);
    echo "Fetching Proposal ID: {$proposalID} </br>";
}
catch (SoapFault $e) {
    echo "Could not fetch proposal: " . $e->getMessage();
    exit;
}

$result->Name = "Updated proposal name";
$result->UserId = "myuser";
$result->BillTo->FirstName = "Billing Contact first name";
$result->BillTo->LastName = "Billing Contact last name";
$result->BillTo->Email = "contact@email.com";
$result->BillTo->Country = "US";
$result->BillTo->State = "California";
$result->BillTo->vatCode = "85421564";
$result->BillTo->City = "San Francisco";
$result->BillTo->Address = "Street name No. 9 San Francisco, California";
$result->SellTo->FirstName = "Contact first name";
$result->SellTo->LastName = "Contact last name";
$result->SellTo->Email = "contact@email.com";
$result->SellTo->Country = "US";
$result->SellTo->State = "California";
$result->SellTo->City = "San Francisco";
$result->SellTo->Address = "Street name No. 5 San Francisco, California";

try {
    $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
    echo "New proposal created: </br>", 
    var_dump($updateResult);
}
catch (SoapFault $e) {
    echo "Could not create proposal: " . $e->getMessage();
    exit;
}

Request sample with prorationDate

<?php

        require ('PATH_TO_AUTH');

        $proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

        try {
            $result = $soapClient->getProposalById($sessionID, $proposalID);
            echo "Fetching Proposal ID: {$proposalID} </br>";
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

        $result->Content->LineItems[0]->ProrationData = "2020-11-14T15:28:56+00:00";

        try {
            $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
            echo "New proposal created: </br>",
            var_dump($updateResult);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Request sample with vatCode

<?php

        require ('PATH_TO_AUTH');

        $proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

        try {
            $result = $soapClient->getProposalById($sessionID, $proposalID);
            echo "Fetching Proposal ID: {$proposalID} </br>";
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

        $result->Name = "Updated proposal name";
        $result->UserId = "myuser";
        $result->BillTo->FirstName = "Billing Contact first name";
        $result->BillTo->LastName = "Billing Contact last name";
        $result->BillTo->Email = "contact@email.com";
        $result->BillTo->Country = "US";
        $result->BillTo->State = "California";
        $result->BillTo->City = "San Francisco";
        $result->BillTo->Address = "Street name No. 9 San Francisco, California";
        $result->SellTo->FirstName = "Contact first name";
        $result->SellTo->LastName = "Contact last name";
        $result->SellTo->Email = "contact@email.com";
        $result->SellTo->Country = "US";
        $result->SellTo->State = "California";
        $result->SellTo->vatCode = "85421564";
        $result->SellTo->City = "San Francisco";
        $result->SellTo->Address = "Street name No. 5 San Francisco, California";

        try {
            $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
            echo "New proposal created: </br>", 
            var_dump($updateResult);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Request sample with TaxExemptionId

<?php

        require ('PATH_TO_AUTH');

        $proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

        try {
            $result = $soapClient->getProposalById($sessionID, $proposalID);
            echo "Fetching Proposal ID: {$proposalID} </br>";
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

        $result->Name = "Updated proposal name";
        $result->UserId = "myuser";
        $result->BillTo->FirstName = "Billing Contact first name";
        $result->BillTo->LastName = "Billing Contact last name";
        $result->BillTo->Email = "contact@email.com";
        $result->BillTo->Country = "US";
        $result->BillTo->State = "California";
        $result->BillTo->City = "San Francisco";
        $result->BillTo->Address = "Street name No. 9 San Francisco, California";
        $result->SellTo->FirstName = "Contact first name";
        $result->SellTo->LastName = "Contact last name";
        $result->SellTo->Email = "contact@email.com";
        $result->SellTo->Country = "US";
        $result->SellTo->State = "California";
        $result->SellTo->TaxExemptionId = "85421564";
        $result->SellTo->City = "San Francisco";
        $result->SellTo->Address = "Street name No. 5 San Francisco, California";

        try {
            $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
            echo "New proposal created: </br>", 
            var_dump($updateResult);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Response

The updateProposal call via SOAP API 6.0 returns the Proposal object.

 

Place orders with catalog products

Overview

Use this object to create new orders and collect payments from shoppers using catalog products defined in your Merchant Control Panel.

For orders that require physical delivery, if no shipping methods are provided, 2Checkout will add to the cart your account's default shipping configuration.

You can find a list of common errors that may arise when using the placeOrder call via API 6.0 here.

Supported payment methods/flows

Requirements

For credit card orders placed using API 6.0, 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 passwords 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 in the placeOrder call:

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.
WSOrder Optional (string)
  The WSOrder parameter is used to control the website URL displayed in the email messages shoppers receive after they place an order. By default, 2Checkout reports the URL set as Homepage in the Account information area. Adding WSOrder to the buy-links for your products will cause the optional website address set by using the parameter to override and replace the Homepage URL in the email notifications sent to customers. The behavior is similar to the WS_ORDER parameter supported on checkout/cart pages and described here.

Parameters

 
Parameters Type/Description

Currency

String / Optional

 

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

Country

String / Optional

 

Shopper country. ISO 3166 two-letter code. Example: “us.”

Language

String / Optional

 

ISO 639-1 two-letter code. Language used for the purchase process. Example: “en.”

ExternalReference

String / Optional

 

Set external reference identifiers for orders. Enables you to replicate the functionality of the REF parameter included in Buy Links. Maximum 100 characters. If there is a need for longer references, you can apply an md5 hash for any string value, resulting in a 32 characters string. You can verify the hash after the order notification, on the client-side.

Source

String / Optional

 

The link source for the sales. Enables you to replicate the functionality of the SRC (separate link identifier) parameter when included in Buy Links. Use the SRC parameter to track sale sources.

 

Maximum length 255 characters.

CustomerReference

Integer / Optional

 

Set an external customer ID, attached to the customer.

Affiliate Object/Optional
                   AffiliateCode String/Required
  The affiliate unique code (as returned by the affiliates API methods).
                   AffiliateSource String/Optional
  The affiliate source.

Items

Array of object / Required

 

Details below. 

 

OrderItem

Object

 

 

Details below. 

 

 

Code

String / Mandatory

 

 

 

Unique product identifier your control. Max length 256 characters. Only for catalog products.

 

 

Quantity

Integer / Optional

 

 

 

Number of units

 

 

PriceOptions

Array of strings / Optional

 

 

 

Array of price option codes.

 

 

SKU

String / Optional

 

 

 

SKU identifier.

 

 

Price

Object - Can be NULL. If Price Type is set to 'CUSTOM', dynamic pricing can be added to the order via the Amount parameter.

 

 

CrossSell

Object – Can be NULL

 

 

 

Details below. 

 

 

 

ParentCode

String 

 

 

 

 

The product code of the master product you set to trigger the campaign.

 

 

 

CampaignCode

String 

 

 

 

 

Unique, system-generated identifier for cross-sell campaigns.

 

 

Trial

Object – Can be NULL

 

 

 

Details below. 

 

 

 

Period

Integer 

 

 

 

 

The length of the trial subscription lifetime in days.

 

 

 

Price

Double / Optional

 

 

 

 

Total trial price in the payment currency before 2Checkout deducts any taxes, discounts, etc.

 

 

AdditionalFields

Array of objects – Can be NULL

 

 

 

AdditionalFieldSet

Object – Can be NULL

 

 

 

 

Code

String

 

 

 

 

 

The alpha-numeric characters, underscores and dashes that are set as the field identifier.

 

 

 

 

Value

String

 

 

 

 

 

Selected field value.

    SubscriptionStartDate String
     

Specify the date time stamp when the subscription becomes active. Format 2016-07-02 22:22:22 (YYYY-MM-DD HH:mm:ss). Available for JSON-RPC and REST.

Send empty or NULL to activate subscriptions on the same date when customers purchase them.

You can exclude HH:mm:ss when sending the date and include only YYYY-MM-DD. In this case, 2Checkout uses 00:00:01. Default time zone GMT+02:00.

    SubscriptionCustomSettings Object/Optional
      To use this, the ExtraInformation object with AssistedSale property set to "true" is required.
   

CycleAmountType

String/Required
      Billing cycle unit NET/GROSS.
   

CycleUnit

String/Required
      DAY/MONTH. Can be NULL.
   

CycleAmount

Float/Required
      Billing cycle (renewal) price.
   

CycleLength

Integer/Required
      Billing cycle length. Can be NULL.
   

ContractLength

Integer/Optional
      Contract period length (expressed in the specified CycleUnit; must be multiple of CycleLength). Can be NULL.
   

MerchantDealAutoRenewal

Boolean/Optional
      Merchant deal auto-renewal flag.
   

ClientDealAutoRenewal

Boolean/Optional
      Client deal auto-renewal flag.

BillingDetails

Object / Required

 

Details below. 

 

FirstName

String/Required

 

 

Shopper name.

 

LastName

String/Required

 

 

Shopper surname.

 

CountryCode

String/Required

 

 

Shopper country. ISO 3166 two-letter code.

 

State

String/Optional – Required for US, Canada, Brazil, Turkey, India and Romania

 

 

The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two-letter code.

 

City

String/Required

 

 

Shopper city.

 

Address1

String/Required

 

 

Shopper address.

 

Address2

String / Optional

 

 

Shopper address.

 

Zip

String/Required

 

 

ZIP/ Postal code.

 

Email

String/Required

 

 

Shopper email address.

 

Phone

String / Optional

 

 

Shopper phone number. Mandatory when you set Brazil as the Billing Country. Can be NULL.

 

Company

String / Optional

 

 

Company name. Can be null for end users. When present, you also need to provide the FiscalCode.

 

FiscalCode

String / Optional– 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).

Mandatory when you set India as the Billing Country, and purchase is made by a Company.

• Can be NULL for end users.

 

TaxExemptionId

String / Optional

 

 

Tax Exempt Certification id used to deduct taxes for US orders.
Example: 1b80eecc349v

DeliveryDetails

Object / Required

 

Details below. 

 

 

FirstName

String / Required

 

 

 

Shopper name from the delivery details.

 

 

LastName

String / Required

 

 

 

Shopper surname from the delivery details.

 

 

CountryCode

String / Required

 

 

 

Shopper country. ISO 3166 two-letter code from the delivery details.

 

 

State

String/Optional – Required for US, Canada, Brazil, Turkey, India and Romania

 

 

 

The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two-letter code.

 

 

City

String / Optional

 

 

 

Shopper city from the delivery details.

 

 

Address1

String / Optional

 

 

 

Shopper address from the delivery details.

 

 

Address2

String / Optional

 

 

 

Shopper address from the delivery details.

 

 

Zip

String / Optional

 

 

 

ZIP/ Postal code from the delivery details.

 

 

Email

String / Optional

 

 

 

Shopper email address from the delivery details.

 

 

Phone

String / Optional

 

 

 

Shopper phone number from the delivery details. Mandatory when you set Brazil as the Billing Country. Can be NULL.

 

 

Company

String / Optional

 

 

 

Company name from the delivery details. Can be null for end users. When present, you also need to provide the FiscalCode.

DeliveryInformation

Object / Optional

For products that require physical delivery, use this object to send the shipping method.

    ShippingMethod

Object

Details below

      Code String
  System-generated identified for your shipping method configuration

PaymentDetails

Object / Required

 

Adapt this object to the desired payment method.

 

Type

Required (string)

 

 

The payment method:

  • CC (credit/debit card - including local Brazilian cards).
  • ENCRYPTED_PAYMENT_DATA (client-side encryption)
  • PAYPAL
  • PAYPAL_EXPRESS
  • DIRECT_EBANKING (SOFORT)
  • 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.
  • WE_CHAT_PAY (for WeChat payments).
  • IDEAL (for iDEAL payments).
  • PURCHASEORDER - use for orders with POs.
  • FREE – for 0 value orders for which you’re not requiring customers to provide payment details.
  • ALIPAY
  • WEBMONEY
  • GIROPAY
  • UNIONPAY
  • TRUSTLY (for Trustly payments)
  • EES_TOKEN_PAYMENT (2Pay.js)
  • APPLE PAY
  • BOLETO
  • GOOGLE PAY

 

Currency

Required (string)

 

 

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

 

PaymentMethod

Optional (object)

 

 

Object structure and parameters differ according to payment method selected and API method (placing orders (POST) vs. retrieving order data (GET)).

 

NULL for 0 value orders for which you’re not requiring customers to enter payment details.

                                             RecurringEnabled Optional (boolean)
   

true – shopper checks the auto-renewal checkbox and 2Checkout charges subscription renewals using a recurring billing process.

false – shopper doesn’t check the auto-renewal checkbox.

 

 

 

CardPayment

Optional (object)

 

 

 

 

Details below. 

 

 

 

 

CardNumber

Required (string)

 

 

 

 

 

The credit/debit card number.

 

 

 

 

CardType

Required (string)

 

 

 

 

 

visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb, hipercard, elo

 

 

 

 

ExpirationYear

Required (string)

 

 

 

 

 

The year in which the card expires.

 

 

 

 

ExpirationMonth

Required (string)

 

 

 

 

 

The month in which the card expires.

 

 

 

 

HolderName

Required (string)

 

 

 

 

 

Card holder name.

 

 

 

 

CCID

Required (string)

 

 

 

 

 

Credit Card Identification - an extra ID printed on the card, usually a 3-4 digit number, the CVC2/CVV2.

        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.
        HolderNameTime Optional (float)
         

The interval of time in seconds in which shoppers enter their name in the HolderName field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

        CardNumberTime Optional (float)
         

The interval of time in seconds in which shopper enter their card number in the CardNumber field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

 

 

 

 

InstallmentsNumber 

Optional (Int)

 

 

 

 

 

Number of installments. Available only when customers un Brazil pay with Visa or MasterCard using Brazilian Real as the order currency. Use 1 or exclude the parameter for full payments. 

 

 

 

PayPalExpress

Optional (object)

 

 

 

 

Details below. 

 

 

 

 

Email

Optional (string)

 

 

 

 

 

Email address customers use for their PayPal account.

 

 

 

 

ReturnURL

Optional (string)

 

 

 

 

 

The PayPal Express Checkout redirect URL returned by calling the getPayPalExpressCheckoutRedirectURL method. The return URL is the page on your website to which PayPal redirects yourbuyer's browser after the buyer logs into PayPal and approves the payment. Typically, this is a secure page (https://...) on your site.

 

 

 

 

CancelURL

Optional (string)

 

 

 

 

 

The cancel URL is the page on your website to which PayPal redirects your buyer's browser if the buyer does not approve the payment. Typically, this is the secure page (https://...) on your site from which you redirected the buyer to PayPal.

 

 

 

PreviousOrder

Optional (Object)

 

 

 

 

 

Details below. 

 

 

 

 

RefNo

Optional (string)

 

 

 

 

 

Order reference a previous purchase which reached the Approved/Complete status. You can use order for which customers paid with credit/debit cards or with PayPal. The status of order should be AUTHRECEIVED or COMPLETE.

 

Check the validity of references with the isValidOrderReference method.

 

The 2Checkout system blocks you from using references for fraudulent or potentially fraudulent orders.

 

 

 

PurchaseOrderPaymentDetails

Optional (Object)

 

 

 

 

Details below. 

 

 

 

 

InternalPONumber

Optional (string)

 

 

 

 

 

Identifier that business customers use internally in their organization to track and manage Purchase Orders (PO). Can be NULL.

 

 

 

 

AutoApprove

Optional (boolean)

 

 

 

 

 

TRUE - requires activation of the PO AutoApprove package (If the package is inactive 2Checkout returns an error). Please contact 2Checkout. When AutoApprove is TRUE, 2Checkout no longer requires that business customers upload a PO document. As such, PO orders are automatically approved for your account, without a PO doc. 2Checkout sets the PURCHASE_PENDING status for auto-approved PO orders.

FALSE - Default. Send this if the PO AUtoApprove package is not available for your account. 2Checkout uses the same flow as cart purchases with Purchase Orders for business customers placing orders with POs via API. This means that customers receive the same emails as if they made the purchase using the cart and need to update the PO document, which is reviewed by 2Checkout and that you need to approve. 2Checkout sets the AVAITING_UPLOAD status for POs andUnfinished for their orders.

 

Can be NULL.

      WE_CHAT_PAY Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
      IDEAL Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
        BankCode Required (string)
          String contains the SWIFT code of the bank, the plus sign "+", and the first 3 characters from the bank name. E.q.: in the case of Rabobank, code parameter is "RABONL2U+RAB".

 

 

 

EXISTING_PAYMENT_DATA

Optional (Object)

 

 

 

 

By using EXISTING_PAYMENT_DAT you no longer require shoppers to enter any payment details.

 

 

 

 

TransientToken

Optional (string)

 

 

 

 

 

Returned as a part of the process of retrieving customer information by SSOToken.

      TRUSTLY  Optional (string)
        Details below.
        ReturnURL Optional (string)
       

 

The return URL is the page to which your customers are redirected after their successful payment. 

 

CustomerIP

Optional (string)

 

 

Shopper IP.

Promotions

Optional (Array of strings)

 

Array of promotion codes.

AdditionalFields

Object / Optional

 

Details below. 

 

Code

Optional (string)

 

 

The alpha-numeric characters, underscores, and dashes are set as the field identifier.

 

Text

Optional (string)

 

 

Field text visible to shoppers in the cart.

 

Value

Optional (string)

 

 

Selected field value.

LocalTime

Optional (string)

 

Local shopper time in the following format: Y-m-d H:i:s.

This parameter can impact the fraud score of an order when it's missing, NULL, or incorrectly formatted.

GiftDetails

Optional (object)

 

Contains contact details for the recipient of gift purchase.

 

FirstName

Optional (string)

 

 

First name of the gift recipient.

 

LastName

Optional (string)

 

 

Last name of the gift recipient.

 

Email

Optional (string)

 

 

Email of the gift recipient. 2Checkout uses this email for the delivery/fulfillment process.

 

GiftNote

Optional (string)

 

 

Custom text shoppers provide a message to the gift recipient.

Request example (with Credit Card)

<?php

declare(strict_types=1);

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.2checkout.com/soap/6.0';
    public const ACTION = 'placeOrder';
    public const ADDITIONAL_OPTIONS = null;
    //array or JSON
    public const PAYLOAD = <<<JSON
{
    "Currency": "USD",
    "Country": "US",
    "CustomerIP": "91.220.121.21",
    "Source": "testAPI.com",
    "WSOrder": "http://www.myurlfortest.com",
    "ExternalReference": null,
    "BillingDetails": {
        "Address1": "Test Address",
        "City": "London",
        "CountryCode": "US",
        "Email": "customer@2Checkout.com",
        "FirstName": "Customer",
        "LastName": "2Checkout",
        "Phone": "556133127400",
        "State": "DF",
        "Zip": "70403-900"
    },
    "PaymentDetails": {
        "Type": "CC",
        "Currency": "USD",
        "CustomerIP": "91.220.121.21",
        "PaymentMethod": {
            "CCID": "123",
            "CardNumber": "4111111111111111",
            "CardNumberTime": "12",
            "CardType": "Visa",
            "ExpirationMonth": "12",
            "ExpirationYear": "2023",
            "HolderName": "John Doe",
            "HolderNameTime": "12",
            "RecurringEnabled": true,
            "Vendor3DSReturnURL": "www.test.com",
            "Vendor3DSCancelURL": "www.test.com"
        }
    },
    "Items": [
        {
            "Code": "testprod",
            "Quantity": "1"
        }
    ]
}
JSON;
}

class Client
{
    public function call(
        string $url = Configuration::URL,
               $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?object
    {
        if (is_array($payload)) {
            $payload = json_encode($payload);
        }
        if (!empty($payload)) {
            // SoapClient works with objects(StdClass)
            $payload = json_decode($payload);
        }

        $soapClient = $this->getClient($url);
        $sessionId = $this->getSession($soapClient);

        $args = array_filter([$sessionId, $payload]);

        return $soapClient->$action(...$args);
    }

    public function getClient(string $url): SoapClient
    {
        return new SoapClient(
            $url . '?wsdl',
            [
                'location' => $url,
                'cache_wsdl' => WSDL_CACHE_NONE,
            ]
        );
    }

    public function getSession(SoapClient $client)
    {
        $date = gmdate('Y-m-d H:i:s');
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $hash = hash_hmac('md5', $string, $key);
        // $client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
        return $client->login($merchantCode, $date, $hash);
    }
}

try {
    $client = new Client();
    var_dump($client->call());
} catch (Exception $ex) {
    var_dump($ex);
}

 

Create promotion

Overview

Use the addPromotion method to create a new promotion.

Parameters 

Parameter Type/Description
sessionID Required (string)
  Output of the Login method.
Promotion Required (object)
  Promotion object that you want to create.

Response

Parameters Type/Description
Promotion

Object

Contains promotion configuration.

Request

<?php

require ('PATH_TO_AUTH');

$promotionObject = new stdClass;
$promotionObject->Name = 'YOUR_PROMOTION_TITLE';
$promotionObject->Description = 'YOUR_PROMOTION_DESCRIPTION';
$promotionObject->StartDate = date('Y-m-d', strtotime('1 month ago'));
$promotionObject->EndDate = date('Y-m-d', strtotime('+1 month'));
$promotionObject->Type = 'REGULAR';
$promotionObject->Enabled = 1;
$promotionObject->MaximumOrdersNumber = 0;
$promotionObject->MaximumQuantity = 0;
$promotionObject->InstantDiscount = false;
$promotionObject->ChannelType = 'ECOMMERCE';
$promotionObject->ApplyRecurring = 'NONE';
$promotionObject->RecurringChargesNumber = 3;
$promotionObject->PublishToAffiliatesNetwork = 0;
$promotionObject->InstantDiscount = 0;

$couponObject = new stdClass;
$couponObject->Type = 'SINGLE';
$couponObject->Code = 'single_code';
$promotionObject->Coupon = $couponObject;

$discountObj = new stdClass;
$discountObj->Type = 'PERCENT';
$discountObj->Value = 30;
$promotionObject->Discount = $discountObj;
$promotionObject->Products = [$productsObj1, $productsObj2, $productsObj3];
//$promotionObject->Translations = [$translation1, $translation2];

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

$result = callRPC((object)$jsonRpcRequest, $host);
var_dump($result);

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