protected function HostedFields::mapCreditCardType in Commerce Braintree 8
Maps the Braintree credit card type to a Commerce credit card type.
Parameters
string $card_type: The Braintree credit card type.
Return value
string The Commerce credit card type.
1 call to HostedFields::mapCreditCardType()
- HostedFields::createPaymentMethod in src/
Plugin/ Commerce/ PaymentGateway/ HostedFields.php - Creates a payment method with the given payment details.
File
- src/
Plugin/ Commerce/ PaymentGateway/ HostedFields.php, line 524
Class
- HostedFields
- Provides the HostedFields payment gateway.
Namespace
Drupal\commerce_braintree\Plugin\Commerce\PaymentGatewayCode
protected function mapCreditCardType($card_type) {
$map = [
'American Express' => 'amex',
'China UnionPay' => 'unionpay',
'Diners Club' => 'dinersclub',
'Discover' => 'discover',
'JCB' => 'jcb',
'Maestro' => 'maestro',
'MasterCard' => 'mastercard',
'Visa' => 'visa',
];
if (!isset($map[$card_type])) {
throw new HardDeclineException(sprintf('Unsupported credit card type "%s".', $card_type));
}
return $map[$card_type];
}