- Issue created by @Tankeroo
- 🇺🇸United States Tankeroo
*UPDATE* in the checkout flow if I move "Payment process" to disabled... I get a "Complete checkout" button on the review page. Upon clicking this button, I get checkout completed and the complete message. However, still no Paypal Smart Buttons on checkout pages only shows on cart page.
- 🇮🇱Israel jsacksick
I'm confused, are you still looking for support? Is PayPal selected from the payment information pane? And then you're not seeing anything on review? You need the PaymentProcess pane, it shouldn't be disabled.
- 🇮🇱Israel jsacksick
The "Payment information" pane should be placed on a step prior to review. Otherwise the payment gateway is not yet associated to the order prior to review, which is why you're not seeing the smart payment buttons. There's no AJAX saving the payment gateway selection and refreshing the entire form which would allow the smart payment buttons to be injected.
- 🇺🇸United States Tankeroo
Hi jsacksick,
Thanks for your response! Yes, I'm still looking for support as I'd like to use this module in the future but now I'm not pressured with time as we've decided to use another module to fulfill the payments for the upcoming event.
I've updated the checkout flow as attached.
This is what I experience.
After adding product to cart:
On cart page, I see "update cart" "checkout" and the paypal smart buttons.Option 1
If I click on the paypal smart button to pay -> It goes through -> then goes to order info page (Shows paypal selected) -> Review page with "pay and complete" button -> Then goes to a white error page "The website encountered an unexpected error. Please try again later."Option 2
If I click on "Checkout" -> It goes to order info page (payment info is empty) "continue to review" -> Review page with paypal smart buttons -> goes to white error page.I check the paypal sandbox accounts and the payments did go through for each test.
The buttons are still showing up on the cart page. Not sure if this is intended?
But it's also showing on other checkout pages now as well which didn't show before, so that's good.In the backend, I receive four Error logs. I'll attach as images. The errors seem to be coming from commerce_order and if so I may need to post in the right place.
Try:
https://mygets.org/en/product/1
https://mygets.org/en/cartI hope this helps! Thank you.
- 🇦🇺Australia thursday_bw
I am experiencing this too. I am not getting the smart buttons on the checkout flow.
I can see them on the cart page if I enable the checkout box to show them on the cart on the payment gateway settings.
but the checkout flow never shows them, no matter what I do.I am trying to setup a digital download and do not want my drupal site to collect the address information.
You stated above that the payment information must appear before the review pane, however this statement contradicts the module's default configuration. Upload installing commerce_paypal my paypal checkout flow exists, and it does not have payment information set in the Order inforamtion section, or the review pane. If I put it there in then asks for address information, even though I have 'collect order information' disabled on the paypal payment gateway settings.
- 🇮🇱Israel jsacksick
The PayPal checkout flow is added to support the "shortcut" flow. The idea being that when the payment is initiated from the cart page, you'd want to offer your customers a shorter experience (i.e. not recollecting a billing address etc etc)...
If the payment is not initiated from the cart page, the checkout flow configured for your order type will be used.
- 🇦🇺Australia thursday_bw
jsacksick, I'm sorry, I dont' understand what you are saying.
what "shortcut" flow?
The fact remains that the smart buttons will not display in the checkout flow, I have been trying different configurations and reading documentation, clearing caches, installing older version etc for days now."The idea being that when the payment is initiated from the cart page," what payment is intiated from the cart page? sorry, what do you mean?
"If the payment is not initiated from the cart page," where else would it be initiated from?
"If the payment is not initiated from the cart page, the checkout flow configured for your order type will be used." my order type has the paypal checkout flow configured as it's order type.
Are you saying I should create my own checkout flow and set my order type to use that and also disabled the smart buttons on the cart?
maybe, I have tried so many combinations of configuration I can't remember what I have tried and what I haven't.. are you sure they work at all? I'll try creating my own checkout flow and adding the paypal payment process to that and set my order type to user that checkout flow.. if that is what you mean. - 🇦🇺Australia thursday_bw
But first, I need to reinstall the latest release because I downgraded 1.0 hoping the issue would not have been introduced in the older version. :/
- 🇮🇱Israel jsacksick
The "shortcut" flow is when you initiate/approve the payment from the smart payment buttons displayed on the cart page.
When the payment is approved the checkot flow is changed to "paypal_checkout".If you follow the regular flow, by going to checkout instead, then the checkout flow normally configured for your order type is going to be used.
On that checkout flow, you need to make sure the payment gateway is set prior to the review step.
For example, you'd need to set the payment information pane on the order information step.Not really sure how else I could explain this... And yes I'm sure this works as PayPal is used on hundreds if not thousands of sites.
- 🇦🇺Australia thursday_bw
OK.. I changed my order type to use the default checkout flow instead of the paypal checkout flow.. that is very counter intuitive but it works now. Well kind of, I don't want the 'payment information' screen, all it offers is a radio button to select paypal, which is the only payment gateway configured so it is redundant.
I am configuration this as a payment gateway for a digital download and I have no need to collect a shipping address.I will try now with my own checkout flow as I was going to before I tried with the default one.
Not at any time did it occur to me that using the paypal checkout flow was the wrong way to get paypal to work in the checkout flow.. seemingly obvious why that is confusing isn't it?
I hindsight I now understand what the documentation means at https://www.drupal.org/docs/8/modules/commerce-paypal/paypal-commerce-pl... →
I missinterpreted what "payment is initiated on the cart page" means. :(
"You will also want to verify that the "PayPal Checkout" checkout flow exists in your configuration. If you're working with a fresh install of the Commerce PayPal module, it should be installed automatically. This checkout flow is automatically used when the payment is initiated from the cart page via the Smart Payment Buttons. In this scenario, you want the checkout steps to be reduced to the minimum. "By "payment initiated on the cart page" you mean the user utilised one of the smart buttons on the cart page.. I have effectively conflated the idea of 'checking out' and 'initiating payment' as the same action, so I interpreted 'clicking checkout' as 'initiating payment' and took this to mean that my checkout process had to use the paypal checkout flow. Particular since one imagines that the checkout flow applies to checking out, not to bypassing the checkout.
Do you see how this doc is confusing?
I have been at this for hours and hours and it is 11:41pm now, my brain is mush. I'll attempt to better word the docs when I have had some sleep.
thanks for you response, I was able to tease out the information I needed from that.
I saw on one of these issues someone pointing out that having smart buttons on the checkout AND A checkout button is confusing to the user. I concur with this too. Why have both? I do not understand.
I'm not sure what the purpose and usecase of the smart buttons on the cart page is, especially since one can not disable or remove the checkout button without hacking code.Ok.. that has cleared things up heaps.. I still have some configuring to do to get this to work, but wow, actually seeing paypal in the checkout process is a win. thank you again.
- 🇮🇱Israel jsacksick
I guess "flexibility" is causing the confusion here. There is definitely a usecase for checking out "quickly" from the cart page by skipping most of the steps that a customer would normally go through.
In this case, PayPal kind of works as a drop-in replacement of Drupal's checkout... Feel free to contribute to the documentation as this could save someone else time :).
- 🇦🇺Australia thursday_bw
When I get my head clear.. This is working a treat except that the paypal buttons are now not appearing on the review page when viewing as an anonymous user.. and I see an issue open with a fix for that exact problem :(
Thanks for your help, I'll switch over to that issue to continue to comment. - 🇦🇺Australia thursday_bw
The smart buttons do appear on the cart page for anonymous users when I enable them.
- 🇦🇺Australia thursday_bw
I did a full reinstall of the standard Drupal profile and reenabled the relevant commerce modules and configured it again
and get teh exact same behavior.```
drush en commerce_paypal commerce_product commerce_checkout -y
```I created a store.
I created a payment gateway with all default values apart from the name, the sandbox client id and secret, and disabling the show smart buttons on cart checkbox.
I created a product and then added that product to my cart as admin and went through the checkout process up until I the review page where I saw the smart buttons show.I repeated that step as an anonymous user and got the same result as described above, not smart buttons on the review page.
I have checked the view source of the page as both admin and anonymous and the script tag does not show in the source for anonymous users.
- 🇮🇱Israel jsacksick
I just tried locally and I'm seeing the smart payment buttons locally as an anonymous user... Not really sure what's specific to your install...
If you're comfortable debugging... You can try following the logic from
commerce_paypal_form_commerce_checkout_flow_alter()
(the buttons are injected from there). - 🇮🇱Israel jsacksick
From your other issue we can see the "complete checkout" button which is normally hidden by this logic... So somehow a condition isn't met.
- 🇦🇺Australia thursday_bw
OK. to help avoid confusion, the other issue referred to here is: https://www.drupal.org/project/commerce_paypal/issues/3331179 🐛 Paypal Buttons Don't Appear on Drupal 10 Fixed (Paypal Buttons Don't Appear on Drupal 10)
My final comment ( https://www.drupal.org/project/commerce_paypal/issues/3331179#comment-15... 🐛 Paypal Buttons Don't Appear on Drupal 10 Fixed ) at 3am on that issue after many hours of bashing my head against a brick wall I wrote "Hmm. I have it working now.. I was brain farting at the end there (it is 2:53 am lol)...I wasn't clicking all the way through to the review page and was looking at order information.". That was a few days ago. I have created a fresh install of Drupal and configured PayPal once more and I am back in the same situation, and I am definitely looking at the review page this time, the smart buttons do not display on the review page. I have no idea what caused them to magically show up at 3am in the morning last time.
If you're comfortable debugging... You can try following the logic from commerce_paypal_form_commerce_checkout_flow_alter() (the buttons are injected from there).
I have done some more debugging as requested. The offending code is the following if statement, which I have annotated with some comments:
/** * Implements hook_form_BASE_FORM_ID_alter() for commerce_checkout_flow. */ function commerce_paypal_form_commerce_checkout_flow_alter(&$form, FormStateInterface $form_state) { ... if ($order->get('payment_gateway')->isEmpty() || !$order->get('payment_gateway')->entity || $order->get('checkout_flow')->target_id === 'paypal_checkout') { return; // Is returning here. // Both $order->get('payment_gateway')->isEmpty() and !$order->get('payment_gateway')->entity are TRUE; } ... // Inject the Smart payment buttons on the review page. // Skip injecting the smart payment buttons if the order total is zero or // negative. echo "Inject smart payment buttons on the review page\n"; if (!$order->getTotalPrice() || !$order->getTotalPrice()->isPositive()) { echo "returning 4<br />\n"; return; } if (!$payment_gateway_plugin instanceof CheckoutInterface || $payment_gateway_plugin->getPaymentSolution() !== 'smart_payment_buttons') { echo "returning 5<br />\n"; return; } /** @var \Drupal\commerce_paypal\SmartPaymentButtonsBuilderInterface $builder */ $builder = \Drupal::service('commerce_paypal.smart_payment_buttons_builder'); $form['paypal_smart_payment_buttons'] = $builder->build($order, $payment_gateway, TRUE); $form['actions']['#access'] = FALSE; // Put back the "go back" link. if (isset($form['actions']['next']['#suffix'])) { $form['paypal_smart_payment_buttons']['#suffix'] = $form['actions']['next']['#suffix']; } }
I do not know the commerce API very well, actually I don't know it at all, consider me a site builder at this point.
I have no idea wh payment_gatway would be empty on this order entity, heck, we haven't created an order yet, we haven't completed the checkout or the payment so there can't be an order. I don't know why !$order->get('payment_gateway')->entity is empty.Remember this is only as an anonymous user, the buttons show when I get to the review page on a checkout when logged in as admin.
- 🇦🇺Australia thursday_bw
Apologies for the confusion of putting some of the history on that other ticket, here are the screenshots of the buttons displaying as a logged in user, and not as an anonymous user"
- 🇦🇺Australia thursday_bw
I am changing this to a bug report, it's not a support request, unless you can tell me what configuration I have wrong to create this situation.
I am supplying debugging data from a hook at this point so as to describe the bug.
Replication steps are pretty straight forward:
enable commerce_paypal, commerce_product, commerce_cart and commerce_checkout.drush en commerce_product commerce_cart commerce_checkout commerce_paypal -y
Add a store:
Add a payment gateway.
Add a product and add a price to it's variation.
open a private browser window so as to be a guest.
browse to /product/1
click 'add to cart'
browse to /cart
click 'checkout'
click 'continue as guest':
enter contact email and click 'continue to review':
... Oh man... what?!?!!
OK.. as I was taking all these screenshots, I removed my product and added it again, I also went to the review page and then left it again to go and take a screenshot of the order information page and when I returned to screen shot the review page the paypal buttons appear now.
Similar to other night, "oh, it's workign now".. I have not changed any of my configuration.. we have screenshot evidence of it not showing these buttons.. I do not know what to tell you other than, it works sometimes, others it doesn't.
Can you please test this on a fresh install, freshly configured and add your first product?
I have no option I guess but to keep testing. I have seen this behaviour twice now.
I am trying to give you reproducible steps but it is difficult to document as the behaviour is PROVABLY inconsistent, as per my screenshots and the above debugging information.I will yet another fresh install of drupal, configure this all once more, and see if it is only happening on the first attempt to go through the checkout process.
Tell you what, I may record the entire process, (I already have but I will do it fresh because it's a shit recording) and upload that.
- 🇦🇺Australia thursday_bw
OK.. I did a recording of configuring it on a fresh install, again and it bloody well worked.. I don't know what to tell you :(
The one thing I did differently was not attempt to purchase the same product as admin before trying as guest.
- 🇦🇺Australia thursday_bw
OK. I worked am able to replicate it now.
I was disabling the payment information item from the checkout flow because it seems surpurfluous.
If you view the demo I uploaded you can see that when you first view that as an anonymous user it is empty, it's just an empty fieldset.
and then later if you come back and edit it it has a radio box that just says 'paypal' and it makes no sense to have a single radio
button with only one option.. So I disabled the payment information, I don't want my user to see it as it is confusing.It is disabling that that causes the paypal buttons to not display.
So perhaps this issue needs to be modified from "Paypal smart buttons showing on cart page not review or payment page" to,
"how to hide the the redundant 'payment information' item from the 'order information' pane?I'll change this back from a bug to a support request, but it's debatable because the payment information showing as empty/with only paypal when you got back and edit it is odd behaviour.
- 🇦🇺Australia thursday_bw
Ignore the section where I submitted the order and confused myself lol.
But yes, why is the 'payment information' section empty/why does it only show paypal when clicking on 'edit' on it one the review page and why do the paypal buttons disappear on the review page when the payment information is disabled, but only for anonymous users, it does display for admin users? - 🇦🇺Australia thursday_bw
OH.. so now I understand that code: in commerce_paypal_form_commerce_checkout_flow_alter()
if ($order->get('payment_gateway')->isEmpty() || !$order->get('payment_gateway')->entity || $order->get('checkout_flow')->target_id === 'paypal_checkout') { return; // Is returning here. }
$order->get('payment_gateway')->isEmpty()
is TRUE because having hidden the payment information, the payment gateway was not able to be chosen by the user and therefore was not set.
!$order->get('payment_gateway')->entity
I imagine a very similar issue, we havent' chosen a gateway so no entity could be set on the payment_gateway.My earlier testing showed that
$order->get('checkout_flow')->target_id === 'paypal_checkout'
evaluated to FALSE, but that doesn't make sense, target_id should still be 'default' correct? I can double check that I guess.So, I imagine this code needs to be made more robust if there is only one payment gateway existing and it is a paypal gateway, then the system needs to auto assign paypal as the payment gateway and thus allow the site builder to hide the payment information.
- 🇦🇺Australia thursday_bw
Is this perhaps more of an issue with the commerce module itself?
Is commerce module causing this issue of the empty payment information when only one payment gateway exists?
It definitely is incorrect to display a form (and often empty form) to select the only available payment gateway. - 🇦🇺Australia thursday_bw
I found this 'outdated' issue on the commerce module: https://www.drupal.org/project/commerce/issues/1854062 ✨ hide payment method selection where there is only one payment type Closed: outdated
It is closed as 'fixed in commerce 2.x' but there is no link to the issue or commit where it was fixed :(But it sheds some light on the situation
- 🇦🇺Australia thursday_bw
I whipped up a patch → that implements a way for this module to handle that case of the payment info panel being disabled on the checkout flow when there is only one enabled payment gateway that is one of the paypal payment gateway plugin types.
It will need work, I did it in quite a rush and more as a proof of concept than anything else.
I only performed a very quick test. - 🇦🇺Australia thursday_bw
Dang, I clearly patched that against the wrong version of code..
It's almost midnight and I am knackered, here is a re-roll → - 🇦🇺Australia thursday_bw
OK. now that I have a patch, and given that out of the box this displays a broken payment information panel, I'm marking this back to critical.
Along with the patch the site builder needs to know to disable the payment information panel or it displays in a broken manner..
we also need to figure out why that panel displays in a broken manner, and we need to discuss how to handle it appropriately, it makes no sense to offer a form item to choose a payment method when there is only one payment method to choose from.
A module shouldn't require one to add CSS or use an alter hook to hide things (eg the payment information panel), it should not result in confusing and misleading form options displaying in Drupal's standard theme with the most basic and essential settings, that is not a support issue, it is a reproducible bug. - 🇦🇺Australia thursday_bw
I realise there is a lot to get through on this, and I have been going backwards and forwards doing detective work to identify what is going on.
I have made mistakes here and there along the way as there are so many moving parts and variables that alter behavior.This comment is to highlight what I believe is the root cause of the complexity
This screen is easily reproducible. Just install Drupal with the standard profile, then install commerce_paypal module, commerce_cart, commerce_product and commerce_checkout modules.
Create a store.
Create a payment gateway and uncheck the box for showing smart payment buttons on the cart page.
Add a product, then add that product to you cart.
View your cart, and you will see a page like this:
Notice how the 'payment information' pane is empty? That is the problem here. That is the issue. That is what starts a cascade of confusion.
As a site builder, not a developer, it is a perfectly reasonable conclusion at this point to say "Well, I obviously do not have any payment information, I will go to the checkout flow and disable that panel from the review pane", but doing breaks the entire checkout flow, it silently breaks it, no warnings, no errors it just results in a checkout flow that does not function.
My patch supplied earlier is a hack to attempt to resolve this, but it only half works, it allows the smart buttons to be added to the review page but the order never goes through.
It does happen that if one clicks "continue to review" the payment information is rendered again, on this page however it does indeed show 'paypal'. It shows but I assert that this is redundant and confusing at this point, the user did not select paypal because on the previous page the payment information was blank.
If you then click 'edit' on the payment information panel you are taken back to the 'order information' page and this time it does render the 'payment method' box with a single radio box labelled 'paypal', and that is also nonsensical, why have an unalterable radio button to select the only possibly available selection.
So, two recommendations:
1) Resolve the issue with the payment information box being blank when first viewing the order information page.
** In an incognito window it seems that it is only the VERY first time you view the page that this happens. If it does render try clearing the cookies perhaps? I am using an incognito window, closing that window and opening it again will cause the payment information to become blank once more.2) Implement a warning during checkout on the 'order information' page, or perhaps write the log a message to indicate that the the payment information panel as been disabled and that it needs to be enabled. It is perfectly reasonable for a site builder to want to hide that and modify the checkout flow to do so. This is mitigated however by the fact that if the payment information renders correctly as resolved by recommendation 1 then it is far less likely for a site builder to have disabled the payment information pane.
- 🇦🇺Australia thursday_bw
OK doke, I have done some digging into why the payment information panel renders with empty content.
What I have ended up doing is creating this one liner patchdiff --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 */
To be honest, I do not know why
Element::getVisibleChildren($form[$pane_id]);
in commerce module's modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php file is returning an array containingadd_payment_method
I do not have my IDE setup properly, and get memory allocation errors when I dump that form. I'm hoping someone else can investigate, the form does render empty, we can see that in my previous screenshots and this patch resolves the issue.
There may be consequences that I am not aware of.I hope this helps to clarify both what the issue is and what needs to be done to resolve it and gives you a large clue as to why that payment information panel renders empty. I have put in a lot of time to try and move this along and relieve the workload.
- 🇮🇱Israel jsacksick
Because of the number of comments... I'm really confused by this issue... I have no idea what's the actual problem in the end :).
- 🇦🇺Australia thursday_bw
Then just read from comment #31.
I put days, i'm at about 45 hours now, of my own time into this to help resolve it and it is extremely disheartening to receive the comment you just made.
I even upload a demo that shows exactly what the issue is. Have you watched it? :(
If I repeat myself and explain once more that will just create more comments.
Please? The root issue is really straight forward, and maybe seems of low value and innocuous to you, but it triggered a cascade of misunderstanding due to ambiguous UX and going by the history I am not the first to experience it.
I really don't want to explain it again and generate even more comments.
Please read comment #31
- 🇮🇱Israel jsacksick
Well... Just in case you didn't know... I have a dozen modules at least to worry about on my own... Besides, this issue has contradicting comments, screenshots, videos, different patches and then finally a one-liner patch... Just because you put 45 hours into this doesn't entitle you for "priority" support... You got a reply on december 31 st and you compain in your comments so... good luck.
- 🇦🇺Australia thursday_bw
I am not complaining, I am reporting a bug, sorry if that puts you out. I have put in hours of my own time to do the detective work, so that YOU don't have to, you are welcome, I have created and offered a fix, so THAT you don't have to work it all out, you are double welcome.
I have gone above and beyond and you accuse me of complaining, nice work champ.
Thanks you for that, yes sarcasm is intended here.I have not asked you for support, not once, let alone priority support. I have given a reported on my findings, I have put the work in
myself, and offered you a patch. Not responding at all is better than your response that devalues my effort and my work.I have done all this to not put extra load on you. I have not asked any more of you than to acknowledge the bug. You gave me the brush off and bounced the ball back into my court, and so I did the work, I put in the hours to figure out the root of the issue. I reported back and you replied with the insinuation that you can't be bothered to read it. You could have just ignored it but you chose to reply and be rude instead.
I am complaining now, I am complaining about your attitude, sorry if my reporting of a bug and supplying a fix has somehow offended you.You have given me the brush off multiple times. I have not complained, I complain now, please don't accuse me again, I have gone above and beyond for you, done the due diligence so as to not put you out and this is how you respond.
- 🇮🇱Israel jsacksick
Closing this as a duplicate of 🐛 Payment Information box on Order Information page of the checkout flow is empty Fixed . Feel free to reopen if this is a different issue.
- Status changed to Closed: duplicate
11 months ago 3:22pm 2 January 2024 This is great. I just received $15000 via hack transfer from d a r k w e b p r o g r a m m e r @ g m a i l .c o m , they awesome