Skip to main content

Veritran Docs

Optional Steps in Configurable Transactions

The Optional feature allows you to configure optional steps within configurable transactions to manage transaction timeouts more effectively. It allows you to designate a request as optional within a transaction flow. This ensures that, if an optional step experiences a timeout or connection error, the transaction will continue without interruption. This is useful for non-critical services like verifying a user's promotions or a card balance, where delays should not disrupt the main transaction, such as a login transaction.

Important

To use this feature, you need to update VT-NET to version 1.15.0.14.

All actions that execute a request, such as HTTP Request, API Rest and API Soap, can be set as optional.

Once set as optional, the request shows three different paths: response, timeout and error. Depending on the service's response, the transaction will continue its execution through one of these paths. See the table below to learn about the transaction's behavior on each path.

Flow

Behavior

Result

Response

The request receives a response from the service, which can be successful or a failed response. Possible status received: 200, 300, 400, 500.

The value 000 is stored in token 10.

Timeout

The transaction does not receive a response from the service before the timeout configured in the optional request expires. In a sequential transaction, this would return errors such as H23, or H24 in the case of monetary transactions.

The 100 value is stored in token 10.

Error

The request cannot be completed due to a connection error caused by an incorrect url, an error on an SSL certificate, or an infrastructure issue with VT-NET. In a sequential transaction, this would return errors such as H78.

The 101 value is stored in token 10.

After one of these sets of steps is executed, the transaction will continue its execution from the main flow, connected to the request action (HTTP Request, API Rest or SOAP actions), until the End node. See an example in the section below.

Important

None of the possible responses received from the optional request will interrupt the core transaction's execution.

Create Optional Requests to Verify Promotions

See below for an example on how to build optional steps to validate users' promotions. Keep in mind that, since transactions vary depending on the functionality you want to build and on the client's requirements, you might encounter different approaches on how to build a similar transaction.

Consider this scenario: You need to create a flow for a transaction to validate if a user has any promotion available in its profile. This flow will be embedded within a login transaction, which will be the main transaction in this scenario. Since the promotions validation step is optional and must not interfere with the main transaction execution, this part of the flow is built by setting the request as optional. This way, if the promotions verification fails, the main login transaction will continue its flow as expected.

  1. Open your transaction where you want to include an optional request, or create a new one as described in Create a Configurable Transaction.

  2. Before creating an HTTP Request, you need to prepare the data on a Script action.

    1. Add a Script action to the canvas and, in the Configurations tab, change its name to PromotionsURL.

    2. Paste the service's data on the Script's editor. For this example, use the following, which is the service's URL.

    3. Go to the Script's output section and add the following outputs, which is the service's data that will be transferred to the next action: url, method, headers, body.

      opcionales_1.png
  3. Add an HTTP Request action to the canvas and connect it to the previous Script action. This request will be set as optional, since it will retrieve promotions information. To do this:

    1. Change the HTTP request name to GetPromotions to make the transaction functionality easier to understand.

      optional_true.gif
    2. Click the Is optional drop-down menu on the Configurations tab in the right panel and select True.

    3. In the Optional Timeout field , set a different timeout for this particular action. This is the time the transaction will wait for a response. Enter the timeout in seconds and make sure it does not exceed the transaction's timeout set in Settings. For this example, set 25 as the timeout.

  4. Configure the HTTP request action to receive data from the Script. Go to the HTTP Request's Inputs tab. Here, you see the url, method, headers and body dropdowns set. For each dropdown, click and select the corresponding data retrieved from the Script action, named PromotionURL.

    optional_rest.gif
  5. A Response, Timeout and Error chip will appear when setting the HTTP Request as optional. You can create a specific flow for each possible scenario. For this example, set a value for a variable so that you can then capture the response and track it. Set the value or message Transaction successful for a variable so that, if the transaction's request responds and continues through the response flow, you can see that value assigned to the variable. To do this, follow these steps:

    1. Add a Scrip action after each flow and connect them.

    2. Change the labels so that they are more intuitive when reading the transaction. Change the label for the Script after the response flow to ScriptResponseVar, the label for the one after the timeout flow to ScriptTimeoutVar, and the label for the one after the error flow to ScriptErrorVar. The transaction will look like the example below:

      Resumen_trx.png
    3. Paste the corresponding scripts for the Script actions following the Response, Timeout and Error paths:

      HttpReqVar = "Successful transaction"
      HttpReqVar = "Transaction timeout"
      HttpReqVar = "Transaction failed"
      script_variable.gif
    4. In the Outputs tab for each Script node, click Add Output, and add a value output as shown below. This will help create a data connection that will transfer the variable value to the next step in the flow.

  6. Then, you need to set the variable from the script, HttpReqVar, with the Set Variable action, and consume it. This process will be done in the three optional flows, and will allow you to retrieve data from each response.

    1. Add a Set Variable action after each flow and connect them.

    2. Change the labels so that they are more intuitive when reading the transaction. Change the label for the Set Variable after the response flow to SetResponseVar, the label for the one after the timeout flow to SetTimeoutVar, and the label for the one after the error flow to SetErrorVar. The transaction will look like the example below:

      optional_setvariable.png
    3. In the Variable Name field for the three Set Variable actions, set HTTPReqVar.

    4. Leave the data type as string.

    5. Select the first Set Variable action and go to the Inputs tab. Click the value dropdown and select the value parameter from the ScriptResponseVar Script, as shown below.

      input_setvariable.gif
    6. Repeat the previous step for the Set Variable actions placed after the timeout and error responses, and connect them with the outputs of the corresponding Script action.

  7. Add a Get Variable action after the HTTP Request and connect it to the main flow. Once the optional HTTP request is executed, the core transaction flow will continue from this Get Variable action. It will retrieve, from one of the three possible outcomes, the variable set with the Set Variable action and its value.

    1. In the Label field, change the action's name to GetResponseVar.

    2. In Variable Name, type HTTPReqVar, which was previously set.

    3. Connect it to the End node as the following step in the transaction.

      getvariabletrx.png
  8. Go to the End node and click the Inputs tab. The End node will receive the result of the service call and the variable from its corresponding response flow. For example, if the transaction receives a timeout from the service and continues from the timeout flow, it will then send the variable and its value to the Get Variable action, which will obtain the result and pass it to the End node.

    endoftrx.gif
    1. Click Inputs Bulk Connection and, on the Source node, click the Get Variable node.

    2. The value parameter will appear listed. Select it, enter the token where you want to store this information in the External Variable field, and click Import & connect.

    3. Click Inputs Bulk Connection again, now to receive the request's information. Select the HTTP Request from the Source node drop-down meu.

    4. The status and response parameters will appear listed. Select them, enter the tokens where you want to store this information in the External Variable field, and click Import & connect.

The optional flow explained above can be inserted into any transaction. For example, you can create a login transaction and add this optional request to retrieve an end user's available promotions.