commerce – Make Paypal checkout wait for checkbox state

I wrote a small module to display an “agree-to-the-terms”-checkbox in Drupal Commerce checkout pane, following the documentation HERE and tweaked it to my needs.

My PHP looks like this:


namespace Drupalcheckout_termsPluginCommerceCheckoutPane;

use Drupalcommerce_checkoutPluginCommerceCheckoutPaneCheckoutPaneBase;
use DrupalCoreFormFormStateInterface;

 * AGB-Zustimmung fĂĽr den Checkout.
 * @CommerceCheckoutPane(
 *   id = "checkout_terms_agb_zustimmung",
 *   label = @Translation("AGB Zustimmung"),
 *   display_label = @Translation("AGB Zustimmung"),
 *   default_step = "_review",
 *   wrapper_element = "fieldset",
 * )

class CheckoutTermsAccept extends CheckoutPaneBase {

   * {@inheritdoc}
    public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
      $pane_form('accept_terms') = (
        '#type' => 'checkbox',
        '#title' => 'Ich stimme den allgemeinen Geschäftsbedingungen zu',
        '#default_value' => 0,
        '#required' => TRUE
      return $pane_form;

This works perfect for custom multi-step-checkouts. The checkbox is unchecked by default, but the checkout can’t be finished without checking the box.

But when I choose the Commerce Paypal module to check out, I just ignores my checkbox and does the checkout anyway.

As I am pretty new to Drupal, I would be glad if someone could give me any advise on how to go from here. Is there any possibility to hook into the Paypal module from here and deactivate it as long as the checkbox is still unchecked? Or should I just do it in Javascript on that page?

Thank you very much in advance!