Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions Helper/PaymentResponseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ public function __construct(

public function formatPaymentResponse(
string $resultCode,
array $action = null,
array $additionalData = null
array $action = null
): array {
switch ($resultCode) {
case self::AUTHORISED:
Expand All @@ -117,16 +116,11 @@ public function formatPaymentResponse(
"action" => $action
];
case self::PRESENT_TO_SHOPPER:
return [
"isFinal" => true,
"resultCode" => $resultCode,
"action" => $action
];
case self::RECEIVED:
return [
"isFinal" => true,
"resultCode" => $resultCode,
"additionalData" => $additionalData
"action" => $action
];
default:
return [
Expand Down
3 changes: 1 addition & 2 deletions Model/Api/AdyenOrderPaymentStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public function getOrderPaymentStatus(string $orderId): string

return json_encode($this->paymentResponseHandler->formatPaymentResponse(
$additionalInformation['resultCode'],
!empty($additionalInformation['action']) ? $additionalInformation['action'] : null,
!empty($additionalInformation['additionalData']) ? $additionalInformation['additionalData'] : null
!empty($additionalInformation['action']) ? $additionalInformation['action'] : null
));
}
}
7 changes: 3 additions & 4 deletions Test/Unit/Helper/PaymentResponseHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,15 @@ public function testFormatPaymentResponseForVoucherPayments()
public function testFormatPaymentResponseForOfflinePayments()
{
$resultCode = PaymentResponseHandler::RECEIVED;
$additionalData = ['action' => ['voucher']];

$action = ['type' => 'voucher'];
$expectedResult = [
"isFinal" => true,
"resultCode" => $resultCode,
"additionalData" => $additionalData
"action" => $action
];

// Execute method of the tested class
$result = $this->paymentResponseHandler->formatPaymentResponse($resultCode, null, $additionalData);
$result = $this->paymentResponseHandler->formatPaymentResponse($resultCode, $action);

// Assert conditions
$this->assertEquals($expectedResult, $result);
Expand Down
Loading