Automattic\WooCommerce\Gateways\PayPal

TransactAccountManager::create_merchant_account │ private │ WC 10.5.0

Create the merchant account with the Transact platform.

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

Хуков нет.

Возвращает

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

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

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

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

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

Код TransactAccountManager::create_merchant_account() WC 11.2.2

private function create_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(
		'POST',
		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'] ) ) {
		\WC_Gateway_Paypal::log( 'Transact merchant account creation failed. Response body: ' . wc_print_r( $response_data, true ) );
		return null;
	}

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