WC_Gateway_Paypal_Transact_Account_Manager::create_provider_accountprivateWC 1.0

Create the provider account with the Transact platform.

Method of the class: WC_Gateway_Paypal_Transact_Account_Manager{}

No Hooks.

Returns

true|false. True if the provider account creation was successful, false otherwise.

Usage

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

WC_Gateway_Paypal_Transact_Account_Manager::create_provider_account() code WC 10.4.3

private function create_provider_account() {
	$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(
		'POST',
		sprintf( '/sites/%d/transact/account/%s/onboard', $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;
}