From 7db660425c5b564bb438fa5457e89d374db37745 Mon Sep 17 00:00:00 2001 From: Kevin Saliba Date: Sun, 11 May 2025 15:56:40 -0700 Subject: [PATCH 1/5] Replaced deprecated mcrypt PHP method used to generate random Order Number in examples.php. --- src/Beanstream/examples.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Beanstream/examples.php b/src/Beanstream/examples.php index 21fa19a..36b8009 100644 --- a/src/Beanstream/examples.php +++ b/src/Beanstream/examples.php @@ -12,7 +12,7 @@ //generate a random order number, and set a default $amount (only used for example functions) -$order_number = bin2hex(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)); +$order_number = bin2hex(random_bytes(22)); $amount = 1.00; @@ -153,8 +153,8 @@ //**** PAYMENTS EXAMPLES //make a credit card payment - //$result = $beanstream->payments()->makeCardPayment($payment_data, $complete); - //$transaction_id = $result['id']; + $result = $beanstream->payments()->makeCardPayment($payment_data, $complete); + $transaction_id = $result['id']; //complete a PA //$result = $beanstream->payments()->complete($transaction_id, $amount, $order_number); From 26f6293b05fb8d88e2a7a5147ed23a52fee47852 Mon Sep 17 00:00:00 2001 From: Kevin Saliba Date: Sun, 11 May 2025 16:52:54 -0700 Subject: [PATCH 2/5] Includes changes from PR #24: 'Fixes trying to access array offset on value of type resource on PHP 7.4.' --- src/Beanstream/communications/HttpConnector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Beanstream/communications/HttpConnector.php b/src/Beanstream/communications/HttpConnector.php index f0d0989..9f4eec7 100644 --- a/src/Beanstream/communications/HttpConnector.php +++ b/src/Beanstream/communications/HttpConnector.php @@ -114,7 +114,8 @@ 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)) { + $httpCode = curl_getinfo($req, CURLINFO_HTTP_CODE); + if (isset($res['code']) && 1 < $res['code'] && !($httpCode >= 200 && $httpCode < 300)) { throw new ApiException($res['message'], $res['code']); } From ea8325fe3933ad226b7cab58ae1d5b23f8232a27 Mon Sep 17 00:00:00 2001 From: Kevin Saliba Date: Sun, 11 May 2025 19:32:01 -0700 Subject: [PATCH 3/5] Includes changes from PR #7, #10, #13: 'Add more detail to API exception messages' --- src/Beanstream/communications/HttpConnector.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Beanstream/communications/HttpConnector.php b/src/Beanstream/communications/HttpConnector.php index 9f4eec7..9a95b30 100644 --- a/src/Beanstream/communications/HttpConnector.php +++ b/src/Beanstream/communications/HttpConnector.php @@ -116,7 +116,16 @@ private function request($http_method = NULL, $url, $data = NULL) //check for return errors from the API $httpCode = curl_getinfo($req, CURLINFO_HTTP_CODE); if (isset($res['code']) && 1 < $res['code'] && !($httpCode >= 200 && $httpCode < 300)) { - throw new ApiException($res['message'], $res['code']); + $message = $res['message']; + if (!empty($res['details'])) { + $details = array(); + //build out details from error response to return in API Exception message + foreach ($res['details'] as $detail) { + $details[] = $detail['message']; + } + $message .= ' ('.implode('; ', $details).'.)'; + } + throw new ApiException($message, $res['code']); } return $res; From ca33a8ff05a79eb6b4fe03eacc38dd00736e8279 Mon Sep 17 00:00:00 2001 From: Kevin Saliba Date: Sun, 11 May 2025 20:59:38 -0700 Subject: [PATCH 4/5] Includes changes from PR #16: 'Implement profiles->getCard' --- src/Beanstream/api/Profiles.php | 19 +++++++++++++++++++ src/Beanstream/communications/Endpoints.php | 1 + src/Beanstream/examples.php | 7 +++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Beanstream/api/Profiles.php b/src/Beanstream/api/Profiles.php index 0853777..80d366e 100644 --- a/src/Beanstream/api/Profiles.php +++ b/src/Beanstream/api/Profiles.php @@ -138,6 +138,25 @@ public function getCards($profile_id) { return $result; } + /** + * getCard() function - Retrieve a particular card in a profile + * + * @param string $profile_id Profile Id + * @param string $card_id Card Id + * @return array ProfileCardResponse result + */ + public function getCard($profile_id, $card_id) { + + //get this profile's cards endpoint + $endpoint = $this->_endpoint->getCardURI($profile_id, $card_id); + + //process as is + $result = $this->_connector->processTransaction('GET', $endpoint, NULL); + + //return cards + return $result; + } + /** * addCard() function - Add a card to a profile * @link http://developer.beanstream.com/documentation/tokenize-payments/add-card-profile/ diff --git a/src/Beanstream/communications/Endpoints.php b/src/Beanstream/communications/Endpoints.php index 8c84e1a..dec65b4 100755 --- a/src/Beanstream/communications/Endpoints.php +++ b/src/Beanstream/communications/Endpoints.php @@ -40,6 +40,7 @@ class Endpoints { protected $voidsURL; protected $profileURI; protected $cardsURI; + protected $cardURI; protected $reportsURL; protected $continuationsURL; protected $tokenizationURL; diff --git a/src/Beanstream/examples.php b/src/Beanstream/examples.php index 36b8009..fe59d12 100644 --- a/src/Beanstream/examples.php +++ b/src/Beanstream/examples.php @@ -153,8 +153,8 @@ //**** PAYMENTS EXAMPLES //make a credit card payment - $result = $beanstream->payments()->makeCardPayment($payment_data, $complete); - $transaction_id = $result['id']; + //$result = $beanstream->payments()->makeCardPayment($return_data, $complete); + //$transaction_id = $result['id']; //complete a PA //$result = $beanstream->payments()->complete($transaction_id, $amount, $order_number); @@ -212,6 +212,9 @@ //get all cards in profile //$result = $beanstream->profiles()->getCards($profile_id); + //get a card based on a profile cust code and card id + //$result = $beanstream->profiles()->getCard($profile_id, $card_id); + //update a specfic card in a profile //$result = $beanstream->profiles()->updateCard($profile_id, $card_id, $card_data); From 3bb7ffea6b7d302feca7ec895cebc76c01c11e7d Mon Sep 17 00:00:00 2001 From: Kevin Saliba Date: Sun, 22 Jun 2025 17:26:07 -0700 Subject: [PATCH 5/5] Updated composer.json with new version and PHP requirement. Updated examples in examples.php. --- composer.json | 4 ++-- src/Beanstream/examples.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index e88613a..e852b47 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Beanstream PHP API", "type": "library", "license": "MIT", - "version": "1.0.1", + "version": "1.0.2", "authors": [ { "name": "Pavel Kulbakin", @@ -14,7 +14,7 @@ } ], "require": { - "php": ">=5.3.0" + "php": ">=7.4.0" }, "autoload": { "psr-0": {"Beanstream": "src/"} diff --git a/src/Beanstream/examples.php b/src/Beanstream/examples.php index fe59d12..6fc5329 100644 --- a/src/Beanstream/examples.php +++ b/src/Beanstream/examples.php @@ -32,7 +32,7 @@ 'name' => 'Mr. Card Testerson', 'number' => '4030000010001234', 'expiry_month' => '07', - 'expiry_year' => '22', + 'expiry_year' => '32', 'cvd' => '123' ), 'billing' => array( @@ -82,7 +82,7 @@ 'name' => 'Test Testerson', 'number' => '4030000010001234', 'expiry_month' => '07', - 'expiry_year' => '22', + 'expiry_year' => '32', 'cvd' => '123' ) ); @@ -96,7 +96,7 @@ 'name' => 'Mr. Refund Testerson', 'number' => '4030000010001234', 'expiry_month' => '07', - 'expiry_year' => '22', + 'expiry_year' => '32', 'cvd' => '123' ) ); @@ -112,7 +112,7 @@ $legato_token_data = array( 'number' => '4030000010001234', 'expiry_month' => '07', - 'expiry_year' => '22', + 'expiry_year' => '32', 'cvd' => '123' ); @@ -153,7 +153,7 @@ //**** PAYMENTS EXAMPLES //make a credit card payment - //$result = $beanstream->payments()->makeCardPayment($return_data, $complete); + //$result = $beanstream->payments()->makeCardPayment($payment_data, $complete); //$transaction_id = $result['id']; //complete a PA