public static function factory($requestMethod)
 {
     $requestMethod = strtolower($requestMethod);
     if (empty($requestMethod)) {
         throw new EmptyMethodException('Missing method parameter');
     }
     if (isset(self::$actionCache[$requestMethod])) {
         return self::$actionCache;
     }
     if (!self::actionExists($requestMethod)) {
         throw new InvalidRequestException('Invalid request method .(' . $requestMethod . ')');
     }
     kc_include_once(self::getActionPath($requestMethod));
     $actionClassName = self::getActionClassName($requestMethod);
     $instance = new $actionClassName();
     self::$actionCache[$requestMethod] = $instance;
     return $instance;
 }
 public static function factory($serviceName, $singleton = true)
 {
     if (empty($serviceName)) {
         throw new Exception('Service name is required .');
     }
     $serviceClassName = $serviceName . 'Service';
     if (isset(self::$serviceCache[$serviceClassName])) {
         if ($singleton) {
             return self::$serviceCache[$serviceClassName];
         } else {
             return new $serviceClassName();
         }
     }
     $classFilePath = '';
     if (!self::serviceExists($serviceClassName, $classFilePath)) {
         throw new Exception($serviceClassName . ' not exists');
     }
     kc_include_once($classFilePath);
     $instance = new $serviceClassName();
     self::$serviceCache[$serviceClassName] = $instance;
     return $instance;
 }
    require_once DIR_SYSTEM . 'library/customer.php';
    require_once DIR_SYSTEM . 'library/currency.php';
    require_once DIR_SYSTEM . 'library/tax.php';
    require_once DIR_SYSTEM . 'library/weight.php';
    require_once DIR_SYSTEM . 'library/cart.php';
}
kc_include_once(KANCART_ROOT . '/ErrorHandler.php');
kc_include_once(KANCART_ROOT . '/configure.php');
kc_include_once(KANCART_ROOT . '/util/CryptoUtil.php');
kc_include_once(KANCART_ROOT . '/ActionFactory.php');
kc_include_once(KANCART_ROOT . '/ServiceFactory.php');
kc_include_once(KANCART_ROOT . '/KancartResult.php');
kc_include_once(KANCART_ROOT . '/Exceptions.php');
kc_include_once(KANCART_ROOT . '/common-functions.php');
kc_include_once(KANCART_ROOT . '/actions/BaseAction.php');
kc_include_once(KANCART_ROOT . '/actions/UserAuthorizedAction.php');
kc_include_once(KANCART_ROOT . '/services/BaseService.php');
kc_include_once(KANCART_ROOT . '/Logger.php');
try {
    $actionInstance = ActionFactory::factory(isset($_REQUEST['method']) ? $_REQUEST['method'] : '');
    $actionInstance->init();
    if ($actionInstance->validate()) {
        $actionInstance->execute();
    }
    $result = $actionInstance->getResult();
    die(json_encode($result->returnResult()));
} catch (EmptyMethodException $e) {
    die('KanCart OpenAPI v' . API_VERSION . ' is installed on Opencart v' . KC_CART_VERSION . '. OpenCart Plugin v' . KANCART_PLUGIN_VERSION);
} catch (Exception $e) {
    die(json_encode(array('result' => KancartResult::STATUS_FAIL, 'code' => KancartResult::ERROR_UNKNOWN_ERROR, 'info' => $e->getMessage() . ',' . $e->getTraceAsString())));
}
/**
 * The ansix923 padding string consists of 
 * a sequence of bytes filled with zeros before the length 
 */
define('CRYPT_PADDING_MODE_ANSIX923', 1);
/**
 * The iso10126 padding string consists of random data before the length.
 */
define('CRYPT_PADDING_MODE_ISO10126', 2);
/**
 * The pkcs 7 padding string consists of a sequence of bytes, 
 * each of which is equal to the total number of padding bytes added.
 */
define('CRYPT_PADDING_MODE_PKCS7', 3);
kc_include_once(KANCART_ROOT . '/util/Crypt_DES.php');
kc_include_once(KANCART_ROOT . '/util/Crypt_Rijndael.php');
class CryptoUtil
{
    public static function Crypto($text, $cipher, $key, $isEncrypt)
    {
        switch ($cipher) {
            case 'DES':
                $crypt = new Crypt_DES(CRYPT_DES_MODE_CBC);
                $crypt->setKey($key);
                $crypt->setIV($key);
                if ($isEncrypt) {
                    return strtoupper(bin2hex($crypt->encrypt($text)));
                } else {
                    return $crypt->decrypt(CryptoUtil::hex2bin($text));
                }
                break;