Added functionality to validate Paysera Delivery API credentials (project_id and password) for use during initial setup or configuration changes#4
Conversation
| "require": { | ||
| "php": ">=7.4", | ||
| "paysera/lib-delivery-api-merchant-client": "^1.2", | ||
| "paysera/lib-delivery-api-merchant-client": "dev-master", |
There was a problem hiding this comment.
It's not good, it should be a stable version
There was a problem hiding this comment.
This change is temporary and for testing purposes only. I will revert it back after the pull request has been tested.
| "repositories": [ | ||
| { | ||
| "type": "vcs", | ||
| "url": "https://github.com/alexleopnet/lib-delivery-api-merchant-client.git" |
There was a problem hiding this comment.
It is also not okay when an official package has a dependency on the employee's own repos
There was a problem hiding this comment.
This change is temporary and for testing purposes only. I will revert it back after the pull request has been tested.
| }, | ||
| "prefer-stable": true, | ||
| "minimum-stability": "stable" | ||
| "minimum-stability": "dev" |
There was a problem hiding this comment.
This change is temporary and for testing purposes only. I will revert it back after the pull request has been tested.
| ); | ||
|
|
||
| throw $exception; | ||
| } catch (ClientException $exception) { |
There was a problem hiding this comment.
Too many responsibilities for one method. Move the whole block to a private method
| * @throws RateLimitExceededException | ||
| * @throws MerchantClientNotFoundException | ||
| */ | ||
| public function validateCredentials(ProjectCredentials $credentials): bool |
There was a problem hiding this comment.
Let's refactor this method: move each logger call into its own private method. It'll look much comprehensive
What's Changed
New Features
validateCredentials()method inDeliveryFacadefor credential validationgetPublicMerchantClient()method for unauthenticated requestsCredentialsValidationExceptionexception class for error handlingDocumentation
docs/VALIDATING_CREDENTIALS.md:Technical Implementation
Code Changes:
DeliveryFacade.php- added entry pointvalidateCredentials()methodDeliveryOrderService.php- business logic with loggingDeliveryApiClient.php- error handlingDeliveryOrderApiClient.php- API communicationMerchantClientProvider.php- new public client without MAC authenticationCredentialsValidationException.php- new exception classBaseException.php- addedE_CREDENTIALS_VALIDATION_FAILEDconstantTests:
DeliveryFacadeTest.php- tests for facade layerDeliveryOrderServiceTest.php- tests for service layerDeliveryApiClientTest.php- tests for api clientDeliveryOrderApiClientTest.php- tests for order api clientMerchantClientProviderTest.php- tests for public clientDependencies:
paysera/lib-delivery-api-merchant-clienttodev-masterwithvalidateProjectCredentials()supportHow It Works
The validation uses a public (unauthenticated) API endpoint
/rest/v1/projects/validate-credentials:Usage Example