Automattic\WooCommerce\Internal\Admin\Settings\PaymentProviders

PaymentGateway::get_recommended_payment_methods()publicWC 1.0

Try and determine a list of recommended payment methods for a payment gateway.

This data is not always available, and it is up to the payment gateway to provide it. This is not a definitive list of payment methods that the gateway supports. The data is aimed at helping the user understand what payment methods are recommended for the gateway and potentially help them make a decision on which payment methods to enable.

Метод класса: PaymentGateway{}

Хуков нет.

Возвращает

Массив. The recommended payment methods list for the payment gateway. Empty array if there are none.

Использование

$PaymentGateway = new PaymentGateway();
$PaymentGateway->get_recommended_payment_methods( $payment_gateway, $country_code ): array;
$payment_gateway(WC_Payment_Gateway) (обязательный)
The payment gateway object.
$country_code(строка)
The country code for which to get recommended payment methods. This should be a ISO 3166-1 alpha-2 country code.
По умолчанию: ''

Код PaymentGateway::get_recommended_payment_methods() WC 9.6.1

public function get_recommended_payment_methods( WC_Payment_Gateway $payment_gateway, string $country_code = '' ): array {
	// Bail if the payment gateway does not implement the method.
	if ( ! is_callable( array( $payment_gateway, 'get_recommended_payment_methods' ) ) ) {
		return array();
	}

	// Get the "raw" recommended payment methods from the payment gateway.
	$recommended_pms = call_user_func_array(
		array( $payment_gateway, 'get_recommended_payment_methods' ),
		array( 'country_code' => $country_code ),
	);

	// Validate the received list items.
	$recommended_pms = array_filter(
		$recommended_pms,
		array( $this, 'validate_recommended_payment_method' )
	);

	// Sort the list.
	$recommended_pms = $this->sort_recommended_payment_methods( $recommended_pms );

	// Extract, standardize, and sanitize the details for each recommended payment method.
	$standardized_pms = array();
	foreach ( $recommended_pms as $index => $recommended_pm ) {
		// Use the index as the order since we sorted (and normalized) the list earlier.
		$standardized_pms[] = $this->standardize_recommended_payment_method( $recommended_pm, $index );
	}

	return $standardized_pms;
}