Automattic\WooCommerce\Gateways\PayPal

WebhookHandler::get_action_urlprivateWC 10.5.0

Get the action URL from the links.

Method of the class: WebhookHandler{}

No Hooks.

Returns

String|null.

Usage

// private - for code of main (parent) class only
$result = $this->get_action_url( $links, $action ): ?string;
$links(array) (required)
The links from the webhook event.
$action(string) (required)
The action to perform (capture or authorize).

Changelog

Since 10.5.0 Introduced.

WebhookHandler::get_action_url() code WC 10.7.0

private function get_action_url( array $links, string $action ): ?string {
	$action_url = null;
	foreach ( $links as $link ) {
		if ( $action === $link['rel'] && 'POST' === $link['method'] && filter_var( $link['href'], FILTER_VALIDATE_URL ) ) {
			$action_url = esc_url_raw( $link['href'] );
			break;
		}
	}
	return $action_url;
}