Skip to main content

Create a product group

Response

bool(true)

Request

<?php

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


function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}

$merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')

$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);

try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}

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


$ProductGroup = new stdClass();
$ProductGroup->Name = 'New Product Group from API';
$ProductGroup->Code = null;//Send null for the Code. 2Checkout generates unique product group code identifiers.
$ProductGroup->TemplateName = 'Default Template';//'001 - Two Column Billing'; //the name of the cart template you want to associate with the product group
$ProductGroup->Description = 'This is a generic description';
$ProductGroup->Enabled = true;


try {
    $NewProductGroup = $client->addProductGroup($sessionID, $ProductGroup);
}

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

var_dump("NewProductGroup", $NewProductGroup);


?>

 

Use Purchase order flow

Overview 

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

Requirements

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

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

Currency support 

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

Parameters 

Parameters Type/Description

sessionID

Required (string)

 

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

Order

Required (Object)

 

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

 

Workflow 

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

Response 

Parameters Type/Description

Order information

Object

Request

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'usd';
$Order->Country = 'US';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->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]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'Test Cosmin API';
$Order->BillingDetails->LastName = 'Cosmin API';
$Order->BillingDetails->CountryCode = 'us';
$Order->BillingDetails->State = 'California';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'cosmin.deftu@2checkout.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = 'ABC Company';
$Order->DeliveryDetails = NULL;


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

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

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

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

Add products to a promotion

Overview

Use the addPromotionProducts API call via SOAP API 4.0 to add products to an existing 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 add products to.

promotionProducts

Required (object)

 

Code

Required (string)

 

 

System-generated product code.

 

pricingConfigurationCode

Optional (string)

 

 

System generated pricing configuration code.

 

pricingOptionCodes

Optional (array of strings)

 

 

Pricing option codes that you control.

Response

Parameter Type/Description
promotionProducts Object

Request

<?php 

class Client
{
    protected static $merchantCode;
    protected static $loginDate;
    protected static $hash;
    protected static $baseUrl;
    protected static $callCount = 0;
    protected static $sessionId = '';

    protected static $client;

    public static function setCredentials($code, $key)
    {
        static::$merchantCode = $code;
        static::$loginDate = gmdate('Y-m-d H:i:s');
        static::$hash = hash_hmac('md5', strlen($code) . $code . strlen(static::$loginDate) . static::$loginDate, $key);
        static::$sessionId = static::login();
    }

    public static function setBaseUrl($url)
    {
        static::$baseUrl = $url;
    }

    public static function login()
    {
        $client = static::getClient();
        return $client->login(static::$merchantCode, static::$loginDate, static::$hash);
    }

    public static function __callStatic($name, $arguments = array())
    {
        $client = static::getClient();

        array_unshift($arguments, static::$sessionId);
        $response = call_user_func_array(array($client, $name), $arguments);

        return $response;
    }

    protected static function getClient()
    {
        $opts = array(
            'http'=> ['user_agent' => 'PHPSoapClient'],
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        );

        if (null === static::$client) {
            static::$client = new \SoapClient(static::$baseUrl . '?wsdl', [
                'location' => static::$baseUrl,
                'cache_wsdl' => WSDL_CACHE_NONE,
                'stream_context' => stream_context_create($opts),
            ]);
        }

        return static::$client;
    }
}

Client::setBaseUrl('https://api.avangate.com/soap/3.1/');
Client::setCredentials('YOUR_MERCHANT_CODE', 'YOUR_SECRET_KEY');
Client::login();

// Define first product to add to promotion
$products1 = new stdClass;
$products1->Code = 'YOUR_PRODUCT_CODE';
$products1->PricingConfigurationCode = 'YOUR_PRICING_CONFIGURATION_CODE';
$products1->PricingOptionCodes = ['code1','code2','code3'];

// Define second product to add to promotion
$products2 = new stdClass;
$products2->Code = 'YOUR_PRODUCT_CODE2';
$products2->PricingConfigurationCode = 'YOUR_PRICING_CONFIGURATION_CODE2';

$promotionProducts = [$products1, products2]; // Array of product objects to be added to the promotion

// Retrieve promotion details
$promotionCode = 'YOUR_PROMOTION_CODE'; // code of the promotion that you want to add products to
$response = Client::addPromotionProducts($promotionCode,$promotionProducts);
var_dump($response);

 

Place an order with WeChat

Overview

Use the placeOrder method to create an order and collect the payment from WeChat.

Requirements

WeChat Pay is available only for orders with a minimum value of 0.01 USD, placed by shoppers in China or Hong Kong and using one of the supported currencies. You're required to include the following text when using Avangate API and to make it visible for your customers in the ordering interface.

