Automattic\WooCommerce\Internal\Admin\Settings\PaymentProviders

PaymentGateway::get_iconpublicWC 1.0

Get the provider icon URL of the payment gateway.

We expect to receive a URL to an image file. If the gateway provides an <img> tag or a list of them, we will fall back to the default payments icon.

Method of the class: PaymentGateway{}

No Hooks.

Returns

String. The provider icon URL of the payment gateway.

Usage

$PaymentGateway = new PaymentGateway();
$PaymentGateway->get_icon( $payment_gateway ): string;
$payment_gateway(WC_Payment_Gateway) (required)
The payment gateway object.

PaymentGateway::get_icon() code WC 9.9.4

public function get_icon( WC_Payment_Gateway $payment_gateway ): string {
	$icon_url = $payment_gateway->icon ?? '';
	if ( ! is_string( $icon_url ) || empty( $icon_url ) ) {
		$icon_url = '';
	}

	$icon_url = trim( $icon_url );

	// Test if it actually is a URL as some gateways put an <img> tag or a list of them.
	if ( ! wc_is_valid_url( $icon_url ) ) {
		// Fall back to the default payments icon.
		return plugins_url( 'assets/images/icons/default-payments.svg', WC_PLUGIN_FILE );
	}

	return WC_HTTPS::force_https_url( $icon_url );
}