Automattic\WooCommerce\Gateways\PayPal

TransactAccountManager::fetch_merchant_accountprivateWC 10.5.0

Fetch the merchant account from the Transact platform.

Method of the class: TransactAccountManager{}

No Hooks.

Returns

Array|null. The API response body, or null if the request fails.

Usage

// private - for code of main (parent) class only
$result = $this->fetch_merchant_account(): ?array;

Changelog

Since 10.5.0 Introduced.

TransactAccountManager::fetch_merchant_account() code WC 10.9.4

private function fetch_merchant_account(): ?array {
	$site_id = \Jetpack_Options::get_option( 'id' );
	if ( ! $site_id ) {
		return null;
	}

	$request_body = array(
		'test_mode' => $this->gateway->testmode,
	);

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

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

	$response_data = json_decode( wp_remote_retrieve_body( $response ), true );
	if ( empty( $response_data['public_id'] ) ) {
		return null;
	}

	return array( 'public_id' => $response_data['public_id'] );
}