Skip to content

Commit

Permalink
Merge pull request #196 from bold-commerce/Q1-688
Browse files Browse the repository at this point in the history
Q1-688: Empty payment forms during Checkout.
  • Loading branch information
nmalevanec authored Dec 18, 2023
2 parents e0fcebb + da36e91 commit c2a462e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Model/Payment/Gateway/Config/TitleValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Bold\Checkout\Model\ConfigInterface;
use Magento\Payment\Gateway\Config\ValueHandlerInterface;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Store\Model\StoreManagerInterface;

/**
Expand Down Expand Up @@ -37,16 +38,30 @@ public function __construct(ConfigInterface $config, StoreManagerInterface $stor
*/
public function handle(array $subject, $storeId = null)
{
/** @var PaymentDataObject $paymentObject */
$paymentObject = $subject['payment'] ?? null;
$websiteId = (int)$this->storeManager->getWebsite()->getId();
if (!$paymentObject || !$paymentObject->getPayment()) {
if (!$websiteId) {
$store = $this->storeManager->getDefaultStoreView();
$websiteId = (int)$store->getWebsiteId();
}

return $this->config->getPaymentTitle($websiteId);
}
$ccLast4 = $paymentObject->getPayment()->getCcLast4();
$ccType = $paymentObject->getPayment()->getCcType();
if (!$ccLast4 || !$ccType) {
if (!$websiteId) {
$orderAdapter = $paymentObject->getOrder();
$storeId = $orderAdapter->getStoreId();
$store = $this->storeManager->getStore($storeId);
$websiteId = (int)$store->getWebsiteId();
}

return $this->config->getPaymentTitle($websiteId);
}

return strlen($ccLast4) === 4
? $ccType . ': ending in ' . $ccLast4
: $ccType . ': ' . $ccLast4;
Expand Down

0 comments on commit c2a462e

Please sign in to comment.