WC_Gateway_Paypal::should_use_orders_v2publicWC 1.0

Check if the gateway should use Orders v2 API.

Method of the class: WC_Gateway_Paypal{}

Hooks from the method

Returns

true|false.

Usage

$WC_Gateway_Paypal = new WC_Gateway_Paypal();
$WC_Gateway_Paypal->should_use_orders_v2();

WC_Gateway_Paypal::should_use_orders_v2() code WC 10.7.0

public function should_use_orders_v2() {
	/**
	 * Filters whether the gateway should use Orders v2 API.
	 *
	 * @param bool $use_orders_v2 Whether the gateway should use Orders v2 API.
	 *
	 * @since 10.2.0
	 */
	$use_orders_v2 = apply_filters(
		'woocommerce_paypal_use_orders_v2',
		PayPalHelper::is_orders_v2_migration_eligible()
	);

	// If the conditions are met, but there is an override to not use Orders v2,
	// respect the override.
	if ( ! $use_orders_v2 ) {
		return false;
	}

	// If the gateway is not onboarded, bail early.
	if ( ! $this->is_transact_onboarding_complete() ) {
		return false;
	}

	// We need a Jetpack connection to be able to send authenticated requests to the proxy.
	$jetpack_connection_manager = $this->get_jetpack_connection_manager();
	if ( ! $jetpack_connection_manager || ! $jetpack_connection_manager->is_connected() ) {
		return false;
	}

	// We need merchant and provider accounts with Transact to be able to use the proxy.
	$transact_account_manager = new PayPalTransactAccountManager( $this );
	$merchant_account_data    = $transact_account_manager->get_transact_account_data( 'merchant' );
	if ( empty( $merchant_account_data ) ) {
		return false;
	}

	$provider_account_data = $transact_account_manager->get_transact_account_data( 'provider' );
	if ( empty( $provider_account_data ) ) {
		return false;
	}

	return true;
}