示例#1
0
 public function testIsSatisfiedBy()
 {
     $paymentMethodCode = 'test';
     $this->configMock->expects($this->once())->method('getMethodsInfo')->will($this->returnValue(array($paymentMethodCode => array(\Magento\RecurringPayment\Model\Method\RecurringPaymentSpecification::CONFIG_KEY => 1))));
     $this->recurringPaymentSpecification = $this->objectManagerHelper->getObject('Magento\\RecurringPayment\\Model\\Method\\RecurringPaymentSpecification', array('paymentConfig' => $this->configMock));
     $this->assertTrue($this->recurringPaymentSpecification->isSatisfiedBy($paymentMethodCode));
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function toOptionArray()
 {
     $options = [];
     foreach ($this->_paymentConfig->getCcTypes() as $code => $name) {
         $options[] = ['value' => $code, 'label' => $name];
     }
     return $options;
 }
示例#3
0
 /**
  * @covers \Magento\Braintree\Block\Form::getCcAvailableTypes
  * @param string $countryId
  * @param array $availableTypes
  * @param array $expected
  * @dataProvider countryCardTypesDataProvider
  */
 public function testGetCcAvailableTypes($countryId, array $availableTypes, array $expected)
 {
     $this->sessionQuote->expects(static::once())->method('getCountryId')->willReturn($countryId);
     $this->gatewayConfig->expects(static::once())->method('getAvailableCardTypes')->willReturn(self::$configCardTypes);
     $this->gatewayConfig->expects(static::once())->method('getCountryAvailableCardTypes')->with($countryId)->willReturn($availableTypes);
     $result = $this->block->getCcAvailableTypes();
     static::assertEquals($expected, array_values($result));
 }
 /**
  * Test isSatisfiedBy method
  *
  * @param array $methodsInfo
  * @param bool $result
  * @dataProvider methodsDataProvider
  */
 public function testIsSatisfiedBy($methodsInfo, $result)
 {
     $method = 'method-name';
     $methodsInfo = [$method => $methodsInfo];
     $this->paymentConfigMock->expects($this->once())->method('getMethodsInfo')->will($this->returnValue($methodsInfo));
     $configSpecification = $this->objectManager->getObject('Magento\\Multishipping\\Model\\Payment\\Method\\Specification\\Enabled', ['paymentConfig' => $this->paymentConfigMock]);
     $this->assertEquals($result, $configSpecification->isSatisfiedBy($method), sprintf('Failed payment method test: "%s"', $method));
 }
示例#5
0
 /**
  * @dataProvider getCcTypeNameDataProvider
  */
 public function testGetCcTypeName($configCcTypes, $ccType, $expected)
 {
     $this->paymentConfig->expects($this->any())->method('getCcTypes')->will($this->returnValue($configCcTypes));
     $paymentInfo = $this->getMock('Magento\\Payment\\Model\\Info', ['getCcType'], [], '', false);
     $paymentInfo->expects($this->any())->method('getCcType')->will($this->returnValue($ccType));
     $this->model->setData('info', $paymentInfo);
     $this->assertEquals($expected, $this->model->getCcTypeName());
 }
示例#6
0
文件: Cc.php 项目: nja78/magento2
 /**
  * Retrieve credit card type name
  *
  * @return string
  */
 public function getCcTypeName()
 {
     $types = $this->_paymentConfig->getCcTypes();
     $ccType = $this->getInfo()->getCcType();
     if (isset($types[$ccType])) {
         return $types[$ccType];
     }
     return empty($ccType) ? __('N/A') : $ccType;
 }
示例#7
0
 /**
  * Test isSatisfiedBy method
  *
  * @param array $methodsInfo
  * @param bool $is3DSecureEnabled
  * @param bool $result
  * @dataProvider methodsDataProvider
  */
 public function testIsSatisfiedBy($methodsInfo, $is3DSecureEnabled, $result)
 {
     $method = 'method-name';
     $methodsInfo = array($method => $methodsInfo);
     $this->paymentConfigMock->expects($this->once())->method('getMethodsInfo')->will($this->returnValue($methodsInfo));
     $this->scopeConfigMock->expects($this->any())->method('isSetFlag')->will($this->returnValue($is3DSecureEnabled));
     $configSpecification = $this->objectManager->getObject('Magento\\Multishipping\\Model\\Payment\\Method\\Specification\\Is3DSecure', array('paymentConfig' => $this->paymentConfigMock, 'scopeConfig' => $this->scopeConfigMock));
     $this->assertEquals($result, $configSpecification->isSatisfiedBy($method), sprintf('Failed payment method test: "%s"', $method));
 }
示例#8
0
 /**
  * Return credit cart type
  * 
  * @return string
  */
 protected function getCcTypeName()
 {
     $types = $this->paymentConfig->getCcTypes();
     $ccType = $this->getInfo()->getCcType();
     if (isset($types[$ccType])) {
         return $types[$ccType];
     } else {
         return __('Stored Card');
     }
 }
示例#9
0
 /**
  * Retrieve credit card expire years
  *
  * @return array
  */
 public function getCcYears()
 {
     $years = $this->getData('cc_years');
     if ($years === null) {
         $years = $this->_paymentConfig->getYears();
         $years = [0 => __('Year')] + $years;
         $this->setData('cc_years', $years);
     }
     return $years;
 }
 public function testUpdateOrderStatusForPaymentMethodsNewState()
 {
     $this->_prepareEventMockWithMethods(['getState', 'getStatus']);
     $this->eventMock->expects($this->once())->method('getState')->will($this->returnValue(\Magento\Sales\Model\Order::STATE_NEW));
     $this->eventMock->expects($this->once())->method('getStatus')->will($this->returnValue(self::ORDER_STATUS));
     $defaultStatus = 'defaultStatus';
     $this->orderConfigMock->expects($this->once())->method('getStateDefaultStatus')->with(\Magento\Sales\Model\Order::STATE_NEW)->will($this->returnValue($defaultStatus));
     $this->paymentConfigMock->expects($this->once())->method('getActiveMethods')->will($this->returnValue($this->_getPreparedActiveMethods()));
     $this->coreResourceConfigMock->expects($this->once())->method('saveConfig')->with('payment/' . self::METHOD_CODE . '/order_status', $defaultStatus, 'default', 0);
     $this->updateOrderStatusForPaymentMethodsObserver->execute($this->observerMock);
 }
示例#11
0
 /**
  * {@inheritdoc}
  */
 public function toOptionArray()
 {
     /**
      * making filter by allowed cards
      */
     $allowed = $this->getAllowedTypes();
     $options = [];
     foreach ($this->_paymentConfig->getCcTypes() as $code => $name) {
         if (in_array($code, $allowed) || !count($allowed)) {
             $options[] = ['value' => $code, 'label' => $name];
         }
     }
     return $options;
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($observer->getEvent()->getState() != \Magento\Sales\Model\Order::STATE_NEW) {
         return;
     }
     $status = $observer->getEvent()->getStatus();
     $defaultStatus = $this->_salesOrderConfig->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_NEW);
     $methods = $this->_paymentConfig->getActiveMethods();
     foreach ($methods as $method) {
         if ($method->getConfigData('order_status') == $status) {
             $this->_resourceConfig->saveConfig('payment/' . $method->getCode() . '/order_status', $defaultStatus, 'default', 0);
         }
     }
 }
 public function testGetCcYear()
 {
     $year = [2015 => 2015, 2016 => 2016];
     $expected = [0 => new \Magento\Framework\Phrase('Year'), 2015 => 2015, 2016 => 2016];
     $this->paymentConfigMock->expects($this->once())->method('getYears')->willReturn($year);
     $this->assertEquals($expected, $this->block->getCcYears());
 }
