Skip to content

Commit

Permalink
Merge pull request #13 from andreybolonin/master
Browse files Browse the repository at this point in the history
code style fixes
  • Loading branch information
viplifes committed Feb 3, 2017
2 parents 08c2a27 + 600887d commit 810705d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions LiqPay.php
Expand Up @@ -52,7 +52,7 @@ class LiqPay
*
* @param string $public_key
* @param string $private_key
*
*
* @throws InvalidArgumentException
*/
public function __construct($public_key, $private_key)
Expand Down Expand Up @@ -80,12 +80,12 @@ public function __construct($public_key, $private_key)
*/
public function api($path, $params = array())
{
if(!isset($params['version'])){
if (!isset($params['version'])) {
throw new InvalidArgumentException('version is null');
}
$url = $this->_api_url . $path;
$public_key = $this->_public_key;
$private_key = $this->_private_key;
$private_key = $this->_private_key;
$data = base64_encode(json_encode(array_merge(compact('public_key'), $params)));
$signature = base64_encode(sha1($private_key.$data.$private_key, 1));
$postfields = http_build_query(array(
Expand All @@ -97,8 +97,8 @@ public function api($path, $params = array())
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$server_output = curl_exec($ch);
curl_close($ch);
return json_decode($server_output);
Expand All @@ -111,19 +111,18 @@ public function api($path, $params = array())
* @param array $params
*
* @return string
*
*
* @throws InvalidArgumentException
*/
public function cnb_form($params)
{

$language = 'ru';
{
$language = 'ru';
if (isset($params['language']) && $params['language'] == 'en') {
$language = 'en';
}

$params = $this->cnb_params($params);
$data = base64_encode( json_encode($params) );
$data = base64_encode(json_encode($params));
$signature = $this->cnb_signature($params);

return sprintf('
Expand Down Expand Up @@ -158,7 +157,7 @@ public function cnb_signature($params)
$params = $this->cnb_params($params);
$private_key = $this->_private_key;

$json = base64_encode( json_encode($params) );
$json = base64_encode(json_encode($params));
$signature = $this->str_to_sign($private_key . $json . $private_key);

return $signature;
Expand All @@ -176,7 +175,6 @@ public function cnb_signature($params)
*/
private function cnb_params($params)
{

$params['public_key'] = $this->_public_key;

if (!isset($params['version'])) {
Expand All @@ -186,7 +184,7 @@ private function cnb_params($params)
throw new InvalidArgumentException('amount is null');
}
if (!isset($params['currency'])) {
throw new InvalidArgumentException('currency is null');
throw new InvalidArgumentException('currency is null');
}
if (!in_array($params['currency'], $this->_supportedCurrencies)) {
throw new InvalidArgumentException('currency is not supported');
Expand All @@ -211,10 +209,8 @@ private function cnb_params($params)
*/
public function str_to_sign($str)
{

$signature = base64_encode(sha1($str,1));
$signature = base64_encode(sha1($str, 1));

return $signature;
}

}

0 comments on commit 810705d

Please sign in to comment.