You are here

public function CreditCard::buildLabel in Commerce Core 8.2

Builds a label for the given payment method.

Parameters

\Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method: The payment method.

Return value

string The label.

Overrides PaymentMethodTypeInterface::buildLabel

File

modules/payment/src/Plugin/Commerce/PaymentMethodType/CreditCard.php, line 22

Class

CreditCard
Provides the credit card payment method type.

Namespace

Drupal\commerce_payment\Plugin\Commerce\PaymentMethodType

Code

public function buildLabel(PaymentMethodInterface $payment_method) {
  $card_type = CreditCardHelper::getType($payment_method->card_type->value);
  $args = [
    '@card_type' => $card_type
      ->getLabel(),
    '@card_number' => $payment_method->card_number->value,
  ];
  return $this
    ->t('@card_type ending in @card_number', $args);
}