Redirect after purchasing
In your "submitForm" method write below code:

$form_state-&gt;setRedirect('&lt;front&gt;');
return;


To redirect you can also use the following code:

//after the namespace
use Drupal\Core\Url;

//In your "submitForm"
$url = Url::fromRoute('&lt;front&gt;');
$form_state-&gt;setRedirectUrl($url);


To redirect you can also use the following code:

//after the namespace
use Symfony\Component\HttpFoundation\RedirectResponse;

//In your "submitForm"
global $base_url;
$response = new RedirectResponse($base_url);
$response-&gt;send();
return;