From aee375b504c81bf5caf46fa84bd213d665b7d506 Mon Sep 17 00:00:00 2001 From: securesubmit-buildmaster Date: Thu, 6 Jun 2024 08:08:16 -0400 Subject: [PATCH] OctopusDeploy release: 12.0.5 --- CHANGELOG.md | 8 +- examples/gp-ecom/hpp/example.html | 7 +- examples/gp-ecom/hpp/get-json.php | 3 + metadata.xml | 2 +- src/Entities/HostedPaymentData.php | 2 + src/Entities/RecurringEntity.php | 3 + src/Gateways/GpEcomConnector.php | 3 + .../PAX/Responses/PaxBaseResponse.php | 2 +- test/Data/GpApi3DSTestCards.php | 3 - .../Gateways/GpApiConnector/GpApi3DS1Test.php | 279 ------------------ .../GpApiConnector/GpApi3DSecureTest.php | 19 -- .../Gateways/GpApiConnector/PayerTest.php | 85 +++++- .../ReportingTransactionsTest.php | 2 +- .../Gateways/GpEcomConnector/HppTest.php | 2 + .../GpEcomConnector/Secure3dServiceTest.php | 42 --- .../Gateways/Terminals/PAX/PaxCreditTests.php | 26 ++ 16 files changed, 138 insertions(+), 350 deletions(-) delete mode 100644 test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 416efc3f..cd485ff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,13 @@ # Changelog -## Latest Version - v12.0.4 (05/30/24) +## Latest Version - v12.0.5 (06/07/24) +### Bug Fixes: +- [PAX] Corrected "partial auth" response handling +- [GP-ECOM] Add HPP additional field "HPP_REMOVE_SHIPPING" +- [GP-API] Unit tests enhancements + +## v12.0.4 (05/30/24) ### Enhancements: - [GP-ECOM] Added additional fee to a card transaction (surchargeamount). - [GP-API] Add mapping for "message_received " and "message_sent " on get a Single Action response diff --git a/examples/gp-ecom/hpp/example.html b/examples/gp-ecom/hpp/example.html index 22e174d7..61e19bf7 100644 --- a/examples/gp-ecom/hpp/example.html +++ b/examples/gp-ecom/hpp/example.html @@ -4,6 +4,10 @@ +
+ + +
@@ -19,7 +23,8 @@ $("#payButtonId").click(function() { const data = { captureAddress: document.getElementById("capture_address").checked, - notReturnAddress: document.getElementById("not_return_address").checked + notReturnAddress: document.getElementById("not_return_address").checked, + removeShipping: document.getElementById("remove_shipping").checked }; console.log(data); $.getJSON("get-json.php", data, function (jsonFromRequestEndpoint) { diff --git a/examples/gp-ecom/hpp/get-json.php b/examples/gp-ecom/hpp/get-json.php index 8f1737fd..bb56a044 100644 --- a/examples/gp-ecom/hpp/get-json.php +++ b/examples/gp-ecom/hpp/get-json.php @@ -48,6 +48,9 @@ if (isset($_REQUEST['notReturnAddress'])) { $hostedPaymentData->notReturnAddress = filter_var($_REQUEST['notReturnAddress'], FILTER_VALIDATE_BOOLEAN); } +if (isset($_REQUEST['removeShipping'])) { + $hostedPaymentData->removeShipping = filter_var($_REQUEST['removeShipping'], FILTER_VALIDATE_BOOLEAN); +} $hostedPaymentData->customerCountry = 'DE'; $hostedPaymentData->customerFirstName = 'James'; diff --git a/metadata.xml b/metadata.xml index 33612c48..59f18636 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 12.0.4 + 12.0.5 \ No newline at end of file diff --git a/src/Entities/HostedPaymentData.php b/src/Entities/HostedPaymentData.php index 7d880e14..dabfeeae 100644 --- a/src/Entities/HostedPaymentData.php +++ b/src/Entities/HostedPaymentData.php @@ -34,6 +34,8 @@ class HostedPaymentData */ public $notReturnAddress; + public ?bool $removeShipping = null; + /** * Determines the challenge request preference for 3DS 2.0. * diff --git a/src/Entities/RecurringEntity.php b/src/Entities/RecurringEntity.php index 4771393b..4b1f3a4a 100644 --- a/src/Entities/RecurringEntity.php +++ b/src/Entities/RecurringEntity.php @@ -2,6 +2,7 @@ namespace GlobalPayments\Api\Entities; +use GlobalPayments\Api\Entities\Exceptions\GatewayException; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Entities\Exceptions\ApiException; use GlobalPayments\Api\Entities\Exceptions\UnsupportedTransactionException; @@ -92,6 +93,8 @@ public function saveChanges($configName = 'default') { try { return RecurringService::edit($this); + } catch (GatewayException $exception) { + throw $exception; } catch (ApiException $exc) { throw new ApiException('Update failed, see inner exception for more details', $exc); } diff --git a/src/Gateways/GpEcomConnector.php b/src/Gateways/GpEcomConnector.php index 07499732..b8a4351b 100644 --- a/src/Gateways/GpEcomConnector.php +++ b/src/Gateways/GpEcomConnector.php @@ -385,6 +385,9 @@ public function serializeRequest(AuthorizationBuilder $builder) if (isset($hostedPaymentData->notReturnAddress)) { $this->setSerializeData('HPP_DO_NOT_RETURN_ADDRESS', $hostedPaymentData->notReturnAddress == true); } + if (isset($hostedPaymentData->removeShipping)) { + $this->setSerializeData('HPP_REMOVE_SHIPPING', $hostedPaymentData->removeShipping === true); + } } if (isset($this->hostedPaymentConfig->cardStorageEnabled)) { $this->setSerializeData('CARD_STORAGE_ENABLE', $this->hostedPaymentConfig->cardStorageEnabled ? '1' : '0'); diff --git a/src/Terminals/PAX/Responses/PaxBaseResponse.php b/src/Terminals/PAX/Responses/PaxBaseResponse.php index 53792e48..acfd68b1 100644 --- a/src/Terminals/PAX/Responses/PaxBaseResponse.php +++ b/src/Terminals/PAX/Responses/PaxBaseResponse.php @@ -39,7 +39,7 @@ public function parseResponse($messageReader) public function checkResponse($acceptedCodes = null) { if ($acceptedCodes === null) { - $acceptedCodes = ["000000", "000100"]; + $acceptedCodes = ["000000", "000100", "000002"]; } if (!empty($this->deviceResponseText)) { diff --git a/test/Data/GpApi3DSTestCards.php b/test/Data/GpApi3DSTestCards.php index 97e88c5b..4f7946f8 100644 --- a/test/Data/GpApi3DSTestCards.php +++ b/test/Data/GpApi3DSTestCards.php @@ -4,9 +4,6 @@ class GpApi3DSTestCards { - const CARDHOLDER_NOT_ENROLLED_V1 = "4917000000000087"; - const CARDHOLDER_ENROLLED_V1 = "4012001037141112"; - const CARD_AUTH_SUCCESSFUL_V2_1 = "4263970000005262"; const CARD_AUTH_SUCCESSFUL_NO_METHOD_URL_V2_1 = "4222000006724235"; const CARD_AUTH_ATTEMPTED_BUT_NOT_SUCCESSFUL_V2_1 = "4012001037167778"; diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php b/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php deleted file mode 100644 index f9e1324e..00000000 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php +++ /dev/null @@ -1,279 +0,0 @@ -setUpConfig(); - ServicesContainer::configureService($config); - $this->gatewayProvider = $config->getGatewayProvider(); - $this->currency = 'GBP'; - $this->amount = '10.01'; - - $this->card = new CreditCardData(); - $this->card->number = GpApi3DSTestCards::CARDHOLDER_ENROLLED_V1; - $this->card->expMonth = '12'; - $this->card->expYear = date('Y', strtotime('+1 year')); - $this->card->cardHolderName = "James Mason"; - } - - public static function tearDownAfterClass(): void - { - BaseGpApiTestConfig::resetGpApiConfig(); - } - - public function setUpConfig(): GpApiConfig - { - return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); - } - - /** - * Tests for 3DS v1 Card Enrolled - Check Availability - */ - public function testCardHolderEnrolled_ChallengeRequired_v1() - { - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - } - - public function testCardHolderEnrolled_ChallengeRequired_v1_WithIdempotencyKey() - { - $idempotencyKey = GenerationUtils::getGuid(); - - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withIdempotencyKey($idempotencyKey) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - - $exceptionCaught = false; - try { - Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withIdempotencyKey($idempotencyKey) - ->execute(); - } catch (ApiException $e) { - $exceptionCaught = true; - $this->assertEquals('40039', $e->responseCode); - $this->assertStringContainsString('Idempotency Key seen before', $e->getMessage()); - } finally { - $this->assertTrue($exceptionCaught); - } - } - - public function testCardHolderEnrolled_ChallengeRequired_v1_TokenizedCard() - { - $response = $this->card->tokenize()->execute(); - $tokenId = $response->token; - - $tokenizedCard = new CreditCardData(); - $tokenizedCard->token = $tokenId; - $tokenizedCard->cardHolderName = "James Mason"; - - $secureEcom = Secure3dService::checkEnrollment($tokenizedCard) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - } - - public function testCardHolderEnrolled_ChallengeRequired_v1_AllPreferenceValues() - { - $challengeRequestIndicator = new ChallengeRequestIndicator(); - $reflectionClass = new ReflectionClass($challengeRequestIndicator); - foreach ($reflectionClass->getConstants() as $value) { - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withChallengeRequestIndicator($value) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - } - } - - public function testCardHolderEnrolled_ChallengeRequired_v1_StoredCredentials() - { - $storeCredentials = new StoredCredential(); - $storeCredentials->initiator = StoredCredentialInitiator::MERCHANT; - $storeCredentials->type = StoredCredentialType::INSTALLMENT; - $storeCredentials->sequence = StoredCredentialSequence::SUBSEQUENT; - $storeCredentials->reason = StoredCredentialReason::INCREMENTAL; - - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withStoredCredential($storeCredentials) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - } - - public function testCardHolderEnrolled_ChallengeRequired_v1_AllSources() - { - $source = array("BROWSER", "MERCHANT_INITIATED", "MOBILE_SDK", "STORED_RECURRING"); - foreach ($source as $value) { - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->withAuthenticationSource($value) - ->execute(); - } - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - } - - public function testCardHolderEnrolled_ChallengeRequired_v1_WithNullPaymentMethod() - { - $exceptionCaught = false; - try { - Secure3dService::checkEnrollment($this->card) - ->withPaymentMethod(null) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->execute(); - } catch (ApiException $e) { - $exceptionCaught = true; - $this->assertEquals('40007', $e->responseCode); - $this->assertEquals('Status Code: INVALID_REQUEST_DATA - Request expects the following conditionally mandatory fields number,expiry_month,expiry_year.', $e->getMessage()); - } finally { - $this->assertTrue($exceptionCaught); - } - } - - /** - * Tests for 3DS v1 Card Not Enrolled - Check Availability - */ - public function testCardHolderNotEnrolled_v1() - { - $this->card->number = GpApi3DSTestCards::CARDHOLDER_NOT_ENROLLED_V1; - - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - } - - public function testCardHolderNotEnrolled_v1_TokenizedCard() - { - $this->card->number = GpApi3DSTestCards::CARDHOLDER_NOT_ENROLLED_V1; - - $response = $this->card->tokenize()->execute(); - $tokenId = $response->token; - - $tokenizedCard = new CreditCardData(); - $tokenizedCard->token = $tokenId; - $tokenizedCard->cardHolderName = "James Mason"; - - $secureEcom = Secure3dService::checkEnrollment($tokenizedCard) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - } - - public function testCardHolderEnrolled_PostResult_NonExistentId() - { - $transactionId = "AUT_" . GenerationUtils::getGuid(); - - try { - Secure3dService::getAuthenticationData() - ->withServerTransactionId($transactionId) - ->execute(); - } catch (ApiException $e) { - $this->assertEquals('40118', $e->responseCode); - $this->assertEquals('Status Code: RESOURCE_NOT_FOUND - Authentication ' . $transactionId . - ' not found at this location.', $e->getMessage()); - } - } - - /** - * Tests for 3DS v1 Card Not Enrolled - Obtain Result - */ - public function testCardHolderNotEnrolled_PostResult() - { - $this->card->number = GpApi3DSTestCards::CARDHOLDER_NOT_ENROLLED_V1; - - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - - $exceptionCaught = false; - try { - Secure3dService::getAuthenticationData() - ->withServerTransactionId($secureEcom->serverTransactionId) - ->execute(); - } catch (ApiException $e) { - $exceptionCaught = true; - $this->assertEquals('50136', $e->responseCode); - $this->assertEquals('Status Code: SYSTEM_ERROR_DOWNSTREAM - Message Received Invalid', $e->getMessage()); - } finally { - $this->assertTrue($exceptionCaught); - } - } - - private function assertCheckEnrollmentCardNotEnrolledV1(ThreeDSecure $secureEcom): void - { - $this->assertNotNull($secureEcom); - $this->assertEquals(Secure3dStatus::NOT_ENROLLED, $secureEcom->enrolled); - $this->assertEquals(Secure3dStatus::NOT_ENROLLED, $secureEcom->status); - $this->assertEmpty($secureEcom->eci); - $this->assertEquals("NO", $secureEcom->liabilityShift); - } - -} \ No newline at end of file diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php b/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php index 0f653692..9dbc8de3 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApi3DSecureTest.php @@ -117,25 +117,6 @@ public function setUpConfig(): GpApiConfig return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } - public function testCardHolderNotEnrolled_v1() - { - $this->card->number = GpApi3DSTestCards::CARDHOLDER_NOT_ENROLLED_V1; - - $secureEcom = Secure3dService::checkEnrollment($this->card) - ->withCurrency($this->currency) - ->withAmount($this->amount) - ->execute(); - - $this->assertCheckEnrollmentCardNotEnrolledV1($secureEcom); - - $this->card->threeDSecure = $secureEcom; - - $response = $this->card->charge($this->amount)->withCurrency($this->currency)->execute(); - $this->assertNotNull($response); - $this->assertEquals('SUCCESS', $response->responseCode); - $this->assertEquals(TransactionStatus::CAPTURED, $response->responseMessage); - } - /** * Frictionless scenario * diff --git a/test/Integration/Gateways/GpApiConnector/PayerTest.php b/test/Integration/Gateways/GpApiConnector/PayerTest.php index d13637e0..9ba73c0f 100644 --- a/test/Integration/Gateways/GpApiConnector/PayerTest.php +++ b/test/Integration/Gateways/GpApiConnector/PayerTest.php @@ -8,6 +8,7 @@ use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\PhoneNumberType; use GlobalPayments\Api\Entities\Enums\TransactionStatus; +use GlobalPayments\Api\Entities\Exceptions\GatewayException; use GlobalPayments\Api\Entities\PhoneNumber; use GlobalPayments\Api\Entities\Product; use GlobalPayments\Api\PaymentMethods\BNPL; @@ -18,12 +19,13 @@ use GlobalPayments\Api\Utils\GenerationUtils; use PHPUnit\Framework\TestCase; -class PayerTest extends TestCase +class PayerTest extends TestCase { private Customer $newCustomer; private CreditCardData $card; private Address $billingAddress; private Address $shippingAddress; + public function setup(): void { ServicesContainer::configureService($this->setUpConfig()); @@ -67,7 +69,7 @@ public static function tearDownAfterClass(): void public function setUpConfig(): GpApiConfig { - return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); + return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } public function testCreatePayer() @@ -109,6 +111,53 @@ public function testCreatePayer() } } + public function testCreatePayer_WithoutPaymentMethods() + { + /** @var \GlobalPayments\Api\Entities\Customer $payer */ + $payer = $this->newCustomer->create(); + + $this->assertNotNull($payer->id); + $this->assertEquals($this->newCustomer->firstName, $payer->firstName); + $this->assertEquals($this->newCustomer->lastName, $payer->lastName); + $this->assertEmpty($payer->paymentMethods); + } + + public function testCreatePayer_WithoutFirstName() + { + $this->newCustomer = new Customer(); + $this->newCustomer->key = GenerationUtils::getGuid(); + $this->newCustomer->lastName = "Mason"; + + $exceptionCaught = false; + try { + $this->newCustomer->create(); + } catch (GatewayException $e) { + $exceptionCaught = true; + $this->assertEquals('Status Code: MANDATORY_DATA_MISSING - Request expects the following fields: first_name', $e->getMessage()); + $this->assertEquals('40005', $e->responseCode); + } finally { + $this->assertTrue($exceptionCaught); + } + } + + public function testCreatePayer_WithoutLastName() + { + $this->newCustomer = new Customer(); + $this->newCustomer->key = GenerationUtils::getGuid(); + $this->newCustomer->firstName = "James"; + + $exceptionCaught = false; + try { + $this->newCustomer->create(); + } catch (GatewayException $e) { + $exceptionCaught = true; + $this->assertEquals('Status Code: MANDATORY_DATA_MISSING - Request expects the following fields: last_name', $e->getMessage()); + $this->assertEquals('40005', $e->responseCode); + } finally { + $this->assertTrue($exceptionCaught); + } + } + public function testEditPayer() { $this->newCustomer->key = 'payer-123'; @@ -131,6 +180,38 @@ public function testEditPayer() $this->assertEquals($this->card->token, reset($payer->paymentMethods)->id); } + public function testEditPayer_WithoutCustomerId() + { + $this->newCustomer->key = 'payer-123'; + + $exceptionCaught = false; + try { + $this->newCustomer->saveChanges(); + } catch (GatewayException $e) { + $exceptionCaught = true; + $this->assertEquals('Status Code: SYSTEM_ERROR_DOWNSTREAM - Unable to process your request due to an error with a system down stream.', $e->getMessage()); + $this->assertEquals('50046', $e->responseCode); + } finally { + $this->assertTrue($exceptionCaught); + } + } + + public function testEditPayer_RandomCustomerId() + { + $this->newCustomer->id = 'PYR_' . GenerationUtils::getGuid(); + + $exceptionCaught = false; + try { + $this->newCustomer->saveChanges(); + } catch (GatewayException $e) { + $exceptionCaught = true; + $this->assertEquals('Status Code: RESOURCE_NOT_FOUND - Payer ' . $this->newCustomer->id . ' not found at this location', $e->getMessage()); + $this->assertEquals('40008', $e->responseCode); + } finally { + $this->assertTrue($exceptionCaught); + } + } + public function testCardTokenization() { $payer = $this->newCustomer->create(); diff --git a/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php index 3e592797..1f974ea3 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php @@ -301,7 +301,7 @@ public function testReportFindTransactionsBy_AllStatuses() public function testReportFindTransactionsByCardBrandAndAuthCode() { $cardBrand = 'VISA'; - $authCode = '12345'; + $authCode = '123456'; try { $response = ReportingService::findTransactionsPaged(1, 10) ->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC) diff --git a/test/Integration/Gateways/GpEcomConnector/HppTest.php b/test/Integration/Gateways/GpEcomConnector/HppTest.php index 77917700..62d4622c 100644 --- a/test/Integration/Gateways/GpEcomConnector/HppTest.php +++ b/test/Integration/Gateways/GpEcomConnector/HppTest.php @@ -867,6 +867,7 @@ public function testCaptureBillingShippingInfo() $hostedPaymentData = new HostedPaymentData(); $hostedPaymentData->addressCapture = true; $hostedPaymentData->notReturnAddress = false; + $hostedPaymentData->removeShipping = true; $json = $service->charge(19) ->withCurrency($this->currency) @@ -877,6 +878,7 @@ public function testCaptureBillingShippingInfo() $response = json_decode($json, true); $this->assertTrue($response['HPP_CAPTURE_ADDRESS']); $this->assertFalse($response['HPP_DO_NOT_RETURN_ADDRESS']); + $this->assertTrue($response['HPP_REMOVE_SHIPPING']); } public function testOpenBankingInitiate() diff --git a/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php b/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php index bea63015..330940ae 100644 --- a/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php +++ b/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php @@ -100,28 +100,6 @@ protected function getConfig(): GpEcomConfig return $config; } - public function testFullCycle_v1() - { - $card = new CreditCardData(); - $card->number = 4012001037141112; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $errorFound = false; - try { - Secure3dService::checkEnrollment($card) - ->withAmount(10.01) - ->withCurrency('USD') - ->execute('default', Secure3dVersion::ONE); - } catch (BuilderException $e) { - $errorFound = true; - $this->assertEquals('3D Secure ONE is no longer supported!', $e->getMessage()); - } finally { - $this->assertTrue($errorFound); - } - } - public function testFullCycle_v2() { $secureEcom = Secure3dService::checkEnrollment($this->card) @@ -962,24 +940,4 @@ public function testOptionalMobileFields() $this->assertEquals('00', $response->responseCode); } - public function testCheckVersion_Not_Enrolled() - { - $card = new CreditCardData(); - $card->number = 4917000000000087; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - - $errorFound = false; - try { - Secure3dService::checkEnrollment($card) - ->withAmount(10.01) - ->withCurrency('USD') - ->execute('default', Secure3dVersion::ONE); - } catch (BuilderException $e) { - $errorFound = true; - $this->assertEquals('3D Secure ONE is no longer supported!', $e->getMessage()); - } finally { - $this->assertTrue($errorFound); - } - } } diff --git a/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php b/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php index 3b0c88b8..2e165a5c 100644 --- a/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php +++ b/test/Integration/Gateways/Terminals/PAX/PaxCreditTests.php @@ -401,4 +401,30 @@ public function testCardBrandStorageInfo() : void $this->assertNotNull($cofSaleResponse); $this->assertEquals('00', $cofSaleResponse->responseCode); } + + /** + * This test demonstrates SDK can correctly parse a "partial auth" response + * + * @return void + * @throws InvalidArgumentException + * @throws ExpectationFailedException + */ + public function testPartialAuthHandling() : void + { + /** + * The gateway's partial auth trans amount is $155.00, but there's + * currently a $5.24 surcharge configured on my test device + */ + $partialAuthAmount = 149.76; + + $response = $this->device->sale($partialAuthAmount) + ->withAllowDuplicates(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("PARTIAL APPROVAL", $response->responseText); + $this->assertEquals("10", $response->responseCode); + $this->assertEquals(55, $response->amountDue); + $this->assertEquals(100, $response->transactionAmount); + } }