Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
extendingConditionPluginBase
\Drupal\commerce_payment\Plugin\Commerce\PaymentGatewayCondition\GatewayConditionInterface
extendingConditionInterface
\Drupal\commerce_payment\PaymentGatewayConditionManager
extendingDefaultPluginManager
\Drupal\commerce_payment\Annotation\PaymentGatewayCondition
extendingCondition
annotation
Then enhance \Drupal\commerce_payment\PaymentGatewayStorage::loadMultipleForOrder
to filter the enabled Gateways using the Conditions.
Remaining tasks
- Agree on the approach.
- Build
- 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.
Comment | File | Size | Author |
---|---|---|---|
#11 | Screenshot_20170628_202038.png | 36.2 KB | bojanz |
#7 | payment-conditions.patch | 21.28 KB | jespermb |
Comments
Comment #2
FatherShawnWe are happy to contribute this feature.
Comment #3
FatherShawnComment #4
jespermb CreditAttribution: jespermb at Adapt commentedHas any thought gone into this?
We are very interested in a solution for payment filtering.
Comment #5
FatherShawn@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.
Comment #6
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedi believe even this issue comes under the gateway conditionals?? https://www.drupal.org/node/2860111
Comment #7
jespermb CreditAttribution: jespermb at Adapt commentedNot 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.
Comment #8
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedAdding a related issue which has patch and pr from matt. : https://www.drupal.org/node/2882861
Comment #9
bojanz CreditAttribution: bojanz at Centarro commentedRebuilding this on top of the new CommerceCondition API (that we extracted from promotions).
Comment #10
FatherShawnYou are awesome, @bojanz, thank you for adding this!
Comment #11
bojanz CreditAttribution: bojanz at Centarro commentedWelcome to a Commerce world without Rules :)
100 lines of code, thanks to the new API.