In this tutorial, we are going to discover Btop rules engine and create rules for a seller.
To complete this tutorial, you need to deploy and set up the plugins from the list below.
- Demo payment plugin portlet
- Paypal payment plugin portlet
They are available in the "Download" Page "Download".
In the administration panel you have to configure a seller account. You will also have to assign payment plugins to this seller. These steps are explained in the user guide.
Creating a rule
To set up the rules engine for a seller, access to Liferay BackOffice.
Click on Btop > Configuration > Sellers.
Then, click on "rules" for a particular seller
On the new screen, you get access to the rules engine configuration. Click on "Add rule".
Select a plugin from the drop down menu (for exemple "Paypal payment plugin").
Click on "+" to create a condition. Here are all the conditions availables:
«Has parameter» Test if the parameter exists.
«Parameter is smaller than» Test if the parameter is smaller than the entered value.
«Parameter (as a number) is equal to» Test if the numeric value of the parameter is equal to the entered
«Parameter contains» Test if the parameter contains a piece of text.
«Parameter is equal to» Test if the value is equal to the entered value.
«Parameter is larger than» Test if the parameter is larger than the entered value.
«Parameter matches» Test if the parameter matches the value (as a regular expression).
«Comma separated parameter contains» Test if the value of the parameter is contained in the list.
Select " Paramater is smaller than".
Click inside the field "Parameter (as a number)" and press the down arrow key to display suggestions.
Choose a parameter (for exemple "Transaction amount"):
"TransactionAmount", the amount of the transaction.
"CountryCode", the country code (FR, US...).
"TransactionCurrencyCode", the currency of the transaction (EUR, USD...).
Fill the "Is smaller than" field with a value, for exemple "20". This rule means that the Paypal payment plugin will be
used when the transaction amount is smaller than 20.
You can click on the if / if not toggle to invert it : the Paypal payment plugin would be used when the transaction
amount is not smaller than 20.
Click on "Save".
Creating a rule with multiple conditions
It is possible to associate multiple conditions in a block or sub-block.
Return to the previous exemple and add new conditions. On the left, you can change the value of the dropdown menu
to define how the conditions are grouped :
"Any", needs at least one valid condition to select the plugin.
"All", all conditions must be valid to select the plugin.
"Not all", at least one condition must be false to select the plugin.
"None", all conditions must be false to select the plugin.
Prioritizing plugins order
Once rules are created, they can be sorted. Rules on the top of the list have priority over rules that are under them.
If you want to prioritize plugin selection, you can drag and drop them to change their order.
The last (blue) line is a simple way to define a default plugin that will be picked if no rule is valid.