diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a1722b9..f9e7076f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ ## Latest version +#### Enhancements: +- Added avs/cvv mapping and support for findTransaction method +- Added batch Close response to return GSAP-specific data +- Added support for split tender GiftCardSale transactions +- Fix some GP-API unit tests + +## v2.4.3 (11/17/2021) + #### Enhancements: - Add Unified Payments Application support diff --git a/metadata.xml b/metadata.xml index b7ccdeb9..f855067a 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 2.4.3 + 2.4.4 \ No newline at end of file diff --git a/src/Entities/BatchSummary.php b/src/Entities/BatchSummary.php index 8d94bd0c..ef10a3f5 100644 --- a/src/Entities/BatchSummary.php +++ b/src/Entities/BatchSummary.php @@ -42,4 +42,24 @@ class BatchSummary * @var string */ public $batchReference; + + /** + * @var integer + */ + public $hostBatchNbr; + + /** + * @var integer + */ + public $hostTotalCnt; + + /** + * @var decimal + */ + public $hostTotalAmt; + + /** + * @var integer + */ + public $processedDeviceId; } diff --git a/src/Entities/Reporting/TransactionSummary.php b/src/Entities/Reporting/TransactionSummary.php index 6cca8b78..77c6e671 100644 --- a/src/Entities/Reporting/TransactionSummary.php +++ b/src/Entities/Reporting/TransactionSummary.php @@ -41,6 +41,12 @@ class TransactionSummary */ public $authCode; + /** @var string */ + public $avsResponseCode; + + /** @var string */ + public $avsResponseMessage; + /** * @var DateTime */ @@ -76,6 +82,26 @@ class TransactionSummary */ public $cardHolderLastName; + /** + * @var string + */ + public $cardHolderAddr; + + /** + * @var string + */ + public $cardHolderCity; + + /** + * @var string + */ + public $cardHolderState; + + /** + * @var string + */ + public $cardHolderZip; + /** * @var string */ @@ -145,6 +171,12 @@ class TransactionSummary */ public $customerLastName; + /** @var string */ + public $cvnResponseCode; + + /** @var string */ + public $cvnResponseMessage; + /** * @var bool */ @@ -482,12 +514,6 @@ class TransactionSummary /** @var string */ public $orderId; - /** @var string */ - public $avsResponseCode; - - /** @var string */ - public $cvnResponseCode; - /** @var string */ public $eciIndicator; diff --git a/src/Entities/Transaction.php b/src/Entities/Transaction.php index c2ad9445..ffbf160f 100644 --- a/src/Entities/Transaction.php +++ b/src/Entities/Transaction.php @@ -172,6 +172,9 @@ class Transaction */ public $responseMessage; + /** @var array */ + public $splitTenderBalanceDueAmt; + /** @var array */ public $responseValues; diff --git a/src/Gateways/PorticoConnector.php b/src/Gateways/PorticoConnector.php index f9b5758a..3210a0da 100644 --- a/src/Gateways/PorticoConnector.php +++ b/src/Gateways/PorticoConnector.php @@ -1269,8 +1269,15 @@ protected function mapResponse($rawResponse, BaseBuilder $builder, $request) ? (string)$item->RspText : $gatewayRspText; - if (isset($item) && isset($item->AuthAmt)) { - $result->authorizedAmount = (string)$item->AuthAmt; + if (isset($item) && (isset($item->AuthAmt) || isset($item->SplitTenderCardAmt))) { + $result->authorizedAmount = + isset($item->SplitTenderCardAmt) + ? (string)$item->SplitTenderCardAmt + : (string)$item->AuthAmt; + } + + if (isset($item) && isset($item->SplitTenderBalanceDueAmt)) { + $result->splitTenderBalanceDueAmt = (string)$item->SplitTenderBalanceDueAmt; } if (isset($item) && isset($item->AvailableBalance)) { @@ -1360,6 +1367,19 @@ protected function mapResponse($rawResponse, BaseBuilder $builder, $request) $result->batchSummary->transactionCount = (string)$item->TxnCnt; $result->batchSummary->totalAmount = (string)$item->TotalAmt; $result->batchSummary->sequenceNumber = (string)$item->BatchSeqNbr; + + if (isset($item->HostBatchNbr)) { + $result->batchSummary->hostBatchNbr = (string)$item->HostBatchNbr; + } + if (isset($item->HostTotalCnt)) { + $result->batchSummary->hostTotalCnt = (string)$item->HostTotalCnt; + } + if (isset($item->HostTotalAmt)) { + $result->batchSummary->hostTotalAmt = (string)$item->HostTotalAmt; + } + if (isset($item->ProcessedDeviceId)) { + $result->batchSummary->processedDeviceId = (string)$item->ProcessedDeviceId; + } } if (isset($item) && isset($item->CardBrandTxnId)) { @@ -1371,7 +1391,7 @@ protected function mapResponse($rawResponse, BaseBuilder $builder, $request) $result->payFacData->transactionId = !empty($root->PaymentFacilitatorTxnId) ? (string) $root->PaymentFacilitatorTxnId : ''; $result->payFacData->transactionNumber = !empty($root->PaymentFacilitatorTxnNbr) ? (string) $root->PaymentFacilitatorTxnNbr : ''; } - + return $result; } @@ -1391,7 +1411,8 @@ protected function mapReportResponse($rawResponse, ReportBuilder $builder) } if ($builder->reportType === ReportType::TRANSACTION_DETAIL) { - return $this->hydrateTransactionSummary($doc->Transactions); + if(isset($doc->Data)) + return $this->hydrateTransactionSummary($doc->Data); } return null; @@ -1417,6 +1438,14 @@ protected function hydrateTransactionSummary($item) $summary->authCode = (string)$item->AuthCode; } + if (isset($item) && isset($item->AVSRsltCode)) { + $summary->avsResponseCode = (string)$item->AVSRsltCode; + } + + if (isset($item) && isset($item->AVSRsltText)) { + $summary->avsResponseMessage = (string)$item->AVSRsltText; + } + if (isset($item) && isset($item->BatchCloseDT)) { $summary->batchCloseDate = (string)$item->BatchCloseDT; } @@ -1427,10 +1456,43 @@ protected function hydrateTransactionSummary($item) if (isset($item) && isset($item->CardHolderData)) { if (isset($item->CardHolderData->CardHolderFirstName)) { - $summary->cardHolderFirstName = $item->CardHolderData->CardHolderFirstName; + $summary->cardHolderFirstName = (string)$item->CardHolderData->CardHolderFirstName; } if (isset($item->CardHolderData->CardHolderLastName)) { - $summary->cardHolderLastName = $item->CardHolderData->CardHolderLastName; + $summary->cardHolderLastName = (string)$item->CardHolderData->CardHolderLastName; + } + if (isset($item->CardHolderData->CardHolderAddr)) { + $summary->cardHolderAddr = (string)$item->CardHolderData->CardHolderAddr; + } + if (isset($item->CardHolderData->CardHolderCity)) { + $summary->cardHolderCity = (string)$item->CardHolderData->CardHolderCity; + } + if (isset($item->CardHolderData->CardHolderState)) { + $summary->cardHolderState = (string)$item->CardHolderData->CardHolderState; + } + if (isset($item->CardHolderData->CardHolderZip)) { + $summary->cardHolderZip = (string)$item->CardHolderData->CardHolderZip; + } + } + else + { + if (isset($item->CardHolderFirstName)) { + $summary->cardHolderFirstName = (string)$item->CardHolderFirstName; + } + if (isset($item->CardHolderLastName)) { + $summary->cardHolderLastName = (string)$item->CardHolderLastName; + } + if (isset($item->CardHolderAddr)) { + $summary->cardHolderAddr = (string)$item->CardHolderAddr; + } + if (isset($item->CardHolderCity)) { + $summary->cardHolderCity = (string)$item->CardHolderCity; + } + if (isset($item->CardHolderState)) { + $summary->cardHolderState = (string)$item->CardHolderState; + } + if (isset($item->CardHolderZip)) { + $summary->cardHolderZip = (string)$item->CardHolderZip; } } @@ -1454,6 +1516,14 @@ protected function hydrateTransactionSummary($item) $summary->convenienceAmount = (string)$item->ConvenienceAmtInfo; } + if (isset($item) && isset($item->CVVRsltCode)) { + $summary->cvnResponseCode = (string)$item->CVVRsltCode; + } + + if (isset($item) && isset($item->CVVRsltText)) { + $summary->cvnResponseMessage = (string)$item->CVVRsltText; + } + if (isset($item) && isset($item->DeviceId)) { $summary->deviceId = (string)$item->DeviceId; } @@ -1860,9 +1930,10 @@ protected function mapReportType(ReportBuilder $builder) { switch ($builder->reportType) { case ReportType::ACTIVITY: - case ReportType::TRANSACTION_DETAIL: case ReportType::FIND_TRANSACTIONS: return 'FindTransactions'; + case ReportType::TRANSACTION_DETAIL: + return 'ReportTxnDetail'; default: throw new UnsupportedTransactionException(); } diff --git a/src/Mapping/GpApiMapping.php b/src/Mapping/GpApiMapping.php index 94bd858a..f2a82f9c 100644 --- a/src/Mapping/GpApiMapping.php +++ b/src/Mapping/GpApiMapping.php @@ -297,7 +297,7 @@ public static function mapDisputeSummary($response) $summary = new DisputeSummary(); $summary->caseId = $response->id; $summary->caseIdTime = !empty($response->time_created) ? new \DateTime($response->time_created) : - (!empty($response->stage_time_created) ? $response->stage_time_created : ''); + (!empty($response->stage_time_created) ? new \DateTime($response->stage_time_created) : ''); $summary->caseStatus = $response->status; $summary->caseStage = $response->stage; $summary->caseAmount = StringUtils::toAmount($response->amount); diff --git a/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php b/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php index 9adc876b..46a246ef 100644 --- a/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php +++ b/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php @@ -85,6 +85,17 @@ public function testRefundOnCardPresentChipCard() $this->assertTransactionResponse($response, 'SUCCESS', TransactionStatus::CAPTURED); } + public function testCardPresentWithManualEntryModeTransaction() + { + $card = $this->initCreditCardData(); + + $response = $card->charge($this->amount) + ->withCurrency($this->currency) + ->execute(); + + $this->assertTransactionResponse($response, 'SUCCESS', TransactionStatus::CAPTURED); + } + public function testCreditVerification_CardPresent() { $card = $this->initCreditTrackData(); diff --git a/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php b/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php index 26fc5163..0574f97d 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php +++ b/test/Integration/Gateways/GpApiConnector/GpApi3DS2Test.php @@ -30,6 +30,8 @@ use GlobalPayments\Api\Utils\GenerationUtils; use GlobalPayments\Api\Entities\Enums\Secure3dStatus; use PHPUnit\Framework\TestCase; +use GlobalPayments\Api\Utils\Logging\Logger; +use GlobalPayments\Api\Utils\Logging\SampleRequestLogger; class GpApi3DS2Test extends TestCase { @@ -109,6 +111,7 @@ public function setUpConfig() $config->challengeNotificationUrl = 'https://ensi808o85za.x.pipedream.net/'; $config->methodNotificationUrl = 'https://ensi808o85za.x.pipedream.net/'; $config->merchantContactUrl = 'https://enp4qhvjseljg.x.pipedream.net/'; + $config->requestLogger = new SampleRequestLogger(new Logger("logs")); return $config; } @@ -1000,7 +1003,11 @@ public function testCardHolderEnrolled_ChallengeRequired_v2_Initiate_AllPreferen public function testCardHolderEnrolled_ChallengeRequired_v2_Initiate_AllSourceValues() { - $source = array(AuthenticationSource::BROWSER, AuthenticationSource::MERCHANT_INITIATED, AuthenticationSource::MOBILE_SDK); + $source = [ + AuthenticationSource::BROWSER, + AuthenticationSource::MERCHANT_INITIATED, + AuthenticationSource::MOBILE_SDK + ]; foreach ($source as $value) { $secureEcom = Secure3dService::checkEnrollment($this->card) ->withCurrency($this->currency) diff --git a/test/Integration/Gateways/GpApiConnector/GpApiBatchTests.php b/test/Integration/Gateways/GpApiConnector/GpApiBatchTests.php index cd9eb38b..0f9a3c96 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiBatchTests.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiBatchTests.php @@ -47,13 +47,14 @@ protected function setup() $this->creditCardData->expYear = date('Y', strtotime('+1 year')); $this->creditCardData->cvn = "123"; $this->creditCardData->cardHolderName = "James Mason"; + $this->creditCardData->cardPresent = true; } public function setUpConfig() { $config = new GpApiConfig(); - $config->appId = 'i872l4VgZRtSrykvSn8Lkah8RE1jihvT'; - $config->appKey = '9pArW2uWoA8enxKc'; + $config->appId = 'oDVjAddrXt3qPJVPqQvrmgqM2MjMoHQS'; + $config->appKey = 'DHUGdzpjXfTbjZeo'; $config->environment = Environment::TEST; $config->channel = Channel::CardPresent; // $config->requestLogger = new SampleRequestLogger(new Logger("logs")); @@ -102,7 +103,7 @@ public function testBatchClose_ChipTransaction() ->execute(); $this->assertTransactionResponse($transaction, TransactionStatus::CAPTURED); - sleep(1); + sleep(2); $batch = BatchService::closeBatch($transaction->batchSummary->batchReference); $this->assertBatchCloseResponse($batch, $this->amount); @@ -197,6 +198,8 @@ public function testBatchClose_WithIdempotency() $this->assertTransactionResponse($transaction, TransactionStatus::CAPTURED); + sleep(2); + $batch = (new ManagementBuilder(TransactionType::BATCH_CLOSE)) ->withBatchReference($transaction->batchSummary->batchReference) ->withIdempotencyKey($idempotencyKey) @@ -234,7 +237,7 @@ public function testBatchClose_WithCardNumberDetails() public function testBatchClose_WithCardNumberDetails_DeclinedTransaction() { - $this->creditCardData->cvn = "800"; + $this->creditCardData->number = "38865000000705"; $transaction = $this->creditCardData->charge($this->amount) ->withCurrency($this->currency) @@ -244,7 +247,7 @@ public function testBatchClose_WithCardNumberDetails_DeclinedTransaction() $this->assertEquals('DECLINED', $transaction->responseCode); $this->assertEquals(TransactionStatus::DECLINED, $transaction->responseMessage); - sleep(2); + sleep(3); $exceptionCaught = false; try { @@ -265,9 +268,13 @@ public function testBatchClose_WithClosedBatchReference() ->execute(); $this->assertTransactionResponse($transaction, TransactionStatus::CAPTURED); + sleep(2); + $batch = BatchService::closeBatch($transaction->batchSummary->batchReference); $this->assertBatchCloseResponse($batch, $this->amount); + sleep(2); + $exceptionCaught = false; try { BatchService::closeBatch($transaction->batchSummary->batchReference); @@ -348,27 +355,6 @@ public function testBatchClose_WithInvalidBatchReference() } } - public function testBatchClose_ActionNotAuthorized() - { - $transaction = $this->creditTrackData->charge($this->amount) - ->withCurrency($this->currency) - ->execute(); - $this->assertTransactionResponse($transaction, TransactionStatus::CAPTURED); - - sleep(2); - - $exceptionCaught = false; - try { - BatchService::closeBatch($transaction->batchSummary->batchReference); - } catch (GatewayException $e) { - $exceptionCaught = true; - $this->assertEquals('40212', $e->responseCode); - $this->assertEquals('Status Code: ACTION_NOT_AUTHORIZED - Permission not enabled to execute action', $e->getMessage()); - } finally { - $this->assertTrue($exceptionCaught); - } - } - private function assertBatchCloseResponse($batch, $amount) { $this->assertNotNull($batch); diff --git a/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php b/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php index 43ded9a5..4255b79c 100644 --- a/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php +++ b/test/Integration/Gateways/GpApiConnector/GpApiDigitalWalletTest.php @@ -27,9 +27,9 @@ public function setup() $this->card->expYear = date('Y', strtotime('+1 year')); $this->card->cardHolderName = "James Mason"; $this->googlePayToken = '{ - "signature": "MEUCIQDRwolbHgD116pBJDKEF2TG/l0KbTBErR9PNta9gHVDbwIgQlQZZLPd/5QRsz56w5xCPtzRa8yBzJRRc9ujw7iM/K4=", + "signature": "MEYCIQCOGbdnafdPhLr2oMjwsh9nIWb1bBHX6vpKKaaWQVXN3gIhALB3ps64qkerCacD3Lqh4AGRuFW2WO+VzplVohRsT/iu", "protocolVersion": "ECv1", - "signedMessage": "{\"encryptedMessage\":\"u8U1a6dijdpfA7Jxwi4sO19666Bwis2/spCFAAUEP+llEINKD6ZLWgg8bMuNavicX5Jps57lmhZXhkg0oHxCAdUyAdW2nJx00Q4x5tN+lRfajIHyXSp0E1+29F1OOgbtGqV5qW7yoRUq3rAJwqVYotC5YfCpdNe/SZZV+pIMzfBV8Tm2bl9X4IHYkjzhH55xz0zQkX0Y4uxNSNuybK4n5E3n9+9dKG2bXuklxcTNylFBwaThbJL944EU3qPG0gEH5tTloqaGlqk75qnZgph7MGIxcZmb60yJYu8fKfLvbab5ClbX/5J5Fx8j6UNpGF+c400FjkZZuWCdGCetjfl9RdPIAFM8cqKnWJDTmdqGyGe+xc3o0yrIAXmfgTNpBU/B5qLYn0PKfrPh8+1UUYbPChCmVI3n/MziYDu+y6YVucHiZikWRY9e/OraBBVIpfFoPGnq\",\"ephemeralPublicKey\":\"BK/aN903Xa7imoEEXi38nfkzkOnwBVQZ0MYw8D9QG9D2q6kKtzTgZVR3s03r0MXwPqwVPmx6aKid8y+alT9XCVo\\u003d\",\"tag\":\"AyMdTQznnVLDzZmp+jXz9JhagWAokb+7DEg61vbdNwo\\u003d\"}" + "signedMessage": "{\"encryptedMessage\":\"ye3wPMhj0U+B77nyQ1H7EvTWP5xbSAiJ9AXmhvCBZiDuU2hJfVe+q+PkYvzM0o0hGOg+7lzTuBo4jdM9ZSz2EblbN6hCt6Am+Mlfnqsw1vJ0r0Pf710mrmvEl8+6H0Grclb8Aes/73OPGbQgN17nPmgUw6Yv8toE2QkjpTIll8kwV800FLAZU7cQAJhrV7r/ouh4WuEN4g8A6P1yMVf16nbWqoU6KUWdS44eHs6fNwlICA9ezVOYkzdt18J6J8t97LBBcenHqH/pT4ynOD5qZWpYvkrkjqgm2EMfmtErQHCg+wNmQTa9hCQ1l5uI/KAeyeNAtZo/rvwtuIWZ+C7kyA9wWeiTNdCf0xK+iE1q6VZnPHdTb7464D3Z/r7lT6TCPOvkdklVY8T77wthRkguz/HvlwDBc2nodmhs6tnADfMwJ9BX33StEHcDWBYLvAF2nWbx\",\"ephemeralPublicKey\":\"BIelcOVaB1LudeTtBav5gS4tglEUf/UpM5dO01mJEmuJVUX4oAFbTB5YyfaKztVaRKC9HusZ+ydyp24Xjqd9x2s\\u003d\",\"tag\":\"dMS/Yh/W7w3BhwW3kM1BmSbc9DJtap3ILjtdH1sDg2c\\u003d\"}" }'; } diff --git a/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php b/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php index 1ee4ae7e..1514aaf0 100644 --- a/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php +++ b/test/Integration/Gateways/GpApiConnector/PartnershipModeTest.php @@ -1,31 +1,35 @@ baseConfig = $this->setUpConfig(); @@ -83,8 +89,8 @@ public function setup() public function setUpConfig() { $config = new GpApiConfig(); - $config->appId = 'oDVjAddrXt3qPJVPqQvrmgqM2MjMoHQS'; - $config->appKey = 'DHUGdzpjXfTbjZeo'; + $config->appId = 'zKxybfLqH7vAOtBQrApxD5AUpS3ITaPz'; + $config->appKey = 'GAMlgEojm6hxZTLI'; $config->environment = Environment::TEST; $config->channel = Channel::CardNotPresent; $config->requestLogger = new SampleRequestLogger(new Logger("logs")); @@ -94,8 +100,8 @@ public function setUpConfig() public function testCreditSaleWithPartnerMode() { - $this->markTestSkipped('Partner mode not enabled on this appId/appKey'); $merchants = ['MER_7e3e2c7df34f42819b3edee31022ee3f','MER_c4c0df11039c48a9b63701adeaa296c3']; + $address = new Address(); $address->streetAddress1 = "123 Main St."; $address->city = "Downtown"; @@ -123,14 +129,154 @@ public function testCreditSaleWithPartnerMode() } } + public function testCreditSaleRefundWithPartnerMode() + { + $config = clone($this->baseConfig); + $config->merchantId = $this->merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; + $configName = 'config_' . $this->merchantId; + ServicesContainer::configureService($config, $configName); + + $response = $this->card->charge(11) + ->withCurrency($this->currency) + ->withAddress($this->shippingAddress) + ->execute($configName); + + $this->assertNotNull($response); + $this->assertEquals('SUCCESS', $response->responseCode); + $this->assertEquals(TransactionStatus::CAPTURED, $response->responseMessage); + + $refundResponse = $response->refund(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($refundResponse); + $this->assertEquals('SUCCESS', $refundResponse->responseCode); + $this->assertEquals(TransactionStatus::CAPTURED, $refundResponse->responseMessage); + unset($config); + } + + public function testCreditRefundWithPartnerMode() + { + $config = clone($this->baseConfig); + $config->merchantId = $this->merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; + $configName = 'config_' . $this->merchantId; + ServicesContainer::configureService($config, $configName); + + $refundResponse = $this->card->refund(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($refundResponse); + $this->assertEquals('SUCCESS', $refundResponse->responseCode); + $this->assertEquals(TransactionStatus::CAPTURED, $refundResponse->responseMessage); + unset($config); + } + + public function testCreditAuthAndCaptureWithPartnerMode() + { + $config = clone($this->baseConfig); + $config->merchantId = $this->merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; + $configName = 'config_' . $this->merchantId; + ServicesContainer::configureService($config, $configName); + + $authResponse = $this->card->authorize(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($authResponse); + $this->assertEquals('SUCCESS', $authResponse->responseCode); + $this->assertEquals(TransactionStatus::PREAUTHORIZED, $authResponse->responseMessage); + + $captureResponse = $authResponse->capture(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($captureResponse); + $this->assertEquals('SUCCESS', $captureResponse->responseCode); + $this->assertEquals(TransactionStatus::CAPTURED, $captureResponse->responseMessage); + + unset($config); + } + + public function testCreditAuthAndReverseWithPartnerMode() + { + $config = clone($this->baseConfig); + $config->merchantId = $this->merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; + $configName = 'config_' . $this->merchantId; + ServicesContainer::configureService($config, $configName); + + $authResponse = $this->card->authorize(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($authResponse); + $this->assertEquals('SUCCESS', $authResponse->responseCode); + $this->assertEquals(TransactionStatus::PREAUTHORIZED, $authResponse->responseMessage); + + $reverseResponse = $authResponse->reverse(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($reverseResponse); + $this->assertEquals('SUCCESS', $reverseResponse->responseCode); + $this->assertEquals(TransactionStatus::REVERSED, $reverseResponse->responseMessage); + unset($config); + } + + public function testCreditReAuthWithPartnerMode() + { + $config = clone($this->baseConfig); + $config->merchantId = $this->merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; + $configName = 'config_' . $this->merchantId; + ServicesContainer::configureService($config, $configName); + + $authResponse = $this->card->authorize(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($authResponse); + $this->assertEquals('SUCCESS', $authResponse->responseCode); + $this->assertEquals(TransactionStatus::PREAUTHORIZED, $authResponse->responseMessage); + + $reverseResponse = $authResponse->reverse(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($reverseResponse); + $this->assertEquals('SUCCESS', $reverseResponse->responseCode); + $this->assertEquals(TransactionStatus::REVERSED, $reverseResponse->responseMessage); + + $reAuthResponse = $reverseResponse->reauthorized(11) + ->withCurrency($this->currency) + ->execute($configName); + + $this->assertNotNull($reAuthResponse); + $this->assertEquals('SUCCESS', $reAuthResponse->responseCode); + $this->assertEquals(TransactionStatus::REVERSED, $reAuthResponse->responseMessage); + unset($config); + } + public function testFullCycle3DSChallenge_v2_PartnerMode() { - $this->markTestSkipped('Partner mode not enabled on this appId/appKey'); $this->card->number = '4222000001227408'; - $merchantId = 'MER_7e3e2c7df34f42819b3edee31022ee3f'; $config = clone($this->baseConfig); - $config->merchantId = $merchantId; + $config->merchantId = $this->merchantId; $config->accessTokenInfo = new AccessTokenInfo(); $config->accessTokenInfo->accessToken = $this->accessToken; $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; @@ -138,7 +284,7 @@ public function testFullCycle3DSChallenge_v2_PartnerMode() $config->methodNotificationUrl = 'https://ensi808o85za.x.pipedream.net/'; $config->merchantContactUrl = 'https://enp4qhvjseljg.x.pipedream.net/'; - $configName = 'config_' . $merchantId; + $configName = 'config_' . $this->merchantId; ServicesContainer::configureService($config, $configName); $secureEcom = Secure3dService::checkEnrollment($this->card) @@ -188,16 +334,13 @@ public function testFullCycle3DSChallenge_v2_PartnerMode() public function testVerifyTokenizedPaymentMethodWithPartnerMode() { - $this->markTestSkipped('Partner mode not enabled on this appId/appKey'); - $merchantId = 'MER_7e3e2c7df34f42819b3edee31022ee3f'; - $config = clone($this->baseConfig); - $config->merchantId = $merchantId; + $config->merchantId = $this->merchantId; $config->accessTokenInfo = new AccessTokenInfo(); $config->accessTokenInfo->accessToken = $this->accessToken; $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; - $configName = 'config_' . $merchantId; + $configName = 'config_' . $this->merchantId; ServicesContainer::configureService($config, $configName); $response = $this->card->tokenize()->execute($configName); @@ -216,4 +359,82 @@ public function testVerifyTokenizedPaymentMethodWithPartnerMode() $this->assertEquals('SUCCESS', $response->responseCode); $this->assertEquals('VERIFIED', $response->responseMessage); } + + public function testCreditSaleWithPartnerMode_WrongMerchant() + { + $merchantId = 'MER_' . GenerationUtils::getGuid(); + + $config = clone($this->baseConfig); + $config->merchantId = $merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->transactionProcessingAccountName = 'transaction_processing'; + $configName = 'config_' . $merchantId; + ServicesContainer::configureService($config, $configName); + + $exceptionCaught = false; + try { + $this->card->charge(5) + ->withCurrency($this->currency) + ->execute($configName); + } catch (GatewayException $e) { + $exceptionCaught = true; + $this->assertEquals('40042', $e->responseCode); + $this->assertEquals('Status Code: INVALID_TRANSACTION_ACTION - Retrieve information about this transaction is not supported', $e->getMessage()); + } finally { + $this->assertTrue($exceptionCaught); + } + unset($config); + } + + public function testCreditSaleWithPartnerMode_MisConfiguration() + { + $config = clone($this->baseConfig); + $config->merchantId = $this->merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->transactionProcessingAccountName = 'tokenization'; + $configName = 'config_' . $this->merchantId; + ServicesContainer::configureService($config, $configName); + + $exceptionCaught = false; + try { + $this->card->charge(5) + ->withCurrency($this->currency) + ->execute($configName); + } catch (GatewayException $e) { + $exceptionCaught = true; + $this->assertEquals('40041', $e->responseCode); + $this->assertEquals('Status Code: INVALID_REQUEST_DATA - Merchant configuration does not exist for ,tokenization,US,CNP,EUR,CARD,AUTHORIZE', $e->getMessage()); + } finally { + $this->assertTrue($exceptionCaught); + } + unset($config); + } + + public function testCreditSaleWithPartnerMode_MissingAccountName() + { + $config = clone($this->baseConfig); + $config->merchantId = $this->merchantId; + $config->accessTokenInfo = new AccessTokenInfo(); + $config->accessTokenInfo->accessToken = $this->accessToken; + $config->accessTokenInfo->tokenizationAccountName = 'tokenization'; + $configName = 'config_' . $this->merchantId; + ServicesContainer::configureService($config, $configName); + + $exceptionCaught = false; + try { + $this->card->charge(5) + ->withCurrency($this->currency) + ->execute($configName); + } catch (GatewayException $e) { + $exceptionCaught = true; + $this->assertEquals('40007', $e->responseCode); + $this->assertEquals('Status Code: INVALID_REQUEST_DATA - Request expects the following conditionally mandatory fields account_id, account_name.', $e->getMessage()); + } finally { + $this->assertTrue($exceptionCaught); + } + unset($config); + } + } \ No newline at end of file diff --git a/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php b/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php index 243bdc6d..fc408e1f 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php @@ -18,6 +18,8 @@ use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\ServicesContainer; use PHPUnit\Framework\TestCase; +use GlobalPayments\Api\Utils\Logging\Logger; +use GlobalPayments\Api\Utils\Logging\SampleRequestLogger; class ReportingDisputesTest extends TestCase { @@ -34,6 +36,7 @@ public function setUpConfig() $config->appId = 'oDVjAddrXt3qPJVPqQvrmgqM2MjMoHQS'; $config->appKey = 'DHUGdzpjXfTbjZeo'; $config->environment = Environment::TEST; +// $config->requestLogger = new SampleRequestLogger(new Logger("logs")); return $config; } diff --git a/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php index b815c99b..544efc91 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.php @@ -549,8 +549,8 @@ public function testReportFindSettlementTransactions_FilterBy_Invalid_MerchantID ->andWith(DataServiceCriteria::MERCHANT_ID, $merchantID) ->execute(); } catch (GatewayException $e) { - $this->assertEquals('40100', $e->responseCode); - $this->assertEquals("Status Code: INVALID_REQUEST_DATA - Invalid Value provided in the input field - system.mid", $e->getMessage()); + $this->assertEquals('40090', $e->responseCode); + $this->assertEquals("Status Code: INVALID_REQUEST_DATA - system.mid value is invalid. Please check the format and data provided is correct", $e->getMessage()); } } diff --git a/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php index 2c3bb832..e35f17db 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.php @@ -137,36 +137,6 @@ public function testFindStoredPaymentMethod_By_Status() } } - public function testFindStoredPaymentMethod_By_CardNumberLastFour() - { - $cardNumberLastFour = '1112'; - $response = ReportingService::findStoredPaymentMethodsPaged(1, 10) - ->orderBy(StoredPaymentMethodSortProperty::TIME_CREATED, SortDirection::ASC) - ->where(SearchCriteria::CARD_NUMBER_LAST_FOUR, $cardNumberLastFour) - ->execute(); - - $this->assertNotNull($response); - $this->assertTrue(is_array($response->result)); - - /** @var StoredPaymentMethodSummary $rs */ - foreach ($response->result as $rs) { - $this->assertEquals($cardNumberLastFour, $rs->cardNumberLastFour); - } - } - - public function testFindStoredPaymentMethod_By_CardNumberLastFour0000() - { - $cardNumberLastFour = '0000'; - $response = ReportingService::findStoredPaymentMethodsPaged(1, 10) - ->orderBy(StoredPaymentMethodSortProperty::TIME_CREATED, SortDirection::ASC) - ->where(SearchCriteria::CARD_NUMBER_LAST_FOUR, $cardNumberLastFour) - ->execute(); - - $this->assertNotNull($response); - $this->assertTrue(is_array($response->result)); - $this->assertCount(0, $response->result); - } - public function testFindStoredPaymentMethod_By_Reference() { $reference = '5e3d3885-ceb3-a5ea-015c-945eaa4df8c8'; diff --git a/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php index def584b7..340fbac4 100644 --- a/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php +++ b/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php @@ -450,7 +450,7 @@ public function testReportFindTransactionsByEntryMode() $this->assertTrue(is_array($response->result)); /** @var TransactionSummary $rs */ foreach ($response->result as $rs) { - $this->assertEquals($value, $rs->entryMode); + $this->assertContains($value, $rs->entryMode); } } } diff --git a/test/Integration/Gateways/PorticoConnector/GiftTest.php b/test/Integration/Gateways/PorticoConnector/GiftTest.php index c89b6b7f..7c7b43a4 100644 --- a/test/Integration/Gateways/PorticoConnector/GiftTest.php +++ b/test/Integration/Gateways/PorticoConnector/GiftTest.php @@ -58,6 +58,19 @@ public function testGiftBalanceInquiry() $this->assertEquals('00', $response->responseCode); } + public function testGiftSaleSplitTender() + { + $card = new GiftCard(); + $card->number = "5022440000000000098"; + + $response = $card->charge("100000.00") + ->withCurrency("USD") + ->execute(); + + $this->assertNotNull($response->splitTenderBalanceDueAmt); + $this->assertNotNull($response->authorizedAmount); + } + public function testGiftSale() { $response = $this->card->charge(10) @@ -67,6 +80,7 @@ public function testGiftSale() $this->assertEquals('00', $response->responseCode); } + public function testGiftDeactivate() { $response = $this->card->deactivate() diff --git a/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php b/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php index 73dd9dcd..28249f77 100644 --- a/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php +++ b/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php @@ -294,4 +294,18 @@ public function testCreditOfflineSaleWithShippingAmount() $this->assertNotNull($report); $this->assertEquals('2', $report->shippingAmount); } + + public function testReportTransactionAvsCvvDetail() + { + $response = ReportingService::transactionDetail("1631054288") + ->execute(); + + $this->assertNotNull($response); + + $this->assertNotNull($response->avsResponseCode); + $this->assertNotNull($response->avsResponseMessage); + + $this->assertNotNull($response->cvnResponseCode); + $this->assertNotNull($response->cvnResponseMessage); + } }