Payment Information box on Order Information page of the checkout flow is empty

Created on 1 January 2024, 12 months ago
Updated 26 January 2024, 11 months ago

Problem/Motivation

Problem: Payment Information box on Order Information page of the checkout flow is empty.

Motivation a: This can trigger site builders to disable the payment information pane in the checkout flow and cause the paypal smart buttons to not render on the checkout review page.

Motivation b: This makes the learning curve for new site developers very difficult when trying to test the module for first time and determine how it works. It may not be detected as a bug but being empty leads to confusion.

Steps to reproduce

Install Drupal.

Enable the following modules: commerce_paypal commerce_product commerce_cart commerce_checkout

* Login to fresh install of Drupal.
* Add a store.
* Add a payment gateway configured to use the Paypal checkout (Preferred) plugin
* Add a product
* Add a product variation.
* View the product
* click "add to cart"
* go to /cart
* click "checkout"
Witness the empty "Payment information" panel.

Proposed resolution

Apply this patch

This patch may not be the correct fix.
Here is the patch inline, it is a one liner:

diff --git a/src/PluginForm/Checkout/PaymentMethodAddForm.php b/src/PluginForm/Checkout/PaymentMethodAddForm.php
index 8a5b49f..c87b3da 100644
--- a/src/PluginForm/Checkout/PaymentMethodAddForm.php
+++ b/src/PluginForm/Checkout/PaymentMethodAddForm.php
@@ -78,6 +78,7 @@ class PaymentMethodAddForm extends BasePaymentMethodAddForm {
     // We need to inject the custom card fields, only when this is the solution
     // configured.
     if (!$this->shouldInjectForm($payment_method->getPaymentGateway()->getPlugin())) {
+      $form['#access'] = FALSE;
       return $form;
     }
     /** @var \Drupal\commerce_order\Entity\OrderInterface $order */

The purpose of this patch is to trigger the following code from the commerce module to behave:
modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php:548

547:      // Avoid rendering an empty container.
548:      $form[$pane_id]['#access'] = (bool) Element::getVisibleChildren($form[$pane_id]);

Prior to my patch Element::getVisibleChildren($form[$pane_id]) is returning an array containing 'add_payment_method'.
The addition of $form['#access'] = FALSE; causes that to return an empty array and thus not display the empty container.

Remaining tasks

* Reproduce the empty payment information pane.
* Apply the patch
* Witness the payment information pane hidden.

* Determine if the issue is in fact in the commerce module's logic for detecting an empty container and potentially fix that instead.

User interface changes

Hidden 'payment information' pane.

API changes

None.

Further information

It appears that other users may be experiencing the same confusion and possibly making the same incorrect assumptions that I did, see Paypal smart buttons showing on cart page not review or payment page 💬 Paypal smart buttons showing on cart page not review or payment page Active .

The combination of my inexperience with this module, other misconfiguration that obscured it, caching causing false positives and false negatives, lack of understanding of what that payment information box was supposed to do and inability to see it doing what it is supposed to do so as to learn caused me to make the reasonable assumption of "In my case the payment information is empty. I do not want to display an empty fieldset to my users, I will disable it in the checkout flow". Disabling the payment information caused the PayPal buttons to disappear without any notices in the log, warnings or anything. Given that the payment information appeared to be optional due to the fact that it could be disabled and was empty, it seemed perfectly reasonable to disable it.

I had seen the payment buttons not appear earlier because I had been assigning the "PayPal check flow" to the default order type. This caused the same symptom of "PayPal smart buttons showing on cart page not review or payment page". Along with above mentioned cache issues, this was one more complexity on top of my already confused understanding. It took many hours of trial, error, clearing caches, reconfiguration, thinking it was working, then it's not working before I got the issue simple enough to replicate consistently using the above mentioned steps.

In summary, this pane being rendered with nothing in it leads to confusion on top of an already complex module as is a major barrier to a new site builder's already steep learning curve, and in at least my case triggered me to disable it which silently made things worse.

P.S. This only happens the FIRST time one views the order information page.
If you click through to the review page it will show 'paypal' text. If you click on 'edit' in that panel and go back to the order information page the paypal radio button will show.
If you remove the product from the cart and add it back again, then click 'checkout' the radio button will appear again.

🐛 Bug report
Status

Fixed

Version

1.0

Component

PayPal Checkout

Created by

🇦🇺Australia thursday_bw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @thursday_bw
  • 🇦🇺Australia thursday_bw

    Here's a screencast for you showing me installing a fresh Drupal, the relevant commerce modules, configuring the minimal settings and
    showing the empty payment information pane.
    I also show how adding that patch makes it disappear, and waffle quite a bit at the end LOL, my apologies ;)

    This video is designed to make it VERY clear what the replication steps are and also give you the opportunity to spot if I am doing something
    wrong in order to cause that empty payment information box.

    Thanks for reaching out on slack earlier. No rush on this, I am able to move forward now that I understand the situation and have a patch for
    that box.

    If you have any questions, feel free to reach out, you're welcome to ping me on slack anytime you like.

  • Status changed to Fixed 12 months ago
  • 🇮🇱Israel jsacksick

    Committed your fix... So in the end this is less "bad" than I thought.
    I initially thought this was causing the payment gateway not to be set on the order, but decided to commit your fix anyway.
    Thank you for this thorough research and fix!

  • Status changed to Needs work 12 months ago
  • 🇺🇸United States loze Los Angeles

    Apologies if reopening this issue was not he correct thing to do, but this commit causes the billing profile fields that are supposed to be included by checking "Collect billing information" to be hidden.

    Im my case ive been collecting a billing profile on the "order information" step, but with this latest version I cannot do this any longer.

  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 12 months ago
    2 pass
  • 🇮🇱Israel jsacksick

    What about the attached patch?

  • 🇺🇸United States loze Los Angeles

    Thanks @jsacksick - Yes, this patch does appear to get the billing profile back.

  • 🇮🇱Israel jsacksick

    Well, maybe I should tag another release again...

  • Status changed to Fixed 12 months ago
    • jsacksick committed 62b8c09e on 8.x-1.x
      Issue #3411517 followup: Ensure the payment info pane isn't hidden in...
  • 🇦🇺Australia thursday_bw

    @jsacksick Thanks for help on this one. I went AWOL for a little while, and came back to my pleasant surprise that this is marked as great to "fixed".
    Thank you :)

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024