Rename js_library CommercePaymentGateway plugin key to libraries

Created on 5 August 2024, about 1 month ago
Updated 2 September 2024, 14 days ago

Describe your bug or feature request.

Payment Gateway plugins can define js_library to be attached in different scenarios when the payment gateway option is available for selection. That feature is used by Braintree among other payment modules. The plugin key was added in #2854852: Payment gateway JS is not always loaded .

While this feature is working just well it doesn't fully reflect what are the possibilities therefore the naming can be a bit confusing. Ie. the library doesn't have to only feature JS scripts, it can also feature CSS stylesheets (for example with gateway branding). It can even feature CSS without JS.

Furthermore, there is no reason why plugins should be limited to feature only one library. While additional libraries could still be defined and attached via library dependency we are missing the possibility to conditionally load some libraries, ie. based on plugin configuration. Having the ability to add multiple libraries (mix of CSS ad JS) could help resolve some long-standing issues like #3183931: Display credit card icons in the checkout form . It could also help Payment Gateway to provide branding that should be featured along with the payment method option in the checkout form.

Feature request
Status

Fixed

Version

3.0

Component

Payment

Created by

🇳🇴Norway zaporylie

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

Merge Requests

Comments & Activities

  • Issue created by @zaporylie
  • 🇳🇴Norway zaporylie

    Proposed solution:

    • Add libraries key to plugin definition.
    • Mark js_library as deprecated.
    • Append library defined in js_library to the array of libraries for backward compatibility
    • Adjust code attaching libraries to follow the new format (libraries are arrays of strings, not strings).
  • 🇮🇱Israel jsacksick

    Sounds like a good improvement to me, would you like to work on this?

  • Status changed to Needs review about 1 month ago
  • 🇳🇴Norway zaporylie

    Just added the MR.

  • Pipeline finished with Success
    about 1 month ago
    Total: 737s
    #244452
  • Pipeline finished with Success
    about 1 month ago
    Total: 633s
    #244465
  • 🇮🇱Israel jsacksick

    I'm thinking that we should deprecate the $js_library property as well (both in the annotation and the attribute, and as discussed in Slack, wondering if we should adopt the deprecated format that includes the version number.
    Basically, deprecated in Commerce 3.0.x and removed from Commerce 4.0.x perhaps? Or Commerce 3.1.x? Not sure.

  • Pipeline finished with Success
    about 1 month ago
    Total: 683s
    #244517
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 185s
    #244545
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 340s
    #244546
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 524s
    #244554
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 402s
    #244563
  • Pipeline finished with Success
    about 1 month ago
    #244572
  • Pipeline finished with Success
    about 1 month ago
    Total: 460s
    #244609
  • Status changed to Fixed about 1 month ago
  • 🇮🇱Israel jsacksick

    Thank you for this, merged!

  • 🇮🇱Israel jsacksick

    I was writing a change record for this change, but noticed the actual core issue referenced has been fixed since D9.4.5... Do we still need the workaround/fix, or perhaps we still need this mechanism in place so there is no need to add the library as part of the render array?

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

  • Pipeline finished with Failed
    6 days ago
    Total: 390s
    #279807
  • Pipeline finished with Failed
    5 days ago
    Total: 432s
    #280128
  • Pipeline finished with Failed
    4 days ago
    Total: 648s
    #281562
  • Pipeline finished with Failed
    3 days ago
    #282567
Production build 0.71.5 2024