Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea/

/vendor/
6 changes: 0 additions & 6 deletions Ipsp/Error.php

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $ipsp = new Ipsp_Api( $client );
<?php
function getSignature( $merchant_id , $password , $params = array() ){
$params['merchant_id'] = $merchant_id;
$params = array_filter($params);
$params = array_filter($params,'strlen');
ksort($params);
$params = array_values($params);
array_unshift( $params , $password );
Expand Down
11 changes: 0 additions & 11 deletions autoload.php

This file was deleted.

15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "cloudipsp/ipsp",
"description": "Payment service provider",
"type": "library",
"require": {
"php":">=5.4",
"ext-simplexml":"*",
"ext-curl": "*"
},
"autoload": {
"psr-4": {
"Ipsp\\": "src/"
}
}
}
9 changes: 6 additions & 3 deletions init.example.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
require_once 'ipsp-php/autoload.php';
use Ipsp\Api;
use Ipsp\Client;

define('MERCHANT_ID' , 1000);
define('MERCHANT_PASSWORD' , 'test');
define('IPSP_GATEWAY' , 'api.fondy.eu');
$client = new Ipsp_Client( MERCHANT_ID , MERCHANT_PASSWORD, IPSP_GATEWAY );
$ipsp = new Ipsp_Api( $client );

$client = new Client( MERCHANT_ID , MERCHANT_PASSWORD, IPSP_GATEWAY );
$ipsp = new Api( $client );
20 changes: 11 additions & 9 deletions Ipsp/Api.php → src/Api.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace Ipsp;