示例#14
0
 /**
  * @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);
 }
示例#15
0
 /**
  * Finds all credit card types using global payments config
  *
  * @return mixed
  */
 public function getCcTypes()
 {
     $ccTypes = $this->paymentConfig->getCcTypes();
     if (is_array($ccTypes)) {
         return $ccTypes;
     } else {
         return false;
     }
 }
示例#16
0
文件: Cc.php 项目: aiesh/magento2
 /**
  * Retrieve credit card expire years
  *
  * @return array
  */
 public function getCcYears()
 {
     $years = $this->getData('cc_years');
     if (is_null($years)) {
         $years = $this->_paymentConfig->getYears();
         $years = array(0 => __('Year')) + $years;
         $this->setData('cc_years', $years);
     }
     return $years;
 }
 /**
  * Filter card types for specific country
  * @param array $configCardTypes
  * @param string $countryId
  * @return array
  */
 private function filterCardTypesForCountry(array $configCardTypes, $countryId)
 {
     $filtered = $configCardTypes;
     $countryCardTypes = $this->gatewayConfig->getCountryAvailableCardTypes($countryId);
     // filter card types only if specific card types are set for country
     if (!empty($countryCardTypes)) {
         $availableTypes = array_fill_keys($countryCardTypes, '');
         $filtered = array_intersect_key($filtered, $availableTypes);
     }
     return $filtered;
 }
