Commit 6b876d10 authored by attilak's avatar attilak

Save additionalData and action and refactor handling payments response

Handling the action and additionalData storing processes easier
parent c6bdeeec
...@@ -71,24 +71,22 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -71,24 +71,22 @@ class CheckoutResponseValidator extends AbstractValidator
switch ($response['resultCode']) { switch ($response['resultCode']) {
case "ChallengeShopper": case "ChallengeShopper":
case "IdentifyShopper": case "IdentifyShopper":
$payment->setAdditionalInformation('action', $response['action']);
break;
case "Authorised": case "Authorised":
case "Received": case "Received":
// For banktransfers store all bankTransfer details case "PresentToShopper":
if (!empty($response['additionalData']['bankTransfer.owner'])) { // Store action for the payment to show it on the frontend as a component
foreach ($response['additionalData'] as $key => $value) { if (!empty($response['action'])) {
if (strpos($key, 'bankTransfer') === 0) { $payment->setAdditionalInformation('action', $response['action']);
$payment->setAdditionalInformation($key, $value); }
}
} // Store additionalData for the payment to show it on the frontend
} elseif (!empty($response['additionalData']['comprafacil.entity'])) { if (!empty($response['additionalData'])) {
//Multibanco resultCode has changed after checkout v49 and comprafacil.entity is not received anymore $payment->setAdditionalInformation('additionalData', $response['additionalData']);
foreach ($response['additionalData'] as $key => $value) { }
if (strpos($key, 'comprafacil') === 0) {
$payment->setAdditionalInformation($key, $value); // Store PSP reference if available
} if (!empty($response['pspReference'])) {
} $payment->setAdditionalInformation('pspReference', $response['pspReference']);
} }
// Save cc_type if available in the response // Save cc_type if available in the response
...@@ -97,15 +95,6 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -97,15 +95,6 @@ class CheckoutResponseValidator extends AbstractValidator
$payment->setAdditionalInformation('cc_type', $ccType); $payment->setAdditionalInformation('cc_type', $ccType);
$payment->setCcType($ccType); $payment->setCcType($ccType);
} }
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
break;
case "PresentToShopper":
if (!empty($response['action'])) {
$payment->setAdditionalInformation('action', $response['action']);
}
if (!empty($response['pspReference'])) {
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
}
break; break;
case "RedirectShopper": case "RedirectShopper":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment