Skip to content

Commit

Permalink
NTR: PISHPW-214: Fix ajax response
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Mar 26, 2024
1 parent f214c90 commit c21e103
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
10 changes: 4 additions & 6 deletions Controllers/Frontend/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ public function notifyAction()
'success' => true,
'message' => 'The payment status for the order has been processed.'
];

echo json_encode($data, JSON_PRETTY_PRINT);
$this->View()->assign($data);
} catch (\Exception $e) {
$this->logger->error(
'Error in Mollie Notification',
Expand All @@ -413,11 +412,10 @@ public function notifyAction()
'message' => 'There was a problem. Please see the logs for more.'
];

http_response_code(500);
echo json_encode($data);
}

ob_end_flush();
$this->Response()->setHttpResponseCode(500);
$this->View()->assign($data);
}
}

/**
Expand Down
7 changes: 2 additions & 5 deletions Controllers/Frontend/MollieApplePayDirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ public function getShippingsAction()
'cart' => $formattedCart,
'shippingmethods' => $shippingMethods,
];

echo json_encode($data);
ob_end_flush();
$this->View()->assign($data);
} catch (\Exception $ex) {
$this->logger->error(
'Error loading shippings for Mollie Apple Pay Direct',
Expand All @@ -287,8 +285,7 @@ public function getShippingsAction()
'success' => false,
];

echo json_encode($data);
ob_end_flush();
$this->View()->assign($data);
}
}

Expand Down
8 changes: 2 additions & 6 deletions Traits/Controllers/BackendControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ protected function returnError($message)
protected function returnJson($data, $httpCode = 200)
{
if ($httpCode !== 200) {
http_response_code(intval($httpCode));
$this->Response()->setHttpResponseCode((int)$httpCode);
}

header('Content-Type: application/json');
echo json_encode($data);

ob_end_flush();
$this->View()->assign($data);
}
}

0 comments on commit c21e103

Please sign in to comment.