示例#18
0
 /**
  * Retrieve all payment methods list as an array
  *
  * Possible output:
  * 1) assoc array as <code> => <title>
  * 2) array of array('label' => <title>, 'value' => <code>)
  * 3) array of array(
  *                 array('value' => <code>, 'label' => <title>),
  *                 array('value' => array(
  *                     'value' => array(array(<code1> => <title1>, <code2> =>...),
  *                     'label' => <group name>
  *                 )),
  *                 array('value' => <code>, 'label' => <title>),
  *                 ...
  *             )
  *
  * @param bool $sorted
  * @param bool $asLabelValue
  * @param bool $withGroups
  * @param Store|null $store
  * @return array
  */
 public function getPaymentMethodList($sorted = true, $asLabelValue = false, $withGroups = false, $store = null)
 {
     $methods = array();
     $groups = array();
     $groupRelations = array();
     foreach ($this->getPaymentMethods() as $code => $data) {
         if (isset($data['title'])) {
             $methods[$code] = $data['title'];
         } else {
             if ($this->getMethodInstance($code)) {
                 $methods[$code] = $this->getMethodInstance($code)->getConfigData('title', $store);
             }
         }
         if ($asLabelValue && $withGroups && isset($data['group'])) {
             $groupRelations[$code] = $data['group'];
         }
     }
     if ($asLabelValue && $withGroups) {
         $groups = $this->_paymentConfig->getGroups();
         foreach ($groups as $code => $title) {
             $methods[$code] = $title;
         }
     }
     if ($sorted) {
         asort($methods);
     }
     if ($asLabelValue) {
         $labelValues = array();
         foreach ($methods as $code => $title) {
             $labelValues[$code] = array();
         }
         foreach ($methods as $code => $title) {
             if (isset($groups[$code])) {
                 $labelValues[$code]['label'] = $title;
             } elseif (isset($groupRelations[$code])) {
                 unset($labelValues[$code]);
                 $labelValues[$groupRelations[$code]]['value'][$code] = array('value' => $code, 'label' => $title);
             } else {
                 $labelValues[$code] = array('value' => $code, 'label' => $title);
             }
         }
         return $labelValues;
     }
     return $methods;
 }
