public function Braintree3DSReview::isVisible in Commerce Braintree 8
Determines whether the pane is visible.
Return value
bool TRUE if the pane is visible, FALSE otherwise.
Overrides CheckoutPaneBase::isVisible
File
- src/
Plugin/ Commerce/ CheckoutPane/ Braintree3DSReview.php, line 65
Class
- Braintree3DSReview
- Adds 3DS authentication for Braintree vaulted/stored payment methods.
Namespace
Drupal\commerce_braintree\Plugin\Commerce\CheckoutPaneCode
public function isVisible() {
// Only display for reusable/vaulted 3DS Braintree payment methods.
if ($this->order
->get('payment_method')
->isEmpty() || $this->order
->get('payment_gateway')
->isEmpty() || !$this->order
->get('payment_gateway')->entity) {
return FALSE;
}
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
$payment_gateway = $this->order
->get('payment_gateway')->entity;
if (!$payment_gateway
->getPlugin() instanceof HostedFieldsInterface) {
return FALSE;
}
$configuration = $payment_gateway
->getPlugin()
->getConfiguration();
if (empty($configuration['3d_secure'])) {
return FALSE;
}
$payment_method = $this->order
->get('payment_method')->entity;
if (!$payment_method
->isReusable() || $payment_method
->getType()
->getPluginId() !== 'credit_card') {
return FALSE;
}
return TRUE;
}