Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders
Paymob::is_paymob_in_sandbox_mode
Check if the Paymob payment gateway is in sandbox mode.
Method of the class: Paymob{}
No Hooks.
Returns
?true|false. True if the payment gateway is in sandbox mode, false otherwise. Null if the environment could not be determined.
Usage
// private - for code of main (parent) class only $result = $this->is_paymob_in_sandbox_mode( $payment_gateway ): ?bool;
- $payment_gateway(WC_Payment_Gateway) (required)
- The payment gateway object.
Paymob::is_paymob_in_sandbox_mode() Paymob::is paymob in sandbox mode code WC 10.8.1
private function is_paymob_in_sandbox_mode( WC_Payment_Gateway $payment_gateway ): ?bool {
try {
// Unfortunately, Paymob does not provide a standard way to determine if the gateway is in sandbox mode.
$options = get_option( 'woocommerce_paymob-main_settings', array() );
return 'test' === ( $options['mode'] ?? 'test' );
} 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;
}