Set partner invoice payment details (PayPal payment)
Overview
Requirements
Parameters
Response
Request
<?php
require ('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication
require ('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/Partner/00Set_partner
require ('PATH_TO_setProforma'); // setProforma example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/14Billing/00Capture_card_payment/00Set_partner_invoice
$paymentDetails = new stdClass();
$paymentDetails->Type = 'PAYPAL';
$paymentDetails->Curency = 'YOUR_CURRENCY';
$paymentDetails->CustomerIP = 'CUSTOMER_IP';
$paymentDetails->PaymentMethod = new stdClass();
$paymentDetails->PaymentMethod->Email = 'YOUR_PAYPAL_EMAIL';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'setPaymentDetails',
'params' => array($sessionID, $paymentDetails)
);
var_dump (callRPC((Object)$jsonRpcRequest,$host));
Errors
Add promotion translations
Overview
Use the addPromotionTranslations method via SOAP API 4.0 to add localized texts to existing promotions.
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 translations to. |
|
promotions |
Required (array of PromotionTranslations objects) |
|
PromotionTranslations | Object | |
|
language |
Required (string) |
|
|
ISO country code corresponding to the country you want to set the translation for. |
|
name |
Required (string) |
|
|
Localized promotion name applicable to the selected country. |
Response
Parameters | Type/Description | |
---|---|---|
promotionTranslation |
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();
$promotionCode = 'YOUR_PROMOTION_CODE'; // code of the promotion that you want to update
// Defining a translation for German shoppers
$promotionTranslation1 = new stdClass;
$promotionTranslation1->Language = 'de';
$promotionTranslation1->Name = 'YOUR_GERMAN_PROMOTION_NAME';
// Defining a translation for Bulgarian shoppers
$promotionTranslation2 = new stdClass;
$promotionTranslation2->Language = 'bg';
$promotionTranslation2->Name = 'YOUR_BULGARIAN_PROMOTION_NAME';
$translations = [$promotionTranslation1, $promotionTranslation2];
$response = Client::addPromotionTranslations($promotionCode,$translations); // Add translations to selected promotions
var_dump($response);
Add a pricing configuration
Overview
Use the addPricingConfiguration method to add a new pricing configuration for your account.
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 add a new pricing configuration for your account. |
ProductCode |
Required (string) |
|
The code of the product you assign the configuration to. |
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 = True;
$PricingConfiguration->Name = 'New Pricing Configuration Through API';
$PricingConfiguration->BillingCountries = array();
$PricingConfiguration->BillingCountries[0] = 'RO';
$PricingConfiguration->BillingCountries[1] = 'DE';
$PricingConfiguration->PricingSchema = 'DYNAMIC';
$PricingConfiguration->PriceType = 'NET';
$PricingConfiguration->DefaultCurrency = 'USD';
$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 = 'API_Imported_123456';
try {
$NewPricingConfiguration = $client->addPricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
}
catch (SoapFault $e) {
echo "NewPricingConfiguration: " . $e->getMessage();
exit;
}
var_dump("NewPricingConfiguration", $NewPricingConfiguration);
?>
Retrieve the upgrade price for a subscription
Overview
Use the getProductUpgradeOptionsPrice method to retrieve information about the costs a customer incurs when upgrading a specific subscription. Retrieve information about the costs a customer incurs when upgrading a specific subscription.
Parameters
Parameters |
Type/Description |
sessionID |
Required (string) |
|
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes. |
SubscriptionReference |
Required (string) |
Unique, system-generated subscription identifier. |
|
ProductCode |
Required (string) |
|
Unique identifier of the target product for the subscription upgrade process. You control the product code and can set it up in the Control Panel. |
Currency |
Required (string) |
|
ISO 4217 code. |
Options |
Required (string) |
|
Pricing options of the target product for the subscription upgrade process.
String - ';' separated list of 'OptionValue' returned by getProductUpgradeOptions function. If the pricing options groups is "scale" (interval), the Options parameter should be sent like this: [option group unique code] + "=" + value e.g. Users=7 |
Response
Object |
Request
<?php
$host = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/6.0/?wsdl", array(
'location' => $host . "/soap/6.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.2checkout.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.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;
}
$subscriptionReference = '30E47F8699';
$productCode = 'my_subscription_123';
$Currency = 'usd';
$Options = 'emailsupport;oneuser1';
try {
$upgradeOptions = $client->getProductUpgradeOptionsPrice($sessionID, $subscriptionReference, $productCode, $Currency, $Options);
}
catch (SoapFault $e) {
echo "upgradeOptions: " . $e->getMessage();
exit;
}
var_dump("upgradeOptions", $upgradeOptions);
Retrieve upgrade options for a subscription
Overview
Use the getProductUpgradeOptions method to retrieve the possible upgrade options for a subscription.
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. |
Response
Parameters | Type/Description |
---|---|
Array of objects |
Request
<?php
require ('PATH_TO_AUTH');
$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$jsonRpcRequest = array (
'method' => 'getProductUpgradeOptions',
'params' => array($sessionID, $subscriptionReference),
'id' => $i++,
'jsonrpc' => '2.0');
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
Disable a subscription
Overview
Use the cancelSubscription method to disable an active subscription. 2Checkout disables the subscription immediately and no longer performs any recurring billing actions.
Parameters
Parameters | Type/Description |
---|---|
sessionID |
Required (string) |
|
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes. |
SubscriptionReference |
Required (string) |
Unique, system-generated subscription identifier. |
Response
Parameters | Type/Description |
---|---|
Boolean |
true or false depending on whether the call resulted in success or not. |
Request
<?php
require ('PATH_TO_AUTH');
$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
try {
$disableSubscription = $client->cancelSubscription($sessionID, $subscriptionReference);
}
catch (SoapFault $e) {
echo "disableSubscription: " . $e->getMessage();
exit;
}
var_dump("disableSubscription", $disableSubscription);
Add a pricing configuration
Overview
Use the SOAP API 4 addPricingConfiguration method to add a new pricing configuration for your account.
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 add a new pricing configuration for your account. |
ProductCode |
Required (string) |
|
The code of the product you assign the configuration to. |
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 = True;
$PricingConfiguration->Name = 'New Pricing Configuration Through API';
$PricingConfiguration->BillingCountries = array();
$PricingConfiguration->BillingCountries[0] = 'RO';
$PricingConfiguration->BillingCountries[1] = 'DE';
$PricingConfiguration->PricingSchema = 'DYNAMIC';
$PricingConfiguration->PriceType = 'NET';
$PricingConfiguration->DefaultCurrency = 'USD';
$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 = 'API_Imported_123456';
try {
$NewPricingConfiguration = $client->addPricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
}
catch (SoapFault $e) {
echo "NewPricingConfiguration: " . $e->getMessage();
exit;
}
var_dump("NewPricingConfiguration", $NewPricingConfiguration);
?>
Add translations
Overview
Use the addPromotionTranslations method to add localized texts to existing promotions.
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 translations to. |
|
promotions |
Required (array of PromotionTranslations objects) |
|
PromotionTranslations | Object | |
|
language |
Required (string) |
|
|
ISO country code corresponding to the country you want to set the translation for. |
|
name |
Required (string) |
|
|
Localized promotion name applicable to the selected country. |
Response
Parameters | Type/Description | |
---|---|---|
promotionTranslation |
Object |
Request
<?php
require ('PATH_TO_AUTH');
// Promotion code corresponding to the promotion you want to add translations to
$promotionCode = '';
// Defining a translation for German shoppers
$promotionTranslation1 = new stdClass;
$promotionTranslation1->Language = 'de';
$promotionTranslation1->Name = 'YOUR_GERMAN_PROMOTION_NAME';
// Defining a translation for Bulgarian shoppers
$promotionTranslation2 = new stdClass;
$promotionTranslation2->Language = 'bg';
$promotionTranslation2->Name = 'YOUR_BULGARIAN_PROMOTION_NAME';
$translations = [$promotionTranslation1, $promotionTranslation2];
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addPromotionTranslations',
'params' => array($sessionID, $promotionCode, $translations)
);
var_dump (callRPC($jsonRpcRequest, $host));
Order flow in 2Checkout API
Overview
Order flow in the 2Checkout system is complex no matter what type of integration you choose. Find out more information below on order lifecycle, order statuses, chargeback flow, and user interfaces.
Order lifecycle
Order statuses
Order status
The overall status of an order in the 2Checkout systems.
Status value | Description |
---|---|
PENDING |
2Checkout has yet to block the amount corresponding to the transaction or shoppers used an offline payment method like a wire transfer. |
AUTHRECEIVED |
2Checkout blocks the amount corresponding to the transaction, but the process of collecting funds is incomplete. |
COMPLETE |
The shopper completed the transaction for the purchase and 2Checkout or you fulfilled the order (when required). |
REVERSED |
Payment authorization has been reversed due to being flagged as potentially fraudulent but the order has not been canceled. The shopper can retry payment in order to complete the order. |
REFUND |
2Checkout refunds orders only after they reach the Complete/Finished stage and returns the funds collected to shoppers.
|
CANCELED |
Order has been canceled by the merchant (for partner orders) or by 2Checkout (order not paid when offline payment methods are used). |
PENDING |
2Checkout has yet to block the amount corresponding to the transaction or shoppers used an offline payment method like a wire transfer. |
Merchant Approve Status
Shows if the merchant has approved or not a partner order.
Merchant approve status | Description |
---|---|
OK |
Order approved. |
WAITING |
Order is awaiting a decision. While it depends on the load on the Fraud flow, orders get approved within a matter of minutes. |
REJECTED |
Order canceled. |
Approve Status
The status of the order resulted from the evaluation by the 2Checkout anti-fraud system or by a member of the anti-fraud department. This status varies for new purchases and for orders requiring customers to make manual payments.
Usually, an order will be approved anywhere between a few seconds to a couple of minutes. The approval time depends on a few factors, like the data provided by the shopper (that is used to calculate the risk score), as well as the “age” of the merchant. In the first month, the orders of a new merchant will take a little longer to be authorized by the Risk team.
Approve Status Values | Description |
---|---|
WAITING |
The 2Checkout Anti-Fraud System or a member of the Anti-Fraud Department has yet to approve the order. |
INVALIDATA |
Shopper-supplied data is invalid – 2Checkout did not approve the order. |
FRAUD |
The 2Checkout Anti-Fraud System or a member of the Anti-Fraud Department has flagged the order as being fraudulent. Usually, there is nothing the merchant can do. The 2Checkout Risk department will contact the shopper in order to confirm the order. If the shopper confirms the order, then the status is updated to OK. |
OK |
The 2Checkout Anti-Fraud System or a member of the Anti-Fraud Department approved the order. |
Chargeback flow
Chargebacks are shopper requests for funds reversal made directly to the bank/PayPal, possible only if the payment was made using a credit/debit card or PayPal. As a rule of thumb, buyers contact their credit card bank/issuer or PayPal directly to initiate a chargeback. You can read more on chargebacks here.
Chargeback Resolution
Chargeback Resolution Status | Description |
---|---|
OPEN |
A chargeback has been raised on the order and is in progress. |
WON |
The chargeback raised on the order has been won by the merchant. |
LOST |
The chargeback raised on the order has been won by the shopper. |
ACCEPTED |
The chargeback process has been closed. The merchant agreed to repay the value of the order to the customer |
User Interfaces
Merchant Control Panel
The Merchant Control Panel Dashboard acts as a homepage and comes with a wide array of functionalities that allow live monitoring of the main business metrics, customization, and extended reporting capabilities.
While working on your integration, the Merchant Control Panel offers an easy-to-use interface for debugging and testing your integration.
Shopping Carts
Several cart options are available, based on the required use cases needed and desired behavior.
ConvertPlus is the newest and main cart in the 2Checkout system. ConvertPlus simplifies the process of collecting payments from shoppers using major credit/debit cards as well as localized payment methods and can be used in sync with the API for managing the product catalog, fetching order information, and more.
The InLine Checkout acts as an iframe that opens on your website, enabling you to receive payments without redirecting your customers to a third-party checkout. Inline Checkout integrates ideally with shopping cart applications that collect customer billing and shipping information, allowing you to pass that information over to the cart and minimize customer's efforts during the payment process.
API
The 2Checkout Public API is the main interface for interacting with the 2Checkout systems in a programmatic way. Offering a wide range of functionality, the API is available in a number of protocols and versions.
Webhooks
2Checkout generates automatic notifications for transaction and subscription/license change events which it sends to a location on your server you control via Webhooks.
Using these webhooks, you can perform backend tasks including provisioning, entitlement, customer, and subscription lifecycle management.
The available webhooks are:
- IPN (Instant Payment Notification) - triggered on purchase and transaction events like payment authorization, refunds, or chargebacks.
- LCN (License Change Notifications) - triggered for subscription lifecycle events like renewal, expiration, or upgrade.
- INS (Instant Notification Service) - triggered on order events, used automate order management processes by accepting order information via web posts
Depending on the order status, approval status, and order flow, there are different ways these map to the IPN status:
IPN Message Type | Merchant Control Panel Trigger | Order Status | Description |
---|---|---|---|
PENDING |
Pending orders. |
PENDING |
The shopper places the order. 2Checkout is waiting for bank authorization. |
PENDING |
Pending orders. |
PURCHASE_PENDING |
Shopper places the order using a Purchase Order (PO). 2Checkout approves the PO document and you also approve the PO document. The shopper has yet to finalize the payment. |
PROCESSING |
Orders waiting to be processed by the 2Checkout system. |
PENDING_APPROVAL |
Order is waiting for the 2Checkout system to process it or for anti-fraud review. |
APPROVED |
Authorized and approved orders (sent before electronic delivery). |
PAYMENT_AUTHORIZED |
The bank authorized the payment. |
APPROVED |
Authorized and approved orders (sent before electronic delivery). |
PAYMENT_RECEIVED |
2Checkout sends a notification when it receives payments for offline orders (e.g. Bank/Wire transfer) but only before fulfillment/delivery. |
APPROVED |
Authorized and approved orders (sent before electronic delivery). |
PENDING_ORDER_APPROVAL |
2Checkout sends this status for products/subscriptions configured with the “Requires delivery confirmation” setting. |
AUTH |
Authorized and approved orders (sent after electronic delivery). |
PAYMENT_AUTHORIZED |
The bank authorized the payment. |
AUTH |
Authorized and approved orders (sent after electronic delivery). |
COMPLETE |
2Checkout marks the order as finished and fulfilled. |
APPROVED_DELIVERY |
Order approved for delivery. |
PAYMENT_AUTHORIZED |
You approved an order for fulfillment/delivery. |
COMPLETE |
Completed orders. |
COMPLETE |
2Checkout marks the order as finished and fulfilled. |
COMPLETE |
Completed orders. |
COMPLETE |
The customer pays the PO. |
ORDER_UNDER_REVIEW |
Orders under 2Checkout review. |
PENDING_APPROVAL |
Order is waiting for the 2Checkout system to process it or for anti-fraud review. |
SHOPPER_INVOICE |
Invoice generated. |
COMPLETE |
2Checkout marks the order as finished and fulfilled. |
SUSPECT |
Fraud suspect. |
SUSPECT |
The 2Checkout Risk department is reviewing the order for possible fraud. (Not available by default, contact 2Checkout directly to enable it) |
CANCELED |
Canceled orders. |
CANCELED |
The 2Checkout system can send out notifications for: |
CHARGEBACK_OPEN |
Chargeback open. |
COMPLETE |
ORDERSTATUS is COMPLETE for chargebacks. 2Checkout details information about disputes in the CHARGEBACK_RESOLUTION and CHARGEBACK_REASON_CODE fields. |
CHARGEBACK_CLOSED |
Chargeback closed. |
COMPLETE |
ORDERSTATUS is COMPLETE for chargebacks. 2Checkout details information about disputes in the CHARGEBACK_RESOLUTION and CHARGEBACK_REASON_CODE fields. |
REFUND |
Reversed and refund orders. |
REVERSED |
2Checkout reverses transactions and releases funds back to shoppers for Authorized payments that never reach the Complete status. |
REFUND |
Reversed and refund orders. |
REFUND |
2Checkout repays funds back to shoppers for Complete orders. |
PURCHASE_PENDING |
Approved |
PURCHASE_PENDING |
You approve the PO document. |
PURCHASE_REJECTED_BY_VENDOR |
Rejected |
CANCELED |
You reject the PO document. |
PURCHASE_COMPLETE |
Completed |
COMPLETE |
The customer pays the PO. |
PURCHASE_EXPIRED_NOT_PAID |
Expired, not paid |
CANCELED |
You don’t approve nor reject the PO within a time interval. |
PURCHASE_CANCELED_TIMEOUT |
Canceled |
CANCELED |
You cancel the PO or 2Checkout cancels the order. |
PENDING_APPROVAL_ORDER_FOR_PARTNER |
Pending approval orders from partners. |
PENDING |
Resellers place orders that await your approval. |
VENDOR_APPROVED |
Approved orders from partners. |
PENDING |
You approve partner orders. |
DELIVERED_ORDER_FOR_PARTNER |
Delivered orders from partners. |
PENDING |
2Checkout fulfills partner orders. |
ORDER_SHIPPED |
Order shipped (only for tangible products) |
PAYMENT_AUTHORIZED |
You marked the order as shipped, and the delivery process has started. |
INVALID |
Invalid orders |
INVALID |
Shopper provides invalid billing and/or delivery information. (Not available by default, contact 2Checkout directly to enable it) |
2Checkout also provides the following webhooks:
- IDN (Instant Delivery Notification) - triggered on order events, used to automate the confirmation of order fulfillment and delivery to 2Checkout.
- IRN (Instant Refund Notification) - triggered for order refunds and reversals.
- ISE (Instant Order Search Export) - used to export order data for your account from the 2Checkout platform.
You can read the complete information about webhooks here.