Automattic\WooCommerce\Gateways\PayPal

TransactAccountManager::fetch_provider_accountprivateWC 10.5.0

Fetch the provider account from the Transact platform.

Method of the class: TransactAccountManager{}

No Hooks.

Returns

true|false. True if the provider account exists, false otherwise.

Usage

// private - for code of main (parent) class only
$result = $this->fetch_provider_account(): bool;

Changelog

Since 10.5.0 Introduced.

TransactAccountManager::fetch_provider_account() code WC 10.9.4

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;
}