public static function CreditCard::getType in Commerce Core 8.2
Gets the credit card type with the given ID.
Parameters
string $id: The credit card type ID. For example: 'visa'.
Return value
\Drupal\commerce_payment\CreditCardType The credit card type.
4 calls to CreditCard::getType()
- CreditCard::buildLabel in modules/
payment/ src/ Plugin/ Commerce/ PaymentMethodType/ CreditCard.php - Builds a label for the given payment method.
- CreditCardTest::testGetInvalidType in modules/
payment/ tests/ src/ Unit/ CreditCardTest.php - @covers ::getType
- CreditCardTest::testGetType in modules/
payment/ tests/ src/ Unit/ CreditCardTest.php - @covers ::getType
- CreditCardTest::testsValidateSecurityCode in modules/
payment/ tests/ src/ Unit/ CreditCardTest.php - @covers ::validateSecurityCode @dataProvider securityCodeProvider
File
- modules/
payment/ src/ CreditCard.php, line 28
Class
- CreditCard
- Provides logic for listing card types and validating card details.
Namespace
Drupal\commerce_paymentCode
public static function getType(string $id) : CreditCardType {
$types = self::getTypes();
if (!isset($types[$id])) {
throw new \InvalidArgumentException(sprintf('Invalid credit card type "%s"', $id));
}
return $types[$id];
}