From f7468b1647ec7d7e8ac29e6730c55f1e1055d766 Mon Sep 17 00:00:00 2001 From: Derek Hogue Date: Thu, 19 Nov 2015 10:53:49 -0600 Subject: [PATCH 1/3] Add details to API exceptions So instead of, e.g., "Missing or invalid payment information - Please validate all required payment information." We return: "Missing or invalid payment information - Please validate all required payment information. (State/province does not match country; Shipping state/province does not match country.)" --- src/Beanstream/communications/HttpConnector.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/Beanstream/communications/HttpConnector.php diff --git a/src/Beanstream/communications/HttpConnector.php b/src/Beanstream/communications/HttpConnector.php old mode 100644 new mode 100755 index d6a325f..07fb591 --- a/src/Beanstream/communications/HttpConnector.php +++ b/src/Beanstream/communications/HttpConnector.php @@ -54,7 +54,7 @@ public function processTransaction($http_method, $endpoint, $data) { * @throws ConnectorException */ private function request($http_method = NULL, $url, $data = NULL) - { + { //check to see if we have curl installed on the server if ( ! extension_loaded('curl')) { //no curl @@ -115,7 +115,15 @@ private function request($http_method = NULL, $url, $data = NULL) //check for return errors from the API if (isset($res['code']) && 1 < $res['code'] && !($req['http_code'] >= 200 && $req['http_code'] < 300)) { - throw new ApiException($res['message'], $res['code']); + $message = $res['message']; + if ( ! empty($res['details'])) { + $details = array(); + foreach ($res['details'] as $detail) { + $details[] = $detail['message']; + } + $message .= ' ('.implode('; ', $details).'.)'; + } + throw new ApiException($message, $res['code']); } return $res; From 759ffb776abed245d91850f9c23b083d83b102c5 Mon Sep 17 00:00:00 2001 From: Derek Hogue Date: Thu, 19 Nov 2015 10:56:21 -0600 Subject: [PATCH 2/3] Remove stray tab --- src/Beanstream/communications/HttpConnector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Beanstream/communications/HttpConnector.php b/src/Beanstream/communications/HttpConnector.php index 07fb591..8ea4d4a 100755 --- a/src/Beanstream/communications/HttpConnector.php +++ b/src/Beanstream/communications/HttpConnector.php @@ -54,7 +54,7 @@ public function processTransaction($http_method, $endpoint, $data) { * @throws ConnectorException */ private function request($http_method = NULL, $url, $data = NULL) - { + { //check to see if we have curl installed on the server if ( ! extension_loaded('curl')) { //no curl From 49de5aadeae6260fb42099965c6939904495eb4d Mon Sep 17 00:00:00 2001 From: Derek Hogue Date: Thu, 19 Nov 2015 10:56:46 -0600 Subject: [PATCH 3/3] Cleanup --- src/Beanstream/communications/HttpConnector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Beanstream/communications/HttpConnector.php b/src/Beanstream/communications/HttpConnector.php index 8ea4d4a..dedee45 100755 --- a/src/Beanstream/communications/HttpConnector.php +++ b/src/Beanstream/communications/HttpConnector.php @@ -54,7 +54,7 @@ public function processTransaction($http_method, $endpoint, $data) { * @throws ConnectorException */ private function request($http_method = NULL, $url, $data = NULL) - { + { //check to see if we have curl installed on the server if ( ! extension_loaded('curl')) { //no curl