Skip to content

guide on how to add support for new payment mode

Danish Jamal edited this page Nov 10, 2022 · 1 revision

Guide to add new payment mode support for bulk processor

DOCUMENTATION
Payment mode is a field in input data to bulk processor, which is used for determining where this type of transaction/s should go for processing. Considering the default implementation of bulk processor, the SLCB payment mode will be redirect to slcb flow. Similary in future there can be many new modes like gsma, mojaloop etc. So this doc focuses on explaining how one can add a support for new payment mode, with minimum code changes and keeping the code separated.

Pre requisite

  1. Familiarity with camel routes. (For reference)
  2. Aware of exchange patterns in camel routes. (For reference)
  3. Have understanding of zeebe-variables. (For reference)

Low Level Design

The brief design overview of how things are implemented.
Step1: Parse the payment mode and set default zeebe variables.
Step2: Match condition for respective payment modes.
Step3: Adds mode specific zeebe variables and start the respective process.

*Note:

  1. The step referenced in the document after this part refers to the steps mentioned above in Low Level Design.
  2. All the code referenced in this doc, belongs to the bulk-processor github repository.

How to add new payment mode

Step1 in LLD reference to the direct:start-workflow-step1 camel route, and it doesn't needed to be modified until and unless there is any change in zeebe variables which is common to all the payment modes. Step1 parses and sets the zeebe variable named PAYMENT_MODE which contains the value of payment mode. For step2 in LLD refer the direct:start-workflow-step2 camel route. It contains the camel condition checks for different payment mode. Similarly add the new camel when clause for the new payment mode. For example, .when(exchangeProperty(PAYMENT_MODE).isEqualToIgnoreCase("gsma")). For adding the functionality part of new payment mode add the new .process() block just after the camel when clause. It would look something like.

.when(exchangeProperty(PAYMENT_MODE).isEqualToIgnoreCase("gsma"))
.process(exchange -> {
}

Now you can add all the logic and modify existing zeebe variable(refer below snipper). Based on the requirement for the new payment mode.

.when(exchangeProperty(PAYMENT_MODE).isEqualToIgnoreCase("gsma"))
.process(exchange -> {
    Map<String, Object> variables = exchange.getProperty(ZEEBE_VARIABLE, Map.class);
    variables.put("key", "value");
}

Incase you need to start the new zeebe workflow use zeebeProcessStarter object or if you want to make an external API call use the camel syntax .toD("{endpoint}").