diff --git a/.gitignore b/.gitignore
index 9f11b75..b9991e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
.idea/
+
+/vendor/
diff --git a/Ipsp/Error.php b/Ipsp/Error.php
deleted file mode 100644
index fcb1ae0..0000000
--- a/Ipsp/Error.php
+++ /dev/null
@@ -1,6 +0,0 @@
-=5.4",
+ "ext-simplexml":"*",
+ "ext-curl": "*"
+ },
+ "autoload": {
+ "psr-4": {
+ "Ipsp\\": "src/"
+ }
+ }
+}
diff --git a/init.example.php b/init.example.php
index a54d486..ccb6990 100644
--- a/init.example.php
+++ b/init.example.php
@@ -1,7 +1,10 @@
client = $client;
set_error_handler(array($this, 'handleError'));
set_exception_handler(array($this, 'handleException'));
@@ -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
@@ -91,4 +93,4 @@ public function handleException(\Exception $e) {
);
exit($msg);
}
-}
+}
\ No newline at end of file
diff --git a/Ipsp/Client.php b/src/Client.php
similarity index 96%
rename from Ipsp/Client.php
rename to src/Client.php
index c02dda7..0baea2b 100644
--- a/Ipsp/Client.php
+++ b/src/Client.php
@@ -1,8 +1,11 @@
curl = new Ipsp_Curl;
+ $this->curl = new Curl;
}
/**
* @param $format
diff --git a/Ipsp/Resource.php b/src/Resource.php
similarity index 93%
rename from Ipsp/Resource.php
rename to src/Resource.php
index 10c0d70..f3a237c 100644
--- a/Ipsp/Resource.php
+++ b/src/Resource.php
@@ -1,8 +1,11 @@
client->getPassword() );
@@ -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;
}
@@ -99,7 +102,7 @@ private function formParams($params=array()){
* @return mixed
*/
private function xmlParams($params=array()){
- $xml = new Ipsp_XmlData('');
+ $xml = new XmlData('');
$xml->arrayToXml($params);
return $xml->asXML();
}
@@ -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;
}
/**
@@ -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
diff --git a/Ipsp/Resource/Capture.php b/src/Resource/Capture.php
similarity index 84%
rename from Ipsp/Resource/Capture.php
rename to src/Resource/Capture.php
index c1f9113..ef7ae80 100644
--- a/Ipsp/Resource/Capture.php
+++ b/src/Resource/Capture.php
@@ -1,9 +1,14 @@
-
+array(
diff --git a/Ipsp/Resource/Checkout.php b/src/Resource/Checkout.php
similarity index 88%
rename from Ipsp/Resource/Checkout.php
rename to src/Resource/Checkout.php
index f7c3180..40ffabb 100644
--- a/Ipsp/Resource/Checkout.php
+++ b/src/Resource/Checkout.php
@@ -1,9 +1,14 @@
-
+array(
diff --git a/Ipsp/Resource/P2pcredit.php b/src/Resource/P2pcredit.php
similarity index 91%
rename from Ipsp/Resource/P2pcredit.php
rename to src/Resource/P2pcredit.php
index 8227d55..96aebfa 100644
--- a/Ipsp/Resource/P2pcredit.php
+++ b/src/Resource/P2pcredit.php
@@ -1,9 +1,13 @@
-
+array(
diff --git a/Ipsp/Resource/Result.php b/src/Resource/Result.php
similarity index 86%
rename from Ipsp/Resource/Result.php
rename to src/Resource/Result.php
index c90790c..18015fb 100644
--- a/Ipsp/Resource/Result.php
+++ b/src/Resource/Result.php
@@ -1,9 +1,14 @@
-
+array(
diff --git a/Ipsp/Resource/Verification.php b/src/Resource/Verification.php
similarity index 90%
rename from Ipsp/Resource/Verification.php
rename to src/Resource/Verification.php
index f229004..f4e7a24 100644
--- a/Ipsp/Resource/Verification.php
+++ b/src/Resource/Verification.php
@@ -1,9 +1,14 @@
-
+'y',
diff --git a/src/Resources/Capture.php b/src/Resources/Capture.php
new file mode 100644
index 0000000..511405e
--- /dev/null
+++ b/src/Resources/Capture.php
@@ -0,0 +1,35 @@
+array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'amount' => array(
+ 'type' => 'integer',
+ 'required'=>TRUE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ )
+ );
+}
\ No newline at end of file
diff --git a/src/Resources/Checkout.php b/src/Resources/Checkout.php
new file mode 100644
index 0000000..9637f24
--- /dev/null
+++ b/src/Resources/Checkout.php
@@ -0,0 +1,42 @@
+array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_desc'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'amount' => array(
+ 'type' => 'integer',
+ 'required'=>TRUE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ )
+ );
+ public function redirectToCheckout(){
+ $this->getResponse()->redirectTo('checkout_url');
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/P2pcredit.php b/src/Resources/P2pcredit.php
new file mode 100644
index 0000000..d356709
--- /dev/null
+++ b/src/Resources/P2pcredit.php
@@ -0,0 +1,53 @@
+array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_desc'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'amount' => array(
+ 'type' => 'integer',
+ 'required'=>TRUE
+ ),
+ 'receiver_card_number'=>array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ ),
+ 'receiver_rectoken'=>array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'version' => array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ )
+ );
+}
\ No newline at end of file
diff --git a/src/Resources/Pcidss.php b/src/Resources/Pcidss.php
new file mode 100644
index 0000000..2ffe5df
--- /dev/null
+++ b/src/Resources/Pcidss.php
@@ -0,0 +1,60 @@
+ array(
+ 'type' => 'string',
+ 'required' => TRUE
+ ),
+ 'order_desc' => array(
+ 'type' => 'string',
+ 'required' => TRUE
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'required' => TRUE
+ ),
+ 'amount' => array(
+ 'type' => 'datetime',
+ 'required' => TRUE
+ ),
+ 'card_number' => array(
+ 'type' => 'creditcard',
+ 'required' => TRUE
+ ),
+ 'cvv2' => array(
+ 'type' => 'cvv',
+ 'required' => TRUE
+ ),
+ 'expiry_date' => array(
+ 'type' => 'datetime',
+ 'required' => TRUE
+ )
+ );
+
+ public function acsRedirect( ){
+ $response = $this->response;
+ if(!$response->acs_url) return FALSE;
+ $data = array(
+ 'PaReq' => $response->pareq,
+ 'MD' => $response->md,
+ 'TermUrl' => $this->getParam('response_url')
+ );
+ $html = "
";
+ $html .= "";
+ exit($html);
+ }
+
+}
\ No newline at end of file
diff --git a/src/Resources/PcidssConfirm.php b/src/Resources/PcidssConfirm.php
new file mode 100644
index 0000000..500bbac
--- /dev/null
+++ b/src/Resources/PcidssConfirm.php
@@ -0,0 +1,39 @@
+ array(
+ 'type' => 'string',
+ 'required' => TRUE
+ ),
+ 'merchant_id' => array(
+ 'type' => 'string',
+ 'required' => TRUE
+ ),
+ 'pares' => array(
+ 'type' => 'string',
+ 'required' => TRUE
+ ),
+ 'md' => array(
+ 'type' => 'string',
+ 'required' => TRUE
+ ),
+ 'version' => array(
+ 'type' => 'cvv',
+ 'required' => FALSE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required' => TRUE
+ )
+ );
+}
\ No newline at end of file
diff --git a/src/Resources/Recurring.php b/src/Resources/Recurring.php
new file mode 100644
index 0000000..f5cf2c1
--- /dev/null
+++ b/src/Resources/Recurring.php
@@ -0,0 +1,46 @@
+array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'amount' => array(
+ 'type' => 'integer',
+ 'required'=>TRUE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'rectoken' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'version' => array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ )
+ );
+
+}
\ No newline at end of file
diff --git a/src/Resources/Reports.php b/src/Resources/Reports.php
new file mode 100644
index 0000000..35d9643
--- /dev/null
+++ b/src/Resources/Reports.php
@@ -0,0 +1,37 @@
+array(
+ 'type' => 'string',
+ 'required'=> TRUE
+ ),
+ 'date_from'=>array(
+ 'type' => 'string',
+ 'format' => '',
+ 'required' => TRUE
+ ),
+ 'date_to' => array(
+ 'type' => 'string',
+ 'format' => '' ,
+ 'required'=> TRUE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'version' => array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ )
+ );
+
+}
\ No newline at end of file
diff --git a/src/Resources/Result.php b/src/Resources/Result.php
new file mode 100644
index 0000000..df59233
--- /dev/null
+++ b/src/Resources/Result.php
@@ -0,0 +1,33 @@
+parseResponseData();
+ } else{
+ $this->setResponse($data);
+ }
+ return $this;
+ }
+ private function parseResponseData(){
+ $body = file_get_contents('php://input');
+ $types = $this->request->getContentTypes();
+ $types = array_flip($types);
+ $type = explode(';',$_SERVER['CONTENT_TYPE']);
+ $type = trim($type[0]);
+ if(isset($types[$type])){
+ $this->format = $types[$type];
+ $data = $this->parseRespose($body);
+ $this->setResponse($data);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/Reverse.php b/src/Resources/Reverse.php
new file mode 100644
index 0000000..ece2420
--- /dev/null
+++ b/src/Resources/Reverse.php
@@ -0,0 +1,41 @@
+array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'amount' => array(
+ 'type' => 'integer',
+ 'required'=>TRUE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'version' => array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ )
+ );
+
+}
\ No newline at end of file
diff --git a/src/Resources/Status.php b/src/Resources/Status.php
new file mode 100644
index 0000000..1bed6d2
--- /dev/null
+++ b/src/Resources/Status.php
@@ -0,0 +1,31 @@
+array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'merchant_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'version' => array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ )
+ );
+}
\ No newline at end of file
diff --git a/src/Resources/Verification.php b/src/Resources/Verification.php
new file mode 100644
index 0000000..884b04f
--- /dev/null
+++ b/src/Resources/Verification.php
@@ -0,0 +1,52 @@
+'y',
+ 'verification_type'=>'code'
+ );
+ protected $fields = array(
+ 'merchant_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'order_id'=>array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'amount' => array(
+ 'type' => 'integer',
+ 'required'=>TRUE
+ ),
+ 'verification'=>array(
+ 'type' => 'string',
+ 'equal'=> 'y'
+ ),
+ 'verification_type'=>array(
+ 'type' => 'string',
+ 'equal'=> 'y',
+ 'required'=>TRUE
+ ),
+ 'signature' => array(
+ 'type' => 'string',
+ 'required'=>TRUE
+ ),
+ 'version' => array(
+ 'type' => 'string',
+ 'required'=>FALSE
+ )
+ );
+}
\ No newline at end of file
diff --git a/Ipsp/Response.php b/src/Response.php
similarity index 94%
rename from Ipsp/Response.php
rename to src/Response.php
index c0abff0..767a6b2 100644
--- a/Ipsp/Response.php
+++ b/src/Response.php
@@ -1,9 +1,11 @@
data = $data;
diff --git a/Ipsp/XmlData.php b/src/XmlData.php
similarity index 93%
rename from Ipsp/XmlData.php
rename to src/XmlData.php
index 9b1645d..cec9ffb 100644
--- a/Ipsp/XmlData.php
+++ b/src/XmlData.php
@@ -1,6 +1,8 @@