diff --git a/CHANGELOG.md b/CHANGELOG.md index 46bd7522..85d8790a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ ## Latest Version #### Enhancements: +- [GP-ECOM] Support parseResponse for status_url on HostedService (HPP APMs) +- [GP-ECOM] Added "custnum" from Customer on "payer_new" request + +## v10.0.1 (08/29/2023) +#### Enhancements: - Enhance logs based on environment (GP-API & GP-ECOM) - Security vulnerabilities fixes - [GP-API] Add missing properties to authentication->three_ds (message_version, eci,server_trans_reference, diff --git a/examples/gp-ecom/hpp/get-json.php b/examples/gp-ecom/hpp/get-json.php index edfd5e3c..356af7bb 100644 --- a/examples/gp-ecom/hpp/get-json.php +++ b/examples/gp-ecom/hpp/get-json.php @@ -17,12 +17,18 @@ use GlobalPayments\Api\Services\HostedService; use GlobalPayments\Api\Entities\Enums\PhoneNumberType; use GlobalPayments\Api\Entities\Enums\HostedPaymentMethods; +use GlobalPayments\Api\Entities\Enums\AlternativePaymentType; // configure client, request and HPP settings $config = new GpEcomConfig(); +/* Credentials for OpenBanking HPP $config->merchantId = "openbankingsandbox"; $config->accountId = "internet"; $config->sharedSecret = "sharedsecret"; +*/ +$config->merchantId = "heartlandgpsandbox"; +$config->accountId = "hpp"; +$config->sharedSecret = "secret"; $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; $config->enableBankPayment = true; $config->hostedPaymentConfig = new HostedPaymentConfig(); @@ -42,12 +48,13 @@ $hostedPaymentData->notReturnAddress = filter_var($_REQUEST['notReturnAddress'], FILTER_VALIDATE_BOOLEAN); } -$hostedPaymentData->customerCountry = 'GB'; +$hostedPaymentData->customerCountry = 'DE'; $hostedPaymentData->customerFirstName = 'James'; $hostedPaymentData->customerLastName = 'Mason'; -$hostedPaymentData->transactionStatusUrl = $_SERVER['HTTP_REFERER'] . '/examples/hpp/response-endpoint.php'; -$hostedPaymentData->merchantResponseUrl = $_SERVER['HTTP_REFERER'] . '/examples/hpp/response-endpoint.php'; -$hostedPaymentData->presetPaymentMethods = [HostedPaymentMethods::CARDS, HostedPaymentMethods::OB]; +$baseUrl = 'https://ff6e-2a02-2f0e-5615-3300-b580-5acb-6bf-4b11.ngrok-free.app'; +$hostedPaymentData->transactionStatusUrl = "$baseUrl/examples/gp-ecom/hpp/status-endpoint.php"; +$hostedPaymentData->merchantResponseUrl = "$baseUrl/examples/gp-ecom/hpp/response-endpoint.php"; +$hostedPaymentData->presetPaymentMethods = [HostedPaymentMethods::CARDS, HostedPaymentMethods::OB, AlternativePaymentType::SOFORTUBERWEISUNG]; $billingAddress = new Address(); $billingAddress->streetAddress1 = "Flat 123"; @@ -75,7 +82,7 @@ try { $hppJson = $service->charge(19.99) - ->withCurrency("GBP") + ->withCurrency("EUR") ->withHostedPaymentData($hostedPaymentData) ->withAddress($billingAddress, AddressType::BILLING) ->withAddress($shippingAddress, AddressType::SHIPPING) diff --git a/examples/gp-ecom/hpp/response-endpoint.php b/examples/gp-ecom/hpp/response-endpoint.php index ef61ca63..96767bf3 100644 --- a/examples/gp-ecom/hpp/response-endpoint.php +++ b/examples/gp-ecom/hpp/response-endpoint.php @@ -1,4 +1,8 @@ merchantId = "openbankingsandbox"; $config->accountId = "internet"; $config->sharedSecret = "sharedsecret"; +*/ +$config->merchantId = "heartlandgpsandbox"; +$config->accountId = "hpp"; +$config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; $service = new HostedService($config); @@ -22,11 +32,17 @@ * '"CARD_PAYMENT_BUTTON":"Place Order","AVSADDRESSRESULT":"M","AVSPOSTCODERESULT":"M","BATCHID":"445196",' . * '"MESSAGE":"[ test system ] Authorised","PASREF":"15011597872195765","CVNRESULT":"M","HPP_FRAUDFILTER_RESULT":"PASS"}"; */ -$responseJson = isset($_POST['hppResponse']) ? $_POST['hppResponse'] : ""; +if (!isset($_REQUEST['hppResponse'])) { + $responseJson = json_encode($_REQUEST); + $encoded = false; +} else { + $responseJson = $_REQUEST['hppResponse']; + $encoded = true; +} try { // create the response object from the response JSON - $parsedResponse = $service->parseResponse($responseJson, true); + $parsedResponse = $service->parseResponse($responseJson, $encoded); $orderId = $parsedResponse->orderId; // GTI5Yxb0SumL_TkDMCAxQA $responseCode = $parsedResponse->responseCode; // 00 diff --git a/examples/gp-ecom/hpp/status-endpoint.php b/examples/gp-ecom/hpp/status-endpoint.php new file mode 100644 index 00000000..3934ae3d --- /dev/null +++ b/examples/gp-ecom/hpp/status-endpoint.php @@ -0,0 +1,46 @@ +merchantId = "heartlandgpsandbox"; +$config->accountId = "hpp"; +$config->sharedSecret = "secret"; +$config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + +$service = new HostedService($config); + +/* + * Response JSON comes from Global Payments + * sample response JSON (values will be Base64 encoded): + * $responseJson ='{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999",' . + * '"TIMESTAMP":"20170725154824","SHA1HASH":"843680654f377bfa845387fdbace35acc9d95778","RESULT":"00","AUTHCODE":"12345",' . + * '"CARD_PAYMENT_BUTTON":"Place Order","AVSADDRESSRESULT":"M","AVSPOSTCODERESULT":"M","BATCHID":"445196",' . + * '"MESSAGE":"[ test system ] Authorised","PASREF":"15011597872195765","CVNRESULT":"M","HPP_FRAUDFILTER_RESULT":"PASS"}"; + */ +$responseJson = json_encode($_REQUEST); + +try { + // create the response object from the response JSON + $parsedResponse = $service->parseResponse($responseJson); + + $orderId = $parsedResponse->orderId; // GTI5Yxb0SumL_TkDMCAxQA + $responseCode = $parsedResponse->responseCode; // 00 + $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised + $responseValues = $parsedResponse->responseValues; // get values accessible by key + echo "
"; + echo "Response Code : " . !empty($responseCode) ? $responseCode : ""; + echo "\n Response Message : " . !empty($responseMessage) ? $responseMessage : ""; + echo "\n Response Values : "; + if (!empty($responseValues)) + print_r($responseValues); +} catch (ApiException $e) { + print_r($e); + // For example if the SHA1HASH doesn't match what is expected + // TODO: add your error handling here +} diff --git a/metadata.xml b/metadata.xml index 2d95cea8..784bbb02 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@- \ No newline at end of file diff --git a/src/Builders/RequestBuilder/GpEcom/GpEcomRecurringRequestBuilder.php b/src/Builders/RequestBuilder/GpEcom/GpEcomRecurringRequestBuilder.php index a8469344..93f738fb 100644 --- a/src/Builders/RequestBuilder/GpEcom/GpEcomRecurringRequestBuilder.php +++ b/src/Builders/RequestBuilder/GpEcom/GpEcomRecurringRequestBuilder.php @@ -276,7 +276,6 @@ private function buildCustomer($xml, $builder) $payer->appendChild($xml->createElement("surname", $customer->lastName ?? '')); $payer->appendChild($xml->createElement("company", $customer->company ?? '')); - if ($customer->address != null) { $address = $xml->createElement("address"); $address->appendChild($xml->createElement("line1", $customer->address->streetAddress1 ?? '')); @@ -303,6 +302,7 @@ private function buildCustomer($xml, $builder) $payer->appendChild($phonenumbers); $payer->appendChild($xml->createElement("email", $customer->email ?? '')); + $payer->appendChild($xml->createElement("custnum", $customer->id ?? '')); return $payer; } diff --git a/src/Services/HostedService.php b/src/Services/HostedService.php index 465549ec..82ee1d75 100644 --- a/src/Services/HostedService.php +++ b/src/Services/HostedService.php @@ -4,6 +4,7 @@ use GlobalPayments\Api\Builders\AuthorizationBuilder; use GlobalPayments\Api\Builders\ManagementBuilder; +use GlobalPayments\Api\Entities\AlternativePaymentResponse; use GlobalPayments\Api\Entities\Enums\PaymentMethodType; use GlobalPayments\Api\Entities\Enums\ShaHashType; use GlobalPayments\Api\Entities\Enums\TransactionType; @@ -13,7 +14,6 @@ use GlobalPayments\Api\Utils\GenerationUtils; use GlobalPayments\Api\Entities\Exceptions\ApiException; use GlobalPayments\Api\Entities\Transaction; -use GlobalPayments\Api\ServiceConfigs\ServicesConfig; class HostedService { @@ -95,12 +95,35 @@ public function void($transaction = null) ->withPaymentMethod($transaction); } + private function mapTransactionStatusResponse($response) : array + { + return [ + 'ACCOUNT_HOLDER_NAME' => $response['accountholdername'], + 'ACCOUNT_NUMBER' => $response['accountnumber'], + 'TIMESTAMP' => $response['timestamp'], + 'MERCHANT_ID' => $response['merchantid'], + 'BANK_CODE' => $response['bankcode'], + 'BANK_NAME' => $response['bankname'], + 'HPP_CUSTOMER_BIC' => $response['bic'], + 'COUNTRY' => $response['country'], + 'HPP_CUSTOMER_EMAIL' => $response['customeremail'], + 'TRANSACTION_STATUS' => $response['fundsstatus'], + 'IBAN' => $response['iban'], + 'MESSAGE' => $response['message'], + 'ORDER_ID' => $response['orderid'], + 'PASREF' => $response['pasref'], + 'PAYMENTMETHOD' => $response['paymentmethod'], + 'PAYMENT_PURPOSE' => $response['paymentpurpose'], + 'RESULT' => $response['result'], + $this->shaHashType . "HASH" => $response[strtolower($this->shaHashType).'hash'] + ]; + } + public function parseResponse($response, $encoded = false) { if (empty($response)) { throw new ApiException("Enable to parse : empty response"); } - $response = json_decode($response, true); if ($encoded) { @@ -114,17 +137,24 @@ public function parseResponse($response, $encoded = false) $response = $iterator->getArrayCopy(); } + if (!isset($response['MERCHANT_RESPONSE_URL'])) { + $response = $this->mapTransactionStatusResponse($response); + } + $timestamp = $response["TIMESTAMP"]; $merchantId = $response["MERCHANT_ID"]; $orderId = $response["ORDER_ID"]; $result = $response["RESULT"]; $message = $response["MESSAGE"]; $transactionId = $response["PASREF"]; - $authCode = $response["AUTHCODE"]; + $authCode = $response["AUTHCODE"] ?? ""; + $paymentMethod = $response["PAYMENTMETHOD"] ?? ""; + if (empty($response[$this->shaHashType . "HASH"])) { throw new ApiException("SHA hash is missing. Please check your code and the Developers Documentation."); } $shaHash = $response[$this->shaHashType . "HASH"]; + $hash = GenerationUtils::generateNewHash( $this->sharedSecret, implode('.', [ @@ -134,7 +164,7 @@ public function parseResponse($response, $encoded = false) $result, $message, $transactionId, - $authCode + !isset($response['MERCHANT_RESPONSE_URL']) ? $paymentMethod :$authCode ]), $this->shaHashType ); @@ -146,20 +176,27 @@ public function parseResponse($response, $encoded = false) $ref = new TransactionReference(); $ref->authCode = $authCode; $ref->orderId = $orderId; - $ref->paymentMethodType = PaymentMethodType::CREDIT; + $ref->paymentMethodType = !empty($response['PAYMENTMETHOD']) ? PaymentMethodType::APM : PaymentMethodType::CREDIT; $ref->transactionId = $transactionId; $trans = new Transaction(); - if (isset($response["AMOUNT"])) { - $trans->authorizedAmount = $response["AMOUNT"]; - } + $trans->authorizedAmount = $response["AMOUNT"] ?? null; - $trans->cvnResponseCode = $response["CVNRESULT"]; + $trans->cvnResponseCode = $response["CVNRESULT"] ?? null; $trans->responseCode = $result; $trans->responseMessage = $message; - $trans->avsResponseCode = $response["AVSPOSTCODERESULT"]; + $trans->avsResponseCode = $response["AVSPOSTCODERESULT"] ?? null; $trans->transactionReference = $ref; + if (!empty($response['PAYMENTMETHOD'])) { + $apm = new AlternativePaymentResponse(); + $apm->country = $response['COUNTRY'] ?? ''; + $apm->providerName = $response['PAYMENTMETHOD']; + $apm->paymentStatus = $response['TRANSACTION_STATUS'] ?? null; + $apm->reasonCode = $response['PAYMENT_PURPOSE'] ?? null; + $apm->accountHolderName = $response['ACCOUNT_HOLDER_NAME'] ?? null; + $trans->alternativePaymentResponse = $apm; + } $trans->responseValues = $response; diff --git a/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php b/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php index c2789ab4..512c7418 100644 --- a/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php +++ b/test/Integration/Gateways/GpApiConnector/AccessTokenTest.php @@ -221,7 +221,7 @@ public function testUseOnlyAccessToken() $this->assertEquals('VERIFIED', $response->responseMessage); } - private function assertAccessTokenResponse(AccessTokenInfo $accessTokenInfo) + private function assertAccessTokenResponse(AccessTokenInfo $accessTokenInfo): void { $this->assertNotNull($accessTokenInfo); $this->assertNotNull($accessTokenInfo->accessToken); @@ -237,7 +237,7 @@ private function assertAccessTokenResponse(AccessTokenInfo $accessTokenInfo) $this->assertNotNull($accessTokenInfo->dataAccountID); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { $this->config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); diff --git a/test/Integration/Gateways/GpApiConnector/Certifications/CapabilitiesCardPresentTest.php b/test/Integration/Gateways/GpApiConnector/Certifications/CapabilitiesCardPresentTest.php index 5a689e35..fc5b3ce2 100644 --- a/test/Integration/Gateways/GpApiConnector/Certifications/CapabilitiesCardPresentTest.php +++ b/test/Integration/Gateways/GpApiConnector/Certifications/CapabilitiesCardPresentTest.php @@ -1,6 +1,6 @@ value = ';4024720012345671=18125025432198712345?'; + $debitCard->value = ';4024720012345671=30125025432198712345?'; $debitCard->pinBlock = 'AFEC374574FC90623D010000116001EE'; $debitCard->entryMethod = EntryMethod::SWIPE; $response = $debitCard->charge(100) diff --git a/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php b/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php index 1de73342..89fb73db 100644 --- a/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php +++ b/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php @@ -2,6 +2,7 @@ namespace Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\EmvLastChipRead; use GlobalPayments\Api\Entities\Enums\EntryMethod; @@ -167,7 +168,7 @@ public function testReauthAReversedAuthorizedTransaction() public function testReauthorizedAnExistingTransaction() { - $startDate = (new \DateTime())->modify('-29 days')->setTime(0, 0, 0); + $startDate = (new DateTime())->modify('-29 days')->setTime(0, 0, 0); $response = ReportingService::findTransactionsPaged(1, 1) ->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::ASC) @@ -747,7 +748,7 @@ public function testIncrementalAuth_TransactionNotFound() } } - private function initCreditCardData() + private function initCreditCardData(): CreditCardData { $card = new CreditCardData(); $card->number = "5425230000004415"; @@ -760,7 +761,7 @@ private function initCreditCardData() return $card; } - private function initCreditTrackData($entryMethod = EntryMethod::SWIPE) + private function initCreditTrackData($entryMethod = EntryMethod::SWIPE): CreditTrackData { $card = new CreditTrackData(); $card->setTrackData('%B4012002000060016^VI TEST CREDIT^251210118039000000000396?;4012002000060016=25121011803939600000?'); @@ -769,7 +770,7 @@ private function initCreditTrackData($entryMethod = EntryMethod::SWIPE) return $card; } - private function assertTransactionResponse($transaction, $transactionResponseCode, $transactionStatus) + private function assertTransactionResponse($transaction, $transactionResponseCode, $transactionStatus): void { $this->assertNotNull($transaction); $this->assertEquals($transactionResponseCode, $transaction->responseCode); diff --git a/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php b/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php index 12c759c4..91f66fca 100644 --- a/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php +++ b/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php @@ -316,7 +316,7 @@ public function testCreditGetDccInfo_WithoutCurrency() } } - private function assertDccInfoResponse($dccDetails, $expectedDccValue) + private function assertDccInfoResponse($dccDetails, $expectedDccValue): void { $this->assertNotNull($dccDetails); $this->assertEquals('SUCCESS', $dccDetails->responseCode); @@ -325,7 +325,7 @@ private function assertDccInfoResponse($dccDetails, $expectedDccValue) $this->assertEquals($expectedDccValue, $dccDetails->dccRateData->cardHolderAmount); } - private function assertTransactionResponse($transaction, $transactionStatus, $expectedDccValue) + private function assertTransactionResponse($transaction, $transactionStatus, $expectedDccValue): void { $this->assertNotNull($transaction); $this->assertEquals('SUCCESS', $transaction->responseCode); @@ -335,7 +335,7 @@ private function assertTransactionResponse($transaction, $transactionStatus, $ex } } - private function getAmount($dccDetails) + private function getAmount($dccDetails): float { return round($this->amount * $dccDetails->dccRateData->cardHolderRate, 2); } diff --git a/test/Integration/Gateways/GpApiConnector/DccCardPresentTest.php b/test/Integration/Gateways/GpApiConnector/DccCardPresentTest.php index 047e8281..75a3542b 100644 --- a/test/Integration/Gateways/GpApiConnector/DccCardPresentTest.php +++ b/test/Integration/Gateways/GpApiConnector/DccCardPresentTest.php @@ -7,9 +7,11 @@ use GlobalPayments\Api\Entities\Enums\TransactionStatus; use GlobalPayments\Api\Entities\Exceptions\GatewayException; use GlobalPayments\Api\Entities\GpApi\AccessTokenInfo; +use GlobalPayments\Api\Entities\Transaction; use GlobalPayments\Api\PaymentMethods\CreditCardData; use GlobalPayments\Api\PaymentMethods\CreditTrackData; use GlobalPayments\Api\PaymentMethods\DebitTrackData; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\GpApiService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -20,10 +22,10 @@ class DccCardPresentTest extends TestCase { - private $currency = 'EUR'; - private $amount = 15.11; + private string $currency = 'EUR'; + private float $amount = 15.11; /** @var CreditCardData */ - private $card; + private CreditCardData $card; const DCC_RATE_CONFIG = 'dcc_rate'; public function setup(): void @@ -50,7 +52,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { $config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardPresent); $accessTokenInfo = new AccessTokenInfo(); @@ -59,7 +61,7 @@ public function setUpConfig() return $config; } - public function setUpConfigDcc() + public function setUpConfigDcc(): GpApiConfig { $config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardPresent); $accessTokenInfo = new AccessTokenInfo(); @@ -69,7 +71,7 @@ public function setUpConfigDcc() return $config; } - private function getDccDetails() + private function getDccDetails(): Transaction { return $this->card->getDccRate() ->withAmount($this->amount) diff --git a/test/Integration/Gateways/GpApiConnector/DebitCardTest.php b/test/Integration/Gateways/GpApiConnector/DebitCardTest.php index 882ddb94..d52bb9a4 100644 --- a/test/Integration/Gateways/GpApiConnector/DebitCardTest.php +++ b/test/Integration/Gateways/GpApiConnector/DebitCardTest.php @@ -7,6 +7,7 @@ use GlobalPayments\Api\Entities\Enums\EntryMethod; use GlobalPayments\Api\Entities\Enums\TransactionStatus; use GlobalPayments\Api\PaymentMethods\DebitTrackData; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\BatchService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -161,7 +162,7 @@ public function testBatchClose_DebitTrackData() $this->assertGreaterThanOrEqual(1, $batch->batchSummary->transactionCount); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardPresent); } diff --git a/test/Integration/Gateways/GpApiConnector/EbtCardTest.php b/test/Integration/Gateways/GpApiConnector/EbtCardTest.php index 51b344a6..b9bdf46a 100644 --- a/test/Integration/Gateways/GpApiConnector/EbtCardTest.php +++ b/test/Integration/Gateways/GpApiConnector/EbtCardTest.php @@ -4,6 +4,9 @@ use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\TransactionStatus; +use GlobalPayments\Api\PaymentMethods\EBTCardData; +use GlobalPayments\Api\PaymentMethods\EBTTrackData; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; use GlobalPayments\Api\Tests\Data\TestCards; @@ -11,12 +14,12 @@ class EbtCardTest extends TestCase { - private $card; + private EBTCardData $card; - private $track; + private EBTTrackData $track; - private $amount = 10; - private $currency = 'USD'; + private int $amount = 10; + private string $currency = 'USD'; public function setup(): void { @@ -30,7 +33,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardPresent); } @@ -137,7 +140,7 @@ public function testEbtTransaction_Reverse_TrackData() $this->assertEbtTransactionResponse($response, TransactionStatus::REVERSED); } - private function assertEbtTransactionResponse($transactionResponse, $transactionStatus) + private function assertEbtTransactionResponse($transactionResponse, $transactionStatus): void { $this->assertNotNull($transactionResponse); $this->assertEquals('SUCCESS', $transactionResponse->responseCode); diff --git a/test/Integration/Gateways/GpApiConnector/FraudManagementTest.php b/test/Integration/Gateways/GpApiConnector/FraudManagementTest.php index c5543c85..bb7ea4b5 100644 --- a/test/Integration/Gateways/GpApiConnector/FraudManagementTest.php +++ b/test/Integration/Gateways/GpApiConnector/FraudManagementTest.php @@ -2,9 +2,9 @@ namespace Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Address; use GlobalPayments\Api\Entities\Enums\Channel; -use GlobalPayments\Api\Entities\Enums\Environment; use GlobalPayments\Api\Entities\Enums\FraudFilterMode; use GlobalPayments\Api\Entities\Enums\FraudFilterResult; use GlobalPayments\Api\Entities\Enums\ReasonCode; @@ -13,7 +13,6 @@ use GlobalPayments\Api\Entities\Exceptions\ApiException; use GlobalPayments\Api\Entities\Exceptions\GatewayException; use GlobalPayments\Api\Entities\FraudRuleCollection; -use GlobalPayments\Api\Entities\GpApi\AccessTokenInfo; use GlobalPayments\Api\Entities\GpApi\PagedResult; use GlobalPayments\Api\Entities\Reporting\SearchCriteria; use GlobalPayments\Api\Entities\Reporting\TransactionSummary; @@ -31,11 +30,11 @@ class FraudManagementTest extends TestCase { /** @var CreditCardData */ - private $card; + private CreditCardData $card; /** @var Address $address */ - private $address; + private Address $address; /** @var string */ - private $currency = 'USD'; + private string $currency = 'USD'; public function setup(): void { @@ -60,7 +59,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - private function setUpConfig() + private function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } @@ -720,8 +719,8 @@ public function testHold_InvalidReason() public function testGetTransactionWithFraudCheck() { - $startDate = (new \DateTime())->modify('-30 days'); - $endDate = (new \DateTime())->modify('-3 days'); + $startDate = (new DateTime())->modify('-30 days'); + $endDate = (new DateTime())->modify('-3 days'); /** @var PagedResult $response */ $response = ReportingService::findTransactionsPaged(1, 10) diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php b/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php index 5aa56c85..f9e1324e 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php +++ b/test/Integration/Gateways/GpApiConnector/GpApi3DS1Test.php @@ -4,8 +4,8 @@ use GlobalPayments\Api\Entities\Enums\ChallengeRequestIndicator; use GlobalPayments\Api\Entities\Enums\Channel; +use GlobalPayments\Api\Entities\Enums\GatewayProvider; use GlobalPayments\Api\Entities\Enums\Secure3dStatus; -use GlobalPayments\Api\Entities\Enums\Secure3dVersion; use GlobalPayments\Api\Entities\Enums\StoredCredentialInitiator; use GlobalPayments\Api\Entities\Enums\StoredCredentialReason; use GlobalPayments\Api\Entities\Enums\StoredCredentialSequence; @@ -14,11 +14,11 @@ use GlobalPayments\Api\Entities\StoredCredential; use GlobalPayments\Api\Entities\ThreeDSecure; use GlobalPayments\Api\PaymentMethods\CreditCardData; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\Secure3dService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; use GlobalPayments\Api\Tests\Data\GpApi3DSTestCards; -use GlobalPayments\Api\Tests\Integration\Gateways\ThreeDSecureAcsClient; use GlobalPayments\Api\Utils\GenerationUtils; use PHPUnit\Framework\TestCase; use ReflectionClass; @@ -28,20 +28,20 @@ class GpApi3DS1Test extends TestCase /** * @var string */ - private $gatewayProvider; + private string|GatewayProvider $gatewayProvider; /** * @var string */ - private $currency; + private string $currency; - /** @var string|float */ - private $amount; + /** @var float */ + private float $amount; /** * @var CreditCardData */ - private $card; + private CreditCardData $card; public function setup(): void { @@ -63,7 +63,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } @@ -267,7 +267,7 @@ public function testCardHolderNotEnrolled_PostResult() } } - private function assertCheckEnrollmentCardNotEnrolledV1(ThreeDSecure $secureEcom) + private function assertCheckEnrollmentCardNotEnrolledV1(ThreeDSecure $secureEcom): void { $this->assertNotNull($secureEcom); $this->assertEquals(Secure3dStatus::NOT_ENROLLED, $secureEcom->enrolled); diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php b/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php index d610d2d2..2d011b64 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php +++ b/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php @@ -11,6 +11,7 @@ use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\ColorDepth; use GlobalPayments\Api\Entities\Enums\DeliveryTimeFrame; +use GlobalPayments\Api\Entities\Enums\GatewayProvider; use GlobalPayments\Api\Entities\Enums\MethodUrlCompletion; use GlobalPayments\Api\Entities\Enums\SdkInterface; use GlobalPayments\Api\Entities\Enums\SdkUiType; @@ -23,9 +24,11 @@ use GlobalPayments\Api\Entities\Enums\StoredCredentialType; use GlobalPayments\Api\Entities\Enums\TransactionStatus; use GlobalPayments\Api\Entities\Exceptions\ApiException; +use GlobalPayments\Api\Entities\MobileData; use GlobalPayments\Api\Entities\StoredCredential; use GlobalPayments\Api\Entities\ThreeDSecure; use GlobalPayments\Api\PaymentMethods\CreditCardData; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\Secure3dService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -40,30 +43,30 @@ class GpApi3DS2Test extends TestCase /** * @var Address */ - private $shippingAddress; + private Address $shippingAddress; /** * @var BrowserData */ - private $browserData; + private BrowserData $browserData; /** - * @var string + * @var string|GatewayProvider */ - private $gatewayProvider; + private string|GatewayProvider $gatewayProvider; /** * @var string */ - private $currency; + private string $currency; /** @var string|float */ - private $amount; + private string|float $amount; /** * @var CreditCardData */ - private $card; + private CreditCardData $card; public function setup(): void { @@ -107,7 +110,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } @@ -1127,7 +1130,7 @@ public function testChallengeRequired_v2_Initiate_MobileSDK() ->execute(); $this->assertCheckEnrollment3DSV2($secureEcom); - $mobileData = new \GlobalPayments\Api\Entities\MobileData(); + $mobileData = new MobileData(); $mobileData->encodedData = 'ew0KCSJEViI6ICIxLjAiLA0KCSJERCI6IHsNCgkJIkMwMDEiOiAiQW5kcm9pZCIsDQoJCSJDMDAyIjogIkhUQyBPbmVfTTgiLA0KCQkiQzAwNCI6ICI1LjAuMSIsDQoJCSJDMDA1IjogImVuX1VTIiwNCgkJIkMwMDYiOiAiRWFzdGVybiBTdGFuZGFyZCBUaW1lIiwNCgkJIkMwMDciOiAiMDY3OTc5MDMtZmI2MS00MWVkLTk0YzItNGQyYjc0ZTI3ZDE4IiwNCgkJIkMwMDkiOiAiSm9obidzIEFuZHJvaWQgRGV2aWNlIg0KCX0sDQoJIkRQTkEiOiB7DQoJCSJDMDEwIjogIlJFMDEiLA0KCQkiQzAxMSI6ICJSRTAzIg0KCX0sDQoJIlNXIjogWyJTVzAxIiwgIlNXMDQiXQ0KfQ0K'; $mobileData->applicationReference = 'f283b3ec-27da-42a1-acea-f3f70e75bbdc'; $mobileData->sdkInterface = SdkInterface::BROWSER; @@ -1165,7 +1168,7 @@ public function testChallengeRequired_v2_Initiate_MobileDataAndBrowserData() ->execute(); $this->assertCheckEnrollment3DSV2($secureEcom); - $mobileData = new \GlobalPayments\Api\Entities\MobileData(); + $mobileData = new MobileData(); $mobileData->encodedData = 'ew0KCSJEViI6ICIxLjAiLA0KCSJERCI6IHsNCgkJIkMwMDEiOiAiQW5kcm9pZCIsDQoJCSJDMDAyIjogIkhUQyBPbmVfTTgiLA0KCQkiQzAwNCI6ICI1LjAuMSIsDQoJCSJDMDA1IjogImVuX1VTIiwNCgkJIkMwMDYiOiAiRWFzdGVybiBTdGFuZGFyZCBUaW1lIiwNCgkJIkMwMDciOiAiMDY3OTc5MDMtZmI2MS00MWVkLTk0YzItNGQyYjc0ZTI3ZDE4IiwNCgkJIkMwMDkiOiAiSm9obidzIEFuZHJvaWQgRGV2aWNlIg0KCX0sDQoJIkRQTkEiOiB7DQoJCSJDMDEwIjogIlJFMDEiLA0KCQkiQzAxMSI6ICJSRTAzIg0KCX0sDQoJIlNXIjogWyJTVzAxIiwgIlNXMDQiXQ0KfQ0K'; $mobileData->applicationReference = 'f283b3ec-27da-42a1-acea-f3f70e75bbdc'; $mobileData->sdkInterface = SdkInterface::BROWSER; @@ -1202,7 +1205,7 @@ public function testChallengeRequired_v2_Initiate_With_MobileData_AndSourceBrows ->execute(); $this->assertCheckEnrollment3DSV2($secureEcom); - $mobileData = new \GlobalPayments\Api\Entities\MobileData(); + $mobileData = new MobileData(); $mobileData->encodedData = 'ew0KCSJEViI6ICIxLjAiLA0KCSJERCI6IHsNCgkJIkMwMDEiOiAiQW5kcm9pZCIsDQoJCSJDMDAyIjogIkhUQyBPbmVfTTgiLA0KCQkiQzAwNCI6ICI1LjAuMSIsDQoJCSJDMDA1IjogImVuX1VTIiwNCgkJIkMwMDYiOiAiRWFzdGVybiBTdGFuZGFyZCBUaW1lIiwNCgkJIkMwMDciOiAiMDY3OTc5MDMtZmI2MS00MWVkLTk0YzItNGQyYjc0ZTI3ZDE4IiwNCgkJIkMwMDkiOiAiSm9obidzIEFuZHJvaWQgRGV2aWNlIg0KCX0sDQoJIkRQTkEiOiB7DQoJCSJDMDEwIjogIlJFMDEiLA0KCQkiQzAxMSI6ICJSRTAzIg0KCX0sDQoJIlNXIjogWyJTVzAxIiwgIlNXMDQiXQ0KfQ0K'; $mobileData->applicationReference = 'f283b3ec-27da-42a1-acea-f3f70e75bbdc'; $mobileData->sdkInterface = SdkInterface::BROWSER; @@ -1263,7 +1266,7 @@ public function testChallengeRequired_v2_Initiate_With_SourceMobileSdk_WithoutMo } } - private function assertCheckEnrollment3DSV2(ThreeDSecure $secureEcom) + private function assertCheckEnrollment3DSV2(ThreeDSecure $secureEcom): void { $this->assertNotNull($secureEcom); $this->assertEquals(Secure3dStatus::ENROLLED, $secureEcom->enrolled); @@ -1274,7 +1277,7 @@ private function assertCheckEnrollment3DSV2(ThreeDSecure $secureEcom) $this->assertEmpty($secureEcom->eci); } - private function assertInitiate3DSV2(ThreeDSecure $initAuth) + private function assertInitiate3DSV2(ThreeDSecure $initAuth): void { $this->assertNotNull($initAuth); $this->assertEquals(Secure3dStatus::CHALLENGE_REQUIRED, $initAuth->status); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php b/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php index 57c9c1a6..13b9545f 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php @@ -2,6 +2,7 @@ namespace Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Address; use GlobalPayments\Api\Entities\Customer; use GlobalPayments\Api\Entities\Enums\AccountType; @@ -15,12 +16,13 @@ use GlobalPayments\Api\Entities\Enums\TransactionSortProperty; use GlobalPayments\Api\Entities\Enums\TransactionStatus; use GlobalPayments\Api\Entities\Exceptions\ApiException; -use GlobalPayments\Api\Entities\FundsData; use GlobalPayments\Api\Entities\PhoneNumber; use GlobalPayments\Api\Entities\Reporting\DataServiceCriteria; use GlobalPayments\Api\Entities\Reporting\SearchCriteria; +use GlobalPayments\Api\Entities\Reporting\TransactionSummary; use GlobalPayments\Api\Entities\Transaction; use GlobalPayments\Api\PaymentMethods\ECheck; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -28,11 +30,11 @@ class GpApiAchTest extends TestCase { - private $eCheck; + private ECheck $eCheck; - private $address; + private Address $address; - private $customer; + private Customer $customer; public function setup(): void { @@ -80,7 +82,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } @@ -148,8 +150,8 @@ public function testCheckReauthorize() $this->eCheck->secCode = SecCode::PPD; $this->eCheck->accountNumber = '051904524'; $this->eCheck->routingNumber = '123456780'; - $startDate = (new \DateTime())->modify('-1 year'); - $endDate = (new \DateTime())->modify('-2 days'); + $startDate = (new DateTime())->modify('-1 year'); + $endDate = (new DateTime())->modify('-2 days'); $amount = '1.29'; $response = ReportingService::findTransactionsPaged(1, 10) ->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC) @@ -163,7 +165,7 @@ public function testCheckReauthorize() $this->assertNotNull($response); if (count($response->result) > 0) { $this->assertNotEmpty($response->result); - /** @var \GlobalPayments\Api\Entities\Reporting\TransactionSummary $transactionSummary */ + /** @var TransactionSummary $transactionSummary */ $transactionSummary = reset($response->result); $this->assertNotNull($transactionSummary); $this->assertEquals($amount, $transactionSummary->amount); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiApmTest.php b/test/Integration/Gateways/GpApiConnector/GpApiApmTest.php index e30b9eb3..43ef5960 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiApmTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiApmTest.php @@ -2,6 +2,7 @@ namespace Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Address; use GlobalPayments\Api\Entities\AlternativePaymentResponse; use GlobalPayments\Api\Entities\Enums\AddressType; @@ -15,6 +16,7 @@ use GlobalPayments\Api\Entities\Reporting\TransactionSummary; use GlobalPayments\Api\Entities\Transaction; use GlobalPayments\Api\PaymentMethods\AlternativePaymentMethod; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -22,9 +24,9 @@ class GpApiApmTest extends TestCase { - private $paymentMethod; - private $currency; - private $shippingAddress; + private AlternativePaymentMethod $paymentMethod; + private string $currency; + private Address $shippingAddress; public function setup(): void { @@ -52,7 +54,7 @@ public function setup(): void $this->shippingAddress->countryCode = 'US'; } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } @@ -64,8 +66,8 @@ public static function tearDownAfterClass(): void /** * How to have a success running test. When you will run the test in the console it will be printed the - * paypal redirect url. You need to copy the link and open it in a browser, do the login wih your paypal - * credentials and authorize the payment in the paypal form. You will be redirected to a blank page with a + * PayPal redirect url. You need to copy the link and open it in a browser, do the login wih your PayPal + * credentials and authorize the payment in the PayPal form. You will be redirected to a blank page with a * printed message like this: { "success": true }. This has to be done within a 25 seconds timeframe. * In case you need more time update the sleep() to what you need. */ @@ -84,7 +86,7 @@ public function testPayPalCharge_fullCycle() fwrite(STDERR, print_r($response->alternativePaymentResponse->redirectUrl, TRUE)); sleep(25); - $startDate = new \DateTime(); + $startDate = new DateTime(); $response = ReportingService::findTransactionsPaged(1, 1) ->withTransactionId($response->transactionId) ->where(SearchCriteria::START_DATE, $startDate) @@ -93,7 +95,7 @@ public function testPayPalCharge_fullCycle() $this->assertNotNull($response); $this->assertNotEmpty($response->result); - /** @var \GlobalPayments\Api\Entities\Reporting\TransactionSummary $transactionSummary */ + /** @var TransactionSummary $transactionSummary */ $transactionSummary = reset($response->result); $this->assertTrue($transactionSummary->alternativePaymentResponse instanceof AlternativePaymentResponse); $this->assertEquals(AlternativePaymentType::PAYPAL, $transactionSummary->alternativePaymentResponse->providerName); @@ -124,7 +126,7 @@ public function testPayPalCapture_fullCycle() fwrite(STDERR, print_r($response->alternativePaymentResponse->redirectUrl, TRUE)); sleep(25); - $startDate = new \DateTime(); + $startDate = new DateTime(); $response = ReportingService::findTransactionsPaged(1, 1) ->withTransactionId($response->transactionId) ->where(SearchCriteria::START_DATE, $startDate) @@ -133,7 +135,7 @@ public function testPayPalCapture_fullCycle() $this->assertNotNull($response); $this->assertNotEmpty($response->result); - /** @var \GlobalPayments\Api\Entities\Reporting\TransactionSummary $transactionSummary */ + /** @var TransactionSummary $transactionSummary */ $transactionSummary = reset($response->result); $this->assertNotEmpty($transactionSummary->transactionId); $this->assertNotNull($transactionSummary->transactionId); @@ -172,7 +174,7 @@ public function testPayPalFullCycle_Refund() fwrite(STDERR, print_r($trn->alternativePaymentResponse->redirectUrl, TRUE)); sleep(25); - $startDate = new \DateTime(); + $startDate = new DateTime(); $response = ReportingService::findTransactionsPaged(1, 1) ->withTransactionId($trn->transactionId) ->where(SearchCriteria::START_DATE, $startDate) @@ -181,7 +183,7 @@ public function testPayPalFullCycle_Refund() $this->assertNotNull($response); $this->assertNotEmpty($response->result); - /** @var \GlobalPayments\Api\Entities\Reporting\TransactionSummary $transactionSummary */ + /** @var TransactionSummary $transactionSummary */ $transactionSummary = reset($response->result); $this->assertTrue($transactionSummary->alternativePaymentResponse instanceof AlternativePaymentResponse); $this->assertEquals(AlternativePaymentType::PAYPAL, $transactionSummary->alternativePaymentResponse->providerName); @@ -196,7 +198,6 @@ public function testPayPalFullCycle_Refund() $this->assertEquals('SUCCESS', $response->responseCode); $this->assertEquals(TransactionStatus::CAPTURED, $response->responseMessage); - /** @var Transaction $trnRefund */ $trnRefund = $transaction->refund()->withCurrency($this->currency)->execute(); $this->assertNotNull($trnRefund); $this->assertEquals('SUCCESS', $trnRefund->responseCode); @@ -219,7 +220,7 @@ public function testPayPalFullCycle_Reverse() fwrite(STDERR, print_r($trn->alternativePaymentResponse->redirectUrl, TRUE)); sleep(25); - $startDate = new \DateTime(); + $startDate = new DateTime(); $response = ReportingService::findTransactionsPaged(1, 1) ->withTransactionId($trn->transactionId) ->where(SearchCriteria::START_DATE, $startDate) @@ -228,7 +229,7 @@ public function testPayPalFullCycle_Reverse() $this->assertNotNull($response); $this->assertNotEmpty($response->result); - /** @var \GlobalPayments\Api\Entities\Reporting\TransactionSummary $transactionSummary */ + /** @var TransactionSummary $transactionSummary */ $transactionSummary = reset($response->result); $this->assertTrue($transactionSummary->alternativePaymentResponse instanceof AlternativePaymentResponse); @@ -267,7 +268,7 @@ public function testPayPalMultiCapture_fullCycle() fwrite(STDERR, print_r($response->alternativePaymentResponse->redirectUrl, TRUE)); sleep(25); - $startDate = new \DateTime(); + $startDate = new DateTime(); $response = ReportingService::findTransactionsPaged(1, 1) ->withTransactionId($response->transactionId) ->where(SearchCriteria::START_DATE, $startDate) diff --git a/test/Integration/Gateways/GpApiConnector/GpApiBNPLTest.php b/test/Integration/Gateways/GpApiConnector/GpApiBNPLTest.php index 1c3a1dc0..4d2d2bcc 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiBNPLTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiBNPLTest.php @@ -32,10 +32,10 @@ class GpApiBNPLTest extends TestCase { - private $paymentMethod; - private $currency; - private $shippingAddress; - private $billingAddress; + private BNPL $paymentMethod; + private string $currency; + private Address $shippingAddress; + private Address $billingAddress; public function setup(): void { @@ -876,7 +876,7 @@ public function testBNPL_MissingProductImageUrl() } } - private function setCustomerData() + private function setCustomerData(): Customer { $customer = new Customer(); $customer->id = "12345678"; @@ -889,7 +889,7 @@ private function setCustomerData() return $customer; } - private function setProductList() + private function setProductList(): array { $product = new Product(); $product->productId = GenerationUtils::getGuid(); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiBatchTest.php b/test/Integration/Gateways/GpApiConnector/GpApiBatchTest.php index 320086c2..dfd3ebbf 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiBatchTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiBatchTest.php @@ -11,6 +11,7 @@ use GlobalPayments\Api\PaymentMethods\CreditCardData; use GlobalPayments\Api\PaymentMethods\CreditTrackData; use GlobalPayments\Api\PaymentMethods\DebitTrackData; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\BatchService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -22,15 +23,15 @@ class GpApiBatchTest extends TestCase /** * @var CreditTrackData */ - private $creditTrackData; + private CreditTrackData $creditTrackData; /** * @var CreditCardData */ - private $creditCardData; - private $currency = 'USD'; - private $amount = 2.11; - private $tag = '9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001'; + private CreditCardData $creditCardData; + private string $currency = 'USD'; + private float $amount = 2.11; + private string $tag = '9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001'; public function setup() : void { @@ -54,7 +55,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardPresent); } @@ -349,7 +350,7 @@ public function testBatchClose_WithInvalidBatchReference() } } - private function assertBatchCloseResponse($batch, $amount) + private function assertBatchCloseResponse($batch, $amount): void { $this->assertNotNull($batch); $this->assertEquals('CLOSED', $batch->responseMessage); @@ -357,7 +358,7 @@ private function assertBatchCloseResponse($batch, $amount) $this->assertGreaterThanOrEqual(1, $batch->batchSummary->transactionCount); } - private function assertTransactionResponse($transaction, $transactionStatus) + private function assertTransactionResponse($transaction, $transactionStatus): void { $this->assertNotNull($transaction); $this->assertEquals('SUCCESS', $transaction->responseCode); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php b/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php index 80f0b64d..20dc4ca1 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php @@ -8,17 +8,18 @@ use GlobalPayments\Api\Entities\Enums\TransactionStatus; use GlobalPayments\Api\Entities\Exceptions\GatewayException; use GlobalPayments\Api\PaymentMethods\CreditCardData; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; use PHPUnit\Framework\TestCase; class GpApiDigitalWalletTest extends TestCase { - private $card; - private $currency = 'EUR'; - private $amount = 10; - private $googlePayToken; - private $clickToPayToken; + private CreditCardData $card; + private string $currency = 'EUR'; + private float $amount = 10; + private string $googlePayToken; + private string $clickToPayToken; public function setup(): void { @@ -40,7 +41,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } @@ -253,7 +254,7 @@ public function testGooglePayEncrypted_AuthAndReverse() $this->assertTransactionResponse($reverse, TransactionStatus::REVERSED); } - private function assertTransactionResponse($transaction, $transactionStatus) + private function assertTransactionResponse($transaction, $transactionStatus): void { $this->assertNotNull($transaction); $this->assertEquals("SUCCESS", $transaction->responseCode); @@ -261,7 +262,7 @@ private function assertTransactionResponse($transaction, $transactionStatus) $this->assertNotEmpty($transaction->transactionId); } - private function assertClickToPayPayerDetails($response) + private function assertClickToPayPayerDetails($response): void { $this->assertNotNull($response->payerDetails); $this->assertNotNull($response->payerDetails->email); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiMerchantAccountsTest.php b/test/Integration/Gateways/GpApiConnector/GpApiMerchantAccountsTest.php index aa8efa82..833a677b 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiMerchantAccountsTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiMerchantAccountsTest.php @@ -2,6 +2,7 @@ namespace GlobalPayments\Api\Tests\Integration\Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Address; use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\MerchantAccountsSortProperty; @@ -30,18 +31,18 @@ class GpApiMerchantAccountsTest extends TestCase { - private $startDate; - private $endDate; - private $accountId; + private DateTime $startDate; + private DateTime $endDate; + private string $accountId; /** @var GpApiConfig */ - private $config; + private GpApiConfig $config; public function setup(): void { $this->setUpConfig(); ServicesContainer::configureService($this->config); - $this->startDate = (new \DateTime())->modify('-1 year')->setTime(0, 0, 0); - $this->endDate = (new \DateTime())->modify('-3 days')->setTime(0, 0, 0); + $this->startDate = (new DateTime())->modify('-1 year')->setTime(0, 0, 0); + $this->endDate = (new DateTime())->modify('-3 days')->setTime(0, 0, 0); $response = ReportingService::findAccounts(1, 10) ->orderBy(MerchantAccountsSortProperty::TIME_CREATED, SortDirection::ASC) @@ -58,7 +59,7 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): void { BaseGpApiTestConfig::$appId = BaseGpApiTestConfig::PARTNER_SOLUTION_APP_ID; BaseGpApiTestConfig::$appKey = BaseGpApiTestConfig::PARTNER_SOLUTION_APP_KEY; @@ -204,7 +205,7 @@ public function testEditAccountInformation() ->where(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); $response = ReportingService::findAccounts(1, 10) @@ -215,7 +216,7 @@ public function testEditAccountInformation() ->andWith(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); /** @var MerchantAccountSummary $accountSummary */ $index = array_search( MerchantAccountType::FUND_MANAGEMENT, array_column($response->result, 'type') @@ -312,7 +313,7 @@ public function testEditAccountInformation_WithoutCardDetails() ->where(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); $response = ReportingService::findAccounts(1, 10) @@ -323,7 +324,7 @@ public function testEditAccountInformation_WithoutCardDetails() ->andWith(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); /** @var MerchantAccountSummary $accountSummary */ $index = array_search( MerchantAccountType::FUND_MANAGEMENT, array_column($response->result, 'type') @@ -363,7 +364,7 @@ public function testEditAccountInformation_WithoutAddress() ->where(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); $response = ReportingService::findAccounts(1, 10) @@ -374,7 +375,7 @@ public function testEditAccountInformation_WithoutAddress() ->andWith(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); /** @var MerchantAccountSummary $accountSummary */ $index = array_search( MerchantAccountType::FUND_MANAGEMENT, array_column($response->result, 'type') @@ -422,7 +423,7 @@ public function testEditAccountInformation_WithoutId() ->where(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); $response = ReportingService::findAccounts(1, 10) @@ -433,7 +434,7 @@ public function testEditAccountInformation_WithoutId() ->andWith(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); /** @var MerchantAccountSummary $accountSummary */ $index = array_search( MerchantAccountType::FUND_MANAGEMENT, array_column($response->result, 'type') @@ -477,7 +478,7 @@ public function testEditAccountInformation_WithoutUserRef() $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $accountSummary = $this->getAccountByType( reset($merchants->result)->id, @@ -513,7 +514,7 @@ public function testTransferFundsAccount() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -560,7 +561,7 @@ public function testTransferFundsAccount_AllFields() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -608,7 +609,7 @@ public function testTransferFundsAccount_OnlyMandatoryFields() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -653,7 +654,7 @@ public function testTransferFundsAccount_WithIdempotency() $idempotencyKey = GenerationUtils::getGuid(); $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -716,7 +717,7 @@ public function testTransferFundsAccount_WithoutRecipientAccountId() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -767,7 +768,7 @@ public function testTransferFundsAccount_WithoutAccountIdAndAccountName() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -817,7 +818,7 @@ public function testTransferFundsAccount_WithoutMerchantId() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -868,7 +869,7 @@ public function testTransferFundsAccount_WithoutAmount() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -919,7 +920,7 @@ public function testTransferFundsAccount_RandomAccountId() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -970,7 +971,7 @@ public function testTransferFundsAccount_RandomRecipientId() { $merchants = $this->getMerchants(); - $this->assertTrue(count($merchants->result) > 0); + $this->assertNotEmpty($merchants->result); $merchantSender = reset($merchants->result); $merchantRecipient = $merchants->result[1]; /** @var MerchantAccountSummary $accountSenderSummary */ @@ -1048,7 +1049,7 @@ private function getAccountByType($merchantId, $type) ->andWith(SearchCriteria::ACCOUNT_STATUS, MerchantAccountStatus::ACTIVE) ->execute(); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); $index = array_search($type, array_column($response->result, 'type')); return ($index !== false ? $response->result[$index] : null); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiMerchantsOnboardTest.php b/test/Integration/Gateways/GpApiConnector/GpApiMerchantsOnboardTest.php index 7e482dff..761e230b 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiMerchantsOnboardTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiMerchantsOnboardTest.php @@ -2,19 +2,19 @@ namespace Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Address; use GlobalPayments\Api\Entities\Enums\AccountType; use GlobalPayments\Api\Entities\Enums\Channel; -use GlobalPayments\Api\Entities\Enums\Environment; use GlobalPayments\Api\Entities\Enums\PaymentMethodFunction; use GlobalPayments\Api\Entities\Enums\PersonFunctions; use GlobalPayments\Api\Entities\Enums\PhoneNumberType; use GlobalPayments\Api\Entities\Enums\StatusChangeReason; use GlobalPayments\Api\Entities\Enums\UserStatus; use GlobalPayments\Api\Entities\Enums\UserType; -use GlobalPayments\Api\Entities\Exceptions\ArgumentException; use GlobalPayments\Api\Entities\Exceptions\BuilderException; use GlobalPayments\Api\Entities\Exceptions\GatewayException; +use GlobalPayments\Api\Entities\GpApi\PagedResult; use GlobalPayments\Api\Entities\PayFac\BankAccountData; use GlobalPayments\Api\Entities\PayFac\UserPersonalData; use GlobalPayments\Api\Entities\PaymentStatistics; @@ -23,6 +23,7 @@ use GlobalPayments\Api\Entities\PhoneNumber; use GlobalPayments\Api\Entities\Product; use GlobalPayments\Api\Entities\User; +use GlobalPayments\Api\PaymentMethods\Interfaces\IPaymentMethod; use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\PayFacService; use GlobalPayments\Api\Services\ReportingService; @@ -30,9 +31,6 @@ use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; use GlobalPayments\Api\Tests\Integration\Gateways\ProPay\TestData\TestAccountData; use GlobalPayments\Api\Utils\GenerationUtils; -use GlobalPayments\Api\Utils\Logging\Logger; -use GlobalPayments\Api\Utils\Logging\SampleRequestLogger; -use GlobalPayments\Api\PaymentMethods\Interfaces\IPaymentMethod; use PHPUnit\Framework\TestCase; class GpApiMerchantsOnboardTest extends TestCase @@ -42,7 +40,7 @@ public function setup(): void ServicesContainer::configureService($this->setUpConfig()); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { BaseGpApiTestConfig::$appId = BaseGpApiTestConfig::PARTNER_SOLUTION_APP_ID; BaseGpApiTestConfig::$appKey = BaseGpApiTestConfig::PARTNER_SOLUTION_APP_KEY; @@ -237,7 +235,7 @@ public function testGetMerchantInfo_InvalidId() public function testSearchMerchants() { - /** @var \GlobalPayments\Api\Entities\GpApi\PagedResult $merchants */ + /** @var PagedResult $merchants */ $merchants = ReportingService::findMerchants(1, 10)->execute(); $this->assertGreaterThan(0, $merchants->totalRecordCount); @@ -246,11 +244,11 @@ public function testSearchMerchants() public function testEditMerchantApplicantInfo() { - /** @var \GlobalPayments\Api\Entities\GpApi\PagedResult $merchants */ + /** @var PagedResult $merchants */ $merchants = ReportingService::findMerchants(1, 1)->execute(); $this->assertGreaterThan(0, $merchants->totalRecordCount); - $this->assertEquals(1, count($merchants->result)); + $this->assertCount(1, $merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); $persons = $this->getPersonList('Update'); @@ -264,11 +262,11 @@ public function testEditMerchantApplicantInfo() public function testEditMerchantPaymentProcessing() { - /** @var \GlobalPayments\Api\Entities\GpApi\PagedResult $merchants */ + /** @var PagedResult $merchants */ $merchants = ReportingService::findMerchants(1, 1)->execute(); $this->assertGreaterThan(0, $merchants->totalRecordCount); - $this->assertEquals(1, count($merchants->result)); + $this->assertCount(1, $merchants->result); $paymentStatistics = new PaymentStatistics(); $paymentStatistics->totalMonthlySalesAmount = '1111'; $paymentStatistics->highestTicketSalesAmount = '2222'; @@ -285,11 +283,11 @@ public function testEditMerchantPaymentProcessing() public function testEditMerchantBusinessInformation() { - /** @var \GlobalPayments\Api\Entities\GpApi\PagedResult $merchants */ + /** @var PagedResult $merchants */ $merchants = ReportingService::findMerchants(1, 1)->execute(); $this->assertGreaterThan(0, $merchants->totalRecordCount); - $this->assertEquals(1, count($merchants->result)); + $this->assertCount(1, $merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); $merchant->userStatus = UserStatus::ACTIVE; @@ -323,11 +321,11 @@ public function testEditMerchantBusinessInformation() public function testEditMerchant_RemoveMerchantFromPartner_FewArguments() { - /** @var \GlobalPayments\Api\Entities\GpApi\PagedResult $merchants */ + /** @var PagedResult $merchants */ $merchants = ReportingService::findMerchants(1, 1)->execute(); $this->assertGreaterThan(0, $merchants->totalRecordCount); - $this->assertEquals(1, count($merchants->result)); + $this->assertCount(1, $merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); @@ -351,7 +349,7 @@ public function testEditMerchant_RemoveMerchantFromPartner_TooManyArguments() $merchants = ReportingService::findMerchants(1, 1)->execute(); $this->assertGreaterThan(0, $merchants->totalRecordCount); - $this->assertEquals(1, count($merchants->result)); + $this->assertCount(1, $merchants->result); $merchant = User::fromId(reset($merchants->result)->id, UserType::MERCHANT); @@ -709,10 +707,10 @@ public function testBoardMerchant_WithoutDescription() } } - private function getMerchantData() + private function getMerchantData(): UserPersonalData { $merchantData = new UserPersonalData(); - $merchantData->userName = 'CERT_Propay_' . (new \DateTime())->format("YmdHis"); + $merchantData->userName = 'CERT_Propay_' . (new DateTime())->format("YmdHis"); $merchantData->legalName = 'Business Legal Name'; $merchantData->dba = 'Doing Business As'; $merchantData->merchantCategoryCode = '5999'; @@ -748,7 +746,7 @@ private function getMerchantData() return $merchantData; } - private function getProductList() + private function getProductList(): array { $products = [ 'PRO_TRA_CP-US-CARD-A920_SP', @@ -765,7 +763,7 @@ private function getProductList() return $productData; } - private function getPersonList($type = '') + private function getPersonList($type = ''): PersonList { $person = new Person(); $person->functions = PersonFunctions::APPLICANT; @@ -795,7 +793,7 @@ private function getPersonList($type = '') return $persons; } - private function getBankAccountData() + private function getBankAccountData(): BankAccountData { $bankAccountInformation = new BankAccountData(); $bankAccountInformation->accountHolderName = 'Bank Account Holder Name'; @@ -807,7 +805,7 @@ private function getBankAccountData() return $bankAccountInformation; } - private function getPaymentStatistics() + private function getPaymentStatistics(): PaymentStatistics { $paymentStatistics = new PaymentStatistics(); $paymentStatistics->totalMonthlySalesAmount = '3000000'; diff --git a/test/Integration/Gateways/GpApiConnector/GpApiOpenBankingTest.php b/test/Integration/Gateways/GpApiConnector/GpApiOpenBankingTest.php index 7f0c0554..fc6405cf 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiOpenBankingTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiOpenBankingTest.php @@ -2,6 +2,7 @@ namespace Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\PaymentMethodName; use GlobalPayments\Api\Entities\Enums\PaymentProvider; @@ -14,6 +15,7 @@ use GlobalPayments\Api\Entities\Reporting\TransactionSummary; use GlobalPayments\Api\Entities\Transaction; use GlobalPayments\Api\PaymentMethods\BankPayment; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -23,14 +25,14 @@ class GpApiOpenBankingTest extends TestCase { private string $currency = 'GBP'; private float $amount = 10.99; - private \DateTime $startDate; - private \DateTime $endDate; + private DateTime $startDate; + private DateTime $endDate; public function setup(): void { ServicesContainer::configureService($this->setUpConfig()); - $this->startDate = (new \DateTime())->modify('-30 days')->setTime(0, 0, 0); - $this->endDate = (new \DateTime())->modify('-3 days')->setTime(0, 0, 0); + $this->startDate = (new DateTime())->modify('-30 days')->setTime(0, 0, 0); + $this->endDate = (new DateTime())->modify('-3 days')->setTime(0, 0, 0); } public static function tearDownAfterClass(): void @@ -38,14 +40,14 @@ public static function tearDownAfterClass(): void BaseGpApiTestConfig::resetGpApiConfig(); } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { $config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); $config->country = 'GB'; return $config; } - private function fasterPaymentsConfig() + private function fasterPaymentsConfig(): BankPayment { $bankPayment = new BankPayment(); $bankPayment->accountNumber = '99999999'; @@ -58,7 +60,7 @@ private function fasterPaymentsConfig() return $bankPayment; } - private function sepaConfig() + private function sepaConfig(): BankPayment { $bankPayment = new BankPayment(); $bankPayment->iban = 'GB33BUKB20201555555555'; @@ -69,7 +71,7 @@ private function sepaConfig() return $bankPayment; } - private function assertOpenBankingResponse(Transaction $trn) + private function assertOpenBankingResponse(Transaction $trn): void { $this->assertEquals(TransactionStatus::INITIATED, $trn->responseMessage); $this->assertNotNull($trn->transactionId); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiRiskAssessmentTest.php b/test/Integration/Gateways/GpApiConnector/GpApiRiskAssessmentTest.php index 5a8b3ae0..c78e7dce 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiRiskAssessmentTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiRiskAssessmentTest.php @@ -167,7 +167,7 @@ public function testRiskAssessmentFullOption() ->withPreOrderAvailabilityDate(date('Y-m-d H:i:s')) ->withReorderIndicator(ReorderIndicator::REORDER) ->withOrderTransactionType(OrderTransactionType::GOODS_SERVICE_PURCHASE) - ->withCustomerAccountId(\GlobalPayments\Api\Utils\GenerationUtils::getGuid()) + ->withCustomerAccountId(GenerationUtils::getGuid()) ->withAccountAgeIndicator(AgeIndicator::LESS_THAN_THIRTY_DAYS) ->withAccountCreateDate(date('Y-m-d')) ->withAccountChangeDate(date('Y-m-d')) diff --git a/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php b/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php index 81b4d0d1..c43d2bfc 100644 --- a/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php +++ b/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php @@ -45,21 +45,21 @@ class PartnershipModeTest extends TestCase { /** @var CreditCardData */ - private $card; + private CreditCardData $card; /** @var string */ - private $currency; + private string $currency; /** @var GpApiConfig */ - private $baseConfig; - private $amount; + private GpApiConfig $baseConfig; + private float $amount; /** @var Address */ - private $shippingAddress; + private Address $shippingAddress; /** @var BrowserData */ - private $browserData; + private BrowserData $browserData; - private $merchantId; + private string $merchantId; public function setup(): void { @@ -107,7 +107,7 @@ public function setup(): void } } - private function setUpConfigMerchant() + private function setUpConfigMerchant(): void { $config = clone $this->baseConfig; $config->challengeNotificationUrl = 'https://ensi808o85za.x.pipedream.net/'; diff --git a/test/Integration/Gateways/GpApiConnector/ReportingDepositsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingDepositsTest.php index 381a1c70..44f2a086 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingDepositsTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingDepositsTest.php @@ -10,6 +10,7 @@ use GlobalPayments\Api\Entities\Reporting\DataServiceCriteria; use GlobalPayments\Api\Entities\Reporting\DepositSummary; use GlobalPayments\Api\Entities\Reporting\SearchCriteria; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -211,7 +212,7 @@ public function testReportFindDepositsByAmount() } } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } diff --git a/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php index aff55d52..d0d4563c 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php @@ -2,6 +2,7 @@ namespace Gateways\GpApiConnector; +use DateTime; use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\DepositStatus; use GlobalPayments\Api\Entities\Enums\SortDirection; @@ -13,6 +14,7 @@ use GlobalPayments\Api\Entities\Reporting\DataServiceCriteria; use GlobalPayments\Api\Entities\Reporting\SearchCriteria; use GlobalPayments\Api\Entities\Reporting\TransactionSummary; +use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Tests\Data\BaseGpApiTestConfig; @@ -34,8 +36,8 @@ public static function tearDownAfterClass(): void public function testReportFindSettlementTransactionsByStartDateAndEndDate() { - $startDate = (new \DateTime())->modify('-30 days'); - $endDate = (new \DateTime())->modify('-3 days'); + $startDate = (new DateTime())->modify('-30 days'); + $endDate = (new DateTime())->modify('-3 days'); try { $response = ReportingService::findSettlementTransactionsPaged(1, 10) ->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC) @@ -130,7 +132,7 @@ public function testReportFindSettlementTransactions_OrderBy_DepositId() public function testReportFindSettlementTransactions_FilterBy_NumberFirst6_And_NumberLast4() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $numberFirst6 = "376768"; $numberLast4 = "5006"; @@ -155,7 +157,7 @@ public function testReportFindSettlementTransactions_FilterBy_NumberFirst6_And_N public function testReportFindSettlementTransactions_FilterBy_DepositStatus() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $depositStatus = new DepositStatus(); $reflectionClass = new ReflectionClass($depositStatus); foreach ($reflectionClass->getConstants() as $value) { @@ -182,7 +184,7 @@ public function testReportFindSettlementTransactions_FilterBy_DepositStatus() public function testReportFindSettlementTransactions_FilterBy_CardBrand() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $cardBrand = array("VISA", "MASTERCARD", "AMEX", "DINERS", "DISCOVER", "JCB", "CUP"); foreach ($cardBrand as $value) { try { @@ -208,7 +210,7 @@ public function testReportFindSettlementTransactions_FilterBy_CardBrand() public function testReportFindSettlementTransactions_FilterBy_Wrong_CardBrand() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $cardBrand = "Bank of America"; try { $response = ReportingService::findSettlementTransactionsPaged(1, 10) @@ -226,7 +228,7 @@ public function testReportFindSettlementTransactions_FilterBy_Wrong_CardBrand() public function testReportFindSettlementTransactions_FilterBy_ARN() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $arn = "24137550037630153798573"; try { @@ -248,7 +250,7 @@ public function testReportFindSettlementTransactions_FilterBy_ARN() public function testReportFindSettlementTransactions_FilterBy_Wrong_ARN() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $arn = GenerationUtils::getGuid(); try { @@ -267,7 +269,7 @@ public function testReportFindSettlementTransactions_FilterBy_Wrong_ARN() public function testReportFindSettlementTransactions_FilterBy_BrandReference() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $brandReference = "460008653352066"; try { @@ -289,7 +291,7 @@ public function testReportFindSettlementTransactions_FilterBy_BrandReference() public function testReportFindSettlementTransactions_FilterBy_Wrong_BrandReference() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $brandReference = GenerationUtils::getGuid(); $brandReference = trim(str_replace("-", "", $brandReference)); @@ -309,7 +311,7 @@ public function testReportFindSettlementTransactions_FilterBy_Wrong_BrandReferen public function testReportFindSettlementTransactions_FilterBy_AuthCode() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $authCode = "931951"; try { @@ -331,7 +333,7 @@ public function testReportFindSettlementTransactions_FilterBy_AuthCode() public function testReportFindSettlementTransactions_FilterBy_Reference() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $reference = "50080513769"; try { @@ -353,7 +355,7 @@ public function testReportFindSettlementTransactions_FilterBy_Reference() public function testReportFindSettlementTransactions_FilterBy_Random_Reference() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $reference = GenerationUtils::getGuid(); $reference = trim(str_replace("-", "", $reference)); @@ -376,7 +378,7 @@ public function testReportFindSettlementTransactions_FilterBy_Random_Reference() */ public function testReportFindSettlementTransactions_FilterBy_Status() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $settleTransactionStatus = [TransactionStatus::FUNDED, TransactionStatus::REJECTED]; foreach ($settleTransactionStatus as $value) { try { @@ -402,7 +404,7 @@ public function testReportFindSettlementTransactions_FilterBy_Status() public function testReportFindSettlementTransactions_FilterBy_DepositID() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $depositId = "DEP_2342423423"; try { @@ -424,7 +426,7 @@ public function testReportFindSettlementTransactions_FilterBy_DepositID() public function testReportFindSettlementTransactions_FilterBy_Random_DepositID() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $depositID = GenerationUtils::getGuid(); $depositID = trim(str_replace("-", "", $depositID)); @@ -444,8 +446,8 @@ public function testReportFindSettlementTransactions_FilterBy_Random_DepositID() public function testReportFindSettlementTransactions_FilterBy_FromDepositTimeCreated_And_ToDepositTimeCreated() { - $startDate = (new \DateTime())->modify('-30 days'); - $endDate = (new \DateTime())->modify('-3 days'); + $startDate = (new DateTime())->modify('-30 days'); + $endDate = (new DateTime())->modify('-3 days'); try { $response = ReportingService::findSettlementTransactionsPaged(1, 10) ->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC) @@ -466,8 +468,8 @@ public function testReportFindSettlementTransactions_FilterBy_FromDepositTimeCre public function testReportFindSettlementTransactions_FilterBy_FromBatchTimeCreated_And_ToBatchTimeCreated() { - $startDate = (new \DateTime())->modify('-30 days'); - $endDate = (new \DateTime())->modify('-3 days'); + $startDate = (new DateTime())->modify('-30 days'); + $endDate = (new DateTime())->modify('-3 days'); try { $response = ReportingService::findSettlementTransactionsPaged(1, 10) ->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC) @@ -488,8 +490,8 @@ public function testReportFindSettlementTransactions_FilterBy_FromBatchTimeCreat public function testReportFindSettlementTransactions_FilterBy_SystemMid_And_SystemHierarchy() { - $startDate = (new \DateTime())->modify('-30 days'); - $endDate = (new \DateTime())->modify('-10 days'); + $startDate = (new DateTime())->modify('-30 days'); + $endDate = (new DateTime())->modify('-10 days'); $systemMid = "101023947262"; $systemHierarchy = "055-70-024-011-019"; try { @@ -513,7 +515,7 @@ public function testReportFindSettlementTransactions_FilterBy_SystemMid_And_Syst public function testReportFindSettlementTransactions_FilterBy_Random_MerchantID() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $merchantID = "111"; try { @@ -532,7 +534,7 @@ public function testReportFindSettlementTransactions_FilterBy_Random_MerchantID( public function testReportFindSettlementTransactions_FilterBy_Random_SystemHierarchy() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $systemHierarchy = "100-00-000-000-001"; try { @@ -551,7 +553,7 @@ public function testReportFindSettlementTransactions_FilterBy_Random_SystemHiera public function testReportFindSettlementTransactions_FilterBy_Invalid_MerchantID() { - $startDate = (new \DateTime())->modify('-30 days'); + $startDate = (new DateTime())->modify('-30 days'); $merchantID = GenerationUtils::getGuid(); $merchantID = trim(str_replace("-", "", $merchantID)); @@ -567,7 +569,7 @@ public function testReportFindSettlementTransactions_FilterBy_Invalid_MerchantID } } - public function setUpConfig() + public function setUpConfig(): GpApiConfig { return BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); } diff --git a/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php index 68805735..4aa4cfcc 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php @@ -73,7 +73,7 @@ public function testFindStoredPaymentMethod_By_LastUpdated() $this->assertNotNull($response); $this->assertTrue(is_array($response->result)); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); } public function testFindStoredPaymentMethod_By_LastUpdated_CurrentDay() @@ -88,7 +88,7 @@ public function testFindStoredPaymentMethod_By_LastUpdated_CurrentDay() $this->assertNotNull($response); $this->assertTrue(is_array($response->result)); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); } public function testFindStoredPaymentMethod_By_Id() diff --git a/test/Integration/Gateways/GpEcomConnector/CreditTest.php b/test/Integration/Gateways/GpEcomConnector/CreditTest.php index 03cfb4ff..db243b57 100644 --- a/test/Integration/Gateways/GpEcomConnector/CreditTest.php +++ b/test/Integration/Gateways/GpEcomConnector/CreditTest.php @@ -132,7 +132,7 @@ public function testCreditVerify() $this->assertEquals('00', $response->responseCode); } - protected function getConfig() + protected function getConfig(): GpEcomConfig { $config = new GpEcomConfig(); $config->merchantId = 'heartlandgpsandbox'; @@ -145,7 +145,7 @@ protected function getConfig() return $config; } - protected function dccSetup() + protected function dccSetup(): void { $config = new GpEcomConfig(); $config->merchantId = "heartlandgpsandbox"; diff --git a/test/Integration/Gateways/GpEcomConnector/HppTest.php b/test/Integration/Gateways/GpEcomConnector/HppTest.php index 0dd201f7..f6419cd5 100644 --- a/test/Integration/Gateways/GpEcomConnector/HppTest.php +++ b/test/Integration/Gateways/GpEcomConnector/HppTest.php @@ -25,14 +25,16 @@ use GlobalPayments\Api\Entities\Enums\RemittanceReferenceType; use GlobalPayments\Api\Entities\Enums\ChallengeRequestIndicator; use PHPUnit\Framework\TestCase; +use RecursiveArrayIterator; +use RecursiveIteratorIterator; class HppTest extends TestCase { - private $billingAddress; + private Address $billingAddress; - private $shippingAddress; + private Address $shippingAddress; - private $hppVersionList = [ + private array $hppVersionList = [ HppVersion::VERSION_1, HppVersion::VERSION_2, '' @@ -55,7 +57,7 @@ public function setup() : void $this->shippingAddress->country = "GB"; } - public function basicSetup() + public function basicSetup(): HostedService { $config = new GpEcomConfig(); $config->merchantId = "heartlandgpsandbox"; @@ -378,7 +380,7 @@ public function testEnableDynamicCurrencyConversionRequest() ->serialize(); $this->assertNotNull($json); - $this->assertEquals($json, '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1900","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","DCC_ENABLE":"1","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","HPP_VERSION":"2","SHA1HASH":"448d742db89b05ce97152beb55157c904f3839cc"}'); + $this->assertEquals('{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1900","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","DCC_ENABLE":"1","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","HPP_VERSION":"2","SHA1HASH":"448d742db89b05ce97152beb55157c904f3839cc"}', $json); } public function testDisableDynamicCurrencyConversionRequest() @@ -698,7 +700,7 @@ public function testParseResponse() $this->assertNotNull($response); // Base64 encode values - $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator(json_decode($response, true))); + $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(json_decode($response, true))); foreach ($iterator as $key => $value) { if (!empty($value)) { $iterator->getInnerIterator()->offsetSet($key, base64_encode($value)); @@ -933,8 +935,8 @@ public function testCaptureBillingShippingInfo() ->withHostedPaymentData($hostedPaymentData) ->serialize(); $response = json_decode($json, true); - $this->assertEquals(true, $response['HPP_CAPTURE_ADDRESS']); - $this->assertEquals(false, $response['HPP_DO_NOT_RETURN_ADDRESS']); + $this->assertTrue($response['HPP_CAPTURE_ADDRESS']); + $this->assertFalse($response['HPP_DO_NOT_RETURN_ADDRESS']); } public function testOpenBankingInitiate() @@ -988,7 +990,7 @@ public function test3DSExemption() $config->sharedSecret = "secret"; $config->hostedPaymentConfig = new HostedPaymentConfig(); $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response";; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; $config->hostedPaymentConfig->version = HppVersion::VERSION_2; $service = new HostedService($config); @@ -1009,6 +1011,6 @@ public function test3DSExemption() $jsonResponse = json_decode($json, true); $this->assertTrue(isset($jsonResponse['HPP_ENABLE_EXEMPTION_OPTIMIZATION'])); - $this->assertEquals(true, $jsonResponse['HPP_ENABLE_EXEMPTION_OPTIMIZATION']); + $this->assertTrue($jsonResponse['HPP_ENABLE_EXEMPTION_OPTIMIZATION']); } } diff --git a/test/Integration/Gateways/GpEcomConnector/HppTestCase.php b/test/Integration/Gateways/GpEcomConnector/HppTestCase.php index 41f122b4..1569aa07 100644 --- a/test/Integration/Gateways/GpEcomConnector/HppTestCase.php +++ b/test/Integration/Gateways/GpEcomConnector/HppTestCase.php @@ -14,7 +14,7 @@ class HppTestCase extends TestCase protected HostedService $service; protected GpEcomHppClient $client; - protected function config() + protected function config(): GpEcomConfig { $config = new GpEcomConfig(); $config->merchantId = "heartlandgpsandbox"; @@ -184,7 +184,6 @@ public function testFraudManagementResponse() // TODO: grab the response JSON from the client-side for example: //sample response JSON: $responseJson = array("MERCHANT_ID" => "MerchantId", "ACCOUNT" => "internet", "ORDER_ID" => "GTI5Yxb0SumL_TkDMCAxQA", "AMOUNT" => "1999", "TIMESTAMP" => "20170725154824", "SHA1HASH" => "843680654f377bfa845387fdbace35acc9d95778", "RESULT" => "00", "AUTHCODE" => "12345", "CARD_PAYMENT_BUTTON" => "Place Order", "AVSADDRESSRESULT" => "M", "AVSPOSTCODERESULT" => "M", "BATCHID" => "445196", "MESSAGE" => "[ test system ] Authorised", "PASREF" => "15011597872195765", "CVNRESULT" => "M", "HPP_FRAUDFILTER_RESULT" => "HOLD", "HPP_FRAUDFILTER_RULE_56257838-4590-4227-b946-11e061fb15fe" => "HOLD", "HPP_FRAUDFILTER_RULE_cf609cf9-9e5a-4700-ac69-8aa09c119305" => "PASS"); - ; $parsedResponse = $service->parseResponse(json_encode($responseJson)); $responseCode = $parsedResponse->responseCode; // 00 diff --git a/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php b/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php index c5dd4e6f..6b4cb615 100644 --- a/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php +++ b/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php @@ -2,6 +2,7 @@ use GlobalPayments\Api\Entities\Enums\{BankPaymentStatus, BankPaymentType, RemittanceReferenceType, ShaHashType}; use GlobalPayments\Api\Entities\Exceptions\GatewayException; +use GlobalPayments\Api\Entities\GpApi\PagedResult; use GlobalPayments\Api\Entities\Reporting\{SearchCriteria, TransactionSummary}; use GlobalPayments\Api\Entities\Transaction; use GlobalPayments\Api\PaymentMethods\BankPayment; @@ -198,8 +199,8 @@ public function testSEPARefund() public function testBankPaymentList() { - $startDate = (new \DateTime())->modify('-5 day'); - $endDate = new \DateTime(); + $startDate = (new DateTime())->modify('-5 day'); + $endDate = new DateTime(); $response = ReportingService::findBankPaymentTransactions(1, 10) ->where(SearchCriteria::START_DATE, $startDate) ->andWith(SearchCriteria::END_DATE, $endDate) @@ -216,8 +217,8 @@ public function testBankPaymentList() public function testBankPaymentList_EmptyList() { - $startDate = (new \DateTime())->modify('-29 day'); - $endDate = (new \DateTime())->modify('-28 day'); + $startDate = (new DateTime())->modify('-29 day'); + $endDate = (new DateTime())->modify('-28 day'); $response = ReportingService::findBankPaymentTransactions(1, 10) ->where(SearchCriteria::START_DATE, $startDate) ->andWith(SearchCriteria::END_DATE, $endDate) @@ -232,8 +233,8 @@ public function testBankPaymentList_EmptyList() public function testBankPaymentListWithReturnPii() { - $startDate = (new \DateTime())->modify('-29 day'); - $endDate = (new \DateTime())->modify('-1 day'); + $startDate = (new DateTime())->modify('-29 day'); + $endDate = (new DateTime())->modify('-1 day'); $response = ReportingService::findBankPaymentTransactions(1, 10) ->where(SearchCriteria::START_DATE, $startDate) ->andWith(SearchCriteria::END_DATE, $endDate) @@ -241,7 +242,7 @@ public function testBankPaymentListWithReturnPii() ->execute(); $this->assertNotNull($response); - $this->assertTrue(count($response->result) > 0); + $this->assertNotEmpty($response->result); /** @var TransactionSummary $trn */ $trn = $response->result[rand(0, count($response->result) - 1)]; $bankPaymentResponse = $trn->bankPaymentResponse; @@ -263,7 +264,7 @@ public function testBankPaymentListWithReturnPii() public function testGetBankPaymentById() { $obTransId = 'DuVGjawYd1m8UkbZyi'; - /** @var \GlobalPayments\Api\Entities\GpApi\PagedResult $response */ + /** @var PagedResult $response */ $response = ReportingService::bankPaymentDetail($obTransId) ->execute(); @@ -277,7 +278,7 @@ public function testGetBankPaymentById_RandomId() $length = 18; $obTransId = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1, $length); - /** @var \GlobalPayments\Api\Entities\GpApi\PagedResult $response */ + /** @var PagedResult $response */ $response = ReportingService::bankPaymentDetail($obTransId) ->execute(); @@ -549,7 +550,7 @@ public function testSEPACharge_CADCurrency() } } - private function fasterPaymentsConfig() + private function fasterPaymentsConfig(): BankPayment { $bankPayment = new BankPayment(); $bankPayment->accountNumber = '12345678'; @@ -561,7 +562,7 @@ private function fasterPaymentsConfig() return $bankPayment; } - private function sepaConfig() + private function sepaConfig(): BankPayment { $bankPayment = new BankPayment(); $bankPayment->iban = '123456'; @@ -572,7 +573,7 @@ private function sepaConfig() return $bankPayment; } - private function assertOpenBankingResponse(Transaction $trn) + private function assertOpenBankingResponse(Transaction $trn): void { $this->assertEquals(BankPaymentStatus::PAYMENT_INITIATED, $trn->responseMessage); $this->assertNotNull($trn->transactionId); diff --git a/test/Integration/Gateways/GpEcomConnector/RecurringTest.php b/test/Integration/Gateways/GpEcomConnector/RecurringTest.php index 0da9d46f..f00ae09a 100644 --- a/test/Integration/Gateways/GpEcomConnector/RecurringTest.php +++ b/test/Integration/Gateways/GpEcomConnector/RecurringTest.php @@ -56,7 +56,6 @@ protected function config() $config->accountId = "3dsecure"; $config->refundPassword = "refund"; $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; $config->requestLogger = new SampleRequestLogger(new Logger("logs")); $config->channel = 'ECOM'; return $config; @@ -69,7 +68,6 @@ protected function dccSetup() $config->accountId = "apidcc"; $config->refundPassword = "refund"; $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; ServicesContainer::configureService($config); } @@ -80,6 +78,7 @@ public function setup(): void $this->newCustomer = new Customer(); $this->newCustomer->key = $this->getCustomerId(); + $this->newCustomer->id = 'E8953893489'; $this->newCustomer->title = "Mr."; $this->newCustomer->firstName = "James"; $this->newCustomer->lastName = "Mason"; diff --git a/test/Integration/Gateways/GpEcomConnector/ReportingTest.php b/test/Integration/Gateways/GpEcomConnector/ReportingTest.php index 2009d216..b0a5b71c 100644 --- a/test/Integration/Gateways/GpEcomConnector/ReportingTest.php +++ b/test/Integration/Gateways/GpEcomConnector/ReportingTest.php @@ -13,7 +13,7 @@ class ReportingTest extends TestCase { - protected function config() + protected function config(): GpEcomConfig { $config = new GpEcomConfig(); $config->merchantId = "heartlandgpsandbox"; diff --git a/test/Integration/Gateways/GpEcomConnector/Secure3DSExemptionsTest.php b/test/Integration/Gateways/GpEcomConnector/Secure3DSExemptionsTest.php index 42a3769b..647cc613 100644 --- a/test/Integration/Gateways/GpEcomConnector/Secure3DSExemptionsTest.php +++ b/test/Integration/Gateways/GpEcomConnector/Secure3DSExemptionsTest.php @@ -21,10 +21,10 @@ class Secure3DSExemptionsTest extends TestCase { - private $card; - private $shippingAddress; - private $billingAddress; - private $browserData; + private CreditCardData $card; + private Address $shippingAddress; + private Address $billingAddress; + private BrowserData $browserData; public function setup() : void { @@ -72,7 +72,7 @@ public function setup() : void $this->browserData->userAgent = 'Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'; } - protected function getConfig() + protected function getConfig(): GpEcomConfig { $config = new GpEcomConfig(); $config->merchantId = 'myMerchantId'; diff --git a/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php b/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php index 66330d84..bea63015 100644 --- a/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php +++ b/test/Integration/Gateways/GpEcomConnector/Secure3dServiceTest.php @@ -2,6 +2,7 @@ namespace GlobalPayments\Api\Tests\Integration\Gateways\GpEcomConnector; +use DateTime; use GlobalPayments\Api\Entities\Address; use GlobalPayments\Api\Entities\BrowserData; use GlobalPayments\Api\Entities\Enums\ { @@ -83,7 +84,7 @@ public function setup(): void $this->browserData->userAgent = 'Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'; } - protected function getConfig() + protected function getConfig(): GpEcomConfig { $config = new GpEcomConfig(); $config->merchantId = 'myMerchantId'; @@ -403,9 +404,7 @@ public function testFullCycle_Any() $this->assertNotNull($secureEcom); if ($secureEcom->enrolled) { - if ($secureEcom->getVersion() === Secure3dVersion::TWO) { - $this->assertEquals(Secure3dVersion::TWO, $secureEcom->getVersion()); - + if ($secureEcom->getVersion() == Secure3dVersion::TWO) { // initiate authentication $initAuth = Secure3dService::initiateAuthentication($this->card, $secureEcom) ->withAmount(10.01) @@ -780,7 +779,7 @@ public function testOptionalPriorAuthenticationData() // optionals ->withPriorAuthenticationMethod(PriorAuthenticationMethod::FRICTIONLESS_AUTHENTICATION) ->withPriorAuthenticationTransactionId('26c3f619-39a4-4040-bf1f-6fd433e6d615') - ->withPriorAuthenticationTimestamp((new \DateTime('2019-01-10T12:57:33.333Z'))->format(\DateTime::RFC3339_EXTENDED)) + ->withPriorAuthenticationTimestamp((new DateTime('2019-01-10T12:57:33.333Z'))->format(DateTime::RFC3339_EXTENDED)) ->execute(); $this->assertNotNull($initAuth); @@ -874,7 +873,7 @@ public function testOptionalPayerLoginData() // optionals ->withCustomerAuthenticationData('string') - ->withCustomerAuthenticationTimestamp((new \DateTime('2019-01-10T12:57:33.333Z'))->format(\DateTime::RFC3339_EXTENDED)) + ->withCustomerAuthenticationTimestamp((new DateTime('2019-01-10T12:57:33.333Z'))->format(DateTime::RFC3339_EXTENDED)) ->withCustomerAuthenticationMethod(CustomerAuthenticationMethod::MERCHANT_SYSTEM) ->execute(); $this->assertNotNull($initAuth); @@ -952,7 +951,7 @@ public function testOptionalMobileFields() ->withServerTransactionId($initAuth->serverTransactionId) ->execute(); - $this->assertEquals('CHALLENGE_REQUIRED', $initAuth->status); + $this->assertEquals('CHALLENGE_REQUIRED', $secureEcom->status); $this->card->threeDSecure = $secureEcom; $response = $this->card->charge(10.01)10.0.1 +10.0.2