Exemplo n.º 1
0
 /**
  * Retrieve available credit card types as associative array code & title
  *
  * @param string $country
  * @return array
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getCcAvailableCardTypes($country = null)
 {
     $types = array_flip(explode(',', $this->braintreeCcConfig->getConfigData('cctypes')));
     $mergedArray = [];
     if (is_array($types)) {
         foreach (array_keys($types) as $type) {
             $types[$type] = $this->getCcTypeNameByCode($type);
         }
     }
     //merge options then filter by a specific country
     $countrySpecificTypes = $this->braintreeCcConfig->getCountrySpecificCardTypeConfig();
     //include all country specific in types
     if (is_array($countrySpecificTypes)) {
         foreach ($countrySpecificTypes as $countryArray) {
             foreach ($countryArray as $ccType) {
                 $types[$ccType] = $this->getCcTypeNameByCode($ccType);
             }
         }
     }
     //preserve the same credit card order
     $allTypes = $this->getCcTypes();
     if (is_array($allTypes)) {
         foreach ($allTypes as $ccTypeCode => $ccTypeName) {
             if (array_key_exists($ccTypeCode, $types)) {
                 $mergedArray[$ccTypeCode] = $ccTypeName;
             }
         }
     }
     if ($country) {
         $countrySpecificTypesApplicable = $this->braintreeCcConfig->getApplicableCardTypes($country);
         if (!empty($countrySpecificTypesApplicable)) {
             foreach (array_keys($mergedArray) as $code) {
                 if (!in_array($code, $countrySpecificTypesApplicable)) {
                     unset($mergedArray[$code]);
                 }
             }
         }
     }
     return $mergedArray;
 }
Exemplo n.º 2
0
 /**
  * Get configuration data
  *
  * @param string $path
  * @return mixed
  */
 public function getConfigData($path)
 {
     return $this->config->getConfigData($path);
 }
Exemplo n.º 3
0
 /**
  * Retrieve information from payment configuration
  *
  * @param string $field
  * @param int|string|null|\Magento\Store\Model\Store $storeId
  *
  * @return mixed
  */
 public function getConfigData($field, $storeId = null)
 {
     if ('order_place_redirect_url' === $field) {
         return $this->getOrderPlaceRedirectUrl();
     }
     return $this->config->getConfigData($field, $storeId);
 }
Exemplo n.º 4
0
 /**
  * If it's configured to capture on each shipment
  * 
  * @return bool
  */
 protected function shouldInvoice()
 {
     $flag = $this->config->getConfigData(self::CONFIG_PATH_PAYMENT_ACTION) == \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE && $this->config->getConfigData(self::CONFIG_PATH_CAPTURE_ACTION) == PaymentMethod::CAPTURE_ON_SHIPMENT;
     return $flag;
 }