/**
* Class Ipsp_Api
* Class Api
*/
class Ipsp_Api {
class Api {

private $client;
private $params = array();
Expand All @@ -16,9 +18,9 @@ class Ipsp_Api {
const RUB = 'RUB';
const GBP = 'GBP';
/**
* @param Ipsp_Client $client
* @param Client $client
*/
public function __construct( Ipsp_Client $client ){
public function __construct( Client $client ){
$this->client = $client;
set_error_handler(array($this, 'handleError'));
set_exception_handler(array($this, 'handleException'));
Expand All @@ -28,10 +30,10 @@ public function __construct( Ipsp_Client $client ){
* @return bool
*/
public function initResource($name){
$class = implode('_',array('Ipsp','Resource',ucfirst($name)));
if(!class_exists($class)) new \Exception(sprintf('ipsp resource "%s" not found',$class));
$resource = new $class;
return $resource;
$class = '\Ipsp\Resources\\' . ucfirst($name);
if(!class_exists($class))
new \Exception(sprintf('"%s" not found',$class));
return new $class;
}
/**
* @param null $name
Expand Down Expand Up @@ -91,4 +93,4 @@ public function handleException(\Exception $e) {
);
exit($msg);
}
}
}
5 changes: 4 additions & 1 deletion Ipsp/Client.php → src/Client.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

namespace Ipsp;

/**
* Class PaymentClient
*/
class Ipsp_Client {
class Client {
private $id;
private $password;
private $url;
Expand Down
8 changes: 5 additions & 3 deletions Ipsp/Curl.php → src/Curl.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?
<?php

namespace Ipsp;

/**
* Class Ipsp_Curl
* Class Curl
*/
class Ipsp_Curl {
class Curl {
protected $response = ''; // Contains the cURL response for debug
protected $session; // Contains the cURL handler for a session
protected $url; // URL of the session
Expand Down
8 changes: 8 additions & 0 deletions src/Error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Ipsp;

class Error extends \Exception{


}
8 changes: 5 additions & 3 deletions Ipsp/Request.php → src/Request.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace Ipsp;

/**
* Class Ipsp_Request
* Class Request
*/
class Ipsp_Request {
class Request {
private $curl;
private $format;
private $contentType = array(
Expand All @@ -15,7 +17,7 @@ class Ipsp_Request {
*
*/
public function __construct(){
$this->curl = new Ipsp_Curl;
$this->curl = new Curl;
}
/**
* @param $format
Expand Down
21 changes: 12 additions & 9 deletions Ipsp/Resource.php → src/Resource.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

namespace Ipsp;

/**
* Class Ipsp_Resource
* Class Resource
*/
class Ipsp_Resource {
class Resource {
protected $method = 'POST';
protected $format = 'json';
protected $path;
Expand Down Expand Up @@ -30,7 +33,7 @@ class Ipsp_Resource {
* @return string
*/
private function getSignature(Array $params){
$params = array_filter($params);
$params = array_filter($params,'strlen');
ksort($params);
$params = array_values($params);
array_unshift( $params , $this->client->getPassword() );
Expand All @@ -51,7 +54,7 @@ private function parseJson($json=''){
* @return array
*/
private function parseXml($xml=''){
$xml = new Ipsp_XmlData($xml);
$xml = new XmlData($xml);
$data = $xml->xmlToArray();
return $data;
}
Expand Down Expand Up @@ -99,7 +102,7 @@ private function formParams($params=array()){
* @return mixed
*/
private function xmlParams($params=array()){
$xml = new Ipsp_XmlData('<request/>');
$xml = new XmlData('<request/>');
$xml->arrayToXml($params);
return $xml->asXML();
}
Expand All @@ -118,14 +121,14 @@ protected function buildParams($params){
}
}
public function __construct(){
$this->request = new Ipsp_Request();
$this->request = new Request();
if(!empty($this->defaultParams))
$this->params = $this->defaultParams;
}
/**
* @param Ipsp_Client $client
* @param Client $client
*/
public function setClient(Ipsp_Client $client){
public function setClient(Client $client){
$this->client = $client;
}
/**
Expand Down Expand Up @@ -200,7 +203,7 @@ public function call( $params=array() ){
* @param array $data
*/
public function setResponse($data=array()){
$this->response = new Ipsp_Response($data);
$this->response = new Response($data);
}
/**
* @return array
Expand Down
11 changes: 8 additions & 3 deletions Ipsp/Resource/Capture.php → src/Resource/Capture.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_PaymentResult
* Class PaymentResult
*/
class Ipsp_Resource_Capture extends Ipsp_Resource{
class Capture extends Resource
{
protected $path = '/capture/order_id';
protected $fields = array(
'merchant_id'=>array(
Expand Down
11 changes: 8 additions & 3 deletions Ipsp/Resource/Checkout.php → src/Resource/Checkout.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_PaymentUrl
* Class PaymentUrl
*/
class Ipsp_Resource_Checkout extends Ipsp_Resource{
class Checkout extends Resource
{
protected $path = '/checkout/url';
protected $fields = array(
'merchant_id'=>array(
Expand Down
10 changes: 7 additions & 3 deletions Ipsp/Resource/P2pcredit.php → src/Resource/P2pcredit.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_Refund
* Class Refund
*/
class Ipsp_Resource_P2pcredit extends Ipsp_Resource{
class P2pcredit extends Resource {
protected $path = '/p2pcredit';
protected $defaultParams = array(

Expand Down
10 changes: 7 additions & 3 deletions Ipsp/Resource/Pcidss.php → src/Resource/Pcidss.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_PaymentPcidss
* Class PaymentPcidss
*/
class Ipsp_Resource_Pcidss extends Ipsp_Resource
class Pcidss extends Resource
{
protected $path = '/3dsecure_step1';
protected $fields = array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_PaymentPcidss
* Class PaymentPcidss
*/
class Ipsp_Resource_PcidssConfirm extends Ipsp_Resource
class PcidssConfirm extends Resource
{
protected $path = '/3dsecure_step2';
protected $fields = array(
Expand Down
10 changes: 7 additions & 3 deletions Ipsp/Resource/Recurring.php → src/Resource/Recurring.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_Refund
* Class Refund
*/
class Ipsp_Resource_Recurring extends Ipsp_Resource{
class Recurring extends Resource{
protected $path = '/recurring';
protected $defaultParams = array(

Expand Down
10 changes: 7 additions & 3 deletions Ipsp/Resource/Reports.php → src/Resource/Reports.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_Refund
* Class Refund
*/
class Ipsp_Resource_Reports extends Ipsp_Resource{
class Reports extends Resource{
protected $path = '/reports';
protected $fields = array(
'merchant_id'=>array(
Expand Down
11 changes: 8 additions & 3 deletions Ipsp/Resource/Result.php → src/Resource/Result.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_PaymentResult
* Class PaymentResult
*/
class Ipsp_Resource_Result extends Ipsp_Resource{
class Result extends Resource
{
public function call( $data = NULL ){
if( empty( $data ) )
{
Expand Down
12 changes: 8 additions & 4 deletions Ipsp/Resource/Reverse.php → src/Resource/Reverse.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?
<?php

namespace Ipsp\Resource;

use Ipsp\Resource;

/**
* Class Ipsp_Resource_Refund
* Class Refund
*/
class Ipsp_Resource_Reverse extends Ipsp_Resource{

class Reverse extends Resource
{
protected $path = '/reverse/order_id';

protected $fields = array(
Expand Down
Loading