Skip to content

Commit

Permalink
OctopusDeploy release: 13.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Dec 4, 2024
1 parent 25a4819 commit 2924c58
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 75 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
</a>

# Changelog
## Latest Version - v13.0.7 (12/03/24)
### Enhancements:
- Add console logger feature
- [GP-API/GP-ECOM] Unit tests enhancements

## Latest Version - v13.0.6 (11/19/24)
## v13.0.6 (11/19/24)
### Enhancements:
- [GP-API] - Add new mapping fields on get transaction list: "funding", "authentication"

Expand Down
2 changes: 1 addition & 1 deletion metadata.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<xml>
<releaseNumber>13.0.6</releaseNumber>
<releaseNumber>13.0.7</releaseNumber>
</xml>
22 changes: 1 addition & 21 deletions src/Gateways/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function sendRequest(
array $queryStringParams = null
) {
try {
$queryString = $this->buildQueryString($queryStringParams);
$queryString = !empty($queryStringParams) ? "?" . http_build_query($queryStringParams) : '';
$request = curl_init($this->serviceUrl . $endpoint . $queryString);

$headers = $this->prepareHeaders($data);
Expand Down Expand Up @@ -213,24 +213,4 @@ private function prepareHeaders(?string $data) : array

return $headers ?? [];
}

/**
* @param array<string,string>|null $queryStringParams
*
* @return string
*/
private function buildQueryString(array $queryStringParams = null)
{
if ($queryStringParams === null) {
return '';
}

$query = [];

foreach ($queryStringParams as $key => $value) {
$query[] = sprintf('%s=%s', $key, $value);
}

return sprintf('?%s', implode('&', $query));
}
}
51 changes: 51 additions & 0 deletions src/Utils/Logging/RequestConsoleLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace GlobalPayments\Api\Utils\Logging;

use GlobalPayments\Api\Entities\IRequestLogger;
use GlobalPayments\Api\Gateways\GatewayResponse;
use GlobalPayments\Api\Utils\StringUtils;

class RequestConsoleLogger implements IRequestLogger
{
public function requestSent($verb, $endpoint, $headers, $queryStringParams, $data)
{
print_r(PHP_EOL . "Request/Response START" . PHP_EOL);
print_r("Request START" . PHP_EOL);
print_r("Request verb: " . $verb . PHP_EOL);
print_r("Request endpoint: " . $endpoint . PHP_EOL);
print_r("Request headers: " . json_encode($headers, JSON_PRETTY_PRINT) . PHP_EOL);
if (!empty($data)) {
print_r("Request body: " . $data . PHP_EOL);
}
print_r("REQUEST END" . PHP_EOL);
}

public function responseReceived(GatewayResponse $response)
{
print_r("Response START" . PHP_EOL);
print_r("Status code: " . $response->statusCode . PHP_EOL);
$rs = clone $response;
if (str_contains($rs->header, ': gzip')) {
$rs->rawResponse = gzdecode($rs->rawResponse);
}
if (StringUtils::isJson($rs->rawResponse)) {
$rs->rawResponse = json_encode(json_decode($rs->rawResponse), JSON_PRETTY_PRINT);
}
print_r("Response body: " . $rs->rawResponse . PHP_EOL);
print_r("Response END" . PHP_EOL);
print_r("Request/Response END" . PHP_EOL);
print_r("=============================================");
}

public function responseError(\Exception $e, $headers = '')
{
print_r("Exception START" . PHP_EOL);
print_r("Response headers: " . $headers . PHP_EOL);
print_r("Error occurred while communicating with the gateway" . PHP_EOL);
print_r("Exception type: " . get_class($e) . PHP_EOL);
print_r("Exception message: " . $e->getMessage() . PHP_EOL);
print_r("Exception END" . PHP_EOL);
print_r("=============================================");
}
}
3 changes: 1 addition & 2 deletions src/Utils/Logging/SampleRequestLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ public function requestSent($verb, $endpoint, $headers, $queryStringParams, $dat
$this->logger->info("REQUEST END");
}


