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

Use UniTokens

Use the placeOrder method to create an order using products defined in your Control Panel and collect the payment using a previously issued UniToken instead of full card details.

A UniToken represents a card that has already been used successfully by a customer. Pass its ID in PaymentDetails.UniToken with PaymentDetails.Type set to UNITOKEN. If the order is instead authorized with raw card details and the card matches an existing UniToken for the same customer (same first 4 and last 4 digits, on the same CustomerReference / ExternalCustomerReference), the system updates that existing UniToken with the new order reference rather than creating a new one.

Use listUniTokens to retrieve the tokens available for a customer before placing an order this way.

Request parameters

Parameter
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
require ('PATH_TO_AUTH');
$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;
$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 = '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 = 'UNITOKEN';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->UniToken = '6e9cbf02-35f3-4c8e-b409-89807a78d79d';
$Order->PaymentDetails->RecurringEnabled = true;
$Order->PaymentDetails->Vendor3DSReturnURL = "http://www.success.ro";
$Order->PaymentDetails->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 containing order information.

Last updated

Was this helpful?