Automattic\WooCommerce\Gateways\PayPal

TransactAccountManager::fetch_provider_account │ private │ WC 10.5.0

Fetch the provider account from the Transact platform.

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

Хуков нет.

Возвращает

bool. True if the provider account exists, false otherwise.

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

// private - только в коде основоного (родительского) класса
$result = $this->fetch_provider_account(): bool;

Список изменений

С версии 10.5.0 Введена.

Код TransactAccountManager::fetch_provider_account() WC 11.2.2

private function fetch_provider_account(): bool {
	$site_id = \Jetpack_Options::get_option( 'id' );
	if ( ! $site_id ) {
		return false;
	}

	$request_body = array(
		'test_mode'     => $this->gateway->testmode,
		'provider_type' => self::TRANSACT_PROVIDER_TYPE,
	);

	$response = $this->send_transact_api_request(
		'GET',
		sprintf( '/sites/%d/transact/account/%s', $site_id, self::TRANSACT_PROVIDER_TYPE ),
		$request_body
	);

	if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
		return false;
	}

	// Provider account response only returns an empty onboarding link,
	// which we do not need.
	return true;
}