This event would allow altering the labels displayed for payment gateways. For instance, customizing the display label.
Payment options are currently built in an unmodifiable way
// 1) Add options to reuse stored payment methods for known customers.
$options[$payment_method_id] = new PaymentOption([
'id' => $payment_method_id,
'label' => $payment_method->label(),
'payment_gateway_id' => $payment_gateway->id(),
'payment_method_id' => $payment_method_id,
]);
// 2) Add the order's payment method if it was not included above.
$options[$order_payment_method_id] = new PaymentOption([
'id' => $order_payment_method_id,
'label' => $order_payment_method->label(),
'payment_gateway_id' => $order_payment_method->getPaymentGatewayId(),
'payment_method_id' => $order_payment_method_id,
]);
// 3) Add options to create new stored payment methods of supported types.
$option_label = $payment_method_type->getCreateLabel();
// If there is more than one option for this payment method type,
// append the payment gateway label to avoid duplicate option labels.
if ($payment_method_type_counts[$payment_method_type_id] > 1) {
$option_label = $this->t('@payment_method_label (@payment_gateway_label)', [
'@payment_method_label' => $payment_method_type->getCreateLabel(),
'@payment_gateway_label' => $payment_gateway_plugin->getDisplayLabel(),
]);
}
$options[$option_id] = new PaymentOption([
'id' => $option_id,
'label' => $option_label,
'payment_gateway_id' => $payment_gateway->id(),
'payment_method_type_id' => $payment_method_type_id,
]);
// 4) Add options for the remaining gateways (off-site, manual, etc).
foreach ($other_payment_gateways as $payment_gateway) {
$payment_gateway_id = $payment_gateway->id();
$options[$payment_gateway_id] = new PaymentOption([
'id' => $payment_gateway_id,
'label' => $payment_gateway->getPlugin()->getDisplayLabel(),
'payment_gateway_id' => $payment_gateway_id,
]);
}
This can lead to needing to override the PaymentInformation pane or verbose form alters.
A main example is the "@payment_method_label (@payment_gateway_label)" display and modifying this behavior.