Problem/Motivation

In addition to supporting multiple gateways on the payment form (See related issues) we also need to implement Conditions to give control over which gateways to load. This is a todo tag in \Drupal\commerce_payment\PaymentGatewayStorage::loadMultipleForOrder

Proposed resolution

I looks to me like we need the following:

  • \Drupal\commerce_payment\Plugin\Commerce\PaymentGatewayCondition\GatewayConditionBase extending ConditionPluginBase
  • \Drupal\commerce_payment\Plugin\Commerce\PaymentGatewayCondition\GatewayConditionInterface extending ConditionInterface
  • \Drupal\commerce_payment\PaymentGatewayConditionManager extending DefaultPluginManager
  • \Drupal\commerce_payment\Annotation\PaymentGatewayCondition extending Condition annotation

Then enhance \Drupal\commerce_payment\PaymentGatewayStorage::loadMultipleForOrder to filter the enabled Gateways using the Conditions.

Remaining tasks

  1. Agree on the approach.
  2. Build
  3. Test

User interface changes

None for this issue at first. Conditions can be code only to start.

API changes

Would make Conditional Gateways available to gateway developers.

Data model changes

None that I can see.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FatherShawn created an issue. See original summary.

FatherShawn’s picture

Assigned: Unassigned » FatherShawn

We are happy to contribute this feature.

FatherShawn’s picture

Issue summary: View changes
jespermb’s picture

Has any thought gone into this?

We are very interested in a solution for payment filtering.

FatherShawn’s picture

@jespermb Yes - I've discussed it with mglaman but not updated the issue summary. The intent now is it use the Conditional subsystem already in Core to define conditions on gateways and display those gateways which pass their conditions. Now that #2827144 is addressed it seems like time to tackle this one.

sumanthkumarc’s picture

i believe even this issue comes under the gateway conditionals?? https://www.drupal.org/node/2860111

jespermb’s picture

FileSize
21.28 KB

Not sure, but i have created an initial patch which we are testing at the moment.

This allows you to select conditions on the payment gateway and it will validate those conditions when you reach the payment information step.

Unfortunately I don't have time to write tests at the moment, but if someone could have a look at it and see if its going the correct way.

sumanthkumarc’s picture

Adding a related issue which has patch and pr from matt. : https://www.drupal.org/node/2882861

bojanz’s picture

Title: Add Payment Gateway Conditionals » Add Payment Gateway Conditions
Assigned: FatherShawn » bojanz
Status: Active » Needs work

Rebuilding this on top of the new CommerceCondition API (that we extracted from promotions).

FatherShawn’s picture

You are awesome, @bojanz, thank you for adding this!

bojanz’s picture

Status: Needs work » Fixed
FileSize
36.2 KB

Welcome to a Commerce world without Rules :)

100 lines of code, thanks to the new API.

  • bojanz committed a5f646b on 8.x-2.x
    Issue #2835574 by jespermb, FatherShawn, bojanz: Add Payment Gateway...

Status: Fixed » Closed (fixed)

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