Contents

Rule management

 

URL
Rules, conditions and actions are all managed through the MyST Rule Manager

To get there, click “Rule manager” from the navigation on the left of the MyST interface.

Note: You must have role Site admin, Developer or Developer 2 to view this page.

 

 


 

Create a rule

To create a rule, please follow these steps:

  1. Select the sitereference and action type from the drop-down boxes in the upper-left (1) and click “Change”.
  2. Follow the instructions provided under the “Information” pane (2) and use the buttons provided to create a condition and an action.
  3. Under the “Existing rules for site” tab (3), use the drop-down boxes to assign a condition to an action. Click “Save” to add the rule to your site. Once a rule has been created, it is immediately activated. (Information on rule deactivation is documented below)

 

Additional notes

Info
We recommend testing your rules on your test site reference before re-creating them on your live site reference.

 


 

Rule identifiers

There are two types of rule identifiers supported:

 

Secure Trading Rules (STR)

Rules with a rule ID of “STR-x” (where x is a number) are Secure Trading Rules. e.g. STR-1

These are pre-defined rules that are available to all merchants and are displayed within the Rule Manager interface. They can be activated and deactivated at any time on any of your sites. Secure Trading Rules cannot be modified or deleted.

 

User-Defined Rules (UDR)

Rules with a rule ID of “UDR-x” (where x is a number) are User-Defined Rules. e.g. UDR-23

These are rules created by MyST users using the Rule Manager interface. These can be modified by the users that created them and deleted when no longer needed.

 

Info
Secure Trading Rules always take priority over User-Defined Rules.

 


 

Activating and deactivating rules

You can activate or deactivate rules either within the MyST interface or by submitting additional fields in the JSON request.

 

Using MyST

Rules can be activated on any of your site references by using MyST. This can be used to easily apply rules to ALL of your processed requests, without having to modify the JSON submitted.

Rules can be activated/deactivated as required from the table on the lower-half of the page (3).

 

When a rule is first created, it will be shown as “Active” under the “Existing rules for site” tab, with a tick in the “Active” column. Rules can be deactivated by un-ticking the “Active” checkbox and pressing “Save” and likewise reactivated by re-ticking the “Active” checkbox and pressing “Save”.

Additional notes

 

In the JSON request

Rules can be activated for individual JSON requests by submitting the unique rule identifier in the ruleidentifier field. Rules specified in the JSON request will instruct our system to perform certain actions if pre-defined criteria are met (regardless of whether or not said rules have been set to active in MyST). The following is an example request where two rules STR-1 and UDR-23 are specified:

 


#!/usr/bin/python
import securetrading

stconfig = securetrading.Config()
stconfig.username = "[email protected]"
stconfig.password = "Password1^"
st = securetrading.Api(stconfig)

auth = {
  "sitereference": "test_site12345",
  "requesttypedescriptions": ["AUTH"],
  "accounttypedescription": "ECOM",
  "currencyiso3a": "GBP",
  "baseamount": "1050",
  "orderreference": "My_Order_123",
  "cachetoken": "token_posted_by_st.js",
  "ruleidentifier": ["STR-1","UDR-23"]
}

strequest = securetrading.Request()
strequest.update(auth)
stresponse = st.process(strequest) #stresponse contains the transaction response
<?php

if (!($autoload = realpath(__DIR__ . '/../../../autoload.php')) && !($autoload = realpath(__DIR__ . '/../vendor/autoload.php'))) {
  throw new Exception('Composer autoloader file could not be found.');
}
require_once($autoload);

$configData = array(
  'username' => '[email protected]',
  'password' => 'Password1^',
);

$requestData = array(
  'sitereference' => 'test_site12345', 
  'requesttypedescriptions' => array('AUTH'),
  'accounttypedescription' => 'ECOM',
  'currencyiso3a' => 'GBP',
  'baseamount' => '1050',
  'orderreference' => 'My_Order_123',
  'cachetoken' => 'token_posted_by_st.js',
  'ruleidentifier' => array('STR-1','UDR-23')
);

