PluginProbe
WooCommerce / 11.1.0
WooCommerce v11.1.0
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Internal / Admin / Settings / PaymentsProviders / Affirm.php
Affirm.php
46 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare( strict_types=1 );
3
4 namespace Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders;
5
6 use Automattic\WooCommerce\Internal\Logging\SafeGlobalFunctionProxy;
7 use Throwable;
8 use WC_Payment_Gateway;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Affirm payment gateway provider class.
14 *
15 * This class handles all the custom logic for the Affirm payment gateway provider.
16 */
17 class Affirm extends PaymentGateway {
18
19 /**
20 * Check if the payment gateway needs setup.
21 *
22 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
23 *
24 * @return bool True if the payment gateway needs setup, false otherwise.
25 */
26 public function needs_setup( WC_Payment_Gateway $payment_gateway ): bool {
27 try {
28 if ( is_callable( array( $payment_gateway, 'isValidForUse' ) ) ) {
29 return ! wc_string_to_bool( $payment_gateway->isValidForUse() );
30 }
31 } catch ( Throwable $e ) {
32 // Do nothing but log so we can investigate.
33 SafeGlobalFunctionProxy::wc_get_logger()->debug(
34 'Failed to determine if gateway needs setup: ' . $e->getMessage(),
35 array(
36 'gateway' => $payment_gateway->id,
37 'source' => 'settings-payments',
38 'exception' => $e,
39 )
40 );
41 }
42
43 return parent::needs_setup( $payment_gateway );
44 }
45 }
46