示例#19
0
 /**
  * @param \Magento\Framework\DataObject $postObject
  *
  * @return bool
  * @throws \Exception
  */
 public function sendrequest($postObject)
 {
     if (!filter_var($postObject->getData('to'), FILTER_VALIDATE_EMAIL)) {
         throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address.'));
     }
     if (strlen(trim($postObject->getData('replyto')))) {
         if (!filter_var($postObject->getData('replyto'), FILTER_VALIDATE_EMAIL)) {
             throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address (reply to).'));
         }
         $this->_transportBuilder->setReplyTo(trim($postObject->getData('replyto')));
     }
     $sender = ['name' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/name'), 'email' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/email')];
     if (!strlen($sender['email'])) {
         throw new \Exception('Please set your shop e-mail address!');
     }
     $modules = [];
     foreach ($this->_moduleLoader->load() as $module) {
         if (!in_array($module['name'], $this->_moduleBlacklist)) {
             $modules[] = $module['name'];
         }
     }
     natsort($modules);
     $payments = $this->_paymentConfig->getActiveMethods();
     /** @var \Magento\Framework\App\Config\Data $cfg */
     $cfg = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     $foreign = array();
     $mine = array();
     foreach ($payments as $paymentCode => $paymentModel) {
         /** @var AbstractPayment $paymentModel */
         $method = array('label' => $paymentModel->getTitle(), 'value' => $paymentCode, 'config' => []);
         if (preg_match('/^wirecard_/i', $paymentCode)) {
             $method['config'] = $cfg->getValue('payment/' . $paymentCode);
             $mine[$paymentCode] = $method;
         } else {
             $foreign[$paymentCode] = $method;
         }
     }
     $versioninfo = new \Magento\Framework\DataObject();
     $versioninfo->setData($this->_dataHelper->getVersionInfo());
     $transport = $this->_transportBuilder->setTemplateIdentifier('contact_support_email')->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_ADMINHTML, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject, 'modules' => $modules, 'foreign' => $foreign, 'mine' => $mine, 'configstr' => $this->_dataHelper->getConfigString(), 'versioninfo' => $versioninfo])->setFrom($sender)->addTo($postObject->getData('to'))->getTransport();
     $transport->sendMessage();
     return true;
 }
 public function testGetCcYears()
 {
     $data = [1, 2, 3];
     $this->configMock->expects($this->once())->method('getYears')->willReturn($data);
     $this->assertEquals($data, $this->model->getCcYears());
 }
示例#21
0
 public function testGetYears()
 {
     $this->date->expects($this->once())->method('date')->with('Y')->will($this->returnValue(self::CURRENT_YEAR));
     $this->assertEquals($this->_getPreparedYearsList(), $this->config->getYears());
 }
 /**
  * Construct
  *
  * @param PaymentConfig $paymentConfig
  */
 public function __construct(PaymentConfig $paymentConfig)
 {
     $this->methodsInfo = $paymentConfig->getMethodsInfo();
 }
示例#23
0
文件: Config.php 项目: aiesh/magento2
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory
  * @param \Magento\Framework\Locale\ListsInterface $localeLists
  * @param \Magento\Framework\Config\DataInterface $dataStorage
  * @param \Magento\Framework\Stdlib\DateTime\DateTime $date
  * @param \Magento\Framework\UrlInterface $urlBuilder
  * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, \Magento\Framework\Locale\ListsInterface $localeLists, \Magento\Framework\Config\DataInterface $dataStorage, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor)
 {
     parent::__construct($scopeConfig, $paymentMethodFactory, $localeLists, $dataStorage, $date);
     $this->_urlBuilder = $urlBuilder;
     $this->_encryptor = $encryptor;
 }
示例#24
0
 public function testGetGroups()
 {
     $expected = array('any_payment' => 'Any Payment Methods', 'offline' => 'Offline Payment Methods');
     $groups = $this->_model->getGroups();
     $this->assertEquals($expected, $groups);
 }
示例#25
0
 /**
  * Retrieve credit card expire years
  *
  * @return array
  */
 public function getCcYears()
 {
     return $this->config->getYears();
 }