From ebd075ef44c49e0a286304531dcbb25aef547366 Mon Sep 17 00:00:00 2001 From: securesubmit-buildmaster Date: Tue, 23 Jul 2024 08:03:53 -0400 Subject: [PATCH] OctopusDeploy release: 12.0.8 --- CHANGELOG.md | 4 ++++ metadata.xml | 2 +- src/Gateways/GpApiConnector.php | 7 ++++-- .../GpApiConnector/AccessTokenTest.php | 22 +++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0733b7e9..0da76c7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ # Changelog +## Latest Version - v12.0.8 (07/23/24) +### Bug Fixes: +- [GP-API] Fix re-sign in after token expiration + ## Latest Version - v12.0.7 (07/16/24) ### Enhancements: - [GP-API] Adds avs data to "/transaction" request for digital wallet diff --git a/metadata.xml b/metadata.xml index a4d7360b..6d177324 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 12.0.7 + 12.0.8 \ No newline at end of file diff --git a/src/Gateways/GpApiConnector.php b/src/Gateways/GpApiConnector.php index 9130dff3..fdec5513 100644 --- a/src/Gateways/GpApiConnector.php +++ b/src/Gateways/GpApiConnector.php @@ -315,18 +315,21 @@ public function doTransaction( ); } catch (GatewayException $exception) { if ( - in_array($exception->responseCode, ['NOT_AUTHENTICATED', '401']) && + str_contains($exception->getMessage(), 'NOT_AUTHENTICATED') && !empty($this->gpApiConfig->appKey) && !empty($this->gpApiConfig->appKey) ) { $this->gpApiConfig->accessTokenInfo = null; + $this->headers['Authorization'] = null; $this->signIn(); - return parent::doTransaction( + $response = parent::doTransaction( $verb, $endpoint, $data, $queryStringParams ); + + return json_decode($response); } throw $exception; diff --git a/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php b/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php index 3ad9510b..4049a82d 100644 --- a/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php +++ b/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php @@ -21,9 +21,16 @@ class AccessTokenTest extends TestCase */ private GpApiConfig $config; + private CreditCardData $card; + public function setUp(): void { $this->setUpConfig(); + $this->card = new CreditCardData(); + $this->card->number = "4263970000005262"; + $this->card->expMonth = "05"; + $this->card->expYear = "2025"; + $this->card->cvn = "852"; } public static function tearDownAfterClass(): void @@ -221,6 +228,21 @@ public function testUseOnlyAccessToken() $this->assertEquals('VERIFIED', $response->responseMessage); } + public function testShouldReSignInAfterTokenExpiration() + { + $this->config->secondsToExpire = 60; + $accessTokenInfo = GpApiService::generateTransactionKey($this->config); + $this->assertAccessTokenResponse($accessTokenInfo); + + $this->config->accessTokenInfo = $accessTokenInfo; + ServicesContainer::configureService($this->config); + sleep(61); + $response = $this->card->verify()->withCurrency('USD')->execute(); + $this->assertNotNull($response); + $this->assertEquals('SUCCESS', $response->responseCode); + $this->assertEquals('VERIFIED', $response->responseMessage); + } + private function assertAccessTokenResponse(AccessTokenInfo $accessTokenInfo): void { $this->assertNotNull($accessTokenInfo);