ISO Rules

PruTAN's Hostbox module offers powerful rules features to enhance user experience during the development process by conditionally manipulating the response for ISO requests. These rules enable conditional adjustments to response data, ensuring tailored and precise responses during testing.

Example:

We will utilize the UPI_Debit request example simulated in Hostbox in the previous section to apply rules and validate the response.

// Request Body
<isomsg>
  <header/>
  <field id="0" value="0200"/>
  <!-- MTI (Message Type Identifier) for request -->
  <field id="2" value="9876543210987654321"/>
  <!-- Primary Account Number (PAN) -->
  <field id="3" value="310000"/>
  <!-- Processing Code: 310000 for UPI Debit -->
  <field id="4" value="000000010000"/>
  <!-- Transaction Amount: 100.00 (amount in cents) -->
  <field id="7" value="2503221123"/>
  <!-- Transmission Date & Time (YYMMDDhhmmss) -->
  <field id="11" value="123456"/>
  <!-- Systems Trace Audit Number (STAN) -->
  <field id="12" value="012345"/>
  <!-- Time, Local Transaction (hhmmss) -->
  <field id="13" value="2503"/>
  <!-- Date, Local Transaction (MMDD) -->
  <field id="41" value="12345678"/>
  <!-- Terminal Identification -->
  <field id="43" value="UPIAPP"/>
  <!-- Application Name -->
</isomsg>

// Response Body
<isomsg>
  <header/>
  <field id="0" value="0210"/>
  <!-- MTI (Message Type Identifier) for response -->
  <field id="2" value="9876543210987654321"/>
  <!-- Primary Account Number (PAN) -->
  <field id="4" value="000000010000"/>
  <!-- Transaction Amount: 100.00 (amount in cents) -->
  <field id="11" value="123456"/>
  <!-- Systems Trace Audit Number (STAN) -->
  <field id="39" value="00"/>
  <!-- Response Code: 00 (Approved) -->
  <field id="43" value="UPIAPP"/>
  <!-- Application Name -->
</isomsg>

Now, we have written a Rules script to update the response conditionally:

// Rules script

// ISO if-else block with Get & Set variable
if (req.getBody('4') > '10000') {
  res.setBody('54', '35610C0005000');
} else {
  res.setBody('54', '35610C0001000');
}

// 356 → Currency Code for INR
// 10 → Cashback amount type
// C → Credit
// 0005000 → 50.00 INR

Now, navigate to the API module and execute this request following the steps provided in the previous section using necessary data like URL, reqBody, port, etc. You will get the conditionally updated response.

// Expected Response Body after rule implementation
<isomsg>
  <!-- org.jpos.iso.packager.GenericPackager -->
  <field id="0" value="0210"/>
  <field id="2" value="9876543210987654321"/>
  <field id="4" value="000000010000"/>
  <field id="11" value="123456"/>
  <field id="39" value="00"/>
  <field id="43" value="UPIAPP                                  "/>
  <field id="54" value="35610C0001000"/>
</isomsg>

In the above response, we have added an additional field 54 using rules scripts. You can compare both responses (With Rule & without Rule) and find the difference in Field ID = 54.

PruTAN's Hostbox Rules feature empowers users to fine-tune responses with precision and agility. By harnessing dynamic adjustments based on request conditions, it enhances the testing environment's adaptability and accuracy, ultimately facilitating smoother development cycles.