$api = \Securetrading\api($configData);
$response = $api->process($requestData);
var_dump($response->toArray());

?>
curl --user [email protected]:Password1^ https://webservices.securetrading.net/json/ -H "Content-type: application/json" -H "Accept: application/json" -X POST -d '{
"alias":"[email protected]",
"version": "1.00",
"request": [{
  "currencyiso3a": "GBP",
  "requesttypedescriptions": ["AUTH"],
  "sitereference": "test_site12345",
  "baseamount": "1050",
  "orderreference": "My_Order_123",
  "accounttypedescription": "ECOM",
  "cachetoken": "token_posted_by_st.js",
  "ruleidentifier": ["STR-1","UDR-23"]
}]}'

 

Info
Rules cannot be inherited in child requests. They can only be activated by using the methods described above.

 

Field specification

Key

 

Field name Type Request Description
ruleidentifier Alphanumeric including hyphens As shown in the example request above, you can submit unique identifiers for rules to be applied to this request (e.g. STR-1).

 


 

Was the action performed?

If a rule was applied to a request and the criteria specified in the condition were met, resulting in the action being triggered, the response contains additional fields to confirm this has taken place. Please refer to the example response below, where two rules were applied and their actions were performed.

Info
If a condition is not met, the action will not be performed and no additional fields will be returned in the response.

 


{
  u 'requestreference': u 'A0bxh87wt',
    u 'version': u '1.00',
    u 'responses': [{
      u 'transactionstartedtimestamp': u '2016-12-07 11:32:44',

#### OTHER FIELDS NORMALLY RETURNED IN AUTH RESPONSE ####

            u 'rules': [{
              u 'ruleidentifier': u 'STR-1',
              u 'ruledescription': u 'Auth security code not matched - Merchant decline'
            }, {
              u 'ruleidentifier': u 'UDR-23',
              u 'ruledescription': u 'successful Visa AUTH - server 1'
            }],
    }]
}
array(3) {
  ["requestreference"] => string(9) "A3579dkvx"
  ["version"] => string(4) "1.00"
  ["responses"] => array(1) {
    [0] => array(27) {

#### OTHER FIELDS NORMALLY RETURNED IN AUTH RESPONSE ####

      ["rules"] => array(2) {
        [0] => array(2) {
          ["ruleidentifier"] => string(5) "STR-1"
          ["ruledescription"] => string(49) "Auth security code not matched - Merchant decline"
        }
        [1] => array(2) {
          ["ruleidentifier"] => string(6) "UDR-23"
          ["ruledescription"] => string(31) "successful Visa AUTH - server 1"
        }
      }
  }
}
}
{
  "requestreference": "W23-fjgvn3d8",
  "version": "1.00",
  "response": [{

#### OTHER FIELDS NORMALLY RETURNED IN AUTH RESPONSE ####

            "rules": [
                {
                    "ruleidentifier": "STR-1",
                    "ruledescription": "Auth security code not matched - Merchant decline"
                },
                {
                    "ruleidentifier": "UDR-23",
                    "ruledescription": "successful Visa AUTH - server 1"
                }
            ],
  }],
  "secrand": "zO9"
}

 

Key

Field name Type Response Description
rules If any actions were performed, rules is returned in the response.

This contains information for each rule where an action was performed.

ruleidentifier Alphanumeric including hyphens For each rule where action was performed, the unique rule identifier (e.g. STR-1) will be returned in the response.

Always returned if an action has been triggered, otherwise not returned.

ruledescription Alphanumeric For each rule where action was performed, the rule description will be returned in the response. This consists of the condition name and action name in a string, both separated with a hyphen, as shown in the response example above.

 


 

Deleting rules

Rules can be deleted when required by using the table on the lower-half of the page (3).

 

Tick the “Delete” checkbox next to rule(s) you would like to remove from your site. When you are ready to delete the rule(s), press “Save”. The page will reload to reflect the changes made.

 

Additional notes