Location-based products simulation
π§ͺ Simulating a Location-Based Purchase with Dummy Products#
This guide explains how to test in a simulated way your implementation of the dynamic flow of location-based dummy products using CSQβs API suite. This simulation mimics real-world selection logic based on geography and product catalog, providing developers with a reliable test structure for integration and error handling.
π General Overview#
Location-based products follow a dynamic path composed of chained GET
calls, each one revealing the next step (nextPath
, nextField
). This approach guarantees that your integration remains resilient to product complexity changes or future updates to the API structure.π§ Remember you can use the Get Labels method to have a preview of all the possible steps any dynamic flow might have.
This dummy sequence is geographically contextualized and, in the case of this dummy flow, it specifically follows:6.
Create Cart (always mandatory)
7.
Purchase (alwaysmandatory)
The only optional step skipped in this dummy flows is Get Deliver Locations
, but have mind it could play a role in real life products. This is why it is mandatory to follow the flow through the nextPath
field from each response..β οΈ Important Notice β Dynamic Flow LogicThe location-based product flow follows a dynamic GET sequence, where each response includes a nextPath
indicating the next endpoint to call. This path-driven logic means the number of steps required before reaching GET /products
can vary depending on the specific product configuration.π§ In real scenarios, some products may involve:Additional intermediate steps, such as districts, sectors, or delivery points
Or fewer steps, skipping certain fields entirely
β
To ensure compatibility across all products, never hardcode assumptions about the number of steps. Instead:Always follow the nextPath
provided in each API response
Continue iterating until you reach the product listing endpoint
π Dynamic GET Sequence in this dummy scenario#
The full sequence of dynamic GET
requests for location-based dummy products, is designed to simulate geographical product selection before cart creation and purchase.Each call returns a nextPath
, guiding the client to the next step. Dummy responses are predictable and reusable for developer tests β especially with fixed values such as categoryId = 8
,countryId = 192
, stateId = 473
, and municipalityId = 499
.Letβs walk through the GET flow in simple terms, with full example responses and developer tips β
.
π Step 1 β Get Countries#
[
{
"countryId": 192,
"name": "Cuba",
"nextPath": "/physical-products/categories/{{terminalId}}/192",
"nextField": "categoryId"
}
]
countryId = 192
β Required for Create Cart
Follow the nextPath
shown above.
ποΈ Step 2 β Get Categories#
[
{
"categoryId": 4,
"name": "PHONE",
"nextPath": "/physical-products/states/{{terminalId}}/4/192",
"nextField": "stateId"
},
{
"categoryId": 5,
"name": "MODEM",
"nextPath": "/physical-products/states/{{terminalId}}/5/192",
"nextField": "stateId"
},
{
"categoryId": 2,
"name": "COMBO",
"nextPath": "/physical-products/states/{{terminalId}}/2/192",
"nextField": "stateId"
},
{
"categoryId": 8,
"name": "DUMMY",
"nextPath": "/physical-products/states/{{terminalId}}/8/192",
"nextField": "stateId"
}
]
categoryId = 8
("DUMMY") β needed for dummy flow.
Follow its nextPath
to load states.
β οΈ Important Warning β Dummy Flow SafetyWhen testing the location-based product flow, it is mandatory to use category 8
("DUMMY"). This category is specifically designed for simulation and safe testing.π« Using any other category (e.g. "PHONE"
, "MODEM"
, "COMBO"
) may result in:Actual charges to your account
Irreversible transactions affecting end users
categoryId = 8
is selected when building the dummy test flow.
π For internal QA and developer environments, hardcode categoryId = 8
when applicable or validate programmatically before sending requests to cart and purchase endpoints.This practice protects your team, your customers, and your integration from accidental costs or data exposure.
ποΈ Step 3 β Get States#
Response Example (shortened):[
{
"stateId": 472, "name": "Pinar del RΓo", "nextPath": "/physical-products/municipalities/{{terminalId}}/8/472", "nextField": "municipalityId"
},
{
"stateId": 473, "name": "La Habana", "nextPath": "/physical-products/municipalities/{{terminalId}}/8/473", "nextField": "municipalityId"
},
{
"stateId": 474, "name": "Artemisa", "nextPath": "/physical-products/municipalities/{{terminalId}}/8/474", "nextField": "municipalityId"
}
]
stateId = 473
("La Habana") β required for cart creation
ποΈ Step 4 β Get Municipalities#
Response Example (shortened):[
{
"municipalityId": 499, "name": "Centro Habana", "nextPath": "/physical-products/products/{{terminalId}}/8/499", "nextField": "productId"
},
{
"municipalityId": 512, "name": "Habana Vieja", "nextPath": "/physical-products/products/{{terminalId}}/8/512", "nextField": "productId"
},
{
"municipalityId": 513, "name": "Diez de Octubre", "nextPath": "/physical-products/products/{{terminalId}}/8/513", "nextField": "productId"
}
]
municipalityId = 499
("Centro Habana") β required for cart creation
π¦ Step 5 β Get Products#
[
{
"productPriceX100": 100,
"productId": 846,
"operatorId": 9988,
"name": "Arroz 1kg",
"description": "Paquete de arroz de 1 kilogramo",
"imageUrl": "https://static.csqworld.com/flags/CU.png"
},
{
"productPriceX100": 100,
"productId": 847,
"operatorId": 9988,
"name": "Aceite 1L",
"description": "Botella de aceite de 1 litro",
"imageUrl": "https://static.csqworld.com/flags/CU.png"
}
]
productId = 846
("Arroz 1kg") -> required as a parameter in the body of create cart
step.
operatorId = 9988
β required as a parameter in the Create Cart
and Purchase
steps.
π Summary of Dummy Test Values (Stable)#
Field | Dummy Value |
---|
countryId | 192 β Cuba |
categoryId | 8 β Dummy |
stateId | 473 β La Habana |
municipalityId | 499 β Centro Habana |
β
These are fixed values you can hardcode for dummy testing.
The only variable is the actual product (productId
and operatorId
), which may change.
β οΈ Important Reminder β Follow nextPath
AlwaysIn real product flows, the number of GET steps may increase or decrease depending on configuration.
Thatβs why you should always:Read the nextPath
from each response
Donβt skip or guess the next call
Continue until you reach GET /products
π Step 6: Create Cart#
{
"productId": 846,
"countryId": 192,
"stateId": 473,
"municipalityId": 499,
"buyerName": "TEST CSQ",
"buyerSurname": "TEST CSQ",
"buyerPhone": "123456789",
"buyerEmail": "test@test.com",
"buyerDocumentNumber": "98787666",
"beneficiaryName": "beneficiary",
"beneficiarySurname": "surname",
"beneficiaryPhone": "888999111",
"beneficiaryEmail": "beneficiary@email.com",
"beneficiaryDocumentNumber": "61827396",
"beneficiaryDocumentType": "ID_CARD",
"city": "LA HABANA",
"address": "PRUEBA"
}
{
"resultMessage": "Cart created successfully",
"resultCode": 0,
"cartId": 440,
"productPriceX100": 100,
"amountToSendX100": 600,
"deliveryPriceX100": 500
}
cartId
-> required as a parameter in the body of purchase
step.
amountToSendx100
β required as a parameter in the body of purchase
step.
Always ensure consistency between location fields (stateId
, municipalityId
, countryId
) used across steps.
You must always call Create Cart
before Purchase
.
deliveryPriceX100
is included in the cart response but handled internally.
π³ Step 7: Purchase#
{
"amountToSendX100": 600,
"localDateTime": "2025-07-09T14:06:00",
"cartId": "440"
}
β
This call finalizes the transaction and returns confirmation:{
"rc": 0,
"items": [
{
"finalstatus": 0,
"resultcode": "10",
"resultmessage": "Operation completed successfully",
"supplierreference": "440",
"suppliertoken": ""
}
]
}
π§ Use supplierreference
and suppliertoken
for reconciliation or audit tracking.
β οΈ Stable Values in Dummy Flow#
In the location-based dummy flow, the following values are considered fixed and always available for testing purposes:Field | Dummy Value |
---|
countryId | 192 β Cuba |
categoryId | 8 β Dummy (most relevant!!) |
stateId | 473 β La Habana |
municipalityId | 499 β Centro Habana |
These locations are preconfigured in the simulation environment and can be reliably used across dummy test scenarios. Even if product options (productId
) may change over time, this location path will consistently return valid data to reach the product listing step.β
Tip: If you're building automated tests or frontends for this flow, you can hardcode this location chain for dummy simulations while keeping productId
dynamic.Modified atΒ 2025-07-09 13:40:31