/**
  * This method return value from the attribute config
  * @param null $key attribute you want to retrive
  * @return array|CheckoutApi_Lib_RespondObj|null
  * @throws Exception
  */
 private function getConfig($key = null, $args = null)
 {
     if ($key != null) {
         $value = null;
         if (isset($this->_config[$key])) {
             $value = $this->_config[$key];
         } elseif (isset($this->_updateConfig[$key])) {
             $value = $this->_updateConfig[$key];
         }
         if (isset($args["returnAsArray"]) && $args["returnAsArray"]) {
             /** Return the response as an array */
             if (is_array($value)) {
                 return $value;
             }
         } elseif (is_array($value)) {
             /** @var CheckoutApi_Lib_RespondObj $to_return */
             $to_return = CheckoutApi_Lib_Factory::getInstance('CheckoutApi_Lib_RespondObj');
             $to_return->setConfig($value);
             return $to_return;
         }
         return $value;
     }
     if ($key == null) {
         return $this->_config;
     }
     return null;
 }
 public function getInstance()
 {
     global $module_params;
     $methodType = $module_params['param05'];
     if (!$this->_instance) {
         switch ($methodType) {
             case 'yes':
                 $this->_instance = CheckoutApi_Lib_Factory::getInstance('model_methods_creditcardpci');
                 break;
             default:
                 $this->_instance = CheckoutApi_Lib_Factory::getInstance('model_methods_creditcard');
                 break;
         }
     }
     return $this->_instance;
 }
function getInstance($methodType = null)
{
    global $sql_tbl;
    $payment_cc_data = cko_config();
    if (!$methodType) {
        $methodType = $payment_cc_data['param05'];
        switch ($methodType) {
            case 'yes':
                $instance = CheckoutApi_Lib_Factory::getInstance('model_methods_creditcardpci');
                break;
            default:
                $instance = CheckoutApi_Lib_Factory::getInstance('model_methods_creditcard');
                break;
        }
    }
    return $instance;
}
示例#4
0
 /**
  * Convert a json to a CheckoutApi_Lib_RespondObj object
  * @param JSON $parser
  * @return CheckoutApi_Lib_RespondObj|null
  * @throws Exception
  */
 public function parseToObj($parser)
 {
     /** @var CheckoutApi_Lib_RespondObj $respondObj */
     $respondObj = CheckoutApi_Lib_Factory::getInstance('CheckoutApi_Lib_RespondObj');
     if ($parser && is_string($parser)) {
         $encoding = mb_detect_encoding($parser);
         if ($encoding == "ASCII") {
             $parser = iconv('ASCII', 'UTF-8', $parser);
         } else {
             $parser = mb_convert_encoding($parser, "UTF-8", $encoding);
         }
         $jsonObj = json_decode($parser, true);
         $jsonObj['rawOutput'] = $parser;
         $respondObj->setConfig($jsonObj);
     }
     $respondObj->setConfig($this->getResourceInfo());
     return $respondObj;
 }