Automattic\WooCommerce\Internal\Admin\Settings

PaymentProviders::maybe_add_pseudo_mollie_gatewayprivateWC 1.0

Add the pseudo Mollie gateway to the payment gateways list if necessary.

Method of the class: PaymentProviders{}

No Hooks.

Returns

Array. The payment gateways list with the pseudo Mollie gateway added if necessary.

Usage

// private - for code of main (parent) class only
$result = $this->maybe_add_pseudo_mollie_gateway( $payment_gateways ): array;
$payment_gateways(array) (required)
The payment gateways list.

PaymentProviders::maybe_add_pseudo_mollie_gateway() code WC 9.9.3

private function maybe_add_pseudo_mollie_gateway( array $payment_gateways ): array {
	$mollie_provider = $this->get_payment_gateway_provider_instance( 'mollie' );

	// Do nothing if there is a Mollie gateway registered.
	if ( $mollie_provider->is_gateway_registered( $payment_gateways ) ) {
		return $payment_gateways;
	}

	// Get the Mollie suggestion and determine if the plugin is active.
	$mollie_suggestion = $this->get_extension_suggestion_by_id( ExtensionSuggestions::MOLLIE );
	if ( empty( $mollie_suggestion ) ) {
		return $payment_gateways;
	}
	$mollie_suggestion = $this->enhance_extension_suggestion( $mollie_suggestion );
	// Do nothing if the plugin is not active.
	if ( self::EXTENSION_ACTIVE !== $mollie_suggestion['plugin']['status'] ) {
		return $payment_gateways;
	}

	// Add the pseudo Mollie gateway to the list since the plugin is active but there is no Mollie gateway registered.
	$payment_gateways[] = $mollie_provider->get_pseudo_gateway( $mollie_suggestion );

	return $payment_gateways;
}