Commit 0ff6764b authored by GiorgosK's avatar GiorgosK

Modify controller to display regular page with message from bank

parent e377c47a
......@@ -3,6 +3,6 @@ commerce_winbank.payment_callback:
path: '/commerce_winbank/callback'
defaults:
_controller: '\Drupal\commerce_winbank\Controller\CallbackController::callback'
_title: 'Winbank Payment Controller'
_title: 'Winbank Payment'
requirements:
_permission: 'access content'
......@@ -41,8 +41,11 @@ class CallbackController extends ControllerBase {
* @return Response
*/
public function callback(Request $request) {
$this->processCallback($request);
return new Response();
$message = $this->processCallback($request);
return [
'#type' => 'markup',
'#markup' => $message,
];
}
......@@ -58,9 +61,10 @@ class CallbackController extends ControllerBase {
$hash = $this->calculateHash($request, $order_id, $ticket_result);
if( $hash !== $hashkey) {
$this->createPayment($order, $request, $ticket_result, "Unvalidated");
return;
return "Sorry we were not able to validate your payment";
}
$this->createPayment($order, $request, $ticket_result);
return $this->getDisplayMessage($request);
}
/**
......@@ -114,4 +118,36 @@ class CallbackController extends ControllerBase {
);
return hash_hmac('sha256', $concatValues, $ticket_result['TranTicket'], false);
}
/**
* Get message .
*
* @param $request
*
* @param $IssueNewTicketResult
*
* @return string
*/
public function getDisplayMessage($request) {
$message = $request->get('ResultDescription');
if (empty($message)) {
$messages = [
'00' => 'Completed successfully',
'08' => 'Completed successfully',
'10' => 'Completed successfully',
'16' => 'Completed successfully',
'11' => 'Transaction already processed',
'05' => 'Declined',
'12' => 'Declined',
'51' => 'Declined',
'34' => 'Lost card / Stolen card / Pick up',
'43' => 'Lost card / Stolen card / Pick up',
'54' => 'Expired card',
'62' => 'Restricted Card',
'92' => 'Declined',
];
$message = $messages[$request->get('ResponseCode')];
}
return $message;
}
}
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