Order processed by Avangate, authorized reseller and merchant of the products and services offered within this store. 

Supported currencies

  • CNY
  • USD
  • HKD

Workflow

  1. Shoppers select WeChat as payment option in the interface you provide to them.
  2. Create the order object. Use WE_CHAT_PAY as the type of the PaymentDetails object, and include ReturnURL and CancelURL.
  3. Use the placeOrder method to send the data to Avangate.
  4. Once you place the order, Avangate logs it into the system. At this point in time, the status of the order is PENDING.
  5. Avangate returns an Order object as the output of the placeOrder method. 
  6. Use the PaymentMethod object to create a redirect URL for the shoppers, concatenating the values of the Href and avng8apitoken parameters. Here's an example of the redirect URL:
    https://api.avangate.com/4.0/scripts/we_chat_pay/authorize/?avng8apitoken=1abc7fd72d008428
  7. After being redirected to WeChat Pay, shoppers need to scan the QR code provided, using the WeChat smartphone app.
  8. After customers enter their payment password, WeChat notifies Avangate if the payment is approved, and the status of the order becomes COMPLETE.
  9. Shoppers are redirected to the RedirectURL from the Order information object. In case the payment fails, shoppers are redirected to the CancelURL. 

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 WeChat, use WE_CHAT_PAY as the type of the PaymentDetails object and provide a ReturnURL and a CancelURL as part of the PaymentMethod object. See code sample. 

    Response

    Order information

    Object

    Request

    
    <?php
    
    // authentication script: https://knowledgecenter.avangate.com/Integration/JSON-RPC_API/API_4.0/00Authentication
    
    require ('PATH_TO_AUTH');
    
    $Order = new stdClass();
    $Order->RefNo = NULL;
    $Order->Currency = 'cny';
    $Order->Country = 'cn';
    $Order->Language = 'en';
    $Order->CustomerIP = '91.220.121.21';
    $Order->ExternalReference = NULL;
    $Order->Source = NULL;
    $Order->AffiliateId = NULL;
    $Order->CustomerReference = NULL;
    $Order->Items = array();
    $Order->Items[0] = new stdClass();
    $Order->Items[0]->Code = 'my_subscription_1';
    $Order->Items[0]->Quantity = 1;
    $Order->Items[0]->PriceOptions = NULL;
    $Order->Items[0]->SKU = NULL;
    $Order->Items[0]->Price = NULL;
    $Order->Items[0]->CrossSell = NULL;
    $Order->Items[0]->Trial = false;
    $Order->Items[0]->AdditionalFields = NULL;
    $Order->BillingDetails = new stdClass();
    $Order->BillingDetails->FirstName = 'FirstName';
    $Order->BillingDetails->LastName = 'LastName';
    $Order->BillingDetails->CountryCode = 'CN';
    $Order->BillingDetails->State = 'State Example';
    $Order->BillingDetails->City = 'City Example';
    $Order->BillingDetails->Address1 = 'Address example';
    $Order->BillingDetails->Address2 = NULL;
    $Order->BillingDetails->Zip = '12345';
    $Order->BillingDetails->Email = 'email@address.com';
    $Order->BillingDetails->Phone = NULL;
    $Order->BillingDetails->Company = NULL;
    $Order->PaymentDetails = new stdClass ();
    $Order->PaymentDetails->Type = 'WE_CHAT_PAY';
    $Order->PaymentDetails->Currency = 'cny';
    $Order->PaymentDetails->PaymentMethod = new stdClass ();
    $Order->PaymentDetails->CustomerIP = '91.220.121.21';
    $Order->PaymentDetails->PaymentMethod->ReturnURL = 'YOUR_RETURN_URL';
    $Order->PaymentDetails->PaymentMethod->CancelURL= 'YOUR_CANCEL_URL';
    
    $jsonRpcRequest = new stdClass();
    $jsonRpcRequest->jsonrpc = '2.0';
    $jsonRpcRequest->method = 'placeOrder';
    $jsonRpcRequest->params = array($sessionID, $Order);
    $jsonRpcRequest->id = $i++;
     
    $output = callRPC($jsonRpcRequest, $host);
    
    $wechatredirect = $output->PaymentDetails->PaymentMethod->Authorize->Href."/?avng8apitoken=".$output->PaymentDetails->PaymentMethod->Authorize->Params->avng8apitoken;
    
    header('Location:' . $wechatredirect);
    

    Place an order with PayPal

    Overview

    Use the placeOrder method to create an order and collect the payment from PayPal.

    Requirements

    You're required to include the following text when using Avangate API and to make it visible for your customers in the ordering interface. 

    Order processed by Avangate, authorized reseller and merchant of the products and services offered within this store. 
    

    Currency support

    Check with Avangate support for a list of currencies available for PayPal. 

    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. 

    Workflow

    1. Create the order object. Use PAYPAL as the type of the PaymentDetails object and send the shopper email and a return URL as part of the PaymentMethod object. Place the order.
    2. Once you place the order, Avangate logs it into the system. At this point in time, the status of the order is PENDING. Avangate responds with the Order information object.
    3. Redirect shoppers to the RedirectURL from the Order information object you receive as response from Avangate.
    4. Once shoppers log into their PayPal account and complete the transaction, they're redirected to the ReturnURL you set in the order object. Avangate also authorizes the order and updates the status to AUTHRECEIVED. 

    Response

    Order information

    Object

    Request

    
    <?php
    
    require ('PATH_TO_AUTH');
    
    $Order = new stdClass();
    $Order->RefNo = NULL;
    $Order->Currency = 'usd';
    $Order->Country = 'US';
    $Order->Language = 'en';
    $Order->CustomerIP = '91.220.121.21';
    $Order->ExternalReference = NULL;
    $Order->Source = NULL;
    $Order->AffiliateId = NULL;
    $Order->CustomerReference = NULL;
    $Order->Items = array();
    $Order->Items[0] = new stdClass();
    $Order->Items[0]->Code = 'my_subscription_1';
    $Order->Items[0]->Quantity = 1; 
    $Order->Items[0]->PriceOptions = NULL;
    $Order->Items[0]->SKU = NULL;
    $Order->Items[0]->Price = NULL;
    $Order->Items[0]->CrossSell = NULL;
    $Order->Items[0]->Trial = false; 
    $Order->Items[0]->AdditionalFields = NULL;
    $Order->BillingDetails = new stdClass();
    $Order->BillingDetails->FirstName = 'FirstName';
    $Order->BillingDetails->LastName = 'LastName';
    $Order->BillingDetails->CountryCode = 'us';
    $Order->BillingDetails->State = 'California';
    $Order->BillingDetails->City = 'LA';
    $Order->BillingDetails->Address1 = 'Address example';
    $Order->BillingDetails->Address2 = NULL;
    $Order->BillingDetails->Zip = '90210';
    $Order->BillingDetails->Email = 'email@avangate.com';
    $Order->BillingDetails->Phone = NULL;
    $Order->BillingDetails->Company = NULL;
    $Order->DeliveryDetails = NULL;
    $Order->PaymentDetails = new stdClass ();
    $Order->PaymentDetails->Type = 'PAYPAL';
    $Order->PaymentDetails->Currency = 'usd';
    $Order->PaymentDetails->PaymentMethod = new stdClass ();
    $Order->PaymentDetails->CustomerIP = '10.10.10.10';
    $Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
    $Order->PaymentDetails->PaymentMethod->Email = 'email@avangate.com';
    $Order->PaymentDetails->PaymentMethod->ReturnURL = 'http://YourReturnURL.com';
    $Order->Promotions = NULL;
    $Order->AdditionalFields = NULL;
    $Order->LocalTime = NULL;
    $Order->GiftDetails = NULL;
    
    $jsonRpcRequest = array (
    'method' => 'placeOrder',
    'params' => array($sessionID, $Order),
    'id' => $i++,
    'jsonrpc' => '2.0'
    );
    
    $APIOrderFullInfo = callRPC((Object)$jsonRpcRequest, $host);
        
    $url = $APIOrderFullInfo->PaymentDetails->PaymentMethod->RedirectURL;
    
    header ("Location: $url");
    

    Update pricing configuration

    Overview

    Use the updatePricingConfiguration method to update/edit an existing pricing configuration.

    Parameters

    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.

    PricingConfiguration

    Required (object)

     

    Use this object to update/edit an existing pricing configuration for your account.

    ProductCode

    Required (string)

     

    The unique product code that you control not the system-generated product identifier.

    You cannot modify:

    • The pricing configuration CODE.
    • The PricingSchema from DYNAMIC to FLAT or vice versa.
    • The intervals of an existing pricing configuration (MinQuantity and MaxQuantity).

    Response

    bool(true)
    

    Request

    <?php
    
    $host   = "https://api.avangate.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 = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')
    
    $string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
    $hash   = hmac($key, $string);
    
    try {
        $sessionID = $client->login($merchantCode, $now, $hash);
    }
    
    catch (SoapFault $e) {
        echo "Authentication: " . $e->getMessage();
        exit;
    }
    $PricingConfiguration                                                 = new stdClass();
    $PricingConfiguration->Default                                        = FALSE;
    $PricingConfiguration->Name                                           = 'lnxbc2hls0';
    $PricingConfiguration->BillingCountries                               = array();
    $PricingConfiguration->BillingCountries[0]                            = 'UK';
    $PricingConfiguration->BillingCountries[1]                            = 'DE';
    $PricingConfiguration->PricingSchema                                  = 'DYNAMIC';
    $PricingConfiguration->PriceType                                      = 'NET';
    $PricingConfiguration->DefaultCurrency                                = 'EUR';
    $PricingConfiguration->Prices                                         = new stdClass();
    $PricingConfiguration->Prices->Regular                                = array();
    $PricingConfiguration->Prices->Regular[0]                             = new stdClass();
    $PricingConfiguration->Prices->Regular[0]->Amount                     = 69.09;
    $PricingConfiguration->Prices->Regular[0]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Regular[0]->MinQuantity                = 1;
    $PricingConfiguration->Prices->Regular[0]->MaxQuantity                = 35;
    $PricingConfiguration->Prices->Regular[0]->OptionCodes                = array();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Code       = 'G77ICHEM1C';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[0] = 'zh5onfolw7';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[1] = '75rjldfcnz';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Code       = 'BAWAQB8LZP';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[0] = 'r3oi06opvi';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[1] = '76gqbq4bhd';
    $PricingConfiguration->Prices->Regular[1]                             = new stdClass();
    $PricingConfiguration->Prices->Regular[1]->Amount                     = 64.66;
    $PricingConfiguration->Prices->Regular[1]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Regular[1]->MinQuantity                = 36;
    $PricingConfiguration->Prices->Regular[1]->MaxQuantity                = 83;
    $PricingConfiguration->Prices->Regular[1]->OptionCodes                = array();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Code       = '8RNXV3T3RE';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[0] = 'rorqkqnd9p';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[1] = 'aeu89gqdg6';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Code       = 'DJYD713MKC';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[0] = 'y2z2squ7c1';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[1] = 'g74qfskbjg';
    $PricingConfiguration->Prices->Renewal                                = array();
    $PricingConfiguration->Prices->Renewal[0]                             = new stdClass();
    $PricingConfiguration->Prices->Renewal[0]->Amount                     = 7.89;
    $PricingConfiguration->Prices->Renewal[0]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Renewal[0]->MinQuantity                = 84;
    $PricingConfiguration->Prices->Renewal[0]->MaxQuantity                = 100;
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes                = array();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Code       = '73QCSXYH0E';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[0] = '54xu7mngqm';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[1] = 'p6m8im2unl';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Code       = '0QD0CF0OIE';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[0] = 'ytbac9wpmh';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[1] = 'lpkxxqsqxb';
    $PricingConfiguration->Prices->Renewal[1]                             = new stdClass();
    $PricingConfiguration->Prices->Renewal[1]->Amount                     = 76.99;
    $PricingConfiguration->Prices->Renewal[1]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Renewal[1]->MinQuantity                = 101;
    $PricingConfiguration->Prices->Renewal[1]->MaxQuantity                = 544;
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes                = array();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Code       = '03APF0H4QF';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[0] = '15ce5uw2j6';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[1] = 'e88d5hk0tb';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Code       = 'PT00TYI2VY';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[0] = '10c24smlbl';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[1] = '0ondbwdk3q';
    $PricingConfiguration->PriceOptions                                   = array();
    $PricingConfiguration->PriceOptions[0]                                = new stdClass();
    $PricingConfiguration->PriceOptions[0]->Code                          = 'FKQ8CFLYKM';
    $PricingConfiguration->PriceOptions[0]->Required                      = false;
    $PricingConfiguration->PriceOptions[1]                                = new stdClass();
    $PricingConfiguration->PriceOptions[1]->Code                          = 'TH1HKFOTFR';
    $PricingConfiguration->PriceOptions[1]->Required                      = true;
    
    $ProductCode = '4643199';
    
    try {
        $UpdatedPricingConfiguration = $client->updatePricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
    }
    
    catch (SoapFault $e) {
        echo "UpdatedPricingConfiguration: " . $e->getMessage();
        exit;
    }
    
    var_dump("UpdatedPricingConfiguration", $UpdatedPricingConfiguration);
    
    
    ?>
    

     

    Retrieve 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

    PriceOptionGroup

    Array of objects

    Request

    <?php
    
    $host   = "https://api.2checkout.com";
    $client = new SoapClient($host . "/soap/4.0/?wsdl", array(
        'location' => $host . "/soap/4.0/",
        "stream_context" => stream_context_create(array(
            'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false
            )
        ))
    ));
    
    
    function hmac($key, $data)
    {
        $b = 64; // byte length for md5
        if (strlen($key) > $b) {
            $key = pack("H*", md5($key));
        }
        
        $key    = str_pad($key, $b, chr(0x00));
        $ipad   = str_pad('', $b, chr(0x36));
        $opad   = str_pad('', $b, chr(0x5c));
        $k_ipad = $key ^ $ipad;
        $k_opad = $key ^ $opad;
        return md5($k_opad . pack("H*", md5($k_ipad . $data)));
    }
    
    $merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')
    
    $string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
    $hash   = hmac($key, $string);
    
    try {
        $sessionID = $client->login($merchantCode, $now, $hash);
    }
    
    catch (SoapFault $e) {
        echo "Authentication: " . $e->getMessage();
        exit;
    }
    
    $SearchOptions       = new stdClass();
    $SearchOptions->Name = 'New Users from API';
    
    $SearchOptions->Types = array(
        'INTERVAL',
        'RADIO',
        'COMBO',
        'CHECKBOX'
    ); //RADIO, CHECKBOX, INTERVAL, COMBO, INTERVAL
    
    $SearchOptions->Limit = 10;
    $SearchOptions->Page  = 1;
    
    try {
        $existentPriceOptions = $client->searchPriceOptionGroups($sessionID, $SearchOptions);
    }
    
    catch (SoapFault $e) {
        echo "existentPriceOptions: " . $e->getMessage();
        exit;
    }
    
    var_dump("existentPriceOptionst", $existentPriceOptions);
    
    ?>
    

     

    Update pricing configuration

    Overview

    Use the updatePricingConfiguration method to update/edit an existing pricing configuration.

    Parameters

    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.

    PricingConfiguration

    Required (object)

     

    Use this object to update/edit an existing pricing configuration for your account.

    ProductCode

    Required (string)

     

    The unique product code that you control not the system-generated product identifier.

    You cannot modify:

    • The pricing configuration CODE.
    • The PricingSchema from DYNAMIC to FLAT or vice versa.
    • The intervals of an existing pricing configuration (MinQuantity and MaxQuantity).

    Response

    bool(true)
    

    Request

    <?php
    
    $host   = "https://api.2checkout.com";
    $client = new SoapClient($host . "/soap/4.0/?wsdl", array(
        'location' => $host . "/soap/4.0/",
        "stream_context" => stream_context_create(array(
            'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false
            )
        ))
    ));
    
    
    function hmac($key, $data)
    {
        $b = 64; // byte length for md5
        if (strlen($key) > $b) {
            $key = pack("H*", md5($key));
        }
        
        $key    = str_pad($key, $b, chr(0x00));
        $ipad   = str_pad('', $b, chr(0x36));
        $opad   = str_pad('', $b, chr(0x5c));
        $k_ipad = $key ^ $ipad;
        $k_opad = $key ^ $opad;
        return md5($k_opad . pack("H*", md5($k_ipad . $data)));
    }
    
    $merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')
    
    $string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
    $hash   = hmac($key, $string);
    
    try {
        $sessionID = $client->login($merchantCode, $now, $hash);
    }
    
    catch (SoapFault $e) {
        echo "Authentication: " . $e->getMessage();
        exit;
    }
    $PricingConfiguration                                                 = new stdClass();
    $PricingConfiguration->Default                                        = FALSE;
    $PricingConfiguration->Name                                           = 'lnxbc2hls0';
    $PricingConfiguration->BillingCountries                               = array();
    $PricingConfiguration->BillingCountries[0]                            = 'UK';
    $PricingConfiguration->BillingCountries[1]                            = 'DE';
    $PricingConfiguration->PricingSchema                                  = 'DYNAMIC';
    $PricingConfiguration->PriceType                                      = 'NET';
    $PricingConfiguration->DefaultCurrency                                = 'EUR';
    $PricingConfiguration->Prices                                         = new stdClass();
    $PricingConfiguration->Prices->Regular                                = array();
    $PricingConfiguration->Prices->Regular[0]                             = new stdClass();
    $PricingConfiguration->Prices->Regular[0]->Amount                     = 69.09;
    $PricingConfiguration->Prices->Regular[0]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Regular[0]->MinQuantity                = 1;
    $PricingConfiguration->Prices->Regular[0]->MaxQuantity                = 35;
    $PricingConfiguration->Prices->Regular[0]->OptionCodes                = array();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Code       = 'G77ICHEM1C';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[0] = 'zh5onfolw7';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[1] = '75rjldfcnz';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Code       = 'BAWAQB8LZP';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[0] = 'r3oi06opvi';
    $PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[1] = '76gqbq4bhd';
    $PricingConfiguration->Prices->Regular[1]                             = new stdClass();
    $PricingConfiguration->Prices->Regular[1]->Amount                     = 64.66;
    $PricingConfiguration->Prices->Regular[1]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Regular[1]->MinQuantity                = 36;
    $PricingConfiguration->Prices->Regular[1]->MaxQuantity                = 83;
    $PricingConfiguration->Prices->Regular[1]->OptionCodes                = array();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Code       = '8RNXV3T3RE';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[0] = 'rorqkqnd9p';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[1] = 'aeu89gqdg6';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Code       = 'DJYD713MKC';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[0] = 'y2z2squ7c1';
    $PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[1] = 'g74qfskbjg';
    $PricingConfiguration->Prices->Renewal                                = array();
    $PricingConfiguration->Prices->Renewal[0]                             = new stdClass();
    $PricingConfiguration->Prices->Renewal[0]->Amount                     = 7.89;
    $PricingConfiguration->Prices->Renewal[0]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Renewal[0]->MinQuantity                = 84;
    $PricingConfiguration->Prices->Renewal[0]->MaxQuantity                = 100;
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes                = array();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Code       = '73QCSXYH0E';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[0] = '54xu7mngqm';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[1] = 'p6m8im2unl';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Code       = '0QD0CF0OIE';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[0] = 'ytbac9wpmh';
    $PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[1] = 'lpkxxqsqxb';
    $PricingConfiguration->Prices->Renewal[1]                             = new stdClass();
    $PricingConfiguration->Prices->Renewal[1]->Amount                     = 76.99;
    $PricingConfiguration->Prices->Renewal[1]->Currency                   = 'USD';
    $PricingConfiguration->Prices->Renewal[1]->MinQuantity                = 101;
    $PricingConfiguration->Prices->Renewal[1]->MaxQuantity                = 544;
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes                = array();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Code       = '03APF0H4QF';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options    = array();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[0] = '15ce5uw2j6';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[1] = 'e88d5hk0tb';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]             = new stdClass();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Code       = 'PT00TYI2VY';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options    = array();
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[0] = '10c24smlbl';
    $PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[1] = '0ondbwdk3q';
    $PricingConfiguration->PriceOptions                                   = array();
    $PricingConfiguration->PriceOptions[0]                                = new stdClass();
    $PricingConfiguration->PriceOptions[0]->Code                          = 'FKQ8CFLYKM';
    $PricingConfiguration->PriceOptions[0]->Required                      = false;
    $PricingConfiguration->PriceOptions[1]                                = new stdClass();
    $PricingConfiguration->PriceOptions[1]->Code                          = 'TH1HKFOTFR';
    $PricingConfiguration->PriceOptions[1]->Required                      = true;
    
    $ProductCode = '4643199';
    
    try {
        $UpdatedPricingConfiguration = $client->updatePricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
    }
    
    catch (SoapFault $e) {
        echo "UpdatedPricingConfiguration: " . $e->getMessage();
        exit;
    }
    
    var_dump("UpdatedPricingConfiguration", $UpdatedPricingConfiguration);
    
    
    ?>
    

     

    Assign a product group

    Response

    bool(true)
    

    Request

    <?php
    
    $host   = "https://api.2checkout.com";
    $client = new SoapClient($host . "/soap/4.0/?wsdl", array(
        'location' => $host . "/soap/4.0/",
        "stream_context" => stream_context_create(array(
            'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false
            )
        ))
    ));
    
    
    function hmac($key, $data)
    {
        $b = 64; // byte length for md5
        if (strlen($key) > $b) {
            $key = pack("H*", md5($key));
        }
        
        $key    = str_pad($key, $b, chr(0x00));
        $ipad   = str_pad('', $b, chr(0x36));
        $opad   = str_pad('', $b, chr(0x5c));
        $k_ipad = $key ^ $ipad;
        $k_opad = $key ^ $opad;
        return md5($k_opad . pack("H*", md5($k_ipad . $data)));
    }
    
    $merchantCode = "YOURCODE123"; //your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $key          = "SECRET_KEY"; //your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
    $now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')
    
    $string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
    $hash   = hmac($key, $string);
    
    try {
        $sessionID = $client->login($merchantCode, $now, $hash);
    }
    
    catch (SoapFault $e) {
        echo "Authentication: " . $e->getMessage();
        exit;
    }
    
    $ProductCode = 'AAA4643116';
    $Code = "5C08A761E1";
    
    try {
        $AssignedProductGroup = $client->assignProductGroup($sessionID, $ProductCode, $Code);
    }
    
    catch (SoapFault $e) {
        echo "AssignedProductGroup: " . $e->getMessage();
        exit;
    }
    
    var_dump("AssignedProductGroup", $AssignedProductGroup);
    
    ?>
    

     

    Use Credit cards

    Overview

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

    Parameters 

    Parameters Type/Description

    sessionID

    Required (string)

     

    Session identifier, the output of the Login method. Include sessionID into all your requests. 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.

    Requirements 

    For credit card orders placed using API 5.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 password to trigger the completion of the charge. By using 3D Secure, you get additional protection from liability for fraudulent card payments, with customers having to go through an extra layer of authentication. Send the following parameters 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.

    Response 

    Parameters Type/Description

    Order information

    Object

      Object containing order information.

    Request

    <?php
    
    require ('PATH_TO_AUTH');
    
    $Order = new stdClass();
    $Order->Currency = "USD";
    $Order->Language = "EN";
    $Order->Country = "US";
    $Order->CustomerIP = '91.220.121.21';//"10.10.13.37";
    $Order->Source = "sourceAPI.net";
    $Order->LocalTime = date('Y-m-d H:i:s');
    $Order->CustomerReference = 421820775;
    $Order->Items = array();
    
    /**
    * 1st Product
    */
    $Order->Items[0] = new stdClass();
    $Order->Items[0]->Code = null;
    $Order->Items[0]->Quantity = 2;
    $Order->Items[0]->PurchaseType = 'PRODUCT';
    $Order->Items[0]->Tangible = false; // physical
    $Order->Items[0]->IsDynamic = true;
    
    $Order->Items[0]->Price = new stdClass();
    $Order->Items[0]->Price->Amount = 100;
    $Order->Items[0]->Price->Type = 'CUSTOM';
    
    $Order->Items[0]->Name = 'Dynamic Product 1 '. date("Y-m-d H:i:s");
    $Order->Items[0]->Description = 'Description Produs OTF';
    
    $Order->Items[0]->PriceOptions = [];
    $priceOption = new stdClass();
    $priceOption->Name = 'Name';
    $priceOption->Value = 'Value';
    $priceOption->Surcharge = 10;
    $Order->Items[0]->PriceOptions[] = $priceOption;
    
    $priceOption1 = new stdClass();
    $priceOption1->Name = 'Name';
    $priceOption1->Value = 'Value123';
    $priceOption1->Surcharge = 11;
    $Order->Items[0]->PriceOptions[] = $priceOption1;
    
    $priceOption2 = new stdClass();
    $priceOption2->Name = 'Name1';
    $priceOption2->Value = 'Value1';
    $priceOption2->Surcharge = 12;
    $Order->Items[0]->PriceOptions[] = $priceOption2;
    
    $Order->Items[0]->RecurringOptions = new stdClass();
    $Order->Items[0]->RecurringOptions->CycleLength = 1;
    $Order->Items[0]->RecurringOptions->CycleUnit = 'MONTH';
    $Order->Items[0]->RecurringOptions->CycleAmount = 1234;
    $Order->Items[0]->RecurringOptions->ContractLength = 3;
    $Order->Items[0]->RecurringOptions->ContractUnit = 'YEaR';
    
    //$Order->Items[0]->SubscriptionStartDate = '2017-10-22 12:34:56'; set a custom start date for the subscription
    
    /**
    * 3rd Product - SHIPPING
    */
    $Order->Items[2] = new stdClass();
    $Order->Items[2]->Name = 'Shipping Item '. date("Y-m-d H:i:s");
    $Order->Items[2]->PurchaseType = 'SHIPPING';
    $Order->Items[2]->Quantity = 1;
    $Order->Items[2]->Price = new stdClass();
    $Order->Items[2]->Price->Amount = 123;
    $Order->Items[2]->IsDynamic = true;
    
    /**
    * 4th Product - TAX
    */
    $Order->Items[3] = new stdClass();
    $Order->Items[3]->Name = 'Tax Item '. date("Y-m-d H:i:s");
    $Order->Items[3]->PurchaseType = 'TAX';
    $Order->Items[3]->Quantity = 1;
    $Order->Items[3]->Price = new stdClass();
    $Order->Items[3]->Price->Amount = 456;
    $Order->Items[3]->IsDynamic = true;
    $Order->Items[3]->RecurringOptions = new stdClass();
    $Order->Items[3]->RecurringOptions->CycleLength = 1;
    $Order->Items[3]->RecurringOptions->CycleUnit = 'MONTH';
    $Order->Items[3]->RecurringOptions->CycleAmount = 10.2;
    $Order->Items[3]->RecurringOptions->ContractLength = 3;
    $Order->Items[3]->RecurringOptions->ContractUnit = 'YEaR';
    
    /**
    * 5th Product - COUPON
    */
    $Order->Items[4] = new stdClass();
    $Order->Items[4]->Name = 'Coupon Item '. date("Y-m-d H:i:s");
    $Order->Items[4]->PurchaseType = 'COUPON';
    $Order->Items[4]->Quantity = 1;
    $Order->Items[4]->Price = new stdClass();
    $Order->Items[4]->Price->Amount = 234;
    $Order->Items[4]->IsDynamic = true;
    
    /**/
    $additionalField1 = new stdClass();
    $additionalField1->Code = "additional_field_order_1";
    $additionalField1->Text = "REST";
    $additionalField1->Value = "1";
    
    $additionalField2 = new stdClass();
    $additionalField2->Code = "additional_field_order_2";
    $additionalField2->Text = "REST";
    $additionalField2->Value = "a";
    
    $additionalField3 = new stdClass();
    $additionalField3->Code = "additional_field_order_3";
    $additionalField3->Text = "REST";
    $additionalField3->Value = "a";
    
    $Order->AdditionalFields = array();
    $Order->AdditionalFields[0] = $additionalField1;
    $Order->AdditionalFields[1] = $additionalField2;
    $Order->AdditionalFields[2] = $additionalField3;
    
    $additionalField1 = new stdClass();
    $additionalField1->Code = "REST";
    $additionalField1->Text = "REST";
    $additionalField1->Value = "REST";
    
    
    
    $Order->MachineId = 'machineIdTestDan';
    $Order->Discount = null;
    $Order->ExternalReference = null;
    
    $Order->BillingDetails = new stdClass();
    $Order->BillingDetails->Address1 = 'API BILL';
    $Order->BillingDetails->Address2 = 'API BILL2';
    $Order->BillingDetails->City = 'London';
    $Order->BillingDetails->State = 'Greater London';
    $Order->BillingDetails->CountryCode = 'UK';
    $Order->BillingDetails->Phone = 12345;
    $Order->BillingDetails->Email = 'shopper@avangate.com';//"mail463@aPpLe.com";//
    $Order->BillingDetails->FirstName = 'First Name Bil';
    $Order->BillingDetails->LastName = 'Last Name Bil';
    $Order->BillingDetails->Company = 'Api Company';
    $Order->BillingDetails->Zip = '12345';
    $Order->BillingDetails->FiscalCode = 13205628845;
    
    /**/
    $Order->DeliveryDetails = new stdClass();
    $Order->DeliveryDetails->Address1 = 'Api Del';
    $Order->DeliveryDetails->Address2 = 'Api Del2';
    $Order->DeliveryDetails->City = 'Api City Del';
    $Order->DeliveryDetails->State = 'Paris';
    $Order->DeliveryDetails->CountryCode = 'US';
    $Order->DeliveryDetails->Phone = '12345';
    $Order->DeliveryDetails->Email = 'deli@email.com';
    $Order->DeliveryDetails->FirstName = 'Api First Name Del';
    $Order->DeliveryDetails->LastName = 'Api Last Name Del';
    $Order->DeliveryDetails->Zip = 12345;
    /**/
    
    $Order->PaymentDetails = new stdClass ();
    $Order->PaymentDetails->Type = 'CC';
    $Order->PaymentDetails->Currency = 'usd';
    $Order->PaymentDetails->PaymentMethod = new stdClass ();
    $Order->PaymentDetails->CustomerIP = '10.10.10.10';
    $Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
    $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';
    $Order->PaymentDetails->PaymentMethod->CardNumberTime = 83.21; // can be null - high value in seconds is a red flag for fraud attempts.
    $Order->PaymentDetails->PaymentMethod->HolderNameTime = 13.35; // can be null - high value in seconds is a red flag for fraud attempts.
    $Order->PaymentDetails->PaymentMethod->Vendor3DSReturnURL = "http://www.success.ro"; 
    $Order->PaymentDetails->PaymentMethod->Vendor3DSCancelURL = "http://www.error.ro"; 
    
    $Order->AdditionalFields = NULL;
    $Order->LocalTime = NULL;
    $Order->GiftDetails = NULL;
    
    try {
        $newOrder = $client->placeOrder($sessionID, $Order);
    }
    catch (SoapFault $e) {
        echo "newOrder: " . $e->getMessage();
        exit;
    }
    
    var_dump("newOrder", $Order);
    

    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