public function responseReceived(GatewayResponse $response)
{
$this->logger->info("Response START");
$this->logger->info("Status code: " . $response->statusCode);
$rs = clone $response;
if (strpos($rs->header, ': gzip') !== false) {
if (str_contains($rs->header, ': gzip')) {
$rs->rawResponse = gzdecode($rs->rawResponse);
}
if (StringUtils::isJson($rs->rawResponse)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig;
use GlobalPayments\Api\Tests\Data\GpApiAvsCheckTestCards;
use GlobalPayments\Api\Utils\GenerationUtils;
use GlobalPayments\Api\Utils\Logging\RequestConsoleLogger;
use PHPUnit\Framework\TestCase;

class CreditCardNotPresentTest extends TestCase
Expand Down Expand Up @@ -1405,14 +1406,14 @@ public function AvsCardTests(): array
public function setUpConfig(): GpApiConfig
{
$config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent);
$config->requestLogger = new RequestConsoleLogger();
//DO NO DELETE - usage example for some settings
// $config->dynamicHeaders = [
// 'x-gp-platform' => 'prestashop;version=1.7.2',
// 'x-gp-extension' => 'coccinet;version=2.4.1',
// ];
// $config->permissions = ['TRN_POST_Authorize'];
// $config->webProxy = new CustomWebProxy('127.0.0.1:8866');
// $config->requestLogger = new SampleRequestLogger(new Logger("logs"));

return $config;
}
Expand Down
60 changes: 20 additions & 40 deletions test/Integration/Gateways/GpApiConnector/DccCardPresentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,25 @@
use GlobalPayments\Api\ServicesContainer;
use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig;
use GlobalPayments\Api\Utils\GenerationUtils;
use GlobalPayments\Api\Utils\Logging\Logger;
use GlobalPayments\Api\Utils\Logging\SampleRequestLogger;
use PHPUnit\Framework\TestCase;

class DccCardPresentTest extends TestCase
{
private string $currency = 'EUR';
private float $amount = 15.11;
private float $amount = 0.10;
/** @var CreditCardData */
private CreditCardData $card;
const DCC_RATE_CONFIG = 'dcc_rate';

public function setup(): void
{
$this->markTestIncomplete();
$config = $this->setUpConfig();
$config->country = 'GB';
$accessTokenInfo = GpApiService::generateTransactionKey($config);
$config->accessTokenInfo->accessToken = $accessTokenInfo->accessToken;
ServicesContainer::configureService($config);
$dccRateConfig = $this->setUpConfigDcc();
$dccRateConfig->accessTokenInfo->accessToken = $accessTokenInfo->accessToken;
ServicesContainer::configureService($dccRateConfig, self::DCC_RATE_CONFIG);

$this->card = new CreditCardData();
$this->card->number = "4263970000005262";
$this->card->number = "4242424242424242";
$this->card->expMonth = date('m');
$this->card->expYear = date('Y', strtotime('+1 year'));
$this->card->cardHolderName = "James Mason";
Expand All @@ -56,32 +50,21 @@ public function setUpConfig(): GpApiConfig
{
$config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardPresent);
$accessTokenInfo = new AccessTokenInfo();
$accessTokenInfo->transactionProcessingAccountName = 'dcc';
$accessTokenInfo->transactionProcessingAccountName = 'dcc_p';
$config->accessTokenInfo = $accessTokenInfo;
return $config;
}

public function setUpConfigDcc(): GpApiConfig
{
$config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardPresent);
$accessTokenInfo = new AccessTokenInfo();
$accessTokenInfo->transactionProcessingAccountName = 'dcc_rate';
$config->accessTokenInfo = $accessTokenInfo;
$config->requestLogger = new SampleRequestLogger(new Logger("logs"));
return $config;
}

private function getDccDetails(): Transaction
{
return $this->card->getDccRate()
->withAmount($this->amount)
->withCurrency($this->currency)
->execute(self::DCC_RATE_CONFIG);
->execute();
}

public function testCreditGetDccInfo()
{
$this->card->number = '4006097467207025';
$orderId = GenerationUtils::generateOrderId();

$dccDetails = $this->getDccDetails();
Expand All @@ -105,7 +88,6 @@ public function testCreditGetDccInfo()

public function testCreditDccRateAuthorize()
{
$this->card->number = '4006097467207025';
$orderId = GenerationUtils::generateOrderId();

$dccDetails = $this->getDccDetails();
Expand All @@ -129,7 +111,6 @@ public function testCreditDccRateAuthorize()

public function testCreditDccRateRefundStandalone()
{
$this->card->number = '4006097467207025';
$orderId = GenerationUtils::generateOrderId();

$dccDetails = $this->getDccDetails();
Expand All @@ -153,7 +134,6 @@ public function testCreditDccRateRefundStandalone()

public function testCreditDccRateReversal()
{
$this->card->number = '4006097467207025';
$orderId = GenerationUtils::generateOrderId();

$dccDetails = $this->getDccDetails();
Expand Down Expand Up @@ -185,7 +165,6 @@ public function testCreditDccRateReversal()

public function testCreditDccRateRefund()
{
$this->card->number = '4006097467207025';
$orderId = GenerationUtils::generateOrderId();

$dccDetails = $this->getDccDetails();
Expand Down Expand Up @@ -219,31 +198,32 @@ public function testCreditDccRateRefund()
public function testCreditGetDccInfo_CreditTrackData()
{
$creditTrackData = new CreditTrackData();
$creditTrackData->setTrackData('%B4012002000060016^VI TEST CREDIT^251210118039000000000396?;4012002000060016=25121011803939600000?');
$creditTrackData->entryMethod = EntryMethod::SWIPE;
$creditTrackData->setTrackData(';4761739001010036=25122011184404889?');
$creditTrackData->entryMethod = EntryMethod::PROXIMITY;
$tagData = "9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001";
$orderId = GenerationUtils::generateOrderId();

$dccDetails = $this->getDccDetails();
$dccDetails = $creditTrackData->getDccRate()
->withAmount($this->amount)
->withCurrency($this->currency)
->execute();

$this->assertNotNull($dccDetails);
$this->assertEquals('SUCCESS', $dccDetails->responseCode);
$this->assertEquals('NOT_AVAILABLE', $dccDetails->responseMessage);
$this->assertEquals('AVAILABLE', $dccDetails->responseMessage);
$this->assertNotNull($dccDetails->dccRateData);

$exceptionCaught = false;
try {
$creditTrackData->charge($this->amount)
$transaction = $creditTrackData->charge($this->amount)
->withCurrency($this->currency)
->withAllowDuplicates(true)
->withDccRateData($dccDetails->dccRateData)
->withClientTransactionId($orderId)
->withTagData($tagData)
->execute();
} catch (GatewayException $e) {
$exceptionCaught = true;
$this->assertEquals('Status Code: MANDATORY_DATA_MISSING - 37,Request expects the following field payer_amount payer_currency exchange_rate commission_percentage from the Merchant.', $e->getMessage());
$this->assertEquals('40211', $e->responseCode);
} finally {
$this->assertTrue($exceptionCaught);
}

$this->assertNotNull($transaction);
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals(TransactionStatus::CAPTURED, $transaction->responseMessage);
}

public function testCreditGetDccInfo_DebitTrackData()
Expand Down
10 changes: 5 additions & 5 deletions test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public function testCardHolderChallengeRequired_PostResult()

$this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status);
$this->assertEquals('05', $secureEcom->eci);
$this->assertEquals('2.1.0', $secureEcom->messageVersion);
$this->assertEquals('2.2.0', $secureEcom->messageVersion);
$this->assertNotNull($secureEcom->acsTransactionId);
$this->assertNotNull($secureEcom->serverTransactionId);
$this->assertNotNull($secureEcom->directoryServerTransactionId);
Expand Down Expand Up @@ -611,7 +611,7 @@ public function testCardHolderChallengeRequired_PostResult_WithIdempotencyKey()

$this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status);
$this->assertEquals('05', $secureEcom->eci);
$this->assertEquals('2.1.0', $secureEcom->messageVersion);
$this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion());
$this->assertNotNull($secureEcom->acsTransactionId);
$this->assertNotNull($secureEcom->serverTransactionId);
$this->assertNotNull($secureEcom->directoryServerTransactionId);
Expand Down Expand Up @@ -664,7 +664,7 @@ public function testCardHolderFrictionless_PostResult()

$this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status);
$this->assertEquals('05', $secureEcom->eci);
$this->assertEquals('2.2.0', $secureEcom->messageVersion);
$this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion());
$this->assertNotNull($secureEcom->acsTransactionId);
$this->assertNotNull($secureEcom->serverTransactionId);
$this->assertNotNull($secureEcom->directoryServerTransactionId);
Expand Down Expand Up @@ -702,7 +702,7 @@ public function testCardHolderFrictionless_PostResult_WithIdempotencyKey()

$this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status);
$this->assertEquals('05', $secureEcom->eci);
$this->assertEquals('2.2.0', $secureEcom->messageVersion);
$this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion());
$this->assertNotNull($secureEcom->acsTransactionId);
$this->assertNotNull($secureEcom->serverTransactionId);
$this->assertNotNull($secureEcom->directoryServerTransactionId);
Expand Down Expand Up @@ -1290,7 +1290,7 @@ private function assertInitiate3DSV2(ThreeDSecure $initAuth): void
$this->assertNotNull($initAuth->payerAuthenticationRequest);
$this->assertNotNull($initAuth->acsTransactionId);
$this->assertEmpty($initAuth->eci);
$this->assertEquals("2.1.0", $initAuth->messageVersion);
$this->assertEquals("2.2.0", $initAuth->messageVersion);
}

}
2 changes: 1 addition & 1 deletion test/Integration/Gateways/GpApiConnector/GpApiAchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function testCheckReauthorize()
$this->eCheck->routingNumber = '123456780';
$startDate = (new DateTime())->modify('-1 year');
$endDate = (new DateTime())->modify('-2 days');
$amount = '1.29';
$amount = '11';
$response = ReportingService::findTransactionsPaged(1, 10)
->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC)
->where(SearchCriteria::START_DATE, $startDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function testAccountAddressLookup()
$address = new Address();
$address->postalCode = 'CB6 1AS';
$address->streetAddress1 = '2649';
$address->streetAddress2 = 'Primrose';
$address->streetAddress2 = 'Primrose Cottage';
/** @var MerchantAccountSummary $response */
$response = ReportingService::accountDetail($this->config->accessTokenInfo->merchantManagementAccountID)
->withPaging(1, 10)
Expand Down
Loading

0 comments on commit 2924c58

Please sign in to comment.