New REST endpoint to disconnect merchant

This commit is contained in:
Philipp Stracker 2025-01-13 13:46:04 +01:00
parent e4a6213f20
commit e5023b5007
No known key found for this signature in database

View file

@ -123,6 +123,15 @@ class AuthenticationRestEndpoint extends RestEndpoint {
),
)
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/disconnect',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'disconnect' ),
'permission_callback' => array( $this, 'check_permission' ),
)
);
}
/**
@ -176,4 +185,15 @@ class AuthenticationRestEndpoint extends RestEndpoint {
return $this->return_success( $response );
}
/**
* Disconnect the merchant and clear the authentication details.
*
* @return WP_REST_Response
*/
public function disconnect() : WP_REST_Response {
$this->authentication_manager->disconnect();
return $this->return_success( 'OK' );
}
}