Problem/Motivation

For some reasons, I had to create a custom Payment information pane, extending the default Payment Information pane.
class CustomPaymentInformation extends PaymentInformation

I discovered then that 'Payment process' pane fails since:

/**
  * {@inheritdoc}
  */
 public function isVisible() {
   // This pane can't be used without the PaymentInformation pane.
   $payment_info_pane = $this->checkoutFlow->getPane('payment_information');
   return $payment_info_pane->isVisible() && $payment_info_pane->getStepId() != '_disabled';
 }

In other words, there is a hardcoded dependency on the pane with id 'payment_information'.
Why that ? I suppose because of
if ($this->order->get('payment_gateway')->isEmpty()) {
Meaning the payment_gateway in the order, setted from the payment_information has to be defined.

Why not checking this on the isVisible() method rather then if the payment_information was visible, since this is actually what was needed.

Proposed resolution

Change isVisible implementation to perform the check $this->order->get('payment_gateway')->isEmpty() there.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Dom. created an issue. See original summary.

dom.’s picture

Status: Active » Needs review
StatusFileSize
new774 bytes

Added a patch for review !

bojanz’s picture

Title: Do not make hard-dependance between 'Payment process' and 'Payment information' panes » Document how to safely replace checkout panes, especially payment ones
Category: Bug report » Task
Status: Needs review » Active

Please see #2861039: PaymentProcess::isVisible() makes it hard to use an alternative payment gateway selection gateway for an explanation. The real problem is in knowing where to redirect.
We could fallback to the previous step (review, usually), but the main point still stands, that if you're in the 1% of the people who are ever going to implement a custom PaymentInformation pane (at least now that the default one is decent), you might as well override the PaymentProcess one as well.

The fact that this was raised for the 3rd time means that we need documentation

bojanz’s picture

bojanz’s picture

Status: Active » Closed (duplicate)

Moved to the docs queue: https://github.com/drupalcommerce/commerce-docs/issues/285

The PaymentInformation pane itself now has instructions in the annotation about proper replacement.