InceptDomainFromCppSdk

Note: This method is necessary for switching the domain subscriptions management from domain plugins developed based on Domain SDK (C++) to domain plugins developed based on the present Domain SDK (PHP). This method is invoked by one of the methods of a special domain SDK migration scripts package and must be built in the target domain plugins developed based on the present Domain SDK (PHP). For more information refer to Operations Provider's Guide.

%Plugin_Name%_InceptDomainFromCppSdk

Purpose

This method converts domain data sets used by a given domain plugin developed based on Domain SDK (C++) to the corresponding domain data sets used by domain plugins developed based on the present Domain SDK (PHP).

Input Parameters

$params – associative array of ('key','value') structures, namely: dictionary of ('additionalfields','sub-dictionary') pairs, where the 'sub-dictionary' contains a single ('data','JSON string') pair, where the 'JSON string' is a structure of these parameters:

  • domain_id – domain ID in Billing.
  • tld – top-level domain name.
  • sld – second-level domain name.
  • original_registrar – C++ domain plug-in instance name in Billing.
  • full_domain_name – concatenated SLD and TLD (sld + "." + tld).
  • registrar_id – C++ domain plug-in instance ID in Billing.
  • registration_date – domain registration date in the UNIX format
  • subscription – structure representing domain subscription (associative array of type 'key' => 'value' – only strings allowed for both key and value):
    • subscription_id – subscription ID in CloudBlue Commerce
    • start_date – date when subscription started (UNIX format)
    • expiration_date – date when subscription expires (UNIX format)
    • expired_at – date when subscription expired (UNIX format)
    • period – how long the subscription has been active since last renewal (units of measure are defined by period_type – see below)
    • period_type – units of measure for period (1 – days, 2 – months, 3 – years)
  • ext_data – supplementary plugin-specific data for domain processing by the original C++ domain plug-in.

Return Parameters

  • additionalfields – the converted domain subscription data (associative array of type 'key' => 'value' – only strings allowed for both key and value).

Mandatory

No. This method is necessary only for switching the domain subscriptions management from domain plugins developed based on Domain SDK (C++) to domain plugins developed based on the present Domain SDK (PHP).

Example 1

Simple switching (the additionalfields parameter does not pass any data, which means that there is no additional data to be converted).

public function Example_inceptDomainFromCppSdk($params) {
        $domainData = json_decode($params['additionalfields']['data'], TRUE);
 		
 	// simply propagate existing extData back to CloudBlue Commerce
        return array(
            "additionalfields" => $domainData['ext_data']
        );
    } 

Example 2

Complex switching (with additionally converting some extra data passed by the additionalfields parameter and/or some data from an external source). In this example, the following domain data structure (passed by the $domainData parameter via a JSON string) is assumed:

{
     "domain_id": 3,
     "tld": "org",
     "sld": "rlbenson12345",
     "original_registrar": "Enom",
     "full_domain_name":"rlbenson12345.org",
     "registrar_id": 6,
     "registration_date": 1477904045,
     "account":{
         "id":1000001,
         "name":"Acme ltd.",
         "latin_name":""
      }
     "subscription":{
         "subscription_id":1000003,
         "start_date":1477861200,
         "expiration_date":1509397200,
         "expired_at":null,
         "period":1,
         "period_type":3 }
     "ext_data":{
         "DomainID":"rlbenson12345.org",
         "OrderID":"162119950",
         "OrderOperationType":"10",
         "Password":"szfE4t0lGMW",
         "TransferKey":""}
}

The method can be implemented in a PHP domain plug-in in the following way:

public function Example_inceptDomainFromCppSdk($params) {
        $domainData = json_decode($params['additionalfields']['data'], TRUE);
        $extData = $domainData['ext_data'];
 
 	// names of supported C++ plug-ins
        $allowedRegNames = array(
            "Example",
            "Example_common",
            "example_vip_customers");
 
        // Check if C++ registrar plug-in is suitable for converting
        $origRegName = $domainData['original_registrar'];
        if (!in_array($origRegName, $allowedRegNames)) {
            $domainName = $extData['DomainID'];
            return array('error' => "Converting ext data for domain '$domainName' has failed - wrong original registrar.");
        }
 
        // Matching parts - field values mapped as is, without data transformation
        $newExtData = array();
        $newExtData['DomainID'] = $extData['DomainID'];
        $newExtData['OrderID'] = $extData['OrderID'];
        $newExtData['TransferKey'] = $extData['TransferKey'];
 
        // Converting part - data transformation
        $newExtData['eng_domain'] = '1'; // adding brand new extData field
        $newExtData['IDNCode'] = $extData['IDNCode'] == null ? “" : (string)$extData['IDNCode'];   // converting the value of an existing field
        $newExtData['expirydate'] = convertExpirationDate($domainData['subscription']['expiration_date']);  // adding new extData field using the subscription data
 
        // Performing some special actions (such as reading from a file
        // which contains additional data required for the converting procedure
        // or requesting some external API)
        // ...
 
        $returnData = array(
            "additionalfields" => $newExtData
        );
 
        return $returnData;
    }