Override payment gateway settings
Describes payment gateway setting extensibility.
You can use extensions to override payment gateway settings. This allows you to define multiple payment gateways per site and multiple MIDs for the same gateway.
-
Create a class that extends HandlerBase.
[DependencyName(nameof(SetGatewayOverride))] public class SetGatewayOverride : HandlerBase<UpdateCartParameter, UpdateCartResult> { // … }
-
Within that class, Override HandlerBase and order with an appropriate value. This value determines when your setting override will happen; smaller numbers run sooner, and larger numbers run later. When overriding payment gateway setting values, it’s important to choose a number that will execute before the payment is actually processed.
public override int Order => 2750;
-
Override
HandlerBase.Execute
, populatingparameter.OverridePaymentGatewaySettings
with appropriate override values.public override UpdateCartResult Execute(IUnitOfWork unitOfWork, UpdateCartParameter parameter, UpdateCartResult result) { parameter.OverridePaymentGatewaySettings = new Dictionary<string, string>() { {"PaymentGatewayName", "AuthorizeDotNet"} }; return this.NextHandler.Execute(unitOfWork, parameter, result); }
Overridden settings are pairs of string values. The first member of the pair is the name of a setting, and the second member of the pair is the value that setting should take on. In the example above, Configured Commerce will ignore the payment gateway set in the Admin Console and use AuthorizeDotNet instead.
The setting PaymentGatewayName
can take any of the following values:
• Adyen
• APS Payments
• AuthorizeDotNet
• Bambora
• CardConnect
• Cenpos
• CyberSource
• EbizCharge
• Elavon
• Evo
• Moneris
• Orbital
• Payeezy
• PayflowPro
• Paymetric
• PaypalExpress
• PayTrace
• Square
• Stripe
• StripeSepa
• Vantiv
• VantivExpress
Overriding settings enables you to select which payment gateway Configured Commerce will use, and in the specific cases of AuthorizeDotNet and CardConnect, you can also control the gateways’ internal settings.
AuthorizeDotNet
The available settings are:
• MerchantId (string)
• SuccessfulResponseCodes (string)
• TransactionKey (string)
• PaymentTokenizationEnabled (boolean)
• TestMode (boolean)
• UseComplexMerchantCustomer (boolean)
• UseEndUserIpAddress (boolean)
Overriding all available settings for AuthorizeDotNet might look like this:
public override UpdateCartResult Execute(IUnitOfWork unitOfWork, UpdateCartParameter parameter, UpdateCartResult result)
{
parameter.OverridePaymentGatewaySettings = new Dictionary<string, string>()
{
{"MerchantId", "01234567"},
{"SuccessfulResponseCodes", "378;402;403"},
{"TransactionKey", "01234567"},
{"PaymentTokenizationEnabled", "true"},
{"TestMode", "true"},
{"UseComplexMerchantCustomer", "false"},
{"UseEndUserIpAddress", "false"},
};
return this.NextHandler.Execute(unitOfWork, parameter, result);
}
CardConnect
The available settings are:
• ApiPassword (string)
• ApiUsername (string)
• MerchantId (string)
• ProductionEndpoint (string)
• SandboxEndpoint (string)
• GatewayVault (boolean)
• TestMode (boolean)
Overriding all available settings for CardConnect might look like this:
public override UpdateCartResult Execute(IUnitOfWork unitOfWork, UpdateCartParameter parameter, UpdateCartResult result)
{
parameter.OverridePaymentGatewaySettings = new Dictionary<string, string>()
{
{"ApiPassword ", "testing123"},
{"ApiUsername ", "testing"},
{"MerchantId ", "01234567"},
{"ProductionEndpoint ", "https://fts.cardconnect.com:6443/cardconnect"},
{"SandboxEndpoint ", "https://test-fts.cardconnect.com:6443/cardconnect"},
{"GatewayVault ", "false"},
{"TestMode ", "true"},
};
return this.NextHandler.Execute(unitOfWork, parameter, result);
}
The “boolean” type can take on one of two values: true or false. When overriding payment gateway settings, the strings “true” or “false” represent boolean values . The string type is a “string” of characters, like a word or a phrase.
Any settings that you do not override will take on the values configured in the Admin Console. This makes it possible to override as few or many settings as you need. You can also select any payment gateway (as shown in the first example above), and it will take on the settings configured in the Admin Console for that gateway.
Note
Configured Commerce will ignore unrecognized setting names. If your attempts to override payment gateway settings do not seem to be working, double-check the spelling – including the capitalization – of the setting names you are using.
Updated over 1 year ago