Set custom values for gateway-specific fields
How to configure gateway-specific fields using Payment Service in Optimizely Configured Commerce.
Optimizely Configured Commerce's Payment Service lets you create a provider to configure specific fields for your gateway.
The following example takes the transaction type and dictionary of custom parameters as input parameters.
The transaction type is set automatically and depends on the current transaction's type.
The parameters are passed from the properties of the AddPaymentTransactionParameter object, which you can populate in the ProcessCreditCardTransactions handler.
There are two ways to customize gateway-specific fields:
- Static fields – Create a custom
GatewaySpecificFieldsProvider. - Flexible fields – Create a custom
GatewaySpecificFieldsProviderand override theProcessCreditCardTransactionshandler and pass custom string values throughAddPaymentTransactionParameter.
Structure of the GatewaySpecificFields object
GatewaySpecificFields objectGatewaySpecificFields is the outer container object. It has a property called GatewaySpecifics, which is a list of GatewaySpecific objects.
GatewaySpecific represents settings or parameters specific to a single payment gateway. In this example, the GatewayName is stripe_payment_intents, meaning these settings are for the Stripe Payment integration. Fields is a list of key-value pairs (GatewaySpecificField) that define specific options or behaviors for this gateway.
GatewaySpecificField represents a single setting for the payment gateway. In this example, Name is request_multicapture, and Value is if_available.
Example
public class CustomGatewaySpecificFieldsProvider : IGatewaySpecificFieldsProvider
{
public GatewaySpecificFields GetGatewaySpecificFields(
TransactionType transactionType,
IDictionary\<string, string> parameters
)
{
return new GatewaySpecificFields
{
GatewaySpecifics = new List<GatewaySpecific>()
{
new GatewaySpecific
{
GatewayName = "stripe_payment_intents",
Fields = new List<GatewaySpecificField>
{
new GatewaySpecificField
{
Name = "request_multicapture",
Value = "if_available"
}
}
}
}
};
}
}Updated 9 days ago