diff --git a/src/Entities/Enums/Secure3dStatus.php b/src/Entities/Enums/Secure3dStatus.php index df29df08..b44f3c38 100644 --- a/src/Entities/Enums/Secure3dStatus.php +++ b/src/Entities/Enums/Secure3dStatus.php @@ -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'; } \ No newline at end of file diff --git a/src/Entities/GpApi/GpApiAuthorizationRequestBuilder.php b/src/Entities/GpApi/GpApiAuthorizationRequestBuilder.php index cbbdf111..14936cb7 100644 --- a/src/Entities/GpApi/GpApiAuthorizationRequestBuilder.php +++ b/src/Entities/GpApi/GpApiAuthorizationRequestBuilder.php @@ -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]; } } diff --git a/src/Entities/GpApi/GpApiSecure3DRequestBuilder.php b/src/Entities/GpApi/GpApiSecure3DRequestBuilder.php index 1e045677..17f25aa4 100644 --- a/src/Entities/GpApi/GpApiSecure3DRequestBuilder.php +++ b/src/Entities/GpApi/GpApiSecure3DRequestBuilder.php @@ -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'] = [ @@ -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, diff --git a/src/Entities/ThreeDSecure.php b/src/Entities/ThreeDSecure.php index e34b772a..3ff17202 100644 --- a/src/Entities/ThreeDSecure.php +++ b/src/Entities/ThreeDSecure.php @@ -87,11 +87,6 @@ public function setAmount($value) */ public $challengeMandated; - /** - * @var string - */ - public $challengeValue; - /** * string */ @@ -351,6 +346,11 @@ public function setVersion($version) */ public $sessionDataFieldName; + /** + * @var string + */ + public $liabilityShift; + public function __construct() { $this->paymentDataType = '3DSecure'; @@ -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); @@ -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); } } diff --git a/src/Mapping/GpApiMapping.php b/src/Mapping/GpApiMapping.php index 8d3a58d6..b33ef28c 100644 --- a/src/Mapping/GpApiMapping.php +++ b/src/Mapping/GpApiMapping.php @@ -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 { @@ -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)) { @@ -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; diff --git a/src/ServiceConfigs/Gateways/GpApiConfig.php b/src/ServiceConfigs/Gateways/GpApiConfig.php index 439dc614..5f1ddc5b 100644 --- a/src/ServiceConfigs/Gateways/GpApiConfig.php +++ b/src/ServiceConfigs/Gateways/GpApiConfig.php @@ -58,6 +58,11 @@ class GpApiConfig extends GatewayConfig */ public $challengeNotificationUrl; + /** + * @var string + */ + public $merchantContactUrl; + /** * @var array */ diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php b/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php index 120ac226..0e47976e 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php +++ b/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php @@ -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 @@ -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; } @@ -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(); @@ -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"); @@ -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); } @@ -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); @@ -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); } @@ -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); } } \ No newline at end of file diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php b/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php index 753f4552..400a7c9a 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php +++ b/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php @@ -10,7 +10,6 @@ use GlobalPayments\Api\Entities\Enums\DeliveryTimeFrame; use GlobalPayments\Api\Entities\Enums\Environment; use GlobalPayments\Api\Entities\Enums\GpApi\Channels; -use GlobalPayments\Api\Entities\Enums\GpApi\PaymentType; use GlobalPayments\Api\Entities\Enums\MethodUrlCompletion; use GlobalPayments\Api\Entities\Enums\Secure3dVersion; use GlobalPayments\Api\Entities\Enums\ShippingMethod; @@ -29,6 +28,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 GpApi3DS2Test extends TestCase @@ -101,13 +101,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; } @@ -140,13 +141,16 @@ public function testFullCycle_v2_Frictionless() ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('SUCCESS_AUTHENTICATED', $initAuth->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $initAuth->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); - $this->card->threeDSecure = $initAuth; - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + + $this->card->threeDSecure = $secureEcom; $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -177,13 +181,15 @@ public function testFullCycle_v2_FrictionlessFailed() ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('NOT_AUTHENTICATED', $initAuth->status); + $this->assertEquals(Secure3dStatus::NOT_AUTHENTICATED, $initAuth->status); + $this->assertNotEquals('YES', $initAuth->liabilityShift); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); - $this->card->threeDSecure = $initAuth; - $this->assertEquals('NOT_AUTHENTICATED', $secureEcom->status); + + $this->assertEquals(Secure3dStatus::NOT_AUTHENTICATED, $secureEcom->status); + $this->card->threeDSecure = $secureEcom; $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -208,7 +214,8 @@ public function testFullCycle_v2_WithCardTokenization() ->execute(); $this->assertCheckEnrollment3DSV2($secureEcom); - $this->assertNotEmpty($secureEcom->issuerAcsUrl); + $this->assertNotNull($secureEcom->issuerAcsUrl); + $this->assertNotNull($secureEcom->payerAuthenticationRequest); $initAuth = Secure3dService::initiateAuthentication($tokenizedCard, $secureEcom) ->withAmount($this->amount) @@ -221,13 +228,15 @@ public function testFullCycle_v2_WithCardTokenization() ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); + + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); $tokenizedCard->threeDSecure = $secureEcom; - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); $response = $tokenizedCard->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -248,7 +257,6 @@ public function testFullCycle_CardHolderEnrolled_ChallengeRequired_v2() ->execute(); $this->assertCheckEnrollment3DSV2($secureEcom); - $this->assertNotEmpty($secureEcom->issuerAcsUrl); $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) ->withAmount($this->amount) @@ -261,10 +269,9 @@ public function testFullCycle_CardHolderEnrolled_ChallengeRequired_v2() ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); - $this->assertTrue($initAuth->challengeMandated); + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); $this->assertNotNull($initAuth->issuerAcsUrl); - $this->assertNotNull($initAuth->challengeValue); + $this->assertNotNull($initAuth->payerAuthenticationRequest); $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); $authClient->setGatewayProvider($this->gatewayProvider); @@ -275,10 +282,9 @@ public function testFullCycle_CardHolderEnrolled_ChallengeRequired_v2() $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($authResponse->getMerchantData()) ->execute(); - $this->card->threeDSecure = $secureEcom; - - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + $this->card->threeDSecure = $secureEcom; $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); $this->assertEquals('SUCCESS', $response->responseCode); @@ -359,7 +365,6 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_AllPreferenceValues( } } - //TODO - storedCredential object not mapped on request body public function testCardHolderEnrolled_ChallengeRequired_v2_StoredCredentials() { $storeCredentials = new StoredCredential(); @@ -377,26 +382,6 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_StoredCredentials() $this->assertCheckEnrollment3DSV2($secureEcom); } - public function testCardHolderEnrolled_ChallengeRequired_v2_Refund() - { - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withOrderTransactionType(PaymentType::REFUND) - ->execute(); - - $this->assertCheckEnrollment3DSV2($secureEcom); - - $secureEcomSale = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withOrderTransactionType(PaymentType::SALE) - ->execute(); - - $this->assertCheckEnrollment3DSV2($secureEcomSale); - $this->assertNotSame($secureEcom, $secureEcomSale); - } - public function testCardHolderEnrolled_ChallengeRequired_v2_AllSources() { $source = array("BROWSER", "MERCHANT_INITIATED", "MOBILE_SDK", "STORED_RECURRING"); @@ -529,28 +514,6 @@ public function testCardHolderEnrolled_Frictionless_v2_StoredCredentials() $this->assertCheckEnrollment3DSV2($secureEcom); } - public function testCardHolderEnrolled_Frictionless_v2_Refund() - { - $this->card->number = GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_V2_2; - - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withOrderTransactionType(PaymentType::REFUND) - ->execute(); - - $this->assertCheckEnrollment3DSV2($secureEcom); - - $secureEcomSale = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withOrderTransactionType(PaymentType::SALE) - ->execute(); - - $this->assertCheckEnrollment3DSV2($secureEcomSale); - $this->assertNotSame($secureEcom, $secureEcomSale); - } - public function testCardHolderEnrolled_Frictionless_v2_AllSources() { $this->card->number = GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_V2_2; @@ -590,7 +553,7 @@ public function testCardHolderChallengeRequired_PostResult() ->withBrowserData($this->browserData) ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); $authClient->setGatewayProvider($this->gatewayProvider); @@ -602,14 +565,12 @@ public function testCardHolderChallengeRequired_PostResult() ->withServerTransactionId($authResponse->getMerchantData()) ->execute(); - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); - $this->assertNotNull($secureEcom->challengeValue); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); $this->assertEquals('05', $secureEcom->eci); $this->assertEquals('2.2.0', $secureEcom->messageVersion); $this->assertNotNull($secureEcom->acsTransactionId); $this->assertNotNull($secureEcom->serverTransactionId); $this->assertNotNull($secureEcom->directoryServerTransactionId); - $this->assertNotNull($secureEcom->challengeValue); } public function testCardHolderChallengeRequired_PostResult_WithIdempotencyKey() @@ -633,7 +594,7 @@ public function testCardHolderChallengeRequired_PostResult_WithIdempotencyKey() ->withBrowserData($this->browserData) ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); $authClient->setGatewayProvider($this->gatewayProvider); @@ -646,14 +607,12 @@ public function testCardHolderChallengeRequired_PostResult_WithIdempotencyKey() ->withIdempotencyKey($idempotencyKey) ->execute(); - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); - $this->assertNotNull($secureEcom->challengeValue); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); $this->assertEquals('05', $secureEcom->eci); $this->assertEquals('2.2.0', $secureEcom->messageVersion); $this->assertNotNull($secureEcom->acsTransactionId); $this->assertNotNull($secureEcom->serverTransactionId); $this->assertNotNull($secureEcom->directoryServerTransactionId); - $this->assertNotNull($secureEcom->challengeValue); $exceptionCaught = false; try { @@ -695,19 +654,19 @@ public function testCardHolderFrictionless_PostResult() ->withBrowserData($this->browserData) ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('SUCCESS_AUTHENTICATED', $initAuth->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $initAuth->status); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); $this->assertEquals('05', $secureEcom->eci); $this->assertEquals('2.2.0', $secureEcom->messageVersion); $this->assertNotNull($secureEcom->acsTransactionId); $this->assertNotNull($secureEcom->serverTransactionId); $this->assertNotNull($secureEcom->directoryServerTransactionId); - $this->assertEmpty($secureEcom->challengeValue); + $this->assertEmpty($secureEcom->payerAuthenticationRequest); } public function testCardHolderFrictionless_PostResult_WithIdempotencyKey() @@ -732,20 +691,20 @@ public function testCardHolderFrictionless_PostResult_WithIdempotencyKey() ->withBrowserData($this->browserData) ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('SUCCESS_AUTHENTICATED', $initAuth->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $initAuth->status); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->withIdempotencyKey($idempotencyKey) ->execute(); - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); $this->assertEquals('05', $secureEcom->eci); $this->assertEquals('2.2.0', $secureEcom->messageVersion); $this->assertNotNull($secureEcom->acsTransactionId); $this->assertNotNull($secureEcom->serverTransactionId); $this->assertNotNull($secureEcom->directoryServerTransactionId); - $this->assertEmpty($secureEcom->challengeValue); + $this->assertEmpty($secureEcom->payerAuthenticationRequest); $exceptionCaught = false; try { @@ -1087,9 +1046,9 @@ public function testCardHolderEnrolled_Frictionless_v2_Initiate() ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('SUCCESS_AUTHENTICATED', $initAuth->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $initAuth->status); $this->assertNotNull($initAuth->issuerAcsUrl); - $this->assertNotNull($initAuth->challengeValue); + $this->assertNotNull($initAuth->payerAuthenticationRequest); $this->assertNotNull($initAuth->acsTransactionId); $this->assertEquals("05", $initAuth->eci); $this->assertEquals("2.2.0", $initAuth->messageVersion); @@ -1149,22 +1108,20 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_Initiate_NonExistent private function assertCheckEnrollment3DSV2(ThreeDSecure $secureEcom) { $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $this->assertNotNull($secureEcom->issuerAcsUrl); $this->assertNotNull($secureEcom->payerAuthenticationRequest); - $this->assertNotNull($secureEcom->challengeValue); $this->assertEmpty($secureEcom->eci); } private function assertInitiate3DSV2(ThreeDSecure $initAuth) { $this->assertNotNull($initAuth); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); - $this->assertTrue($initAuth->challengeMandated); + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); $this->assertNotNull($initAuth->issuerAcsUrl); - $this->assertNotNull($initAuth->challengeValue); + $this->assertNotNull($initAuth->payerAuthenticationRequest); $this->assertNotNull($initAuth->acsTransactionId); $this->assertEmpty($initAuth->eci); $this->assertEquals("2.2.0", $initAuth->messageVersion); diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php b/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php index fcd1c4a2..f25f871b 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php @@ -9,6 +9,7 @@ use GlobalPayments\Api\Entities\Enums\Environment; use GlobalPayments\Api\Entities\Enums\GpApi\Channels; use GlobalPayments\Api\Entities\Enums\MethodUrlCompletion; +use GlobalPayments\Api\Entities\Enums\OrderTransactionType; use GlobalPayments\Api\Entities\Enums\Secure3dVersion; use GlobalPayments\Api\Entities\Enums\TransactionStatus; use GlobalPayments\Api\Entities\Exceptions\ApiException; @@ -20,6 +21,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 GpApi3DSecureTest extends TestCase @@ -91,13 +93,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; } @@ -125,7 +128,8 @@ public function testCardHolderEnrolled_ChallengeRequired_AuthenticationSuccessfu ->withPayerAuthenticationResponse($authResponse->getAuthResponse()) ->execute(); $this->card->threeDSecure = $secureEcom; - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -164,6 +168,7 @@ public function testCardHolderEnrolled_ChallengeRequired_AuthenticationSuccessfu ->execute(); $tokenizedCard->threeDSecure = $secureEcom; $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $response = $tokenizedCard->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -201,6 +206,8 @@ public function testCardHolderEnrolled_ChallengeRequired_AuthenticationFailed_v1 ->execute(); $this->card->threeDSecure = $secureEcom; $this->assertEquals($status, $secureEcom->status); + $liabilityShift = $status == Secure3dStatus::SUCCESS_ATTEMPT_MADE ? 'YES' : 'NO'; + $this->assertEquals($liabilityShift, $secureEcom->liabilityShift); $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -279,9 +286,9 @@ public function testFrictionlessFullCycle_v2($cardNumber, $status) ->execute(); $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) ->withAmount($this->amount) @@ -290,6 +297,7 @@ public function testFrictionlessFullCycle_v2($cardNumber, $status) ->withMethodUrlCompletion(MethodUrlCompletion::YES) ->withOrderCreateDate(date('Y-m-d H:i:s')) ->withAddress($this->shippingAddress, AddressType::SHIPPING) + ->withOrderTransactionType(OrderTransactionType::GOODS_SERVICE_PURCHASE) ->withBrowserData($this->browserData) ->execute(); $this->assertNotNull($initAuth); @@ -298,8 +306,10 @@ public function testFrictionlessFullCycle_v2($cardNumber, $status) $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); - $this->card->threeDSecure = $initAuth; + + $this->card->threeDSecure = $secureEcom; $this->assertEquals($status, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -325,9 +335,9 @@ public function testFrictionlessFullCycle_v2_Failed($cardNumber, $status) ->execute(); $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) ->withAmount($this->amount) @@ -344,8 +354,13 @@ public function testFrictionlessFullCycle_v2_Failed($cardNumber, $status) $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); - $this->card->threeDSecure = $initAuth; + + $liabilityShift = ($status == Secure3dStatus::SUCCESS_ATTEMPT_MADE ? 'YES' : 'NO'); $this->assertEquals($status, $secureEcom->status); + $this->assertEquals($liabilityShift, $secureEcom->liabilityShift); + + $this->card->threeDSecure = $secureEcom; + $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -371,9 +386,9 @@ public function testCardHolderEnrolled_ChallengeRequired_v2($cardNumber, $status ->execute(); $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) ->withAmount($this->amount) @@ -386,10 +401,9 @@ public function testCardHolderEnrolled_ChallengeRequired_v2($cardNumber, $status ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); - $this->assertTrue($initAuth->challengeMandated); + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); $this->assertNotNull($initAuth->issuerAcsUrl); - $this->assertNotNull($initAuth->challengeValue); + $this->assertNotNull($initAuth->payerAuthenticationRequest); $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); $authClient->setGatewayProvider($this->gatewayProvider); @@ -403,6 +417,7 @@ public function testCardHolderEnrolled_ChallengeRequired_v2($cardNumber, $status $this->card->threeDSecure = $secureEcom; $this->assertEquals($status, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -425,9 +440,9 @@ public function testChallengeRequired_GetResultFailed_v2() ->execute(); $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) ->withAmount($this->amount) @@ -440,16 +455,16 @@ public function testChallengeRequired_GetResultFailed_v2() ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); - $this->assertTrue($initAuth->challengeMandated); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); $this->assertNotNull($initAuth->issuerAcsUrl); - $this->assertNotNull($initAuth->challengeValue); + $this->assertNotNull($initAuth->payerAuthenticationRequest); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($initAuth->serverTransactionId) ->execute(); - $this->assertEquals('NOT_ENROLLED', $secureEcom->enrolled); - $this->assertEquals('CHALLENGE_REQUIRED', $secureEcom->status); + + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $secureEcom->status); } /** @@ -474,9 +489,9 @@ public function testFullCycle_WithCardTokenization_v2() ->execute(); $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $initAuth = Secure3dService::initiateAuthentication($tokenizedCard, $secureEcom) ->withAmount($this->amount) @@ -489,14 +504,16 @@ public function testFullCycle_WithCardTokenization_v2() ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); - $tokenizedCard->threeDSecure = $secureEcom; - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); + $tokenizedCard->threeDSecure = $secureEcom; $response = $tokenizedCard->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); $this->assertEquals('SUCCESS', $response->responseCode); @@ -518,9 +535,9 @@ public function testFrictionlessFullCycle_v2_DifferentAmount() ->execute(); $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $this->assertEquals($this->amount, $secureEcom->getAmount()); $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) @@ -533,14 +550,16 @@ public function testFrictionlessFullCycle_v2_DifferentAmount() ->withBrowserData($this->browserData) ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('SUCCESS_AUTHENTICATED', $initAuth->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $initAuth->status); $this->assertEquals($this->amount, $initAuth->getAmount()); + $this->assertEquals('YES', $secureEcom->liabilityShift); $secureEcom = Secure3dService::getAuthenticationData() ->withServerTransactionId($secureEcom->serverTransactionId) ->execute(); $this->card->threeDSecure = $initAuth; - $this->assertEquals('SUCCESS_AUTHENTICATED', $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $this->assertEquals($this->amount, $secureEcom->getAmount()); $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); @@ -559,9 +578,9 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_DuplicateAcsRequest( ->execute(); $this->assertNotNull($secureEcom); - $this->assertEquals('ENROLLED', $secureEcom->enrolled); + $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - $this->assertEquals('AVAILABLE', $secureEcom->status); + $this->assertEquals(Secure3dStatus::AVAILABLE, $secureEcom->status); $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) ->withAmount($this->amount) @@ -574,10 +593,9 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_DuplicateAcsRequest( ->execute(); $this->assertNotNull($initAuth); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); - $this->assertTrue($initAuth->challengeMandated); + $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); $this->assertNotNull($initAuth->issuerAcsUrl); - $this->assertNotNull($initAuth->challengeValue); + $this->assertNotNull($initAuth->payerAuthenticationRequest); $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); $authClient->setGatewayProvider($this->gatewayProvider); @@ -596,7 +614,8 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_DuplicateAcsRequest( ->execute(); $this->card->threeDSecure = $secureEcom; - $this->assertEquals("SUCCESS_AUTHENTICATED", $secureEcom->status); + $this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $secureEcom->status); + $this->assertEquals('YES', $secureEcom->liabilityShift); $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); $this->assertNotNull($response); @@ -607,54 +626,52 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_DuplicateAcsRequest( public function ChallengeSuccessful3DSV2CardTests() { return [ - 'Challenge v2.1' => [GpApi3DSTestCards::CARD_CHALLENGE_REQUIRED_V2_1, 'SUCCESS_AUTHENTICATED'], - 'Challenge v2.2' => [GpApi3DSTestCards::CARD_CHALLENGE_REQUIRED_V2_2, 'SUCCESS_AUTHENTICATED'] + 'Challenge v2.1' => [GpApi3DSTestCards::CARD_CHALLENGE_REQUIRED_V2_1, Secure3dStatus::SUCCESS_AUTHENTICATED], + 'Challenge v2.2' => [GpApi3DSTestCards::CARD_CHALLENGE_REQUIRED_V2_2, Secure3dStatus::SUCCESS_AUTHENTICATED] ]; } public function ChallengeRequiredFailed3DSV1CardTests() { return [ - 'Acs Client result code 5' => [5, 'FAILED'], - 'Acs Client result code 7' => [7, 'SUCCESS_ATTEMPT_MADE'], - 'Acs Client result code 9' => [9, 'NOT_AUTHENTICATED'] + 'Acs Client result code 5' => [5, Secure3dStatus::FAILED], + 'Acs Client result code 7' => [7, Secure3dStatus::SUCCESS_ATTEMPT_MADE], + 'Acs Client result code 9' => [9, Secure3dStatus::NOT_AUTHENTICATED] ]; } public function FrictionlessSuccessful3DSV2CardTests() { return [ - 'Frictionless v2.1' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_V2_1, 'SUCCESS_AUTHENTICATED'], - 'Frictionless no method url v2.1' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_NO_METHOD_URL_V2_1, 'SUCCESS_AUTHENTICATED'], - 'Frictionless v2.2' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_V2_2, 'SUCCESS_AUTHENTICATED'], - 'Frictionless no method url v2.2' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_NO_METHOD_URL_V2_2, 'SUCCESS_AUTHENTICATED'] + 'Frictionless v2.1' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_V2_1, Secure3dStatus::SUCCESS_AUTHENTICATED], + 'Frictionless no method url v2.1' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_NO_METHOD_URL_V2_1, Secure3dStatus::SUCCESS_AUTHENTICATED], + 'Frictionless v2.2' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_V2_2, Secure3dStatus::SUCCESS_AUTHENTICATED], + 'Frictionless no method url v2.2' => [GpApi3DSTestCards::CARD_AUTH_SUCCESSFUL_NO_METHOD_URL_V2_2, Secure3dStatus::SUCCESS_AUTHENTICATED] ]; } public function FrictionlessFailed3DSV2CardTests() { return [ - 'Frictionless failed 1' => [GpApi3DSTestCards::CARD_AUTH_ATTEMPTED_BUT_NOT_SUCCESSFUL_V2_1, 'SUCCESS_ATTEMPT_MADE'], - 'Frictionless failed 2' => [GpApi3DSTestCards::CARD_AUTH_FAILED_V2_1, 'NOT_AUTHENTICATED'], - 'Frictionless failed 3' => [GpApi3DSTestCards::CARD_AUTH_ISSUER_REJECTED_V2_1, 'FAILED'], - 'Frictionless failed 4' => [GpApi3DSTestCards::CARD_AUTH_COULD_NOT_BE_PREFORMED_V2_1, 'FAILED'], - 'Frictionless failed 5' => [GpApi3DSTestCards::CARD_AUTH_ATTEMPTED_BUT_NOT_SUCCESSFUL_V2_2, 'SUCCESS_ATTEMPT_MADE'], - 'Frictionless failed 6' => [GpApi3DSTestCards::CARD_AUTH_FAILED_V2_2, 'NOT_AUTHENTICATED'], - 'Frictionless failed 7' => [GpApi3DSTestCards::CARD_AUTH_ISSUER_REJECTED_V2_2, 'FAILED'], - 'Frictionless failed 8' => [GpApi3DSTestCards::CARD_AUTH_COULD_NOT_BE_PREFORMED_V2_2, 'FAILED'] + 'Frictionless failed 1' => [GpApi3DSTestCards::CARD_AUTH_ATTEMPTED_BUT_NOT_SUCCESSFUL_V2_1, Secure3dStatus::SUCCESS_ATTEMPT_MADE], + 'Frictionless failed 2' => [GpApi3DSTestCards::CARD_AUTH_FAILED_V2_1, Secure3dStatus::NOT_AUTHENTICATED], + 'Frictionless failed 3' => [GpApi3DSTestCards::CARD_AUTH_ISSUER_REJECTED_V2_1, Secure3dStatus::FAILED], + 'Frictionless failed 4' => [GpApi3DSTestCards::CARD_AUTH_COULD_NOT_BE_PREFORMED_V2_1, Secure3dStatus::FAILED], + 'Frictionless failed 5' => [GpApi3DSTestCards::CARD_AUTH_ATTEMPTED_BUT_NOT_SUCCESSFUL_V2_2, Secure3dStatus::SUCCESS_ATTEMPT_MADE], + 'Frictionless failed 6' => [GpApi3DSTestCards::CARD_AUTH_FAILED_V2_2, Secure3dStatus::NOT_AUTHENTICATED], + 'Frictionless failed 7' => [GpApi3DSTestCards::CARD_AUTH_ISSUER_REJECTED_V2_2, Secure3dStatus::FAILED], + 'Frictionless failed 8' => [GpApi3DSTestCards::CARD_AUTH_COULD_NOT_BE_PREFORMED_V2_2, Secure3dStatus::FAILED] ]; } 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); } @@ -663,11 +680,11 @@ 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); + $this->assertEquals('YES', $secureEcom->liabilityShift); } } \ No newline at end of file