From 606ddd1821b77fb8b5d121dec1a86126062fcb71 Mon Sep 17 00:00:00 2001 From: Zain ul abidin Date: Thu, 10 May 2018 12:48:52 +0930 Subject: [PATCH] cc_type: added support for cc_type --- Model/Payment.php | 1 + Model/Result.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Model/Payment.php b/Model/Payment.php index d16ea88..ca68349 100644 --- a/Model/Payment.php +++ b/Model/Payment.php @@ -433,6 +433,7 @@ protected function _handleResponse($response, $payment) if ($result->isSuccess()) { $payment->setCcTransId($result->getToken()); $payment->setTransactionId($result->getToken()); + $payment->setCcType($result->getCCType()); } elseif ($error) { throw new LocalizedException(__($result->getErrorDescription())); } diff --git a/Model/Result.php b/Model/Result.php index 5d0cea5..b55cfe0 100644 --- a/Model/Result.php +++ b/Model/Result.php @@ -67,6 +67,28 @@ public function getToken() return ''; } + /** + * @return string | null + */ + public function getCCType() + { + $oCard = $this->getResponseValue('card'); + return (isset($oCard->scheme)) ? $oCard->scheme : null; + } + + /** + * @param $vKey + * + * @return mixed + */ + protected function getResponseValue($vKey) + { + if (!isset($this->_response) || (!isset($this->_response->response)) || (!isset($this->_response->response->$vKey))){ + return null; + } + return $this->_response->response->$vKey; + } + /** * @return null | string */