diff --git a/CHANGELOG.md b/CHANGELOG.md index 692a33b3..56a42bae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,14 @@ # Changelog -## Latest Version - v11.0.6 (01/16/24) +## Latest Version - v11.0.7 (01/22/24) +### Enhancements: +- [GP-ECOM] Update parseResponse for HostedService + +#### Bug Fixes: +- [MEET-IN-THE-CLOUD][UPA] - Fix endOfDay + +## v11.0.6 (01/16/24) ### Enhancements: - [GP-API] Update QR code payment example for WeChat diff --git a/examples/gp-ecom/hpp/get-json.php b/examples/gp-ecom/hpp/get-json.php index 356af7bb..8f1737fd 100644 --- a/examples/gp-ecom/hpp/get-json.php +++ b/examples/gp-ecom/hpp/get-json.php @@ -21,14 +21,15 @@ // configure client, request and HPP settings $config = new GpEcomConfig(); -/* Credentials for OpenBanking HPP -$config->merchantId = "openbankingsandbox"; -$config->accountId = "internet"; -$config->sharedSecret = "sharedsecret"; -*/ +/* 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(); @@ -51,7 +52,7 @@ $hostedPaymentData->customerCountry = 'DE'; $hostedPaymentData->customerFirstName = 'James'; $hostedPaymentData->customerLastName = 'Mason'; -$baseUrl = 'https://ff6e-2a02-2f0e-5615-3300-b580-5acb-6bf-4b11.ngrok-free.app'; +$baseUrl = 'https://516b-2a02-2f0e-5e11-1500-3944-7324-2f8a-fbfd.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]; @@ -81,6 +82,13 @@ $hostedPaymentData->bankPayment = $bankPayment; try { + /* in case you want to test also a verify request you can use the example below + $hppJson = $service->verify() + ->withCurrency('EUR') + ->withHostedPaymentData($hostedPaymentData) + ->withAddress($billingAddress, AddressType::BILLING) + ->serialize(); + */ $hppJson = $service->charge(19.99) ->withCurrency("EUR") ->withHostedPaymentData($hostedPaymentData) diff --git a/metadata.xml b/metadata.xml index 8b735657..0ddddb94 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 11.0.6 + 11.0.7 \ No newline at end of file diff --git a/src/Services/HostedService.php b/src/Services/HostedService.php index 1315504a..486aeefa 100644 --- a/src/Services/HostedService.php +++ b/src/Services/HostedService.php @@ -136,8 +136,8 @@ public function parseResponse($response, $encoded = false) $response = $iterator->getArrayCopy(); } - - if (!isset($response['MERCHANT_RESPONSE_URL'])) { + $isApm = isset($response['paymentmethod']) || isset($response['PAYMENTMETHOD']); + if (isset($response['fundsstatus'])) { $response = $this->mapTransactionStatusResponse($response); } @@ -164,7 +164,7 @@ public function parseResponse($response, $encoded = false) $result, $message, $transactionId, - !isset($response['MERCHANT_RESPONSE_URL']) ? $paymentMethod :$authCode + isset($response['TRANSACTION_STATUS']) ? $paymentMethod : $authCode ]), $this->shaHashType ); @@ -176,7 +176,7 @@ public function parseResponse($response, $encoded = false) $ref = new TransactionReference(); $ref->authCode = $authCode; $ref->orderId = $orderId; - $ref->paymentMethodType = !empty($response['PAYMENTMETHOD']) ? PaymentMethodType::APM : PaymentMethodType::CREDIT; + $ref->paymentMethodType = $isApm ? PaymentMethodType::APM : PaymentMethodType::CREDIT; $ref->transactionId = $transactionId; $trans = new Transaction(); diff --git a/src/Terminals/DeviceMessage.php b/src/Terminals/DeviceMessage.php index 4d5bdc58..67236211 100644 --- a/src/Terminals/DeviceMessage.php +++ b/src/Terminals/DeviceMessage.php @@ -44,6 +44,9 @@ public function toString() public function getRequestField($key) { + if (!is_array($this->jsonRequest)) { + return; + } $value = null; array_walk_recursive($this->jsonRequest, function ($item, $k) use ($key, &$value) { if ($k === $key) { diff --git a/src/Terminals/TerminalUtils.php b/src/Terminals/TerminalUtils.php index cad05ab1..c30a760c 100644 --- a/src/Terminals/TerminalUtils.php +++ b/src/Terminals/TerminalUtils.php @@ -172,6 +172,8 @@ public static function buildUPAMessage($messageType, $requestId, $otherData = nu array_push($buffer, chr(ControlCodes::ETX)); array_push($buffer, chr(ControlCodes::LF)); - return new DeviceMessage($buffer); + $deviceMessage = new DeviceMessage($buffer); + $deviceMessage->setJsonRequest($requestMessage); + return $deviceMessage; } } diff --git a/test/Integration/Gateways/Terminals/UPA/UpaMicTests.php b/test/Integration/Gateways/Terminals/UPA/UpaMicTests.php index b5f5aca4..ef997c92 100644 --- a/test/Integration/Gateways/Terminals/UPA/UpaMicTests.php +++ b/test/Integration/Gateways/Terminals/UPA/UpaMicTests.php @@ -221,4 +221,13 @@ public function testCreditRefund_WithoutAmount() $this->assertTrue($exceptionCaught); } } + + public function testEndOfDay() + { + $response = $this->device->endOfDay(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->deviceResponseCode); + $this->assertEquals('INITIATED', $response->deviceResponseText); + } } \ No newline at end of file