dev-master
9999999-dev https://github.com/sweetpay/sweetpay-php PHP Library
MIT
The Requires
- php >=5.4
- monolog/monolog 1.*
The Development Requires
by SweetPay
api payment processing sweetpay
Wallogit.com
2017 © Pedro Peláez
sweetpay-php PHP Library
You can install the bindings via Composer. Run the following command:, (*2)
composer require sweetpay/sweetpay-php dev-master
go to to the sweetpay-php directory and run:, (*3)
composer install
this will create a vendor directory inside the src directory., (*4)
To use the bindings, use Composer's autoload:, (*5)
require_once('pathto/vendor/autoload.php');
Also recommended it to use the spl autoloader., (*6)
/*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');
PHP 5.4 and later., (*7)
Set permission for src/logs directory as 777, using the terminal:, (*8)
sudo chmod 777 logs
in this file all the debug information will be added using monolog/monolog., (*9)
// The intital setup, some curl setup can be changed in this array $setup = array( "apiKey" => (string) "NNq7Rcnb8y8jGTsU", "stage" => (boolean) 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(
'transactons' => 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);
}
For a concreate and working exempel for both transactions and subscription see Test/* directory, (*10)
sweetpay-php PHP Library
MIT
api payment processing sweetpay