Variable data validation

  • My question:

I have variable data in a JSON type response, and I want to perform conditions depending on certain parameters. for example:

If in the Body the parameter is * “formaPago”: “PARTIAL” * it means that the client can digitalize a value less than or equal to * “total amount”: * but if the total amount is greater than 1000, he can only pay between 10 and 1000.

If in the Body the parameter is * “formaPago”: “TOTAL” * it means that the client can only pay the * “total amount”: * but if the total amount is greater than 1000, he must reject the sending of an amount message.

  • Details (like screenshots):

Example response of a QUERY “formaPago”: “PARTIAL” greater than 1000

{
“codigoRespuesta”: “00”,
“message”: “Successful transaction”,
“ClientName”: “TESTS 301021”,
“OrdenPrelacion”: “BACK FEE”,
“ready”: [
{
“nroFactura”: “37427”,
“Amount Debt”: 100000.00,
“comisionServicio”: 2.00,
“comisionCanal”: 8.00,
“comisionEmpresa”: 5.00,
“AdditionalConcepts”: null,
“amountTotal”: 100015.00,
* “formaPago”: “PARTIAL”, *
“minimum amount”: 1,
“AmountMaximo”: 100015.00,
“tipoIntegracion”: “ONLINE”,
“DateEmision”: “20210511”,
“expiration date”: “20210511”,
“order”: “1”
}
]
}

Example response of a QUERY “formaPago”: “PARTIAL” less than 1000

{
“codigoRespuesta”: “00”,
“message”: “Successful transaction”,
“ClientName”: “TESTS 381121”,
“OrdenPrelacion”: “BACK FEE”,
“ready”: [
{
“nroFactura”: “37857527”,
“Amount Debt”: 450.00,
“comisionServicio”: 1.00,
“comisionCanal”: 0.00,
“comisionEmpresa”: 4.00,
“AdditionalConcepts”: null,
“amountTotal”: 455.00,
* “formaPago”: “PARTIAL”, *
“minimum amount”: 1,
“AmountMaximo”: 455.00,
“tipoIntegracion”: “ONLINE”,
“DateEmision”: “20210511”,
“expiration date”: “20210511”,
“order”: “1”
}
]
}

Example response of a QUERY “formaPago”: “TOTAL” Greater than 1000

{
“codigoRespuesta”: “00”,
“message”: “Successful transaction”,
“ClientName”: “TESTS 110521”,
“OrdenPrelacion”: “INDISTINCT”,
“ready”: [
{
“nroFactura”: “2020001003018”,
“Amount Debt”: 5500.00,
“comisionServicio”: 0.00,
“comisionCanal”: 3.00,
“comisionEmpresa”: 2.00,
“AdditionalConcepts”: null,
“amountTotal”: 5505.00,
“formaPago”: “TOTAL”,
“minimum amount”: 0,
“AmountMaximo”: 0,
“tipoIntegracion”: “Online”,
“broadcast date”: “20200124”,
“expiration date”: “20200424”,
“order”: “1”
}
]
}

Example response of a QUERY “formaPago”: “TOTAL” Less than 1000

{
“codigoRespuesta”: “00”,
“message”: “Successful transaction”,
“ClientName”: “TESTS 95623”,
“OrdenPrelacion”: “INDISTINCT”,
“ready”: [
{
“nroFactura”: “2020001007539923”,
“Amount Debt”: 88.00,
“comisionServicio”: 0.00,
“comisionCanal”: 0.00,
“comisionEmpresa”: 0.00,
“AdditionalConcepts”: null,
“amountTotal”: 88.00,
“formaPago”: “TOTAL”,
“minimum amount”: 0,
“AmountMaximo”: 0,
“tipoIntegracion”: “Online”,
“broadcast date”: “20210124”,
“expiration date”: “20210424”,
“order”: “1”
}
]
}

  • I’ve already tried:

I have this parameter for the “formaPago”: “PARTIAL” greater than 1000 in the PAYMENT Endpoint send {{formaPago}}

Pre-request Script
pm.environment.set (“formPago”, _.random ((10,1000) * +1, true) .toFixed (2))

//////////////////////////////////////////////////// ///////////////////////////////////////////////

For the “formaPago”: “Total” Less than 1000 I capture the data of the QUERY response, I store it in a variable and send it to another Payment Endpoint {{formaPago}}

Test
var json = JSON.parse (responseBody);
postman.setEnvironmentVariable (“amountTotal”, json.list [0] .importTotal);