示例#1
0
 /**
  * Returns applicable stored cards
  * 
  * @return array
  */
 public function getStoredCards()
 {
     $storedCards = $this->vault->currentCustomerStoredCards();
     $country = $this->checkoutSession->getQuote()->getBillingAddress()->getCountryId();
     $cardTypes = $this->config->getApplicableCardTypes($country);
     $applicableCards = [];
     foreach ($storedCards as $card) {
         if (in_array($this->dataHelper->getCcTypeCodeByName($card->cardType), $cardTypes)) {
             $applicableCards[] = $card;
         }
     }
     return $applicableCards;
 }
示例#2
0
 /**
  * @param array $creditCardsArray
  * @param boolean $useVault
  * @param stdClass $braintreeCustomerObject
  * @dataProvider dataProviderCurrentCustomerStoredCards
  */
 public function testCurrentCustomerStoredCards($creditCardsArray = [], $useVault = false, $braintreeCustomerObject = null)
 {
     $customerId = 1;
     $this->configMock->expects($this->once())->method('useVault')->willReturn($useVault);
     $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn(true);
     $this->customerFactoryMock->expects($this->any())->method('create')->willReturn($this->customerMock);
     $this->helperMock->expects($this->any())->method('generateCustomerId')->willReturn($customerId);
     $this->customerMock->expects($this->any())->method('load')->willReturn($this->customerMock);
     if ($braintreeCustomerObject != null) {
         $this->braintreeCustomerMock->expects($this->any())->method('find')->with($customerId)->willReturn($braintreeCustomerObject);
     } else {
         $this->braintreeCustomerMock->expects($this->any())->method('find')->with($customerId)->willThrowException(new \Braintree_Exception());
     }
     $result = $this->model->currentCustomerStoredCards();
     $this->assertEquals($creditCardsArray, $result);
 }
示例#3
0
 /**
  * Retrieve current stored cards
  *
  * @return array
  */
 public function getCurrentCustomerStoredCards()
 {
     return $this->vault->currentCustomerStoredCards();
 }