コード例 #1
0
/*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);
}
コード例 #2
0
    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');
// The intital setup, some curl setup can be changed in this array
$setup = array("apiKey" => (string) "NNq7Rcnb8y8jGTsU", "stage" => (bool) true, "DEFAULT_TIMEOUT" => (int) 30);
try {
    // run the setup
    \Sweetpay\CheckoutCond::setCondition($setup);
} catch (Exception $e) {
    $input = array('line' => __LINE__, 'path' => __FILE__, 'input' => $setup);
    \Sweetpay\Helper::errorMessage($e, $input);
    // if any error, check stdout for any error message and logs/*
    var_dump(\Sweetpay\CheckoutCond::getApiKey());
}
// end of try
$transactionData = array('transactions' => array(array('amount' => '100', 'currency' => 'SEK'), array('amount' => '200', 'currency' => 'SEK')), 'country' => 'SE', 'merchantId' => 'paylevo');
try {
    $Check = new \Sweetpay\CheckOut($transactionData);
    $vars = $Check->getOutput();
    // check the respons,
    var_dump($vars);
} catch (Exception $e) {
    $input = array('line' => __LINE__, 'path' => __FILE__, 'input' => $transactionData);
    \Sweetpay\Helper::errorMessage($e, $input);
}