Skip to content

Commit

Permalink
OctopusDeploy release: 2.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Jul 20, 2021
1 parent 1329d11 commit d54dd39
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 223 deletions.
3 changes: 2 additions & 1 deletion src/Entities/Enums/Secure3dStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Secure3dStatus extends Enum
const SUCCESS_ATTEMPT_MADE = 'SUCCESS_ATTEMPT_MADE';
const NOT_AUTHENTICATED = 'NOT_AUTHENTICATED';
const FAILED = 'FAILED';
const CHALLENGE_REQUIRED = 'CHALLENGE_REQUIRED';
const NOT_ENROLLED = 'NOT_ENROLLED';
const AVAILABLE = 'AVAILABLE';
const ENROLLED = 'ENROLLED';
const CHALLENGE_REQUIRED = 'CHALLENGE_REQUIRED';
}
9 changes: 1 addition & 8 deletions src/Entities/GpApi/GpApiAuthorizationRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,7 @@ private function createPaymentMethodParam($builder)
if ($paymentMethodContainer instanceof CreditCardData) {
$secureEcom = $paymentMethodContainer->threeDSecure;
if (!empty($secureEcom)) {
$threeDS = [
'message_version' => $secureEcom->messageVersion,
'eci' => $secureEcom->eci,
'value' => $secureEcom->authenticationValue,
'server_trans_ref' => $secureEcom->serverTransactionId,
'ds_trans_ref' => $secureEcom->directoryServerTransactionId
];
$paymentMethod->authentication = ['three_ds' => $threeDS];
$paymentMethod->authentication = ['id' => $secureEcom->serverTransactionId];
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Entities/GpApi/GpApiSecure3DRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ private function verifyEnrolled(Secure3dBuilder $builder, GpApiConfig $config)
$threeDS['amount'] = StringUtils::toNumeric($builder->amount);
$threeDS['currency'] = $builder->currency;
$threeDS['preference'] = $builder->challengeRequestIndicator;
$threeDS['transaction_type'] = $builder->orderTransactionType;
$threeDS['source'] = (string) $builder->authenticationSource;
$threeDS['payment_method'] = $this->setPaymentMethodParam($builder->paymentMethod);
$threeDS['notifications'] = [
Expand Down Expand Up @@ -104,7 +103,7 @@ private function initiateAuthenticationData(Secure3dBuilder $builder, GpApiConfi
'message_version' => $builder->messageVersion
];
$threeDS['method_url_completion_status'] = (string) $builder->methodUrlCompletion;
$threeDS['merchant_contact_url'] = 'https://enp4qhvjseljg.x.pipedream.net/'; // @TODO
$threeDS['merchant_contact_url'] = $config->merchantContactUrl;
$order = [
'time_created_reference' => !empty($builder->orderCreateDate) ?
(new \DateTime($builder->orderCreateDate))->format('Y-m-d\TH:i:s.u\Z') : null,
Expand Down
12 changes: 6 additions & 6 deletions src/Entities/ThreeDSecure.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ public function setAmount($value)
*/
public $challengeMandated;

/**
* @var string
*/
public $challengeValue;

/**
* string
*/
Expand Down Expand Up @@ -351,6 +346,11 @@ public function setVersion($version)
*/
public $sessionDataFieldName;

/**
* @var string
*/
public $liabilityShift;

public function __construct()
{
$this->paymentDataType = '3DSecure';
Expand All @@ -376,7 +376,6 @@ public function merge(ThreeDSecure $secureEcom)
$this->cardHolderResponseInfo = $this->mergeValue($this->cardHolderResponseInfo, $secureEcom->cardHolderResponseInfo);
$this->cavv = $this->mergeValue($this->cavv, $secureEcom->cavv);
$this->challengeMandated = $this->mergeValue($this->challengeMandated, $secureEcom->challengeMandated);
$this->challengeValue = $this->mergeValue($this->challengeValue, $secureEcom->challengeValue);
$this->messageExtension = $this->mergeValue($this->messageExtension, $secureEcom->messageExtension);
$this->currency = $this->mergeValue($this->currency, $secureEcom->currency);
$this->decoupledResponseIndicator = $this->mergeValue($this->decoupledResponseIndicator, $secureEcom->decoupledResponseIndicator);
Expand Down Expand Up @@ -405,6 +404,7 @@ public function merge(ThreeDSecure $secureEcom)
$this->challengeReturnUrl = $this->mergeValue($this->challengeReturnUrl, $secureEcom->challengeReturnUrl);
$this->exemptStatus = $this->mergeValue($this->exemptStatus, $secureEcom->exemptStatus);
$this->exemptReason = $this->mergeValue($this->exemptStatus, $secureEcom->exemptReason);
$this->liabilityShift = $this->mergeValue($this->liabilityShift, $secureEcom->liabilityShift);
}
}

Expand Down
64 changes: 42 additions & 22 deletions src/Mapping/GpApiMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use GlobalPayments\Api\Entities\ThreeDSecure;
use GlobalPayments\Api\Entities\Transaction;
use GlobalPayments\Api\Utils\StringUtils;
use GlobalPayments\Api\Entities\MessageExtension;

class GpApiMapping
{
Expand Down Expand Up @@ -362,7 +363,7 @@ public static function mapResponseSecure3D($response)
$transaction = new Transaction();
$threeDSecure = new ThreeDSecure();
$threeDSecure->serverTransactionId = !empty($response->id) ? $response->id :
(!empty($response->three_ds->server_trans_ref) ? $response->three_ds->server_trans_ref : '');
(!empty($response->three_ds->server_trans_ref) ? $response->three_ds->server_trans_ref : null);
if (!empty($response->three_ds->message_version)) {
$messageVersion = $response->three_ds->message_version;
switch (substr($messageVersion, 0, 2)) {
Expand All @@ -380,52 +381,71 @@ public static function mapResponseSecure3D($response)
}
$threeDSecure->status = $response->status;
$threeDSecure->directoryServerStartVersion = !empty($response->three_ds->ds_protocol_version_start) ?
$response->three_ds->ds_protocol_version_start : '';
$response->three_ds->ds_protocol_version_start : null;
$threeDSecure->directoryServerEndVersion = !empty($response->three_ds->ds_protocol_version_end) ?
$response->three_ds->ds_protocol_version_end : '';
$response->three_ds->ds_protocol_version_end : null;
$threeDSecure->acsStartVersion = !empty($response->three_ds->acs_protocol_version_start) ?
$response->three_ds->acs_protocol_version_start : '';
$response->three_ds->acs_protocol_version_start : null;
$threeDSecure->acsEndVersion = !empty($response->three_ds->acs_protocol_version_end) ?
$response->three_ds->acs_protocol_version_end : '';
$response->three_ds->acs_protocol_version_end : null;
$threeDSecure->enrolled = !empty($response->three_ds->enrolled_status) ?
$response->three_ds->enrolled_status : 'NOT_ENROLLED';
$threeDSecure->eci = !empty($response->three_ds->eci) ? $response->three_ds->eci : '';
$response->three_ds->enrolled_status : null;
$threeDSecure->eci = !empty($response->three_ds->eci) ? $response->three_ds->eci : null;
$threeDSecure->acsInfoIndicator = !empty($response->three_ds->acs_info_indicator) ?
$response->three_ds->acs_info_indicator : null;
$threeDSecure->challengeMandated = !empty($response->three_ds->challenge_status) ?
($response->three_ds->challenge_status == 'MANDATED') : false;
$threeDSecure->payerAuthenticationRequest = !empty($response->three_ds->method_data->encoded_method_data) ?
$response->three_ds->method_data->encoded_method_data : null;
$threeDSecure->issuerAcsUrl = !empty($response->three_ds->method_url) ? $response->three_ds->method_url : '';
$threeDSecure->challengeValue = !empty($response->three_ds->challenge_value) ?
$response->three_ds->challenge_value : '';
$threeDSecure->issuerAcsUrl = !empty($response->three_ds->method_url) ? $response->three_ds->method_url : null;
if (
!empty($response->three_ds->acs_challenge_request_url) &&
$threeDSecure->status == Secure3dStatus::CHALLENGE_REQUIRED
) {
$threeDSecure->issuerAcsUrl = !empty($response->three_ds->acs_challenge_request_url) ?
$response->three_ds->acs_challenge_request_url : null;
$threeDSecure->issuerAcsUrl = $response->three_ds->acs_challenge_request_url;
$threeDSecure->payerAuthenticationRequest = !empty($response->three_ds->challenge_value) ?
$response->three_ds->challenge_value : '';
$response->three_ds->challenge_value : null;
}
$threeDSecure->setCurrency($response->currency);
$threeDSecure->setAmount(StringUtils::toAmount($response->amount));
$threeDSecure->authenticationValue = !empty($response->three_ds->authenticationValue) ?
$response->three_ds->authenticationValue : '';
$threeDSecure->authenticationValue = !empty($response->three_ds->authentication_value) ?
$response->three_ds->authentication_value : null;
$threeDSecure->directoryServerTransactionId = !empty($response->three_ds->ds_trans_ref) ?
$response->three_ds->ds_trans_ref : '';
$response->three_ds->ds_trans_ref : null;
$threeDSecure->acsTransactionId = !empty($response->three_ds->acs_trans_ref) ?
$response->three_ds->acs_trans_ref : '';
$response->three_ds->acs_trans_ref : null;
$threeDSecure->statusReason = !empty($response->three_ds->status_reason) ?
$response->three_ds->status_reason : '';
$response->three_ds->status_reason : null;
$threeDSecure->messageCategory = !empty($response->three_ds->message_category) ?
$response->three_ds->message_category : '';
$response->three_ds->message_category : null;
$threeDSecure->messageType = !empty($response->three_ds->message_type) ?
$response->three_ds->message_type : '';
$response->three_ds->message_type : null;
$threeDSecure->sessionDataFieldName = !empty($response->three_ds->session_data_field_name) ?
$response->three_ds->session_data_field_name : '';
$response->three_ds->session_data_field_name : null;
$threeDSecure->challengeReturnUrl = !empty($response->notifications->challenge_return_url) ?
$response->notifications->challenge_return_url : '';
$response->notifications->challenge_return_url : null;
$threeDSecure->liabilityShift = !empty($response->three_ds->liability_shift) ?
$response->three_ds->liability_shift : null;
$threeDSecure->authenticationSource = !empty($response->three_ds->authentication_source) ?
$response->three_ds->authentication_source : null;
$threeDSecure->authenticationType = !empty($response->three_ds->authentication_request_type) ?
$response->three_ds->authentication_request_type : null;
$threeDSecure->acsInfoIndicator = !empty($response->three_ds->acs_decoupled_response_indicator) ?
$response->three_ds->acs_decoupled_response_indicator : null;
$threeDSecure->whitelistStatus = !empty($response->three_ds->whitelist_status) ?
$response->three_ds->whitelist_status : null;
if (!empty($response->three_ds->message_extension)) {
foreach ($response->three_ds->message_extension as $messageExtension) {
$msgItem = new MessageExtension();
$msgItem->criticalityIndicator = !empty($messageExtension->criticality_indicator) ?
$messageExtension->criticality_indicator : null;
$msgItem->messageExtensionData = !empty($messageExtension->data) ?
json_encode($messageExtension->data) : null;
$msgItem->messageExtensionId = !empty($messageExtension->id) ? $messageExtension->id : null;
$msgItem->messageExtensionName = !empty($messageExtension->name) ? $messageExtension->name : null;
$threeDSecure->messageExtension[] = $msgItem;
}
}

$transaction->threeDSecure = $threeDSecure;

Expand Down
5 changes: 5 additions & 0 deletions src/ServiceConfigs/Gateways/GpApiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class GpApiConfig extends GatewayConfig
*/
public $challengeNotificationUrl;

/**
* @var string
*/
public $merchantContactUrl;

/**
* @var array
*/
Expand Down
50 changes: 10 additions & 40 deletions test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use GlobalPayments\Api\Tests\Data\GpApi3DSTestCards;
use GlobalPayments\Api\Tests\Integration\Gateways\ThreeDSecureAcsClient;
use GlobalPayments\Api\Utils\GenerationUtils;
use GlobalPayments\Api\Entities\Enums\Secure3dStatus;
use PHPUnit\Framework\TestCase;

class GpApi3DS1Test extends TestCase
Expand Down Expand Up @@ -59,13 +60,14 @@ public function setup()
public function setUpConfig()
{
$config = new GpApiConfig();
$config->appId = 'P3LRVjtGRGxWQQJDE345mSkEh2KfdAyg';
$config->appKey = 'ockJr6pv6KFoGiZA';
$config->appId = 'oDVjAddrXt3qPJVPqQvrmgqM2MjMoHQS';
$config->appKey = 'DHUGdzpjXfTbjZeo';
$config->environment = Environment::TEST;
$config->country = 'GB';
$config->channel = Channels::CardNotPresent;
$config->challengeNotificationUrl = 'https://ensi808o85za.x.pipedream.net/';
$config->methodNotificationUrl = 'https://ensi808o85za.x.pipedream.net/';
$config->merchantContactUrl = 'https://enp4qhvjseljg.x.pipedream.net/';

return $config;
}
Expand Down Expand Up @@ -128,7 +130,6 @@ public function testCardHolderEnrolled_ChallengeRequired_v1_TokenizedCard()
$this->assertCheckEnrollmentChallengeV1($secureEcom);
}

//TODO - same response from API
public function testCardHolderEnrolled_ChallengeRequired_v1_AllPreferenceValues()
{
$challengeRequestIndicator = new ChallengeRequestIndicator();
Expand Down Expand Up @@ -161,26 +162,6 @@ public function testCardHolderEnrolled_ChallengeRequired_v1_StoredCredentials()
$this->assertCheckEnrollmentChallengeV1($secureEcom);
}

public function testCardHolderEnrolled_ChallengeRequired_v1_Refund()
{
$secureEcom = Secure3dService::checkEnrollment($this->card)
->withCurrency($this->currency)
->withAmount($this->amount)
->withOrderTransactionType(PaymentType::REFUND)
->execute();

$this->assertCheckEnrollmentChallengeV1($secureEcom);

$secureEcomSale = Secure3dService::checkEnrollment($this->card)
->withCurrency($this->currency)
->withAmount($this->amount)
->withOrderTransactionType(PaymentType::SALE)
->execute();

$this->assertCheckEnrollmentChallengeV1($secureEcomSale);
$this->assertNotSame($secureEcom, $secureEcomSale);
}

public function testCardHolderEnrolled_ChallengeRequired_v1_AllSources()
{
$source = array("BROWSER", "MERCHANT_INITIATED", "MOBILE_SDK", "STORED_RECURRING");
Expand Down Expand Up @@ -271,11 +252,7 @@ public function testCardHolderEnrolled_PostResult()
->withPayerAuthenticationResponse($authResponse->getAuthResponse())
->execute();

$this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status);
$this->assertTrue($secureEcom->challengeMandated);
$this->assertNotNull($secureEcom->issuerAcsUrl);
$this->assertNotNull($secureEcom->payerAuthenticationRequest);
$this->assertNotNull($secureEcom->challengeValue);
$this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status);
$this->assertEquals('5', $secureEcom->eci);
$this->assertEquals('1.0.0', $secureEcom->messageVersion);
}
Expand Down Expand Up @@ -304,11 +281,7 @@ public function testCardHolderEnrolled_PostResult_WithIdempotencyKey()
->withIdempotencyKey($idempotencyKey)
->execute();

$this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status);
$this->assertTrue($secureEcom->challengeMandated);
$this->assertNotNull($secureEcom->issuerAcsUrl);
$this->assertNotNull($secureEcom->payerAuthenticationRequest);
$this->assertNotNull($secureEcom->challengeValue);
$this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status);
$this->assertEquals('5', $secureEcom->eci);
$this->assertEquals('1.0.0', $secureEcom->messageVersion);

