For the complete documentation index, see llms.txt. This page is also available as Markdown.

Place order with custom subscription settings

Use the placeOrder method to create an order using custom subscription settings via JSON-RPC API 6.0.

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

Required (object)

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

Request sample

<?php
$Order = new \stdClass();
$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;

// Don't forget about B2B flag
$Order->ExtraInformation = new \stdClass();
$Order->ExtraInformation->B2B = true;

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

// Subscription custom settings
$Order->Items[0]->SubscriptionCustomSettings = new \stdClass();
$Order->Items[0]->SubscriptionCustomSettings->ContractLength = "123";
$Order->Items[0]->SubscriptionCustomSettings->CycleAmountType = "NET";
$Order->Items[0]->SubscriptionCustomSettings->CycleUnit = "DAY";
$Order->Items[0]->SubscriptionCustomSettings->CycleAmount = "123";
$Order->Items[0]->SubscriptionCustomSettings->CycleLength = "123";
$Order->Items[0]->SubscriptionCustomSettings->MerchantDealAutoRenewal = true;
$Order->Items[0]->SubscriptionCustomSettings->ClientDealAutoRenewal = true;

$Order->BillingDetails = new \stdClass();
$Order->BillingDetails->FirstName = 'First';
$Order->BillingDetails->LastName = 'Last';
$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@address.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;

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

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

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

Response parameters

Parameter
Type / Description

Object

Object that includes all data necessary for an order, including billing, product/subscription plan, and payment details.

Last updated

Was this helpful?