getSupportedBrands() public method

Note: The fact that this class knows about a particular card brand does not imply that your gateway supports it.
See also: self::$supported_cards
public getSupportedBrands ( ) : array
return array
 /**
  * {@inheritdoc}
  */
 public function getConfigTreeBuilder()
 {
     $builder = new TreeBuilder();
     $rootNode = $builder->root('sylius_omnipay');
     $gateways = GatewayFactory::find();
     $omnipayCc = new CreditCard();
     $ccTypes = array_keys($omnipayCc->getSupportedBrands());
     $rootNode->children()->arrayNode('gateways')->useAttributeAsKey('name')->prototype('array')->children()->scalarNode('type')->validate()->ifTrue(function ($type) use($gateways) {
         if (empty($type)) {
             return true;
         }
         if (0 !== strpos($type, '\\') && !in_array($type, $gateways)) {
             return true;
         }
         return false;
     })->thenInvalid(sprintf('Unknown payment gateway selected. Valid gateways are: %s.', implode(", ", $gateways)))->end()->end()->scalarNode('label')->cannotBeEmpty()->end()->booleanNode('mode')->defaultFalse()->end()->booleanNode('active')->defaultTrue()->end()->arrayNode('cc_types')->prototype('scalar')->validate()->ifTrue(function ($ccType) use($ccTypes) {
         if (empty($ccType)) {
             return true;
         }
         if (!in_array($ccType, $ccTypes)) {
             return true;
         }
         return false;
     })->thenInvalid(sprintf('Unknown credit card type selected. Valid credit card types are: %s.', implode(", ", $ccTypes)))->end()->end()->end()->arrayNode('options')->prototype('scalar')->end()->end()->end()->end()->end();
     return $builder;
 }
Exemplo n.º 2
0
 public function testCustomBrandWorks()
 {
     $this->card->addSupportedBrand('omniexpress', '/^9\\d{12}(\\d{3})?$/');
     $this->assertArrayHasKey('omniexpress', $this->card->getSupportedBrands());
     $this->card->setNumber('9111111111111110');
     $this->card->validate();
     $this->assertEquals('omniexpress', $this->card->getBrand());
 }
 /**
  * Get a list of supported credit-card brands.
  * This doesn't depend on the
  * @return array
  */
 public function getCardTypes()
 {
     $card = new CreditCard();
     $brands = $card->getSupportedBrands();
     foreach ($brands as $brand => $x) {
         $brands[$brand] = _t('CreditCard.' . strtoupper($brand), $brand);
     }
     return $brands;
 }
Exemplo n.º 4
0
 public function testGetSupportedBrands()
 {
     $brands = $this->card->getSupportedBrands();
     $this->assertInternalType('array', $brands);
     $this->assertArrayHasKey(CreditCard::BRAND_VISA, $brands);
 }
Exemplo n.º 5
0
 public function testCustomBrandAddedTwiceReturnsFalse()
 {
     $this->assertTrue($this->card->addSupportedBrand('omniexpress', '/^9\\d{12}(\\d{3})?$/'));
     $this->assertArrayHasKey('omniexpress', $this->card->getSupportedBrands());
     $this->assertFalse($this->card->addSupportedBrand('omniexpress', '/^9\\d{12}(\\d{3})?$/'));
 }