You are here

protected function Stripe::mapCreditCardType in Commerce Stripe 8

Maps the Stripe credit card type to a Commerce credit card type.

Parameters

string $card_type: The Stripe credit card type.

Return value

string The Commerce credit card type.

1 call to Stripe::mapCreditCardType()
Stripe::createPaymentMethod in src/Plugin/Commerce/PaymentGateway/Stripe.php
Creates a payment method with the given payment details.

File

src/Plugin/Commerce/PaymentGateway/Stripe.php, line 548

Class

Stripe
Provides the Stripe payment gateway.

Namespace

Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway

Code

protected function mapCreditCardType($card_type) {
  $map = [
    'amex' => 'amex',
    'diners' => 'dinersclub',
    'discover' => 'discover',
    'jcb' => 'jcb',
    'mastercard' => 'mastercard',
    'visa' => 'visa',
    'unionpay' => 'unionpay',
  ];
  if (!isset($map[$card_type])) {
    throw new HardDeclineException(sprintf('Unsupported credit card type "%s".', $card_type));
  }
  return $map[$card_type];
}