public function __construct() { $Check = new CheckoutCond(); $this->condition = $Check->getCond(); /*Only those that can be change by the user*/ $this->checkOption = array("DEFAULT_TIMEOUT", "DEFAULT_CONNECT_TIMEOUT"); foreach ($this->checkOption as $check) { // go throught the checkOption array if (!array_key_exists($check, $this->condition)) { // if the variable dont exist then take the default $this->condition["{$check}"] = self::${$check}; } } }
/*Needed for loading the classes inside src*/ function autoload($className) { $className = ltrim($className, '\\'); $fileName = ''; $namespace = ''; if ($lastNsPos = strrpos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; require $fileName; } spl_autoload_register('autoload'); $setup = ["apiKey" => (string) "NNq7Rcnb8y8jGTsU", "stage" => (bool) true, "DEFAULT_TIMEOUT" => (int) 30]; $transactionData = array('subscriptions' => array(array('amount' => '100', 'currency' => 'SEK', 'startsAt' => '2016-01-01', 'interval' => ' MONTHLY'), array('amount' => '200', 'currency' => 'SEK', 'startsAt' => '2016-01-01', 'interval' => ' MONTHLY')), 'country' => 'SE', 'merchantId' => 'paylevo'); try { \Sweetpay\CheckoutCond::setCondition($setup); } catch (Exception $e) { $input = array('line' => __LINE__, 'path' => __FILE__); \Sweetpay\Helper::errorMessage($e, $input); var_dump(\Sweetpay\CheckoutCond::getApiKey()); } try { $Check = new \Sweetpay\CheckOut($transactionData); var_dump($Check->getOutput()); } catch (Exception $e) { $input = array('line' => __LINE__, 'path' => __FILE__); \Sweetpay\Helper::errorMessage($e, $input); }