Dispatch event in Payment Options builder to filter out specific payment methods

Created on 14 June 2024, 14 days ago

Describe your bug or feature request.

In some cases when using multiple payment method types from the same payment gateway, there is a need to hide or remove specific payment method types.

Scenario:
The shop has a payment gateway commerce_braintree with Paypal options enabled. Among those are credit_card, google_pay, apple_pay, paypal_credit and paypal_pay_later options.

The default output shows all 5 options rendered as radio buttons in the payment pane.
The problem is some of these methods have specific conditions
- Apple Pay - works only on Apple devices
- Paypal Credit and Paypal Pay Later - have specific GEO restrictions.

Possible workarounds
- create multiple payment gateways of Braintree type, select a specific payment method on each, and manipulate per conditions visibility
- JS or form alter unset of specific methods

Proposed solution

Dispatch event inside \Drupal\commerce_payment\PaymentOptionsBuilder::buildOptions to allow filtering out per payment method type, or any other criteria

If a bug, provide steps to reproduce it from a clean install.

📌 Task
Status

Fixed

Version

2.0

Component

Payment

Created by

🇭🇷Croatia valic Osijek

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024