Skip to content

Commit

Permalink
[ECP-8945] Write unit test for Data Helper (#2614)
Browse files Browse the repository at this point in the history
* [ECP-8945] Write unit test for Data Helper

* [ECP-8945] Write unit test for Data Helper

* [ECP-8945] Write unit test for Data Helper

* [ECP-8945] Write unit test for Data Helper - Adding few more test

* [ECP-8945] Write unit test for Data Helper - Adding few more test

* [ECP-8945] Do not send null if no header info is provided for frontend type

* [ECP-8945] Do not send null if no header info is provided for frontend type

* [ECP-8945] Updating test for last commit
  • Loading branch information
khushboo-singhvi authored May 17, 2024
1 parent fc37801 commit da8060e
Show file tree
Hide file tree
Showing 2 changed files with 1,123 additions and 101 deletions.
19 changes: 7 additions & 12 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,20 +419,14 @@ public function originalAmount($amount, $currency)
return ($amount / $format);
}







/**
* Retrieve decrypted hmac key
*
* @return string
*/
public function getHmac($storeId = null)
{
switch ($this->isDemoMode($storeId)) {
switch ($this->configHelper->isDemoMode($storeId)) {
case true:
$hmacTest = $this->configHelper->getAdyenHppConfigData('hmac_test', $storeId);
if (is_null($hmacTest)) {
Expand Down Expand Up @@ -477,7 +471,7 @@ public function isMotoDemoMode(array $motoMerchantAccountProperties): bool
*/
public function getAPIKey($storeId = null)
{
if ($this->isDemoMode($storeId)) {
if ($this->configHelper->isDemoMode($storeId)) {
$encryptedApiKeyTest = $this->configHelper->getAdyenAbstractConfigData('api_key_test', $storeId);
if (is_null($encryptedApiKeyTest)) {
return null;
Expand All @@ -502,7 +496,7 @@ public function getAPIKey($storeId = null)
public function getClientKey($storeId = null)
{
$clientKey = $this->configHelper->getAdyenAbstractConfigData(
$this->isDemoMode($storeId) ? 'client_key_test' : 'client_key_live',
$this->configHelper->isDemoMode($storeId) ? 'client_key_test' : 'client_key_live',
$storeId
);

Expand All @@ -521,7 +515,7 @@ public function getClientKey($storeId = null)
*/
public function getWsUsername($storeId = null)
{
if ($this->isDemoMode($storeId)) {
if ($this->configHelper->isDemoMode($storeId)) {
$wsUsernameTest = $this->configHelper->getAdyenAbstractConfigData('ws_username_test', $storeId);
if (is_null($wsUsernameTest)) {
return null;
Expand Down Expand Up @@ -1180,7 +1174,8 @@ public function buildRequestHeaders($payment = null)
];

if(isset($payment) && !is_null($payment->getAdditionalInformation(HeaderDataBuilder::FRONTENDTYPE))) {
$headers[HeaderDataBuilder::FRONTENDTYPE] = $payment->getAdditionalInformation(HeaderDataBuilder::FRONTENDTYPE);
$headers[HeaderDataBuilder::FRONTENDTYPE] =
$payment->getAdditionalInformation(HeaderDataBuilder::FRONTENDTYPE);
}

return $headers;
Expand Down Expand Up @@ -1500,7 +1495,7 @@ public function logRequest(array $request, $apiVersion, $endpoint)
if ($isDemo) {
$context['body'] = $request;
} else {
$context['livePrefix'] = $this->getLiveEndpointPrefix($storeId);
$context['livePrefix'] = $this->configHelper->getLiveEndpointPrefix($storeId);
$context['body'] = $this->filterReferences($request);
}

Expand Down
Loading

0 comments on commit da8060e

Please sign in to comment.