You are here

protected function Square::mapCreditCardType in Commerce Square Connect 8

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

Parameters

string $card_type: The Square credit card type.

Return value

string The Commerce credit card type.

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

File

src/Plugin/Commerce/PaymentGateway/Square.php, line 463

Class

Square
Provides the Square payment gateway.

Namespace

Drupal\commerce_square\Plugin\Commerce\PaymentGateway

Code

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