Expand Down Expand Up @@ -397,13 +370,11 @@ public function testCardHolderNotEnrolled_PostResult()
private function assertCheckEnrollmentChallengeV1(ThreeDSecure $secureEcom)
{
$this->assertNotNull($secureEcom);
$this->assertEquals('ENROLLED', $secureEcom->enrolled);
$this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled);
$this->assertEquals(Secure3dVersion::ONE, $secureEcom->getVersion());
$this->assertEquals('CHALLENGE_REQUIRED', $secureEcom->status);
$this->assertTrue($secureEcom->challengeMandated);
$this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $secureEcom->status);
$this->assertNotNull($secureEcom->issuerAcsUrl);
$this->assertNotNull($secureEcom->payerAuthenticationRequest);
$this->assertNotNull($secureEcom->challengeValue);
$this->assertEmpty($secureEcom->eci);
$this->assertEquals("1.0.0", $secureEcom->messageVersion);
}
Expand All @@ -412,11 +383,10 @@ private function assertCheckEnrollmentCardNotEnrolledV1(ThreeDSecure $secureEcom
{
$this->assertNotNull($secureEcom);
$this->assertEquals(Secure3dVersion::ONE, $secureEcom->getVersion());
$this->assertEquals('NOT_ENROLLED', $secureEcom->enrolled);
$this->assertEquals('NOT_ENROLLED', $secureEcom->status);
$this->assertEquals(Secure3dStatus::NOT_ENROLLED, $secureEcom->enrolled);
$this->assertEquals(Secure3dStatus::NOT_ENROLLED, $secureEcom->status);
$this->assertEquals('6', $secureEcom->eci);
$this->assertEquals('1.0.0', $secureEcom->messageVersion);
$this->assertFalse($secureEcom->challengeMandated);
}

}
Loading

0 comments on commit d54dd39

Please sign in to comment.