Overriding settings in custom code

Some Payment Gateways in Optimizely B2B Commerce support the ability to accept overridden settings when creating a payment transaction. This article explains what modifications need to be made to support this behavior in custom code.

Today, there are four payment gateways that support this behavior. Included below are the settings.

Gateway Settings
Authorize.Net MerchantId, TransactionKey
CenPOS AccountId, AccountToken, AcceptorID
VantivExpress/WorldPay Express MerchantId, UserId, Password
Moneris ApiToken, StoreId
Stripe TestApiSecretKey, LiveApiSecretKey

Underlying principles

In order to understand the logic behind overriding settings in custom code, it is important first to understand the concept of a handler chain. In B2B Commerce, this is a series of classes that are called consecutively. Files in this chain are typically numbered incrementally in orders of 100. This is the order in which the handler chain executes. In order to insert a new link into this chain, you would simply need to insert the link into that sequence with an order that fits into the handler chain. This logic will apply to the procedure described below.

In the UpdateCartParameter.cs that gets passed into the UpdateCartHandler, there is a property public Dictionary<string, string> OverridePaymentGatewaySettings { get; set; }. This property is then passed into the AddPaymentTransaction.cs in ProcessCreditCardTransactions.cs right before being sent into the PaymentService. The objective in the following procedure is, first, to add the needed key value pairs to the dictionary. Those values will then be passed into AddPaymentTransaction.


To modify code to accept overridden settings when creating a payment transaction, Optimizely recommends creating a new link in the handle chain. This link should have an order that is:

  1. Lower than 2800 and

  2. Not already in use.

The new link will simply add the needed key value pairs to parameter.OverridePaymentGatewaySettings and continue on to the next link in the handler chain, As a result, when handler execution gets to ProcessCreditCardTransactions (which has an order value of 2800), the dictionary in question would already be populated with the correct values.


Here are some examples of possible value pairs utilizing the CenPOS structure:


{ "MerchantId", "123456ABCD" }


{ "UserId", "123ABC" }


{ "Password", "123ABC!@#" }