Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions

PaymentGatewaysController::extend_response()public staticWC 1.0

Add necessary fields to REST API response.

{} It's a method of the class: PaymentGatewaysController{}

No Hooks.

Return

WP_REST_Response.

Usage

$result = PaymentGatewaysController::extend_response( $response, $gateway, $request );
$response(WP_REST_Response) (required)
Response data.
$gateway(WC_Payment_Gateway) (required)
Payment gateway object.
$request(WP_REST_Request) (required)
Request object.

Code of PaymentGatewaysController::extend_response() WC 6.6.1

public static function extend_response( $response, $gateway, $request ) {
	$data = $response->get_data();

	$data['needs_setup']          = $gateway->needs_setup();
	$data['post_install_scripts'] = self::get_post_install_scripts( $gateway );
	$data['settings_url']         = method_exists( $gateway, 'get_settings_url' )
		? $gateway->get_settings_url()
		: admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) );

	$return_url             = wc_admin_url( '&task=payments&connection-return=' . strtolower( $gateway->id ) . '&_wpnonce=' . wp_create_nonce( 'connection-return' ) );
	$data['connection_url'] = method_exists( $gateway, 'get_connection_url' )
		? $gateway->get_connection_url( $return_url )
		: null;

	$data['setup_help_text'] = method_exists( $gateway, 'get_setup_help_text' )
		? $gateway->get_setup_help_text()
		: null;

	$data['required_settings_keys'] = method_exists( $gateway, 'get_required_settings_keys' )
		? $gateway->get_required_settings_keys()
		: array();

	$response->set_data( $data );

	return $response;
}