From 1ec5fcdd738ad9d82478d78708ea1d99e8652547 Mon Sep 17 00:00:00 2001 From: Rico Simlinger Date: Tue, 18 Apr 2017 11:10:35 +0200 Subject: [PATCH 1/3] FIX markdown - header lines --- doc/guide/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/guide/README.md b/doc/guide/README.md index 0d08113..9819b56 100644 --- a/doc/guide/README.md +++ b/doc/guide/README.md @@ -1,8 +1,8 @@ -#PHP SDK Guide +# PHP SDK Guide -##Getting Started +## Getting Started -###Initialize the client +### Initialize the client ```php include "vendor/autoload.php"; @@ -26,7 +26,7 @@ $store = new DummyStorage(); $secucard = new SecucardConnect($config, $logger, $store, $store, $credentials); ``` -###List all existing customers (without pagination) +### List all existing customers (without pagination) ```php $service = $secucard->payment->customers; @@ -38,7 +38,7 @@ if (empty($customers)) { print_r($customers); ``` -###List all existing customers (with pagination) +### List all existing customers (with pagination) If you have many customers, you would need following code to get them all. ```php $service = $secucard->payment->customers; @@ -56,4 +56,4 @@ if (empty($customers)) { } print_r($customers); -``` \ No newline at end of file +``` From 30f89f440547610066b8d91970d33633ce3089fb Mon Sep 17 00:00:00 2001 From: Rico Simlinger Date: Tue, 30 May 2017 16:33:05 +0200 Subject: [PATCH 2/3] RELEASE 1.4.0 --- .gitignore | 3 +- CHANGELOG.md | 59 ++++- composer.json | 16 +- phpunit.xml | 8 - .../ApiClientConfiguration.php | 4 +- src/SecucardConnect/Auth/AuthCodes.php | 6 - src/SecucardConnect/Auth/BadAuthException.php | 2 - .../Auth/GrantTypeInterface.php | 3 + src/SecucardConnect/Auth/OauthProvider.php | 42 ++-- src/SecucardConnect/Client/ApiError.php | 20 +- src/SecucardConnect/Client/ClientError.php | 12 +- src/SecucardConnect/Client/DummyStorage.php | 28 ++- src/SecucardConnect/Client/FileStorage.php | 56 ++--- .../Client/MediaResourceTrait.php | 14 +- src/SecucardConnect/Client/ProductService.php | 168 +++++++------- src/SecucardConnect/Client/QueryParams.php | 3 +- .../Client/ResourceMetadata.php | 36 +-- .../Event/DefaultEventHandler.php | 10 +- src/SecucardConnect/Event/EventDispatcher.php | 2 +- src/SecucardConnect/Event/EventHandler.php | 1 + .../Product/Common/Model/BaseCollection.php | 2 +- .../Product/Document/Model/Upload.php | 18 ++ .../Product/Document/UploadsService.php | 46 ++++ .../Product/Loyalty/Model/Card.php | 1 - .../Product/Payment/Event/PaymentChanged.php | 24 +- .../Product/Payment/Model/Basket.php | 8 +- .../Product/Payment/Model/Container.php | 2 +- .../Product/Payment/Model/Contract.php | 8 +- .../Product/Payment/Model/Experience.php | 24 +- .../Product/Payment/Model/OptData.php | 16 +- .../Payment/Model/PaymentInstrument.php | 4 +- .../Product/Payment/Model/RedirectUrl.php | 40 ++-- .../Product/Payment/Model/Subscription.php | 12 +- .../Product/Payment/Model/Transaction.php | 82 ++++--- .../Product/Payment/SecupayDebitsService.php | 14 +- .../Payment/SecupayInvoicesService.php | 14 +- .../Product/Payment/SecupayPrepaysService.php | 14 +- .../Payment/Service/PaymentService.php | 213 +++++++++++++++--- .../Service/PaymentServiceInterface.php | 26 +-- .../Product/Services/IdentCasesService.php | 50 ++++ .../Product/Services/IdentRequestsService.php | 33 ++- .../Product/Services/IdentResultsService.php | 90 ++++---- .../Product/Services/Model/Address.php | 26 +++ .../Services/Model/AddressComponents.php | 25 ++ .../Product/Services/Model/Attachment.php | 3 + .../Product/Services/Model/Company.php | 59 +++++ .../Product/Services/Model/Contact.php | 54 +++++ .../Product/Services/Model/ContactData.php | 3 + .../Product/Services/Model/Contract.php | 8 +- .../Product/Services/Model/CustomData.php | 4 + .../Product/Services/Model/IdentCase.php | 107 +++++++++ .../Product/Services/Model/IdentRequest.php | 23 +- .../Product/Services/Model/IdentResult.php | 8 +- .../Services/Model/IdentificationDocument.php | 11 +- .../Services/Model/IdentificationProcess.php | 4 +- .../Product/Services/Model/RequestPerson.php | 33 +-- .../Product/Services/Model/ResultPerson.php | 7 +- .../Product/Services/Model/Task.php | 36 +++ .../Product/Services/Model/Tasks.php | 24 ++ .../Product/Services/Model/UserData.php | 25 +- .../Product/Services/Model/Value.php | 6 +- .../Product/Smart/Model/Checkin.php | 4 - .../Product/Smart/Model/Ident.php | 2 - src/SecucardConnect/SecucardConnect.php | 9 +- src/SecucardConnect/Util/GuzzleLogger.php | 1 + src/SecucardConnect/Util/Logger.php | 2 +- tests/SecucardConnect/Auth/ClientAuthTest.php | 18 -- tests/SecucardConnect/Auth/DeviceAuthTest.php | 50 ---- tests/SecucardConnect/BaseClientTest.php | 63 ------ tests/SecucardConnect/Client/StorageTest.php | 62 ----- .../Product/Common/MediaResourceTest.php | 29 --- .../Product/General/AccountsTest.php | 58 ----- .../Product/General/Model/Skeletons.php | 40 ---- .../Product/General/SkeletonsTest.php | 42 ---- .../Product/Loyalty/CardsTest.php | 58 ----- .../Product/Payment/ContainersTest.php | 62 ----- .../Product/Payment/ContractsTest.php | 31 --- .../Product/Payment/CustomersTest.php | 75 ------ .../Product/Payment/SecupayprepaysTest.php | 71 ------ .../Product/Services/IdentcontractsTest.php | 21 -- .../Product/Services/IdentrequestsTest.php | 56 ----- .../Product/Services/IdentresultsTest.php | 40 ---- .../Product/Smart/CheckinsTest.php | 39 ---- .../Product/Smart/DevicesTest.php | 22 -- .../Product/Smart/IdentsTest.php | 29 --- .../Product/Smart/RoutingsTest.php | 39 ---- .../Product/Smart/TransactionsTest.php | 51 ----- 87 files changed, 1156 insertions(+), 1518 deletions(-) delete mode 100644 phpunit.xml create mode 100644 src/SecucardConnect/Product/Document/Model/Upload.php create mode 100644 src/SecucardConnect/Product/Document/UploadsService.php create mode 100644 src/SecucardConnect/Product/Services/IdentCasesService.php create mode 100644 src/SecucardConnect/Product/Services/Model/Address.php create mode 100644 src/SecucardConnect/Product/Services/Model/AddressComponents.php create mode 100644 src/SecucardConnect/Product/Services/Model/Company.php create mode 100644 src/SecucardConnect/Product/Services/Model/Contact.php create mode 100644 src/SecucardConnect/Product/Services/Model/IdentCase.php create mode 100644 src/SecucardConnect/Product/Services/Model/Task.php create mode 100644 src/SecucardConnect/Product/Services/Model/Tasks.php delete mode 100644 tests/SecucardConnect/Auth/ClientAuthTest.php delete mode 100644 tests/SecucardConnect/Auth/DeviceAuthTest.php delete mode 100644 tests/SecucardConnect/BaseClientTest.php delete mode 100644 tests/SecucardConnect/Client/StorageTest.php delete mode 100644 tests/SecucardConnect/Product/Common/MediaResourceTest.php delete mode 100644 tests/SecucardConnect/Product/General/AccountsTest.php delete mode 100644 tests/SecucardConnect/Product/General/Model/Skeletons.php delete mode 100644 tests/SecucardConnect/Product/General/SkeletonsTest.php delete mode 100644 tests/SecucardConnect/Product/Loyalty/CardsTest.php delete mode 100644 tests/SecucardConnect/Product/Payment/ContainersTest.php delete mode 100644 tests/SecucardConnect/Product/Payment/ContractsTest.php delete mode 100644 tests/SecucardConnect/Product/Payment/CustomersTest.php delete mode 100644 tests/SecucardConnect/Product/Payment/SecupayprepaysTest.php delete mode 100644 tests/SecucardConnect/Product/Services/IdentcontractsTest.php delete mode 100644 tests/SecucardConnect/Product/Services/IdentrequestsTest.php delete mode 100644 tests/SecucardConnect/Product/Services/IdentresultsTest.php delete mode 100644 tests/SecucardConnect/Product/Smart/CheckinsTest.php delete mode 100644 tests/SecucardConnect/Product/Smart/DevicesTest.php delete mode 100644 tests/SecucardConnect/Product/Smart/IdentsTest.php delete mode 100644 tests/SecucardConnect/Product/Smart/RoutingsTest.php delete mode 100644 tests/SecucardConnect/Product/Smart/TransactionsTest.php diff --git a/.gitignore b/.gitignore index 56c2618..548f334 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ phpunit.phar .buildpath .project .settings/ -.idea \ No newline at end of file +.idea +/composer.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dfe4ef..9f3ec1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,34 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Removed + + +## [1.4.0] - 2017-05-30 + +### Added +- PaymentService: refund method +- PaymentService: capture method +- PaymentService: updateBasket method +- PaymentService: reverseAccrual method +- PaymentService: initSubsequent method +- PaymentService: setShippingInformation method +- PaymentService: updateSubscription method +- Product Document: UploadsService +- Product Service: IdentCasesService + +### Changed +- Updated dependency "guzzle" to ~6.2 +- Updated dependency "jsonmapper" to ~1.1 + +### Fixed +- PHP 5.5 incompatibility (const array) +- Wrong parent class of class RedirectUrl +- PSR-2 Coding Style conformance + +### Removed +- Removed tests, because the need to be reworked +- Remove development dependency "phpunit" + ## [1.3.1] - 2017-04-28 ### Fixed @@ -25,7 +53,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). -## [1.3.0] - 2017-04-26 +## [1.3.0] - 2017-04-26 [YANKED] ### Deprecated - Pass an array for API client configuration in the constructor of the class "SecucardConnect" is deprecated. @@ -305,4 +333,31 @@ Commit-ID: 5b5eb23 ## [0.0.1] - 2014-11-03 Commit-ID: 787f4fa -First release \ No newline at end of file +First release + + + + +[0.0.2]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.0.1...v0.0.2 +[0.0.3]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.0.2...v0.0.3 +[0.0.4]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.0.3...v0.0.4 +[0.0.5]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.0.4...v0.0.5 +[0.1.0]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.0.5...v0.1.0 +[0.1.1]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.1.0...v0.1.1 +[0.1.2]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.1.1...v0.1.2 +[0.1.3]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.1.2...v0.1.3 +[1.0.0]:https://github.com/secucard/secucard-connect-php-sdk/compare/v0.1.3...v1.0.0 +[1.0.1]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.0...v1.0.1 +[1.0.2]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.1...v1.0.2 +[1.0.3]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.2...v1.0.3 +[1.0.4]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.3...v1.0.4 +[1.0.5]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.4...v1.0.5 +[1.0.6]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.5...v1.0.6 +[1.0.7]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.6...v1.0.7 +[1.0.8]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.7...v1.0.8 +[1.0.9]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.8...v1.0.9 +[1.1.0]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.0.9...v1.1.0 +[1.1.1]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.1.0...v1.1.1 +[1.1.2]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.1.1...v1.1.2 +[1.3.1]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.1.2...v1.3.1 +[1.4.0]:https://github.com/secucard/secucard-connect-php-sdk/compare/v1.3.1...v1.4.0 \ No newline at end of file diff --git a/composer.json b/composer.json index 89e554b..832e41a 100644 --- a/composer.json +++ b/composer.json @@ -3,26 +3,16 @@ "description": "secucard connect PHP client SDK", "license": "Apache-2.0", "homepage": "https://github.com/secucard/secucard-connect-php-sdk", - "version": "v1.3.1", + "version": "v1.4.0", "require": { "php": ">=5.5.0", - "guzzlehttp/guzzle": "~6.0", + "guzzlehttp/guzzle": "~6.2", "psr/log": "~1.0", - "netresearch/jsonmapper": "v0.10.0" + "netresearch/jsonmapper": "~1.1" }, - - "require-dev": { - "phpunit/phpunit": "4.8" - }, - "autoload": { "psr-4": { "SecucardConnect\\": "src/SecucardConnect" } - }, - "autoload-dev": { - "psr-4": { - "SecucardConnect\\": "tests/SecucardConnect" - } } } diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index 7f0cbf0..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - ./tests - - - \ No newline at end of file diff --git a/src/SecucardConnect/ApiClientConfiguration.php b/src/SecucardConnect/ApiClientConfiguration.php index 507b270..8e32964 100644 --- a/src/SecucardConnect/ApiClientConfiguration.php +++ b/src/SecucardConnect/ApiClientConfiguration.php @@ -15,7 +15,7 @@ class ApiClientConfiguration const ACCEPT_LANGUAGE_DE = 'de'; // The following fields are required when creating the client - const REQUIRED_FIELDS = [ + protected static $REQUIRED_FIELDS = [ 'base_url', 'auth_path', 'api_path', @@ -121,7 +121,7 @@ public function isValid() { $data = $this->toArray(); - $missing = array_diff(self::REQUIRED_FIELDS, array_keys($data)); + $missing = array_diff(self::$REQUIRED_FIELDS, array_keys($data)); if ($missing) { throw new \InvalidArgumentException('Config is missing the following keys: ' . implode(', ', $missing)); diff --git a/src/SecucardConnect/Auth/AuthCodes.php b/src/SecucardConnect/Auth/AuthCodes.php index d3eace0..bace01b 100644 --- a/src/SecucardConnect/Auth/AuthCodes.php +++ b/src/SecucardConnect/Auth/AuthCodes.php @@ -1,10 +1,4 @@ auth_path = $auth_path; $this->storage = $storage; @@ -153,15 +153,17 @@ public function getAccessToken($deviceCode = null, $json = false) if ($this->credentials instanceof RefreshTokenCredentials) { $this->updateToken($this->credentials); - } else if ($this->refreshToken) { - if (!$this->credentials instanceof ClientCredentials) { - throw new ClientError('Invalid credentials type supplied, must be of type ' . ClientCredentials::class); - } - $this->updateToken(new RefreshTokenCredentials($this->credentials->client_id, - $this->credentials->client_secret, $this->refreshToken)); - } else { - $this->updateToken(); + if ($this->refreshToken) { + if (!$this->credentials instanceof ClientCredentials) { + throw new ClientError('Invalid credentials type supplied, must be of type ' . ClientCredentials::class); + } + $this->updateToken(new RefreshTokenCredentials($this->credentials->client_id, + $this->credentials->client_secret, $this->refreshToken)); + + } else { + $this->updateToken(); + } } } } @@ -169,11 +171,11 @@ public function getAccessToken($deviceCode = null, $json = false) $at = $this->accessToken['access_token']; if ($json === true) { - $arr = array( + $arr = [ 'access_token' => $at, 'expires_in' => $this->accessToken['expires_in'] - time(), 'expireTime' => $this->accessToken['expires_in'] - ); + ]; return json_encode($arr); } else { return $at; @@ -194,7 +196,7 @@ private function updateToken(RefreshTokenCredentials $refreshToken = null, $devi $tokenData = null; // array of url parameters that will be sent in auth request - $params = array(); + $params = []; if ($refreshToken == null && !empty($deviceCode)) { $tokenData = $this->pollDeviceAccessToken($deviceCode); if ($tokenData === false) { @@ -216,7 +218,7 @@ private function updateToken(RefreshTokenCredentials $refreshToken = null, $devi } // Process the returned data, both expired_in and refresh_token are optional parameters - $this->accessToken = array('access_token' => $tokenData->access_token,); + $this->accessToken = ['access_token' => $tokenData->access_token,]; if (isset($tokenData->expires_in)) { $this->accessToken['expires_in'] = time() + $tokenData->expires_in; } @@ -245,7 +247,7 @@ private function obtainDeviceVerification() throw new ClientError('Invalid credentials set up, must be of type ' . DeviceCredentials::class); } - $params = array(); + $params = []; $this->setParams($params, $this->credentials); // if the guzzle gets response http_status other than 200, it will throw an exception even when there is response available @@ -274,7 +276,7 @@ private function pollDeviceAccessToken($deviceCode) $this->credentials->deviceCode = $deviceCode; - $params = array(); + $params = []; $this->setParams($params, $this->credentials); try { @@ -312,6 +314,6 @@ private function setParams(&$params, GrantTypeInterface $obj) */ private function post($params) { - return $this->httpClient->post($this->auth_path, array('form_params' => $params)); + return $this->httpClient->post($this->auth_path, ['form_params' => $params]); } } diff --git a/src/SecucardConnect/Client/ApiError.php b/src/SecucardConnect/Client/ApiError.php index 3b44704..7fdbbc0 100644 --- a/src/SecucardConnect/Client/ApiError.php +++ b/src/SecucardConnect/Client/ApiError.php @@ -63,16 +63,16 @@ public function getServerError() return $this->serverError; } - /** - * ApiError constructor. - * - * @param string $serverError - * @param int $code - * @param Exception $details - * @param $userMessage - * @param $supportId - * @param Exception|null $previous - */ + /** + * ApiError constructor. + * + * @param string $serverError + * @param int $code + * @param Exception $details + * @param $userMessage + * @param $supportId + * @param Exception|null $previous + */ public function __construct( $serverError, $code, diff --git a/src/SecucardConnect/Client/ClientError.php b/src/SecucardConnect/Client/ClientError.php index eb0554c..538e1e5 100644 --- a/src/SecucardConnect/Client/ClientError.php +++ b/src/SecucardConnect/Client/ClientError.php @@ -12,12 +12,12 @@ */ class ClientError extends AbstractError { - /** - * ClientError constructor. - * - * @param string $message - * @param Exception|null $previous - */ + /** + * ClientError constructor. + * + * @param string $message + * @param Exception|null $previous + */ public function __construct($message = "", Exception $previous = null) { $msg = $message; diff --git a/src/SecucardConnect/Client/DummyStorage.php b/src/SecucardConnect/Client/DummyStorage.php index 7a0a275..7a54f10 100644 --- a/src/SecucardConnect/Client/DummyStorage.php +++ b/src/SecucardConnect/Client/DummyStorage.php @@ -6,25 +6,28 @@ * Class DummyStorage * @package SecucardConnect\Client */ -class DummyStorage implements StorageInterface { - +class DummyStorage implements StorageInterface +{ + protected $storage; - /** - * DummyStorage constructor. - */ - public function __construct() { + /** + * DummyStorage constructor. + */ + public function __construct() + { // init dummy storage var $this->storage = []; } - + /** * Retrieve an item from cache * * @param string $key The key to store it under * @return mixed */ - public function get($key) { + public function get($key) + { if (isset($this->storage[$key])) { return $this->storage[$key]; } @@ -38,7 +41,8 @@ public function get($key) { * @param mixed $value * @return void */ - public function set($key, $value) { + public function set($key, $value) + { $this->storage[$key] = $value; } @@ -48,7 +52,8 @@ public function set($key, $value) { * @param string $key * @return void */ - public function delete($key) { + public function delete($key) + { unset($this->storage[$key]); } @@ -57,7 +62,8 @@ public function delete($key) { * * @return void */ - public function deleteAll() { + public function deleteAll() + { $this->storage = []; } } \ No newline at end of file diff --git a/src/SecucardConnect/Client/FileStorage.php b/src/SecucardConnect/Client/FileStorage.php index 28d6edf..c5dcc5a 100644 --- a/src/SecucardConnect/Client/FileStorage.php +++ b/src/SecucardConnect/Client/FileStorage.php @@ -12,13 +12,13 @@ class FileStorage extends DummyStorage { private $dir; - /** - * FileStorage constructor. - * - * @param $dir - * - * @throws ClientError - */ + /** + * FileStorage constructor. + * + * @param $dir + * + * @throws ClientError + */ public function __construct($dir) { parent::__construct(); @@ -119,9 +119,9 @@ public function deleteAll() return true; } - /** - * @return bool - */ + /** + * @return bool + */ private function load() { $filename = $this->filePath(); @@ -133,20 +133,20 @@ private function load() return false; } - /** - * @return bool - */ + /** + * @return bool + */ private function save() { file_put_contents($this->filePath(), json_encode($this->storage)); return true; } - /** - * @param $key - * - * @return bool|int - */ + /** + * @param $key + * + * @return bool|int + */ private function findFile($key) { $files = glob($this->filePath($key)); @@ -167,11 +167,11 @@ private function findFile($key) return false; } - /** - * @param $key - * - * @return bool - */ + /** + * @param $key + * + * @return bool + */ private function deleteFile($key) { $file = $this->findFile($key); @@ -186,11 +186,11 @@ private function deleteFile($key) return unlink($file); } - /** - * @param $key - * - * @return bool - */ + /** + * @param $key + * + * @return bool + */ private function deleteStore($key) { if (isset($this->storage[$key])) { diff --git a/src/SecucardConnect/Client/MediaResourceTrait.php b/src/SecucardConnect/Client/MediaResourceTrait.php index a5e402b..aa85c03 100644 --- a/src/SecucardConnect/Client/MediaResourceTrait.php +++ b/src/SecucardConnect/Client/MediaResourceTrait.php @@ -114,13 +114,13 @@ public function getContents($cache = true) return $result; } - /** - * @param bool $cache - * - * @return null|\Psr\Http\Message\StreamInterface - * @throws ClientError - * @throws \Exception - */ + /** + * @param bool $cache + * + * @return null|\Psr\Http\Message\StreamInterface + * @throws ClientError + * @throws \Exception + */ private function downloadMe($cache = true) { if (empty($this->httpClient)) { diff --git a/src/SecucardConnect/Client/ProductService.php b/src/SecucardConnect/Client/ProductService.php index b6bec0b..c908eae 100644 --- a/src/SecucardConnect/Client/ProductService.php +++ b/src/SecucardConnect/Client/ProductService.php @@ -63,13 +63,13 @@ abstract class ProductService private $actionId; - /** - * @param string $product - * @param string $resource - * @param ClientContext $context - * - * @return mixed - */ + /** + * @param string $product + * @param string $resource + * @param ClientContext $context + * + * @return mixed + */ public static function create($product, $resource, ClientContext $context) { $rm = new ResourceMetadata($product, $resource); @@ -142,14 +142,14 @@ public function getNextBatch($id) return $this->getListInternal(null, null, $id); } - /** - * @param QueryParams|null $query - * @param null $expireTime - * @param null $scrollId - * - * @return BaseCollection - * @throws ClientError - */ + /** + * @param QueryParams|null $query + * @param null $expireTime + * @param null $scrollId + * + * @return BaseCollection + * @throws ClientError + */ private function getListInternal(QueryParams $query = null, $expireTime = null, $scrollId = null) { $sp = new SearchParams($query, $expireTime, $scrollId); @@ -288,10 +288,11 @@ public function save(BaseModel $model) return $inst; } - /** - * @return string - */ - public function getResourceId(){ + /** + * @return string + */ + public function getResourceId() + { return $this->resourceMetadata->resourceId; } @@ -306,60 +307,61 @@ public function getResourceId(){ * The given ID is immediately cleared (null) after applied for a service call, even after a failure. * @param $id string Any unique id. */ - public function setActionId($id){ + public function setActionId($id) + { $this->actionId = $id; } - /** - * @param $id - * @param $action - * @param null $actionArg - * @param null $object - * @param null $class - * - * @return bool|mixed|null|string - */ + /** + * @param $id + * @param $action + * @param null $actionArg + * @param null $object + * @param null $class + * + * @return bool|mixed|null|string + */ protected function updateWithAction($id, $action, $actionArg = null, $object = null, $class = null) { return $this->requestAction(RequestOps::UPDATE, $id, $action, $actionArg, $object, $class); } - /** - * @param $id - * @param $action - * @param null $actionArg - * @param null $object - * @param null $class - * - * @return bool|mixed|null|string - */ + /** + * @param $id + * @param $action + * @param null $actionArg + * @param null $object + * @param null $class + * + * @return bool|mixed|null|string + */ protected function deleteWithAction($id, $action, $actionArg = null, $object = null, $class = null) { return $this->requestAction(RequestOps::DELETE, $id, $action, $actionArg, $object, $class); } - /** - * @param $id - * @param $action - * @param null $actionArg - * @param null $object - * @param null $class - * - * @return bool|mixed|null|string - */ + /** + * @param $id + * @param $action + * @param null $actionArg + * @param null $object + * @param null $class + * + * @return bool|mixed|null|string + */ protected function execute($id, $action, $actionArg = null, $object = null, $class = null) { return $this->requestAction(RequestOps::EXECUTE, $id, $action, $actionArg, $object, $class); } - /** - * @param $appId - * @param $action - * @param null $object - * @param null $class - * - * @return bool|mixed|null|string - */ + /** + * @param $appId + * @param $action + * @param null $object + * @param null $class + * + * @return bool|mixed|null|string + */ protected function executeCustom($appId, $action, $object = null, $class = null) { return $this->requestAction(RequestOps::EXECUTE, null, $action, null, $object, $class, $appId); @@ -376,17 +378,17 @@ protected function getRequestOptions() return []; } - /** - * @param $op - * @param null $id - * @param $action - * @param null $actionArg - * @param null $object - * @param null $class - * @param null $appId - * - * @return bool|mixed|null|string - */ + /** + * @param $op + * @param null $id + * @param $action + * @param null $actionArg + * @param null $object + * @param null $class + * @param null $appId + * + * @return bool|mixed|null|string + */ private function requestAction( $op, $id = null, @@ -395,8 +397,7 @@ private function requestAction( $object = null, $class = null, $appId = null - ) - { + ) { // todo: should property filtering for json also apply here? $json = $object == null ? null : MapperUtil::jsonEncode($object); @@ -421,14 +422,14 @@ private function requestAction( return $json; } - /** - * @param RequestParams $params - * - * @return bool|mixed - * @throws ApiError - * @throws AuthError - * @throws ClientError - */ + /** + * @param RequestParams $params + * + * @return bool|mixed + * @throws ApiError + * @throws AuthError + * @throws ClientError + */ private function request(RequestParams $params) { /* @@ -615,12 +616,12 @@ protected function initMediaResource(&$arg) return $mr; } - /** - * @param $json - * @param $class - * - * @return mixed|null - */ + /** + * @param $json + * @param $class + * + * @return mixed|null + */ private function createResourceInst($json, $class) { if (empty($json)) { @@ -760,8 +761,7 @@ public function __construct( $actionArg = null, $jsonData = null, array $options = [] - ) - { + ) { $this->operation = $operation; $this->id = $id; $this->searchParams = $searchParams; diff --git a/src/SecucardConnect/Client/QueryParams.php b/src/SecucardConnect/Client/QueryParams.php index 769dfa2..0e12379 100644 --- a/src/SecucardConnect/Client/QueryParams.php +++ b/src/SecucardConnect/Client/QueryParams.php @@ -67,8 +67,7 @@ public function __construct( $offset = null, array $fields = null, array $sortOrder = null, - array - $query = null + array $query = null ) { $this->count = $count; $this->offset = $offset; diff --git a/src/SecucardConnect/Client/ResourceMetadata.php b/src/SecucardConnect/Client/ResourceMetadata.php index dee0dce..ef66cbf 100644 --- a/src/SecucardConnect/Client/ResourceMetadata.php +++ b/src/SecucardConnect/Client/ResourceMetadata.php @@ -66,7 +66,7 @@ public function __construct($product, $resource = null) * check all classes in this product model dir against the given resource name to find the right resource class * necessary because class name may be singular of resource name (seems safer than just stripping the "s") */ - private function findModelClass($dir, $resource, $classPrefix) + private function findModelClass($dir, $resource, $classPrefix) { $lcres = strtolower($resource); $files = glob($dir . DIRECTORY_SEPARATOR . '*.php'); @@ -94,13 +94,13 @@ private function findModelClass($dir, $resource, $classPrefix) return null; } - /** - * @param $dir - * @param $resource - * @param $classPrefix - * - * @return null|string - */ + /** + * @param $dir + * @param $resource + * @param $classPrefix + * + * @return null|string + */ private function findServiceClass($dir, $resource, $classPrefix) { $lcres = strtolower($resource); @@ -108,21 +108,21 @@ private function findServiceClass($dir, $resource, $classPrefix) foreach ($files as $file) { $name = basename($file, '.php'); if (strpos(strtolower($name), $lcres) !== false) { - $parentClassName = $className = $classPrefix . $name; + $parentClassName = $className = $classPrefix . $name; do { - $rc = new \ReflectionClass($parentClassName); - $parent = $rc->getParentClass(); + $rc = new \ReflectionClass($parentClassName); + $parent = $rc->getParentClass(); - if (!$parent) { - break; - } + if (!$parent) { + break; + } - $parentClassName = $parent->getName(); + $parentClassName = $parent->getName(); - if (ProductService::class === $parentClassName) { - return $className; - } + if (ProductService::class === $parentClassName) { + return $className; + } } while (true); } diff --git a/src/SecucardConnect/Event/DefaultEventHandler.php b/src/SecucardConnect/Event/DefaultEventHandler.php index 23fa91f..6c46dc1 100644 --- a/src/SecucardConnect/Event/DefaultEventHandler.php +++ b/src/SecucardConnect/Event/DefaultEventHandler.php @@ -57,11 +57,11 @@ protected function accept(Event $event) return $event->target === $this->eventTarget && $event->type === $this->eventType; } - /** - * @param Event $event - * - * @return bool - */ + /** + * @param Event $event + * + * @return bool + */ function handle(Event $event) { if ($this->accept($event)) { diff --git a/src/SecucardConnect/Event/EventDispatcher.php b/src/SecucardConnect/Event/EventDispatcher.php index afaace0..355d2c7 100644 --- a/src/SecucardConnect/Event/EventDispatcher.php +++ b/src/SecucardConnect/Event/EventDispatcher.php @@ -44,7 +44,7 @@ public function dispatch($eventStr) try { // decode as array because data proprty, which has unknown structure (only known by handler), // must remain array after mapping to event - $arr = MapperUtil::jsonDecode($eventStr, true); + $arr = MapperUtil::jsonDecode($eventStr, true); $event = MapperUtil::map($arr, Event::class); } catch (Exception $e) { throw new ClientError("Invalid event JSON", $e); diff --git a/src/SecucardConnect/Event/EventHandler.php b/src/SecucardConnect/Event/EventHandler.php index f8918ae..c184bef 100644 --- a/src/SecucardConnect/Event/EventHandler.php +++ b/src/SecucardConnect/Event/EventHandler.php @@ -1,4 +1,5 @@ function (&$value) { +// if ($value instanceof BaseCollection) { +// $results = $value->items; +// } elseif ($value instanceof Upload) { +// $results[] = $value; +// } else { +// return; +// } +// +// foreach ($results as $result) { +// $this->process($result); +// } +// } +// ]; +// } +// +// /** +// * @param Upload $request +// */ +// private function process(Upload &$request) +// { +////... +// } +} diff --git a/src/SecucardConnect/Product/Loyalty/Model/Card.php b/src/SecucardConnect/Product/Loyalty/Model/Card.php index 9140618..932d642 100644 --- a/src/SecucardConnect/Product/Loyalty/Model/Card.php +++ b/src/SecucardConnect/Product/Loyalty/Model/Card.php @@ -5,7 +5,6 @@ namespace SecucardConnect\Product\Loyalty\Model; -use DateTime; use SecucardConnect\Product\Common\Model\BaseModel; use SecucardConnect\Product\General\Model\Account; diff --git a/src/SecucardConnect/Product/Payment/Event/PaymentChanged.php b/src/SecucardConnect/Product/Payment/Event/PaymentChanged.php index 0ef0b24..1067352 100644 --- a/src/SecucardConnect/Product/Payment/Event/PaymentChanged.php +++ b/src/SecucardConnect/Product/Payment/Event/PaymentChanged.php @@ -11,17 +11,17 @@ */ class PaymentChanged extends DefaultEventHandler { - /** - * @param $event - * - * @throws ClientError If the payment transaction id is missing in the event data - */ - function onEvent($event) - { - if (!isset($event->data[0]['id'])) { - throw new ClientError('Invalid event data, payment id not found.'); - } + /** + * @param $event + * + * @throws ClientError If the payment transaction id is missing in the event data + */ + function onEvent($event) + { + if (!isset($event->data[0]['id'])) { + throw new ClientError('Invalid event data, payment id not found.'); + } - call_user_func($this->callback, $this->service->get($event->data[0]['id'])); - } + call_user_func($this->callback, $this->service->get($event->data[0]['id'])); + } } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Payment/Model/Basket.php b/src/SecucardConnect/Product/Payment/Model/Basket.php index 0c0a23e..85e7a6c 100644 --- a/src/SecucardConnect/Product/Payment/Model/Basket.php +++ b/src/SecucardConnect/Product/Payment/Model/Basket.php @@ -10,10 +10,10 @@ */ class Basket extends BaseModel { - const ITEM_TYPE_ARTICLE = 'article'; - const ITEM_TYPE_SHIPPING = 'shipping'; - const ITEM_TYPE_DONATION = 'donation'; - const ITEM_TYPE_STAKEHOLDER_PAYMENT = 'stakeholder_payment'; + const ITEM_TYPE_ARTICLE = 'article'; + const ITEM_TYPE_SHIPPING = 'shipping'; + const ITEM_TYPE_DONATION = 'donation'; + const ITEM_TYPE_STAKEHOLDER_PAYMENT = 'stakeholder_payment'; /** * @var int diff --git a/src/SecucardConnect/Product/Payment/Model/Container.php b/src/SecucardConnect/Product/Payment/Model/Container.php index 89f9c26..eca74cf 100644 --- a/src/SecucardConnect/Product/Payment/Model/Container.php +++ b/src/SecucardConnect/Product/Payment/Model/Container.php @@ -29,7 +29,7 @@ class Container extends BaseModel * @var \SecucardConnect\Product\Payment\Model\Data */ public $private; - + /** * @var string */ diff --git a/src/SecucardConnect/Product/Payment/Model/Contract.php b/src/SecucardConnect/Product/Payment/Model/Contract.php index 8a59a9a..ab2ead8 100644 --- a/src/SecucardConnect/Product/Payment/Model/Contract.php +++ b/src/SecucardConnect/Product/Payment/Model/Contract.php @@ -61,8 +61,12 @@ class CloneParams */ public $project; - public function __construct($project = null, Data $payment_data = null, $allow_transactions = null, $url_push = null) - { + public function __construct( + $project = null, + Data $payment_data = null, + $allow_transactions = null, + $url_push = null + ) { $this->allow_transactions = $allow_transactions; $this->url_push = $url_push; $this->payment_data = $payment_data; diff --git a/src/SecucardConnect/Product/Payment/Model/Experience.php b/src/SecucardConnect/Product/Payment/Model/Experience.php index 170e200..06aff9f 100644 --- a/src/SecucardConnect/Product/Payment/Model/Experience.php +++ b/src/SecucardConnect/Product/Payment/Model/Experience.php @@ -10,17 +10,17 @@ */ class Experience extends BaseModel { - /** - * The number of positive customer experiences - * - * @var int - */ - public $positiv; + /** + * The number of positive customer experiences + * + * @var int + */ + public $positiv; - /** - * The number of negative customer experiences (open orders - * - * @var int - */ - public $negativ; + /** + * The number of negative customer experiences (open orders + * + * @var int + */ + public $negativ; } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Payment/Model/OptData.php b/src/SecucardConnect/Product/Payment/Model/OptData.php index 18d6023..f2eae53 100644 --- a/src/SecucardConnect/Product/Payment/Model/OptData.php +++ b/src/SecucardConnect/Product/Payment/Model/OptData.php @@ -10,13 +10,13 @@ */ class OptData extends BaseModel { - /** - * @var bool - */ - public $has_accepted_disclaimer = false; + /** + * @var bool + */ + public $has_accepted_disclaimer = false; - /** - * @var bool - */ - public $hide_disclaimer = false; + /** + * @var bool + */ + public $hide_disclaimer = false; } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Payment/Model/PaymentInstrument.php b/src/SecucardConnect/Product/Payment/Model/PaymentInstrument.php index 9fc462f..3d80737 100644 --- a/src/SecucardConnect/Product/Payment/Model/PaymentInstrument.php +++ b/src/SecucardConnect/Product/Payment/Model/PaymentInstrument.php @@ -38,7 +38,7 @@ class PaymentInstrument public function createBankAccount($owner, $iban, $bic = null, $bankname = null) { $iban = str_replace(' ', '', $iban); - $iban = substr_replace($iban, str_repeat("X", strlen($iban)-8), 4, -4); + $iban = substr_replace($iban, str_repeat("X", strlen($iban) - 8), 4, -4); $this->type = self::PAYMENT_INSTRUMENT_TYPE_BANK_ACCOUNT; $this->data = [ @@ -61,7 +61,7 @@ public function createBankAccount($owner, $iban, $bic = null, $bankname = null) * * @return self */ - public function createCreditCard($owner, $pan, $expiration_date, $issuer = null ) + public function createCreditCard($owner, $pan, $expiration_date, $issuer = null) { $pan = str_replace(' ', '', $pan); $pan = substr_replace($pan, str_repeat("X", 8), 4, 8); diff --git a/src/SecucardConnect/Product/Payment/Model/RedirectUrl.php b/src/SecucardConnect/Product/Payment/Model/RedirectUrl.php index 621f7b0..c4d7aef 100644 --- a/src/SecucardConnect/Product/Payment/Model/RedirectUrl.php +++ b/src/SecucardConnect/Product/Payment/Model/RedirectUrl.php @@ -2,32 +2,30 @@ namespace SecucardConnect\Product\Payment\Model; -use SecucardConnect\Product\Common\Model\BaseModel; - /** * RedirectUrl Data Model class * */ -class RedirectUrl extends BaseModel +class RedirectUrl { - /** - * The url for redirect the customer back to the shop after a successful payment checkout - * - * @var string - */ - public $url_success; + /** + * The url for redirect the customer back to the shop after a successful payment checkout + * + * @var string + */ + public $url_success; - /** - * The url for redirect the customer back to the shop after a failure (or on cancel) on the payment checkout page - * - * @var string - */ - public $url_failure; + /** + * The url for redirect the customer back to the shop after a failure (or on cancel) on the payment checkout page + * + * @var string + */ + public $url_failure; - /** - * The url for redirect the customer to the payment checkout page - * - * @var string - */ - public $iframe_url; + /** + * The url for redirect the customer to the payment checkout page + * + * @var string + */ + public $iframe_url; } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Payment/Model/Subscription.php b/src/SecucardConnect/Product/Payment/Model/Subscription.php index cf7b927..666c8e7 100644 --- a/src/SecucardConnect/Product/Payment/Model/Subscription.php +++ b/src/SecucardConnect/Product/Payment/Model/Subscription.php @@ -10,10 +10,10 @@ */ class Subscription extends BaseModel { - /** - * The name of the subscription (for the customer) - * - * @var string - */ - public $purpose; + /** + * The name of the subscription (for the customer) + * + * @var string + */ + public $purpose; } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Payment/Model/Transaction.php b/src/SecucardConnect/Product/Payment/Model/Transaction.php index c0dafda..2adecdc 100644 --- a/src/SecucardConnect/Product/Payment/Model/Transaction.php +++ b/src/SecucardConnect/Product/Payment/Model/Transaction.php @@ -1,10 +1,4 @@ onStatusChange($fn); - } + /** + * @deprecated v1.1.0 Use now onStatusChange($fn). + */ + public function onSecupayDebitChanged($fn) + { + $this->onStatusChange($fn); + } } diff --git a/src/SecucardConnect/Product/Payment/SecupayInvoicesService.php b/src/SecucardConnect/Product/Payment/SecupayInvoicesService.php index 51a20f7..63d5009 100644 --- a/src/SecucardConnect/Product/Payment/SecupayInvoicesService.php +++ b/src/SecucardConnect/Product/Payment/SecupayInvoicesService.php @@ -10,11 +10,11 @@ */ class SecupayInvoicesService extends PaymentService { - /** - * @deprecated v1.1.0 Use now onStatusChange($fn). - */ - public function onSecupayInvoiceChanged($fn) - { - $this->onStatusChange($fn); - } + /** + * @deprecated v1.1.0 Use now onStatusChange($fn). + */ + public function onSecupayInvoiceChanged($fn) + { + $this->onStatusChange($fn); + } } diff --git a/src/SecucardConnect/Product/Payment/SecupayPrepaysService.php b/src/SecucardConnect/Product/Payment/SecupayPrepaysService.php index 09d05bb..66d99f4 100644 --- a/src/SecucardConnect/Product/Payment/SecupayPrepaysService.php +++ b/src/SecucardConnect/Product/Payment/SecupayPrepaysService.php @@ -10,11 +10,11 @@ */ class SecupayPrepaysService extends PaymentService { - /** - * @deprecated v1.1.0 Use now onStatusChange($fn). - */ - public function onSecupayPrepayChanged($fn) - { - $this->onStatusChange($fn); - } + /** + * @deprecated v1.1.0 Use now onStatusChange($fn). + */ + public function onSecupayPrepayChanged($fn) + { + $this->onStatusChange($fn); + } } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Payment/Service/PaymentService.php b/src/SecucardConnect/Product/Payment/Service/PaymentService.php index 5d2fbee..363427d 100644 --- a/src/SecucardConnect/Product/Payment/Service/PaymentService.php +++ b/src/SecucardConnect/Product/Payment/Service/PaymentService.php @@ -4,6 +4,9 @@ use SecucardConnect\Client\ProductService; use SecucardConnect\Product\Payment\Event\PaymentChanged; +use SecucardConnect\Product\Payment\Model\Basket; +use SecucardConnect\Product\Payment\Model\Subscription; +use SecucardConnect\Product\Payment\Model\Transaction; /** * Class PaymentService @@ -11,52 +14,196 @@ */ abstract class PaymentService extends ProductService implements PaymentServiceInterface { - /** - * Cancel or Refund an existing transaction. - * Currently there are only full refunds allowed. - * @param string $paymentId The payment transaction id. - * @param string $contractId The id of the contract that was used to create this transaction. May be null if the - * contract is an parent contract (not cloned). - * @return bool TRUE if successful FALSE else. - */ - public function cancel($paymentId, $contractId = null) - { - $o = [['contract' => $contractId]]; - $res = $this->execute($paymentId, 'cancel', null, $o); - - if(is_object($res)) { - return (bool)$res->result; - } - - return (bool)$res['result']; - } - /** + * Cancel or Refund an existing transaction. + * Currently, partial refunds are are not allowed for all payment products. + * * @param string $paymentId The payment transaction id. + * @param string $contractId The id of the contract that was used to create this transaction. May be null if the + * contract is an parent contract (not cloned). + * @param int $amount The amount that you want to refund to the payer. Use '0' for a full refund. + * * @return bool TRUE if successful FALSE else. */ - public function capture($paymentId) + public function cancel($paymentId, $contractId = null, $amount = null) + { + $object = [ + [ + 'contract' => $contractId, + 'amount' => $amount, + ] + ]; + $res = $this->execute($paymentId, 'cancel', null, $object); + + if (is_object($res)) { + return true; + } + + return (bool)$res['result']; + } + + /** + * Capture a pre-authorized payment transaction. + * + * @param string $paymentId The payment transaction id + * @return bool TRUE if successful, FALSE otherwise. + */ + public function capture($paymentId) { $class = $this->resourceMetadata->resourceClass; + /** + * @var $object Transaction + */ $object = new $class(); $object->id = $paymentId; - $res = $this->updateWithAction($paymentId, null, null, $object, $class); + $res = $this->execute($paymentId, 'capture', null, $object, $class); - if(is_object($res)) { - return (bool)$res->result; + if ($res) { + return true; } - return (bool)$res['result']; + return false; + } + + /** + * Add additional basket items to the payment transaction. F.e. for adding stakeholder payment items. + * + * @param string $paymentId The payment transaction id + * @param Basket[] $basket + * @return bool TRUE if successful, FALSE otherwise. + */ + public function updateBasket($paymentId, array $basket) + { + $class = $this->resourceMetadata->resourceClass; + /** + * @var $object Transaction + */ + $object = new $class(); + $object->id = $paymentId; + $object->basket = $basket; + $res = $this->updateWithAction($paymentId, 'basket', null, $object, $class); + + if ($res) { + return true; + } + + return false; + } + + /** + * Remove the accrual flag of an existing payment transaction. + * + * @param string $paymentId The payment transaction id + * @return bool + */ + public function reverseAccrual($paymentId) + { + $class = $this->resourceMetadata->resourceClass; + /** + * @var $object Transaction + */ + $object = new $class(); + $object->id = $paymentId; + $object->accrual = false; + $res = $this->updateWithAction($paymentId, 'accrual', null, $object, $class); + + if ($res) { + return true; + } + + return false; + } + + /** + * Subsequent posting to a approved transaction. This can only be executed once per payment transaction. + * + * @param string $paymentId The payment transaction id + * @param int $amount The new total amount (max. 120% of the old amount) + * @param Basket[] $basket The new basket items + * @return bool TRUE if successful, FALSE otherwise. + */ + public function initSubsequent($paymentId, $amount, array $basket) + { + $class = $this->resourceMetadata->resourceClass; + /** + * @var $object Transaction + */ + $object = new $class(); + $object->id = $paymentId; + $object->amount = $amount; + $object->basket = $basket; + $res = $this->execute($paymentId, 'subsequent', null, $object, $class); + + if ($res) { + return true; + } + + return false; + } + + /** + * Add some shipping information, like the shipping provider (carrier) or a tracking number for the parcel. + * For invoice payment transactions this will also capture the transaction (set the shipping date of an invoice). + * + * @param string $paymentId The payment transaction id + * @param string $provider The shipping provider + * @param string $number The tracking number (comma separated if there is more than one parcel) + * @param string $invoice_number The invoice number of the shipped order + * @return bool TRUE if successful, FALSE otherwise. + */ + public function setShippingInformation($paymentId, $provider, $number, $invoice_number = null) + { + $object = [ + [ + 'provider' => $provider, + 'number' => $number, + 'invoice_number' => $invoice_number, + ] + ]; + + $res = $this->updateWithAction($paymentId, 'shippingInformation', null, $object); + + if ($res) { + return true; + } + + return false; } + /** + * Create or update a subscription for a existing transaction + * + * @param string $paymentId The payment transaction id + * @param string $purpose The purpose of the subscription + * @return bool TRUE if successful, FALSE otherwise. + */ + public function updateSubscription($paymentId, $purpose) + { + $class = $this->resourceMetadata->resourceClass; + /** + * @var $object Transaction + */ + $object = new $class(); + $object->id = $paymentId; + $object->subscription = new Subscription(); + $object->subscription->purpose = $purpose; + $res = $this->updateWithAction($paymentId, 'subscription', null, $object, $class); - /** - * Set a callback to be notified when a creditcard has changed. Pass null to remove a previous setting. - * @param $fn callable|null Any function which accepts a "Transaction" model class argument. - */ - public function onStatusChange($fn) - { - $this->registerEventHandler(static::class, $fn === null ? null : new PaymentChanged($fn, $this)); - } + if ($res) { + return true; + } + + return false; + } + + + /** + * Set a callback to be notified when a creditcard has changed. Pass null to remove a previous setting. + * @param $fn callable|null Any function which accepts a "Transaction" model class argument. + */ + public function onStatusChange($fn) + { + $this->registerEventHandler(static::class, $fn === null ? null : new PaymentChanged($fn, $this)); + } } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Payment/Service/PaymentServiceInterface.php b/src/SecucardConnect/Product/Payment/Service/PaymentServiceInterface.php index 4b867cf..d44bab1 100644 --- a/src/SecucardConnect/Product/Payment/Service/PaymentServiceInterface.php +++ b/src/SecucardConnect/Product/Payment/Service/PaymentServiceInterface.php @@ -8,20 +8,20 @@ */ interface PaymentServiceInterface { - /** - * Cancel an existing transaction. - * @param string $paymentId The payment transaction id. - * @param string $contractId The id of the contract that was used to create this transaction. May be null if the - * contract is an parent contract (not cloned). - * @return bool True if successful false else. - */ - public function cancel($paymentId, $contractId = null); + /** + * Cancel an existing transaction. + * @param string $paymentId The payment transaction id. + * @param string $contractId The id of the contract that was used to create this transaction. May be null if the + * contract is an parent contract (not cloned). + * @return bool True if successful false else. + */ + public function cancel($paymentId, $contractId = null); - /** - * Set a callback to be notified when a payment transaction has changed. Pass NULL to remove a previous setting. - * @param $fn callable|null Any function which accepts a "Transaction" model class argument. - */ - public function onStatusChange($fn); + /** + * Set a callback to be notified when a payment transaction has changed. Pass NULL to remove a previous setting. + * @param $fn callable|null Any function which accepts a "Transaction" model class argument. + */ + public function onStatusChange($fn); } \ No newline at end of file diff --git a/src/SecucardConnect/Product/Services/IdentCasesService.php b/src/SecucardConnect/Product/Services/IdentCasesService.php new file mode 100644 index 0000000..2a554ae --- /dev/null +++ b/src/SecucardConnect/Product/Services/IdentCasesService.php @@ -0,0 +1,50 @@ +execute($identcaseId, 'start', null, null, IdentCase::class); + } + + /** + * @param string $identcaseId IdentCase ID + * @return mixed + */ + public function closeIdentCase($identcaseId) + { + return $this->execute($identcaseId, 'close', null, null, IdentCase::class); + } + + /** + * @param string $identcaseId IdentCase ID + * @return mixed + */ + public function resetIdentCase($identcaseId) + { + return $this->execute($identcaseId, 'reset', null, null, IdentCase::class); + } + + /** + * @param string $identcaseId IdentCase ID + * @param string $taskId Task ID + * @return mixed + */ + public function taskIdentCase($identcaseId, $taskId) + { + return $this->updateWithAction($identcaseId, 'task', $taskId, null, IdentCase::class); + } +} diff --git a/src/SecucardConnect/Product/Services/IdentRequestsService.php b/src/SecucardConnect/Product/Services/IdentRequestsService.php index c0dc9b6..65902d4 100644 --- a/src/SecucardConnect/Product/Services/IdentRequestsService.php +++ b/src/SecucardConnect/Product/Services/IdentRequestsService.php @@ -7,29 +7,12 @@ use SecucardConnect\Product\Common\Model\BaseCollection; use SecucardConnect\Product\Services\Model\IdentRequest; - /** * Operations for the services/identrequests resource. * @package SecucardConnect\Product\Services */ class IdentRequestsService extends ProductService { - /** - * Handles proper contact picture initialization after retrieval of a ident request. - * @param IdentRequest $request - */ - private function process(IdentRequest &$request) - { - if (isset($request->person)) { - foreach ($request->person as $p) { - $contact = $p->contact; - if (!empty($contact) && !empty($contact->picture)) { - $contact->pictureObject = $this->initMediaResource($contact->picture); - } - } - } - } - /** * {@inheritDoc} */ @@ -51,4 +34,20 @@ protected function getRequestOptions() } ]; } + + /** + * Handles proper contact picture initialization after retrieval of a ident request. + * @param IdentRequest $request + */ + private function process(IdentRequest &$request) + { + if (isset($request->person)) { + foreach ($request->person as $p) { + $contact = $p->contact; + if (!empty($contact) && !empty($contact->picture)) { + $contact->pictureObject = $this->initMediaResource($contact->picture); + } + } + } + } } diff --git a/src/SecucardConnect/Product/Services/IdentResultsService.php b/src/SecucardConnect/Product/Services/IdentResultsService.php index 298d2ec..ab4d817 100644 --- a/src/SecucardConnect/Product/Services/IdentResultsService.php +++ b/src/SecucardConnect/Product/Services/IdentResultsService.php @@ -11,7 +11,6 @@ use SecucardConnect\Product\General\Model\Event; use SecucardConnect\Product\Services\Model\IdentResult; - /** * Operations for the services/identresults resource. * @package SecucardConnect\Product\Services @@ -19,21 +18,31 @@ class IdentResultsService extends ProductService { /** - * Handles proper attachments initialization after retrieval of a ident result. - * @param IdentResult $result + * Returns an array of IdentResult instances for a given array of IdentRequest ids. + * @param array $ids The request ids. + * @return BaseCollection The obtained results. */ - private function process(IdentResult &$result) + public function getListByRequestIds($ids) { - if (isset($result->person)) { - foreach ($result->person as $p) { - $attachments = $p->attachments; - if (!empty($attachments)) { - foreach ($attachments as $attachment) { - $this->initMediaResource($attachment); - } - } - } + $parts = []; + foreach ($ids as $id) { + $parts[] = 'request.id:' . $id; } + $qp = new QueryParams(); + $qp->query = join(' OR ', $parts); + return $this->getList($qp); + } + + /** + * Set a callback to be notified when ident-request has changed and a ident result is available. + * Pass null to remove a previous setting. + * @param $fn callable|null Any function which accepts a BaseCollection class argument. + * The collection contains the IdentResult instances. + * + */ + public function onIdentRequestsChanged($fn) + { + $this->registerEventHandler('idreschanged', $fn === null ? null : new IdentResChanged($fn, $this)); } /** @@ -59,31 +68,21 @@ protected function getRequestOptions() } /** - * Returns an array of IdentResult instances for a given array of IdentRequest ids. - * @param array $ids The request ids. - * @return BaseCollection The obtained results. + * Handles proper attachments initialization after retrieval of a ident result. + * @param IdentResult $result */ - public function getListByRequestIds($ids) + private function process(IdentResult &$result) { - $parts = array(); - foreach ($ids as $id) { - $parts[] = 'request.id:' . $id; + if (isset($result->person)) { + foreach ($result->person as $p) { + $attachments = $p->attachments; + if (!empty($attachments)) { + foreach ($attachments as $attachment) { + $this->initMediaResource($attachment); + } + } + } } - $qp = new QueryParams(); - $qp->query = join(' OR ', $parts); - return $this->getList($qp); - } - - /** - * Set a callback to be notified when ident-request has changed and a ident result is available. - * Pass null to remove a previous setting. - * @param $fn callable|null Any function which accepts a BaseCollection class argument. - * The collection contains the IdentResult instances. - * - */ - public function onIdentRequestsChanged($fn) - { - $this->registerEventHandler('idreschanged', $fn === null ? null : new IdentResChanged($fn, $this)); } } @@ -93,14 +92,6 @@ public function onIdentRequestsChanged($fn) */ class IdentResChanged extends DefaultEventHandler { - /** - * Overwrite the accept function, so the event with identrequest can be handled by identresults service - */ - protected function accept(Event $event) - { - return $event->target === 'services.identrequests' && $event->type === $this->eventType; - } - /** * @param Event $event * @throws ClientError @@ -112,11 +103,22 @@ function onEvent($event) throw new ClientError('Invalid event data, no ident-request id(s) found.'); } - $ids = array(); + $ids = []; foreach ($event->data as $item) { $ids[] = $item['id']; } call_user_func($this->callback, $this->service->getListByRequestIds($ids)); } + + /** + * Overwrite the accept function, so the event with identrequest can be handled by identresults service + * + * @param Event $event + * @return bool + */ + protected function accept(Event $event) + { + return $event->target === 'services.identrequests' && $event->type === $this->eventType; + } } diff --git a/src/SecucardConnect/Product/Services/Model/Address.php b/src/SecucardConnect/Product/Services/Model/Address.php new file mode 100644 index 0000000..9b0b035 --- /dev/null +++ b/src/SecucardConnect/Product/Services/Model/Address.php @@ -0,0 +1,26 @@ +enabled) { return; diff --git a/tests/SecucardConnect/Auth/ClientAuthTest.php b/tests/SecucardConnect/Auth/ClientAuthTest.php deleted file mode 100644 index 9d787ac..0000000 --- a/tests/SecucardConnect/Auth/ClientAuthTest.php +++ /dev/null @@ -1,18 +0,0 @@ -client->authenticate(); - $this->assertTrue($result === true); - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Auth/DeviceAuthTest.php b/tests/SecucardConnect/Auth/DeviceAuthTest.php deleted file mode 100644 index 179f4ed..0000000 --- a/tests/SecucardConnect/Auth/DeviceAuthTest.php +++ /dev/null @@ -1,50 +0,0 @@ - 'value1']); - } - - /** - * Existing tokens must be removed before running the test! - * - * @test - */ - public function testAuth() - { - $codes = $this->client->authenticate(); - - $this->assertTrue($codes instanceof AuthCodes); - - Logger::logInfo($this->logger, 'User code: ' . $codes->user_code); - - // NOTE: - // Poll timeout is set to 2 min for test purposes, but normally the timeout is defined by $codes->$expires_in! - $timeout = time() + 60 * 2; - - do { - $result = $this->client->authenticate(['devicecode' => $codes->device_code]); - if ($result === true) { - break; - } - Logger::logInfo($this->logger, 'Auth pending, try again'); - - // pause according to the given interval at least - sleep($codes->interval); - - } while (time() < $timeout); - - $this->assertTrue($result === true); - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/BaseClientTest.php b/tests/SecucardConnect/BaseClientTest.php deleted file mode 100644 index 779b6a4..0000000 --- a/tests/SecucardConnect/BaseClientTest.php +++ /dev/null @@ -1,63 +0,0 @@ - 'https://connect-dev10.secupay-ag.de', - 'debug' => true - ); - -// $fp = fopen("/tmp/secucard_php_test.log", "a"); - $fp = fopen("php://stdout", "a"); - $this->logger = new Logger($fp, true); - - - $store = new FileStorage(__DIR__ . '/../../' . '.secucardclientstore'); -// $store = new DummyStorage(); - - $this->client = new SecucardConnect($config, $this->logger, $store, $store, $this->getCredentials()); - } - - /** - * @test - */ - public function testClientCreation() - { - $this->assertFalse(empty($this->client)); - } - - /** - * Override in tests to set special credentials. - * @return ClientCredentials - */ - protected function getCredentials() - { - return new ClientCredentials('your-id', 'your-secret'); - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Client/StorageTest.php b/tests/SecucardConnect/Client/StorageTest.php deleted file mode 100644 index 1006cc0..0000000 --- a/tests/SecucardConnect/Client/StorageTest.php +++ /dev/null @@ -1,62 +0,0 @@ -dir . DIRECTORY_SEPARATOR . 'file'; - $key = 'key'; - $cachefile = $this->dir . DIRECTORY_SEPARATOR . $key; - - $s = new FileStorage($this->dir); - $this->assertTrue($s->set($key, 'value')); - - $s = new FileStorage($this->dir); - $this->assertTrue($s->get($key) === 'value'); - $this->assertNull($s->get('954815492217')); - - // replace with file - $f = fopen($file, 'w'); - fwrite($f, '12345'); - fclose($f); - $this->assertTrue($s->set($key, new Stream(fopen($file, 'r')))); - - $s = new FileStorage($this->dir); - $this->assertTrue(is_resource($s->get($key))); - - // replace again - $this->assertTrue($s->set($key, '938443')); - $this->assertTrue($s->get($key) === '938443'); - $this->assertTrue(count(glob($cachefile)) === 0); - - // delete - $this->assertTrue($s->delete($key)); - $this->assertNull($s->get($key)); - $this->assertTrue($s->set($key, new Stream(fopen($file, 'r')))); - $this->assertTrue($s->delete($key)); - $this->assertNull($s->get($key)); - $this->assertTrue(count(glob($cachefile)) === 0); - - $this->assertTrue($s->deleteAll()); - } - - protected function tearDown() - { - array_map('unlink', glob($this->dir . DIRECTORY_SEPARATOR . '*')); - rmdir($this->dir); - } - - -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Common/MediaResourceTest.php b/tests/SecucardConnect/Product/Common/MediaResourceTest.php deleted file mode 100644 index bc6f3e6..0000000 --- a/tests/SecucardConnect/Product/Common/MediaResourceTest.php +++ /dev/null @@ -1,29 +0,0 @@ -setHttpClient(new Client()); - $mr->setStore(new FileStorage($this->dir)); - $mr->setUrl('https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Region_M%C3%BCnchen_-_Satellitenbild.jpg/170px-Region_M%C3%BCnchen_-_Satellitenbild.jpg'); - $this->assertTrue(is_resource($mr->getContents())); - $this->assertTrue(count(glob($this->dir . DIRECTORY_SEPARATOR . '*')) === 1); - $mr->clear(); - $this->assertTrue(count(glob($this->dir . DIRECTORY_SEPARATOR . '*')) === 0); - } - -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/General/AccountsTest.php b/tests/SecucardConnect/Product/General/AccountsTest.php deleted file mode 100644 index 35ce00a..0000000 --- a/tests/SecucardConnect/Product/General/AccountsTest.php +++ /dev/null @@ -1,58 +0,0 @@ -client->general->accounts; - $query = new QueryParams(3, 2); - $list = $service->getList($query); - $this->assertFalse(count($list) == 0); - $this->assertTrue(count($list) == 3); - $this->assertTrue(count($list) <= $list->totalCount); - } - - public function testGetListScroll() - { - $service = $this->client->general->accounts; - $query = new QueryParams(2); - $list = $service->getScrollableList($query, '1m'); - $this->assertFalse(empty($list->scrollId)); - $this->assertTrue(count($list) == 2); - $list = $service->getNextBatch($list->scrollId); - $this->assertFalse(count($list) == 0); - $this->assertTrue(count($list) == 2); - $list = $service->getNextBatch($list->scrollId); - $this->assertFalse(count($list) == 0); - $this->assertTrue(count($list) == 2); - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->general->accounts->getList(new QueryParams(1)); - - $this->assertTrue($list->count() == 1); - $sample_item_id = $list[0]->id; - $this->assertFalse(empty($sample_item_id), 'Cannot get one item, because none is available'); - - if ($sample_item_id) { - $item = $this->client->general->accounts->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } -} diff --git a/tests/SecucardConnect/Product/General/Model/Skeletons.php b/tests/SecucardConnect/Product/General/Model/Skeletons.php deleted file mode 100644 index e282b97..0000000 --- a/tests/SecucardConnect/Product/General/Model/Skeletons.php +++ /dev/null @@ -1,40 +0,0 @@ -array('type'=>BaseModel::DATA_TYPE_STRING), - 'id'=>array('type'=>BaseModel::DATA_TYPE_STRING, 'options'=>array('id'=>true)), - 'a'=>array('type'=>BaseModel::DATA_TYPE_STRING), - 'b'=>array('type'=>BaseModel::DATA_TYPE_STRING), - 'c'=>array('type'=>BaseModel::DATA_TYPE_STRING), - 'amount'=>array('type'=>BaseModel::DATA_TYPE_STRING), - 'date'=>array('type'=>BaseModel::DATA_TYPE_DATETIME), - 'picture'=>array('type'=>BaseModel::DATA_TYPE_STRING), - 'type'=>array('type'=>BaseModel::DATA_TYPE_STRING), - ); - - protected $_relations = array( - //'location'=>array('type'=>BaseModel::RELATION_HAS_ONE, 'class'=>'Common\\Location'), - - 'location'=>array('type'=>MainModel::RELATION_HAS_ONE, 'category'=>'Common', 'model'=>'Location'), - // TODO - 'skeleton'=>array('type'=>MainModel::RELATION_HAS_ONE, 'category'=>'General', 'model'=>'Skeletons'), - // TODO - 'skeleton_list'=>array('type'=>MainModel::RELATION_HAS_MANY, 'category'=>'General', 'model'=>'Skeletons'), - ); - - // model specific functions -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/General/SkeletonsTest.php b/tests/SecucardConnect/Product/General/SkeletonsTest.php deleted file mode 100644 index c9d5030..0000000 --- a/tests/SecucardConnect/Product/General/SkeletonsTest.php +++ /dev/null @@ -1,42 +0,0 @@ -client->general->skeletons->getList(array()); - - $this->assertFalse(empty($list)); - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->general->skeletons->getList(array('count'=>1)); - - $this->assertFalse(empty($list)); - $sample_item_id = $list[0]->id; - $this->assertFalse(empty($sample_item_id), 'Cannot get one item, because none is available'); - - if ($sample_item_id) { - $item = $this->client->general->skeletons->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Loyalty/CardsTest.php b/tests/SecucardConnect/Product/Loyalty/CardsTest.php deleted file mode 100644 index b5efaff..0000000 --- a/tests/SecucardConnect/Product/Loyalty/CardsTest.php +++ /dev/null @@ -1,58 +0,0 @@ -client->loyalty->cards->getList(array()); - - $this->assertFalse(empty($list), 'Card list empty'); - - // test lazy loading for account - $temp_account = null; - $count = 0; - foreach ($list as $card) { - // do not load all the cards available - if ($count > 20) { - break; - } - if (!empty($card->account)) { - $this->assertFalse(empty($card->account->id)); - - // it is needed for lazy loading to copy the loading property to some temporary variable - $tmp = $card->account->display_name; - $temp_account = $card->account; - $this->assertFalse(empty($card->account->display_name)); - } - $count++; - } - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->loyalty->cards->getList(array('count'=>1)); - - $this->assertFalse(empty($list)); - $sample_item_id = $list[0]->id; - $this->assertFalse(empty($sample_item_id), 'Cannot get one item, because none is available'); - - if ($sample_item_id) { - $item = $this->client->loyalty->cards->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Payment/ContainersTest.php b/tests/SecucardConnect/Product/Payment/ContainersTest.php deleted file mode 100644 index d9a6492..0000000 --- a/tests/SecucardConnect/Product/Payment/ContainersTest.php +++ /dev/null @@ -1,62 +0,0 @@ -client->payment->containers->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - * - public function testCreation() - { - // Dummy Log File - $fp = fopen('/tmp/secucard_php_test.log', 'a'); - $logger = new \secucard\client\log\Logger($fp, true); - - $container_data = ['type' => 'bank_account', - 'private' => [ - 'owner'=> 'John Doe', - 'iban'=> 'correct_iban' - ]]; - - $secucard = $this->client; - - $container = $secucard->factory('Payment\Containers'); - $logger->debug('created object'); - $container->initValues($container_data); - $logger->debug('object data initialized'); - $success = false; - try { - $success = $container->save(); - } catch (\GuzzleHttp\Exception\TransferException $e) { - $logger->error('Error message: '. $e->getMessage()); - if ($e->hasResponse()) { - if ($e->getResponse()->getBody()) { - $logger->error('Body: ' . json_encode($e->getResponse()->getBody()->__toString())); - } - } - } catch (Exception $e) { - $logger->error('Error message: '. $e->getMessage()); - } - $this->assertTrue($success); - if ($success) { - $logger->info('Created Object with id: ' . $container->id); - $logger->info('Object data: ' . $container->as_json()); - } - }*/ -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Payment/ContractsTest.php b/tests/SecucardConnect/Product/Payment/ContractsTest.php deleted file mode 100644 index fa659bd..0000000 --- a/tests/SecucardConnect/Product/Payment/ContractsTest.php +++ /dev/null @@ -1,31 +0,0 @@ -client->payment->contracts->getList(); - $this->assertFalse(empty($list)); - } - - public function testClone() - { - $params = new CloneParams('project', new Data('iban'), false); - - $contr = $this->client->payment->contracts->cloneMyContract($params); - - $this->assertNotNull($contr); - } -} diff --git a/tests/SecucardConnect/Product/Payment/CustomersTest.php b/tests/SecucardConnect/Product/Payment/CustomersTest.php deleted file mode 100644 index 09347cb..0000000 --- a/tests/SecucardConnect/Product/Payment/CustomersTest.php +++ /dev/null @@ -1,75 +0,0 @@ -client->payment->customers->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - * - public function testCreation() - { - // Dummy Log File - $fp = fopen('/tmp/secucard_php_test.log', 'a'); - $logger = new \secucard\client\log\Logger($fp, true); - - $contact = [ - 'salutation' => 'Mr.', - 'title' => 'Dr.', - 'forename' => 'John', - 'surname' => 'Doe', - 'companyname' => 'Example Inc.', - 'dob' => '1901-02-03', - 'email' => 'example@example.com', - 'phone' => '0049-123-456789', - 'mobile' => '0049-987-654321', - 'address' => [ - 'street' => 'Example Street', - 'street_number' => '6a', - 'postal_code' => '01234', - 'city' => 'Examplecity', - 'country' => 'Germany' - ]]; - $customer_data = ['contact' => $contact,]; - - $secucard = $this->client; - - $customer = $secucard->factory('Payment\Customers'); - $logger->debug('created object'); - $customer->initValues($customer_data); - $logger->debug('object data initialized'); - $success = false; - try { - $success = $customer->save(); - } catch (\GuzzleHttp\Exception\TransferException $e) { - $logger->error('Error message: '. $e->getMessage()); - if ($e->hasResponse()) { - if ($e->getResponse()->getBody()) { - $logger->error('Body: ' . json_encode($e->getResponse()->getBody()->__toString())); - } - } - } catch (Exception $e) { - $logger->error('Error message: '. $e->getMessage()); - } - $this->assertTrue($success); - if ($success) { - $logger->info('Created Object with id: ' . $customer->id); - $logger->info('Object data: ' . $customer->as_json()); - } - }*/ -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Payment/SecupayprepaysTest.php b/tests/SecucardConnect/Product/Payment/SecupayprepaysTest.php deleted file mode 100644 index 81c2ce8..0000000 --- a/tests/SecucardConnect/Product/Payment/SecupayprepaysTest.php +++ /dev/null @@ -1,71 +0,0 @@ -client->payment->Secupayprepays->get($id); - - $this->assertFalse(empty($object)); - } - - /** - * @test - * - public function testCreation() - { - $fp = fopen('/tmp/secucard_php_test.log', 'a'); - $logger = new \secucard\client\log\Logger($fp, true); - - $prepay_data = [ - 'customer' => [ - 'object' => 'payment.customers', - 'id' => 'PCU_xxxx' - ], - 'contract' => [ - 'object' => 'payment.contracts', - 'id' => 'PCR_xxxx', - ], - 'amount' => '100', - 'currency' => 'EUR', - 'purpose' => 'for what text', - 'order_id' => 'ZZZZZZ' - ]; - - $secucard = $this->client; - - $object = $secucard->factory('Payment\Secupayprepays'); - $logger->debug('created object'); - $object->initValues($prepay_data); - $logger->debug('object data initialized'); - $success = false; - try { - $success = $object->save(); - } catch (\GuzzleHttp\Exception\TransferException $e) { - $logger->error('Error message: '. $e->getMessage()); - if ($e->hasResponse()) { - if ($e->getResponse()->getBody()) { - $logger->error('Body: ' . json_encode($e->getResponse()->getBody()->__toString())); - } - } - } catch (Exception $e) { - $logger->error('Error message: '. $e->getMessage()); - } - $this->assertTrue($success); - if ($success) { - $logger->info('Created Object with id: ' . $object->id); - $logger->info('Object data: ' . $object->as_json()); - } - }/**/ -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Services/IdentcontractsTest.php b/tests/SecucardConnect/Product/Services/IdentcontractsTest.php deleted file mode 100644 index 522f346..0000000 --- a/tests/SecucardConnect/Product/Services/IdentcontractsTest.php +++ /dev/null @@ -1,21 +0,0 @@ -client->services->identcontracts->getList(); - - $this->assertFalse(empty($list)); - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Services/IdentrequestsTest.php b/tests/SecucardConnect/Product/Services/IdentrequestsTest.php deleted file mode 100644 index 1aec272..0000000 --- a/tests/SecucardConnect/Product/Services/IdentrequestsTest.php +++ /dev/null @@ -1,56 +0,0 @@ -client->services->identrequests->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->services->identrequests->getList(new QueryParams(1)); - - $this->assertFalse(empty($list), 'Cannot get any item, because list is empty'); - $sample_item_id = $list->items[0]->id; - $this->assertFalse(empty($sample_item_id)); - - if ($sample_item_id) { - $item = $this->client->services->identrequests->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } - - /** - * @test - */ - public function testGetAllItemsForListCount() - { - $list = $this->client->services->identrequests->getList(); - - $this->assertFalse(empty($list)); - - $i = 0; - foreach ($list as $item) { - $this->client->logger->info('Item: ' . ($i + 1) . ': ' . $item->id); - $i++; - } - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Services/IdentresultsTest.php b/tests/SecucardConnect/Product/Services/IdentresultsTest.php deleted file mode 100644 index 7c53b98..0000000 --- a/tests/SecucardConnect/Product/Services/IdentresultsTest.php +++ /dev/null @@ -1,40 +0,0 @@ -client->services->identresults->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->services->identresults->getList(new QueryParams(1)); - - $this->assertTrue($list->count == 1, 'Cannot get any item, because list is empty'); - $sample_item_id = $list->items[0]->id; - $this->assertFalse(empty($sample_item_id)); - - if ($sample_item_id) { - $item = $this->client->services->identresults->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Smart/CheckinsTest.php b/tests/SecucardConnect/Product/Smart/CheckinsTest.php deleted file mode 100644 index e0f7254..0000000 --- a/tests/SecucardConnect/Product/Smart/CheckinsTest.php +++ /dev/null @@ -1,39 +0,0 @@ -client->smart->checkins->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->smart->checkins->getList(array()); - - $this->assertFalse(empty($list) || $list->count() < 1, 'Cannot get any item, because list is empty'); - $sample_item_id = $list[0]->id; - $this->assertFalse(empty($sample_item_id)); - - if ($sample_item_id) { - $item = $this->client->smart->checkins->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Smart/DevicesTest.php b/tests/SecucardConnect/Product/Smart/DevicesTest.php deleted file mode 100644 index a8a32ad..0000000 --- a/tests/SecucardConnect/Product/Smart/DevicesTest.php +++ /dev/null @@ -1,22 +0,0 @@ -client->smart->devices->getList(); - - $this->assertFalse(empty($list)); - } - -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Smart/IdentsTest.php b/tests/SecucardConnect/Product/Smart/IdentsTest.php deleted file mode 100644 index 4969ee3..0000000 --- a/tests/SecucardConnect/Product/Smart/IdentsTest.php +++ /dev/null @@ -1,29 +0,0 @@ -client->smart->idents->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - */ - public function testGetItem() - { - // idents does not have method to get one Item - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Smart/RoutingsTest.php b/tests/SecucardConnect/Product/Smart/RoutingsTest.php deleted file mode 100644 index 1e00115..0000000 --- a/tests/SecucardConnect/Product/Smart/RoutingsTest.php +++ /dev/null @@ -1,39 +0,0 @@ -client->smart->routings->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->smart->routings->getList(array()); - - $this->assertFalse(empty($list) || $list->count() < 1, 'Cannot get any item, because list is empty'); - $sample_item_id = $list[0]->id; - $this->assertFalse(empty($sample_item_id)); - - if ($sample_item_id) { - $item = $this->client->smart->routings->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } -} \ No newline at end of file diff --git a/tests/SecucardConnect/Product/Smart/TransactionsTest.php b/tests/SecucardConnect/Product/Smart/TransactionsTest.php deleted file mode 100644 index 70e6c42..0000000 --- a/tests/SecucardConnect/Product/Smart/TransactionsTest.php +++ /dev/null @@ -1,51 +0,0 @@ -client->smart->transactions->getList(); - - $this->assertFalse(empty($list)); - } - - /** - * @test - */ - public function testGetItem() - { - $list = $this->client->smart->transactions->getList(array()); - - $this->assertFalse(empty($list) || $list->count() < 1, 'Cannot get any item, because list is empty'); - $sample_item_id = $list[0]->id; - $this->assertFalse(empty($sample_item_id)); - - if ($sample_item_id) { - $item = $this->client->smart->transactions->get($sample_item_id); - - $this->assertFalse(empty($item)); - } - } -} \ No newline at end of file From d9922b85b870d882375486dc205934996fff81f5 Mon Sep 17 00:00:00 2001 From: Rico Simlinger Date: Tue, 30 May 2017 16:35:06 +0200 Subject: [PATCH 3/3] RELEASE 1.4.0 --- CHANGELOG.md | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3ec1c..0521351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,7 +84,6 @@ Not published ## [1.1.2] - 2017-01-09 -Commit-ID: 7c69043 ### Changed - Fix push service for ident service @@ -92,7 +91,6 @@ Commit-ID: 7c69043 ## [1.1.1] - 2017-01-18 -Commit-ID: 5fa107d ###Added - Provider to Services.IdentRequest @@ -100,7 +98,6 @@ Commit-ID: 5fa107d ## [1.1.0] - 2016-12-06 -Commit-ID: 7ac3ee6 ###Added - Credit card payment @@ -108,7 +105,6 @@ Commit-ID: 7ac3ee6 ## [1.0.9] - 2016-11-29 -Commit-ID: 7daf776 ### Changed - Fix fatal on cancel request @@ -116,7 +112,6 @@ Commit-ID: 7daf776 ## [1.0.8] - 2016-11-29 -Commit-ID: 562487e ### Changed - Fix fatal on delete request @@ -127,7 +122,6 @@ Commit-ID: 562487e ## [1.0.7] - 2016-11-23 -Commit-ID: 4f6f80f ### Added - Basket @@ -136,7 +130,6 @@ Commit-ID: 4f6f80f ## [1.0.6] - 2016-10-14 -Commit-ID: 9fdcc06 ### Added - Basket @@ -149,7 +142,6 @@ Commit-ID: 9fdcc06 - composer.lock file ## [1.0.5] - 2016-04-29 -Commit-ID: 57989cc ### Added - X-Action header support. @@ -161,7 +153,6 @@ Commit-ID: 57989cc ## [1.0.4] - 2016-04-28 -Commit-ID: 3d8185e ### Added - Add expire time to JSON token export. @@ -172,7 +163,6 @@ Commit-ID: 3d8185e ## [1.0.3] - 2016-04-21 -Commit-ID: 7202f07 ### Changed - unknown @@ -180,7 +170,6 @@ Commit-ID: 7202f07 ## [1.0.2] - 2016-04-20 -Commit-ID: f08127f ### Changed - Readme @@ -188,7 +177,6 @@ Commit-ID: f08127f ## [1.0.1] - 2016-04-06 -Commit-ID: c8923d5 ###Added - Client method for getting token JSON for JS usage. @@ -196,7 +184,6 @@ Commit-ID: c8923d5 ## [1.0.0] - 2016-03-12 -Commit-ID: 61d5f43 ###Added - payment services. @@ -246,7 +233,6 @@ Commit-ID: 61d5f43 ## [0.1.3] - 2015-10-15 -Commit-ID: 17cc357 ### Changed - Correctly implemented processPush method for handling pushes @@ -254,7 +240,6 @@ Commit-ID: 17cc357 ## [0.1.2] - 2015-09-22 -Commit-ID: d40c9d4 ### Changed - Fix updating and deleting Models @@ -262,7 +247,6 @@ Commit-ID: d40c9d4 ## [0.1.1] - 2015-08-05 -Commit-ID: c241859 ### Added - Added const to model Smart/Transactions @@ -273,7 +257,6 @@ Commit-ID: c241859 ## [0.1.0] - 2015-08-04 -Commit-ID: 9035f25 ### Added - Receipts for Smart/Transactions @@ -284,7 +267,6 @@ Commit-ID: 9035f25 ## [0.0.5] - 2015-07-03 -Commit-ID: 9bfdc86 ### Changed - Fix creation of Secupaydebits @@ -292,7 +274,6 @@ Commit-ID: 9bfdc86 ## [0.0.4] - 2015-07-03 -Commit-ID: 2bbec34 ### Added - "Payment" product @@ -303,7 +284,6 @@ Commit-ID: 2bbec34 ## [0.0.3] - 2015-05-13 -Commit-ID: a2be050 ### Added - "Smart" product @@ -314,7 +294,6 @@ Commit-ID: a2be050 ## [0.0.2] - 2015-02-04 -Commit-ID: 5b5eb23 ### Added - License @@ -332,7 +311,6 @@ Commit-ID: 5b5eb23 ## [0.0.1] - 2014-11-03 -Commit-ID: 787f4fa First release