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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2866429-hardcoded_payment_pane_dependencies--2.patch | 774 bytes | dom. |
Comments
Comment #2
dom. commentedAdded a patch for review !
Comment #3
bojanz commentedPlease 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
Comment #4
bojanz commentedComment #5
bojanz commentedMoved 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.