/**
  * Check whether payment method is enabled
  *
  * @inheritdoc
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$this->config->isActive() || !$this->config->isDisplayShoppingCart()) {
         $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
         /** @var Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setPath('noRoute');
         return $resultRedirect;
     }
     return parent::dispatch($request);
 }
 /**
  * Run test getConfig method
  *
  * @param array $config
  * @param array $expected
  * @dataProvider getConfigDataProvider
  */
 public function testGetConfig($config, $expected)
 {
     $this->braintreeAdapter->expects(static::once())->method('generate')->willReturn(self::CLIENT_TOKEN);
     foreach ($config as $method => $value) {
         $this->config->expects(static::once())->method($method)->willReturn($value);
     }
     $this->payPalConfig->expects(static::once())->method('isActive')->willReturn(true);
     $this->payPalConfig->expects(static::once())->method('isAllowToEditShippingAddress')->willReturn(true);
     $this->payPalConfig->expects(static::once())->method('getMerchantName')->willReturn('Test');
     $this->payPalConfig->expects(static::once())->method('getTitle')->willReturn('Payment Title');
     $this->localeResolver->expects(static::once())->method('getLocale')->willReturn('en_US');
     static::assertEquals($expected, $this->configProvider->getConfig());
 }
 /**
  * @param array $details
  */
 private function updateBillingAddressStep(array $details)
 {
     $this->configMock->expects(self::once())->method('isRequiredBillingAddress')->willReturn(true);
     $this->updateAddressDataStep($this->billingAddressMock, $details['billingAddress']);
     $this->billingAddressMock->expects(self::once())->method('setLastname')->with($details['lastName']);
     $this->billingAddressMock->expects(self::once())->method('setFirstname')->with($details['firstName']);
     $this->billingAddressMock->expects(self::once())->method('setEmail')->with($details['email']);
 }
 /**
  * Update billing address
  *
  * @param Quote $quote
  * @param array $details
  * @return void
  */
 private function updateBillingAddress(Quote $quote, array $details)
 {
     $billingAddress = $quote->getBillingAddress();
     if ($this->config->isRequiredBillingAddress()) {
         $this->updateAddressData($billingAddress, $details['billingAddress']);
     } else {
         $this->updateAddressData($billingAddress, $details['shippingAddress']);
     }
     $billingAddress->setFirstname($details['firstName']);
     $billingAddress->setLastname($details['lastName']);
     $billingAddress->setEmail($details['email']);
 }
 /**
  * @return string
  */
 public function getMerchantName()
 {
     return $this->config->getMerchantName();
 }
 /**
  * Retrieve assoc array of checkout configuration
  *
  * @return array
  */
 public function getConfig()
 {
     $isPayPalActive = $this->payPalConfig->isActive();
     return ['payment' => [self::CODE => ['isActive' => $this->config->isActive(), 'isSingleUse' => !$isPayPalActive, 'clientToken' => $this->getClientToken(), 'ccTypesMapper' => $this->config->getCctypesMapper(), 'sdkUrl' => $this->config->getSdkUrl(), 'countrySpecificCardTypes' => $this->config->getCountrySpecificCardTypeConfig(), 'availableCardTypes' => $this->config->getAvailableCardTypes(), 'useCvv' => $this->config->isCvvEnabled(), 'environment' => $this->config->getEnvironment(), 'kountMerchantId' => $this->config->getKountMerchantId(), 'hasFraudProtection' => $this->config->hasFraudProtection(), 'merchantId' => $this->config->getMerchantId()], Config::CODE_3DSECURE => ['enabled' => $this->config->isVerify3DSecure(), 'thresholdAmount' => $this->config->getThresholdAmount(), 'specificCountries' => $this->config->get3DSecureSpecificCountries()], self::PAYPAL_CODE => ['isActive' => $isPayPalActive, 'title' => $this->payPalConfig->getTitle(), 'isAllowShippingAddressOverride' => $this->payPalConfig->isAllowToEditShippingAddress(), 'merchantName' => $this->payPalConfig->getMerchantName(), 'locale' => strtolower($this->localeResolver->getLocale()), 'paymentAcceptanceMarkSrc' => 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png']]];
 }