diff --git a/CHANGELOG.md b/CHANGELOG.md index d7bb45af..09e2f043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,17 @@ # Changelog - ## Latest version #### Enhancements: +- HPP Exemption Optimization Service +- Update timestamp on the Logger + +## v4.0.0 (06/07/2022) +#### Enhancements: - GP-ECOM: Add payment scheduler - GP-ECOM/GP-API: Structure refacto - Upgrade to min PHP 7.1 +- GP-API: Add example with Google Pay ## v3.1.1 (05/17/2022) #### Enhancements: diff --git a/metadata.xml b/metadata.xml index 1fa918bc..01bb7198 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 4.0.0 + 4.0.1 \ No newline at end of file diff --git a/src/Entities/HostedPaymentData.php b/src/Entities/HostedPaymentData.php index 074dc4de..52a3bcdb 100644 --- a/src/Entities/HostedPaymentData.php +++ b/src/Entities/HostedPaymentData.php @@ -125,6 +125,9 @@ class HostedPaymentData /** @var BankPayment */ public $bankPayment; + /** @var boolean */ + public $enableExemptionOptimization; + /** * Instantiates a new `HostedPaymentData` object. * diff --git a/src/Gateways/GpEcomConnector.php b/src/Gateways/GpEcomConnector.php index 896eb943..feb13982 100644 --- a/src/Gateways/GpEcomConnector.php +++ b/src/Gateways/GpEcomConnector.php @@ -387,6 +387,7 @@ public function serializeRequest(AuthorizationBuilder $builder) $this->setSerializeData('HPP_CUSTOMER_PHONENUMBER_MOBILE', $hostedPaymentData->customerPhoneMobile); $this->setSerializeData('HPP_PHONE', $hostedPaymentData->customerPhoneMobile); $this->setSerializeData('HPP_CHALLENGE_REQUEST_INDICATOR', $hostedPaymentData->challengeRequest); + $this->setSerializeData('HPP_ENABLE_EXEMPTION_OPTIMIZATION', $hostedPaymentData->enableExemptionOptimization); if (isset($hostedPaymentData->addressesMatch)) { $this->setSerializeData('HPP_ADDRESS_MATCH_INDICATOR', $hostedPaymentData->addressesMatch ? 'TRUE' : 'FALSE'); } diff --git a/src/Utils/Logging/Logger.php b/src/Utils/Logging/Logger.php index d5067c7d..92785cb8 100644 --- a/src/Utils/Logging/Logger.php +++ b/src/Utils/Logging/Logger.php @@ -308,7 +308,7 @@ private function getTimestamp() { $originalTime = microtime(true); $micro = sprintf("%06d", ($originalTime - floor($originalTime)) * 1000000); - $date = new DateTime(date('Y-m-d H:i:s.' . $micro, $originalTime)); + $date = new DateTime(date('Y-m-d H:i:s.' . $micro, (int) $originalTime)); return $date->format($this->options['dateFormat']); } diff --git a/test/Integration/Gateways/GpEcomConnector/HppTest.php b/test/Integration/Gateways/GpEcomConnector/HppTest.php index 0735cf30..d3610fec 100644 --- a/test/Integration/Gateways/GpEcomConnector/HppTest.php +++ b/test/Integration/Gateways/GpEcomConnector/HppTest.php @@ -18,10 +18,10 @@ use GlobalPayments\Api\Entities\Enums\AddressType; use GlobalPayments\Api\Entities\Enums\FraudFilterMode; use GlobalPayments\Api\Entities\Enums\GatewayProvider; -//use GlobalPayments\Api\ServiceConfigs\Gateways\GpEcomConfig; use GlobalPayments\Api\ServiceConfigs\Gateways\GpEcomConfig; use GlobalPayments\Api\Tests\Integration\Gateways\GpEcomConnector\Hpp\GpEcomHppClient; use GlobalPayments\Api\Entities\Enums\RemittanceReferenceType; +use GlobalPayments\Api\Entities\Enums\ChallengeRequestIndicator; use PHPUnit\Framework\TestCase; class HppTest extends TestCase @@ -987,4 +987,36 @@ public function testOpenBankingInitiate() $parsedResponse = $service->parseResponse($response); $this->assertEquals(BankPaymentStatus::PAYMENT_INITIATED, $parsedResponse->responseMessage); } + + public function test3DSExemption() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "3dsecure"; + $config->sharedSecret = "secret"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response";; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + + $service = new HostedService($config); + + // data to be passed to the HPP along with transaction level settings + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->enableExemptionOptimization = true; + $hostedPaymentData->challengeRequest = ChallengeRequestIndicator::NO_CHALLENGE_REQUESTED; + + //serialize the request + $json = $service->charge(10.01) + ->withCurrency("EUR") + ->withAddress($this->billingAddress, AddressType::BILLING) + ->withAddress($this->shippingAddress, AddressType::SHIPPING) + ->withHostedPaymentData($hostedPaymentData) + ->serialize(); + $this->assertNotNull($json); + + $jsonResponse = json_decode($json, true); + $this->assertTrue(isset($jsonResponse['HPP_ENABLE_EXEMPTION_OPTIMIZATION'])); + $this->assertEquals(true, $jsonResponse['HPP_ENABLE_EXEMPTION_OPTIMIZATION']); + } }