GatewayFactory Class

GatewayFactory is the class with one method getGateway which is responsible for returning the required gateway object. See below sample code.

To get the AUTHORIZE gateway.

   Gateway gateway = GatewayFactory.getGateway(AvailableGateways.AUTHORIZE);

Since java enum also support string values if you are getting gateway name from database here is how you could get gateway by string name.

   Gateway gateway = GatewayFactory.getGateway(AvailableGateways.valueOf("AUTHORIZE"));
Note: To know all supported gateways by J2pay see supported gateways section.