From af2141b7e8899219cd2e1c8ec00ab3f96eec2c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20J=C3=B3=C5=BAwiak?= Date: Mon, 1 Apr 2019 18:20:47 +0200 Subject: [PATCH] Checking the company name Added check if there is empty name and surname but not empty company name, to avoid errors while creating transactions. --- Model/TpayCards.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Model/TpayCards.php b/Model/TpayCards.php index f9d97ff..c3e5d40 100644 --- a/Model/TpayCards.php +++ b/Model/TpayCards.php @@ -164,7 +164,10 @@ public function getTpayFormData($orderId = null) $billingAddress = $order->getBillingAddress(); $amount = number_format($order->getGrandTotal(), 2, '.', ''); $name = $billingAddress->getData('firstname') . ' ' . $billingAddress->getData('lastname'); - + $companyName = $billingAddress->getData('company'); + if (strlen($name) <= 3 && !empty($companyName) && strlen($companyName) > 3) { + $name = $companyName; + } $om = ObjectManager::getInstance(); $resolver = $om->get('Magento\Framework\Locale\Resolver'); $language = Validate::validateCardLanguage($resolver->getLocale()); @@ -185,7 +188,8 @@ public function getTpayFormData($orderId = null) } /** - * + * @param int $orderId + * @return \Magento\Sales\Api\Data\OrderInterface */ protected function getOrder($orderId = null) { @@ -314,7 +318,6 @@ public function refund(InfoInterface $payment, $amount) throw new Exception(__('Payment refunding error.')); } - return $this; }