Skip to content

Commit

Permalink
[ECP-9408] Fix response collection array parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sushmita committed Sep 5, 2024
1 parent b493dd0 commit 0a6e08e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Gateway/Http/Client/TransactionPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,15 @@ public function placeRequest(TransferInterface $transferObject): array

$client = $this->adyenHelper->initializeAdyenClientWithClientConfig($clientConfig);
$service = $this->adyenHelper->initializePaymentsApi($client);

$responseCollection = [];
$responseCollection['hasOnlyGiftCards'] = false;

try {
list($requestData, $responseCollection) = $this->processGiftcards($requestData, $service);
$responseCollection['hasOnlyGiftCards'] = false;
list($requestData, $giftcardResponseCollection) = $this->processGiftcards($requestData, $service);

/** @var array $responseCollection */
if (!empty($responseCollection)) {
if (!empty($giftcardResponseCollection)) {
$responseCollection = $giftcardResponseCollection;

if ($this->remainingOrderAmount === 0) {
$responseCollection['hasOnlyGiftCards'] = true;
Expand Down
5 changes: 4 additions & 1 deletion Gateway/Validator/CheckoutResponseValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ public function validate(array $validationSubject): ResultInterface
// Assign the remaining items to $commandSubject
$commandSubject = $validationSubject;

if(empty($responseCollection)) {
if (empty($responseCollection)) {
throw new ValidatorException(__("No responses were provided"));
}

// hasOnlyGiftCards is needed later but cannot be processed as a response
unset($responseCollection['hasOnlyGiftCards']);
foreach ($responseCollection as $thisResponse) {

$responseSubject = array_merge($commandSubject, ['response' => $thisResponse]);
$this->validateResponse($responseSubject);
}
Expand Down

0 comments on commit 0a6e08e

Please sign in to comment.