Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

MercadoPago::is_mercado_pago_in_sandbox_modeprivateWC 1.0

Check if the MercadoPago payment gateway is in sandbox mode.

For MercadoPago, there are two different environments: sandbox and production.

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

Хуков нет.

Возвращает

?true|false. True if the payment gateway is in sandbox mode, false otherwise. Null if the environment could not be determined.

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

// private - только в коде основоного (родительского) класса
$result = $this->is_mercado_pago_in_sandbox_mode( $payment_gateway ): ?bool;
$payment_gateway(WC_Payment_Gateway) (обязательный)
The payment gateway object.

Код MercadoPago::is_mercado_pago_in_sandbox_mode() WC 10.8.1

private function is_mercado_pago_in_sandbox_mode( WC_Payment_Gateway $payment_gateway ): ?bool {
	global $mercadopago;

	try {
		// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
		if ( class_exists( '\MercadoPago\Woocommerce\WoocommerceMercadoPago' ) &&
			class_exists( '\MercadoPago\Woocommerce\Configs\Store' ) &&
			$mercadopago instanceof \MercadoPago\Woocommerce\WoocommerceMercadoPago &&
			! is_null( $mercadopago->storeConfig ) &&
			$mercadopago->storeConfig instanceof \MercadoPago\Woocommerce\Configs\Store &&
			is_callable( array( $mercadopago->storeConfig, 'isTestMode' ) )
		) {
			return wc_string_to_bool( $mercadopago->storeConfig->isTestMode() );

		}
	} catch ( \Throwable $e ) {
		// Do nothing but log so we can investigate.
		SafeGlobalFunctionProxy::wc_get_logger()->debug(
			'Failed to determine if gateway is in sandbox mode: ' . $e->getMessage(),
			array(
				'gateway'   => $payment_gateway->id,
				'source'    => 'settings-payments',
				'exception' => $e,
			)
		);
	}

	// Let the caller know that we couldn't determine the environment.
	return null;
}