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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Beanstream PHP API",
"type": "library",
"license": "MIT",
"version": "1.0.1",
"version": "1.0.2",
"authors": [
{
"name": "Pavel Kulbakin",
Expand All @@ -14,7 +14,7 @@
}
],
"require": {
"php": ">=5.3.0"
"php": ">=7.4.0"
},
"autoload": {
"psr-0": {"Beanstream": "src/"}
Expand Down
19 changes: 19 additions & 0 deletions src/Beanstream/api/Profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
1 change: 1 addition & 0 deletions src/Beanstream/communications/Endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Endpoints {
protected $voidsURL;
protected $profileURI;
protected $cardsURI;
protected $cardURI;
protected $reportsURL;
protected $continuationsURL;
protected $tokenizationURL;
Expand Down
14 changes: 12 additions & 2 deletions src/Beanstream/communications/HttpConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,18 @@ 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']);
$httpCode = curl_getinfo($req, CURLINFO_HTTP_CODE);
if (isset($res['code']) && 1 < $res['code'] && !($httpCode >= 200 && $httpCode < 300)) {
$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;
Expand Down
13 changes: 8 additions & 5 deletions src/Beanstream/examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -32,7 +32,7 @@
'name' => 'Mr. Card Testerson',
'number' => '4030000010001234',
'expiry_month' => '07',
'expiry_year' => '22',
'expiry_year' => '32',
'cvd' => '123'
),
'billing' => array(
Expand Down Expand Up @@ -82,7 +82,7 @@
'name' => 'Test Testerson',
'number' => '4030000010001234',
'expiry_month' => '07',
'expiry_year' => '22',
'expiry_year' => '32',
'cvd' => '123'
)
);
Expand All @@ -96,7 +96,7 @@
'name' => 'Mr. Refund Testerson',
'number' => '4030000010001234',
'expiry_month' => '07',
'expiry_year' => '22',
'expiry_year' => '32',
'cvd' => '123'
)
);
Expand All @@ -112,7 +112,7 @@
$legato_token_data = array(
'number' => '4030000010001234',
'expiry_month' => '07',
'expiry_year' => '22',
'expiry_year' => '32',
'cvd' => '123'
);

Expand Down Expand Up @@ -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);

Expand Down