You are here

public function CheckoutPaymentProcess::isVisible in Commerce PayPal 8

Determines whether the pane is visible.

Return value

bool TRUE if the pane is visible, FALSE otherwise.

Overrides PaymentProcess::isVisible

File

src/Plugin/Commerce/CheckoutPane/CheckoutPaymentProcess.php, line 27

Class

CheckoutPaymentProcess
Provides the PayPal Checkout payment process pane.

Namespace

Drupal\commerce_paypal\Plugin\Commerce\CheckoutPane

Code

public function isVisible() {
  if ($this->order
    ->isPaid() || !$this->order
    ->getTotalPrice() || $this->order
    ->getTotalPrice()
    ->isZero()) {

    // No payment is needed if the order is free or has already been paid.
    return FALSE;
  }
  if ($this->checkoutFlow
    ->getPluginId() !== 'paypal_checkout' || empty($this->order
    ->getData('commerce_paypal_checkout')) || $this->order
    ->get('payment_gateway')
    ->isEmpty()) {
    return FALSE;
  }
  $checkout_data = $this->order
    ->getData('commerce_paypal_checkout');

  /** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
  $payment_gateway = $this->order
    ->get('payment_gateway')->entity;
  return $checkout_data['flow'] === 'shortcut' && $payment_gateway
    ->getPlugin() instanceof CheckoutInterface;
}