Paypal Buttons Don't Appear on Drupal 10

Created on 5 January 2023, almost 2 years ago
Updated 26 December 2023, 12 months ago

Specifications:

Ubuntu 22.04 Server
PHP 8.2
Latest Drupal 10 - installed with Composer
Latest Commerce and Commerce_Paypal modules - installed with composer

The issue is that I am stuck on the "Review" process screen and no Paypal buttons appear.

Steps to reproduce

1) Create a new installation of Drupal with composer
2) Install Commerce with Composer
3) Install Commerce Paypal with Composer
4) Enable the necessary modules (i.e. cart)
5) Configure the Payment Gateway to "Paypal Checkout (Preferred)". Select "Show Smart Payment Buttons on the cart page."
6) Create a Store
7) Create a product
8) Open the new product in an incognito browser window, add it to your cart and checkout as a Guest

I don't know what it is that I'm missing here... I fiddled around with several things, such as enabling the guest permission for "Manage own payment methods" (which shouldn't be necessary).

I thought it might have to do with my custom theme, so I tested this on a brand new install with the default theme.

I tested this in both live and sandbox mode for Paypal.

Please see attached screenshot (i.e. - no workflow step after the review page, where the button should be).

Your help is greatly appreciated.

🐛 Bug report
Status

Fixed

Version

1.0

Component

PayPal Checkout

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review almost 2 years ago
  • Status changed to Fixed almost 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed almost 2 years ago
  • 🇦🇺Australia ac Perth

    Line 165 of the patch to js/paypal-checkout-custom-card-fields.js in this commit breaks the card field on checkout. It throws a console error and you can not progress through the checkout:

    Uncaught TypeError: Cannot read properties of undefined (reading 'split')
        at HTMLInputElement.<anonymous> (paypal-checkout-custom-card-fields.js?rp1r4m:167:45)
        at Function.each (jquery.min.js?v=3.6.3:2:3003)
  • 🇦🇺Australia thursday_bw

    I realise this issue is closed and fixed, but I am seeing this exact issue.
    The buttons show for a logged in user, but not anonymous :/
    I have the latest release 1.4 from 18th Jan installed.. hmm.

  • 🇦🇺Australia thursday_bw

    Here you can see as a logged in user the relevant JS files are loaded.

    Here as an anonymous user, they are not.

  • 🇮🇱Israel jsacksick

    Do you have console errors to share? Anything? Do you have conditions set on the gateway configuration perhaps?

  • 🇦🇺Australia thursday_bw

    First thing I did was look for console errors, there was nothing to see there.
    I haven't set any conditions on my payment gateway

  • 🇦🇺Australia thursday_bw

    Network log FYI, nothing much to see here either.
    I can see that 'once' is loaded.

  • 🇮🇱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).

  • 🇦🇺Australia thursday_bw

    I have done some debugging.

    In this file: commerce_paypal/src/PluginForm/Checkout/PaymentMethodAddForm.php
    In the shouldInjectForm() method, `$plugin->getPaymentSolution() ` is returning `smart_payment_buttons` not `custom_card_fields`.

    Does that give you a clue?

  • 🇦🇺Australia thursday_bw

    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.
    so perhaps my reinstall resolved it. My previous setup was a database that had version 1.0 and had been upgraded to 1.4.. maybe that was it. I don't know.. It is 3am, I am going to be and will revisit this tomorrow and see if it still works.

    This is all on a stock standard drupal and I need to transfer to the site I am building, I have learned heaps, thanks for you prompt support.

Production build 0.71.5 2024