/** * Returns customer credit cards if applicable * * @return \Braintree_Customer|boolean */ public function getLoggedInCustomerCards() { $applicableCards = []; $useVault = (bool) (int) $this->scopeConfig->getValue(self::CONFIG_PATH_VAULT, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $this->sessionQuote->getStoreId()); if ($useVault) { $storedCards = false; if ($this->sessionQuote->getCustomerId()) { $customerId = $this->paymentHelper->generateCustomerId($this->sessionQuote->getCustomerId(), $this->sessionQuote->getQuote()->getCustomerEmail()); try { $storedCards = $this->braintreeCustomerAdapter->find($customerId)->creditCards; } catch (\Braintree_Exception $e) { $this->_logger->critical($e); } } if ($storedCards) { $country = $this->sessionQuote->getQuote()->getBillingAddress()->getCountryId(); $cardTypes = $this->paymentHelper->getCcAvailableCardTypes($country); $applicableCards = []; foreach ($storedCards as $card) { if (isset($cardTypes[$this->paymentHelper->getCcTypeCodeByName($card->cardType)])) { $applicableCards[] = $card; } } } } return $applicableCards; }
/** * @param array $data * @param array $expected * @dataProvider getCcAvailableCardTypesDataProvider */ public function testGetCcAvailableCardTypes($data, $expected) { $this->braintreeCcConfig->expects($this->any())->method('getConfigData')->willReturn($data['cctypes']); $this->braintreeCcConfig->expects($this->any())->method('getCountrySpecificCardTypeConfig')->willReturn($data['cctypesCountrySpecific']); $this->braintreeCcConfig->expects($this->any())->method('getApplicableCardTypes')->willReturn($data['applicableCards']); $this->paymentConfig->expects($this->any())->method('getCcTypes')->willReturn($data['ccTypes']); $result = $this->model->getCcAvailableCardTypes($data['country']); $this->assertEquals($expected, $result); }
/** * Retrieve available credit card types * * @return array */ protected function getCcAvailableCcTypes() { $country = $this->checkoutSession->getQuote()->getBillingAddress()->getCountryId(); return $this->dataHelper->getCcAvailableCardTypes($country); }
/** * Retrieve available credit card types * * @return array */ public function getCcAvailableTypes() { return $this->dataHelper->getCcAvailableCardTypes(); }
/** * Retrieve available credit card types * * @return array */ protected function getCcAvailableCcTypes() { return $this->dataHelper->getCcAvailableCardTypes(); }