Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

Affirm{}WC 1.0└─ PaymentGateway

Affirm payment gateway provider class.

This class handles all the custom logic for the Affirm payment gateway provider.

Хуков нет.

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

$Affirm = new Affirm();
// use class methods

Методы

  1. public needs_setup( WC_Payment_Gateway $payment_gateway )

Код Affirm{} WC 10.3.4

class Affirm extends PaymentGateway {

	/**
	 * Check if the payment gateway needs setup.
	 *
	 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
	 *
	 * @return bool True if the payment gateway needs setup, false otherwise.
	 */
	public function needs_setup( WC_Payment_Gateway $payment_gateway ): bool {
		try {
			if ( is_callable( array( $payment_gateway, 'isValidForUse' ) ) ) {
				return ! wc_string_to_bool( $payment_gateway->isValidForUse() );
			}
		} catch ( Throwable $e ) {
			// Do nothing but log so we can investigate.
			SafeGlobalFunctionProxy::wc_get_logger()->debug(
				'Failed to determine if gateway needs setup: ' . $e->getMessage(),
				array(
					'gateway'   => $payment_gateway->id,
					'source'    => 'settings-payments',
					'exception' => $e,
				)
			);
		}

		return parent::needs_setup( $payment_gateway );
	}
}