Payment Service Multiple Configurations
The Payment Service
functionality routes a message to a Payment Gateway Adapter based
on the paymentGatewayId
attribute. Each Payment Gateway Adapter can
have multiple configurations.
The /opt/mtx/conf/payment-service.yaml example file
includes the following parameters for the Braintree Payment Gateway Adapter:
- environment
- merchantId
- publicKey
- privateKey
- (Optional) bypassTokenExchange
Note: The configuration file must have a configuration named
default
. Any additional configurations, such as
config1
in this example, can be any naming convention you have
defined.payment:
gateway:
braintree:
configs:
default:
environment: sandbox
merchantId: nwqrtyrnkwfwc9m5
publicKey: 64qnktpmvhk447kb
privateKey: 93e7d2262d8f1506ec9afe448374ced5
bypassTokenExchange: true
config1:
environment: production
merchantId: testing
publicKey: 64qnktpmvhk447kb
privateKey: 93e7d2262d8f1506ec9afe448374ced5
bypassTokenExchange: true
Routing Rules
The routing rules defined in the /opt/mtx/data/payment-service.yaml indicate which configuration to use for the payment service. These routing rules apply to
multiple Payment Gateway Adapterconfigurations. For a description of the operators in the routing rules, see Supported Operator Values.
TenantId
is a unique ID that identifies the tenant across sub-domains. Routing Rules Properties describes the properties in the following
example:routing:
rules:
- name: default-braintree
paymentGatewayId: 1
targetConfig: default
weight: 100
- name: special-braintree-in
paymentGatewayId: 1
matches:
- field: TenantId
operator: in
value: 1,2,3
targetConfig: targetConfigIn
weight: 80
- name: special-braintree-like
paymentGatewayId: 1
matches:
- field: TenantId
operator: like
value: ^[12345].*$
targetConfig: targetConfigLike
weight: 70
- name: special-braintree-not-equal
paymentGatewayId: 1
matches:
- field: TenantId
operator: not_equal
value: 1
targetConfig: targetConfigNotEqual
weight: 20
- name: special-braintree-equal
paymentGatewayId: 1
matches:
- field: TenantId
operator: equal
value: 1
targetConfig: targetConfigEqual
weight: 90
Routing Rules Properties
describes the routing rule properties.
Property | Requirement | Description |
---|---|---|
routing.rules.name | Optional | A user-defined name that identifies a routing rule. |
routing.rules.paymentGatewayId | Required | Identifier for the specific payment gateway. If a payment gateway ID is not specified, the default payment gateway is used. |
routing.rules.matches | Not required for default routing. Required for custom routing. | Defines the filter that determines if this rule is selected.
You must define the following properties:
For example, field ( When a
Any unsupported operator or unmatched value selects default configuration. |
routing.rules.targetConfig | Required | Specifies the configuration that is used if this rule is
selected. It must match one of the gateway configurations
defined in the configuration file. For example, in the sample
file, the targetConfig value could be
<config1> . |
routing.rules.weight | Not required for default routing. Required for custom routing. | If more than one match criteria is true, the weight determines which rule is used to identify the targetConfig . The higher weight is selected.
For example, if special-braintree-in and special-braintree-equal both evaluate to true, then
special-braintree-equal is selected because its weight of 90 is greater than the special-braintree-in value of 80. |
Supported Operator Values
describes the operators that define a match in the routing rules.
Operator | Description |
---|---|
equal | Results in a match when the field is present
and equal to the value . |
like | Results in a match when the field is present
and matches a value specified with a regex
formula such as ^[12345].*$ . |
in | Results in a match when the field is present and matches one of the members in a comma-separated list of Strings in value such
as 1,2,3 . |
not_equal | Results in a match when the value in the
field is present and when the value does
not equal the value . |
not_like | Results in a match when the field is present
and does not match a value specified with a
regex formula such as ^[12345].*$ . |
not_in | Results in a match when the field is present and does not match one of the members in a comma-separated list of Strings in
value such as 1,2,3 . |