From a3581802d5f632cc5103de96cd076762a7724e9b Mon Sep 17 00:00:00 2001 From: Tom Vonsild Jensen Date: Tue, 16 Jun 2015 11:10:29 +0200 Subject: [PATCH 1/2] Fixed case in required filenames --- QuickPay/QuickPay.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/QuickPay/QuickPay.php b/QuickPay/QuickPay.php index 56f6626..ea16fd1 100644 --- a/QuickPay/QuickPay.php +++ b/QuickPay/QuickPay.php @@ -1,33 +1,33 @@ request = new Request( $client ); From 3423c4c76067ad935add7d5fd96d07fc33361b37 Mon Sep 17 00:00:00 2001 From: Tom Vonsild Jensen Date: Tue, 16 Jun 2015 11:37:28 +0200 Subject: [PATCH 2/2] Throw an exception, if certificate verification failed --- QuickPay/api/Request.php | 71 +++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/QuickPay/api/Request.php b/QuickPay/api/Request.php index 7afd889..c58c441 100644 --- a/QuickPay/api/Request.php +++ b/QuickPay/api/Request.php @@ -17,24 +17,24 @@ class Request /** * Contains QuickPay_Client instance * @access protected - */ + */ protected $client; - - + + /** * __construct function. - * + * * Instantiates the object * * @access public * @return object - */ + */ public function __construct( $client ) { $this->client = $client; } - - + + /** * get function. * @@ -66,7 +66,7 @@ public function get( $path, $query = array() ) // Start the request and return the response return $this->execute('GET'); } - + /** * post function. @@ -75,16 +75,16 @@ public function get( $path, $query = array() ) * * @access public * @return object - */ - public function post( $path, $form = array() ) + */ + public function post( $path, $form = array() ) { // Set the request params $this->set_url( $path ); // Start the request and return the response return $this->execute('POST', $form); - } - + } + /** * put function. @@ -93,17 +93,17 @@ public function post( $path, $form = array() ) * * @access public * @return object - */ - public function put( $path, $form = array() ) + */ + public function put( $path, $form = array() ) { // Set the request params $this->set_url( $path ); // Start the request and return the response return $this->execute('PUT', $form); - } - - + } + + /** * patch function. * @@ -111,17 +111,17 @@ public function put( $path, $form = array() ) * * @access public * @return object - */ - public function patch( $path, $form = array() ) + */ + public function patch( $path, $form = array() ) { // Set the request params $this->set_url( $path ); // Start the request and return the response return $this->execute('PATCH', $form); - } - - + } + + /** * delete function. * @@ -129,8 +129,8 @@ public function patch( $path, $form = array() ) * * @access public * @return object - */ - public function delete( $path, $form = array() ) + */ + public function delete( $path, $form = array() ) { // Set the request params $this->set_url( $path ); @@ -138,8 +138,8 @@ public function delete( $path, $form = array() ) // Start the request and return the response return $this->execute('DELETE', $form); } - - + + /** * set_url function. * @@ -147,13 +147,13 @@ public function delete( $path, $form = array() ) * * @access protected * @return void - */ - protected function set_url( $params ) + */ + protected function set_url( $params ) { curl_setopt( $this->client->ch, CURLOPT_URL, Constants::API_URL . trim( $params, '/' ) ); } - - + + /** * execute function. * @@ -163,8 +163,8 @@ protected function set_url( $params ) * @param string $request_type * @param array $form * @return object - */ - protected function execute( $request_type, $form = array() ) + */ + protected function execute( $request_type, $form = array() ) { // Set the HTTP request type curl_setopt( $this->client->ch, CURLOPT_CUSTOMREQUEST, $request_type ); @@ -178,9 +178,14 @@ protected function execute( $request_type, $form = array() ) // Execute the request $response_data = curl_exec( $this->client->ch ); + if (curl_errno($this->client->ch) !== 0) { + //An error occurred + throw new Exception(curl_error($this->client->ch), curl_errno($this->client->ch)); + } + // Retrieve the HTTP response code $response_code = (int) curl_getinfo( $this->client->ch, CURLINFO_HTTP_CODE ); - + // Return the response object. return new Response( $response_code, $response_data ); }