{
  "info": {
    "_postman_id": "1f8637fd-3645-4dc0-9068-fd2f383aac02",
    "name": "NDC-API",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "9466313"
  },
  "item": [
    {
      "name": "UseCase",
      "item": [
        {
          "name": "Create & confirm on-hold booking",
          "item": [
            {
              "name": "OW - 1ADT, 1CHD, 1INF",
              "item": [
                {
                  "name": "1. AirShopping [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: true\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;\n\n        // Always array\n        if (!Array.isArray(offers)) {\n            offers = [offers];\n        }\n\n        let offerIds = [];\n        let offerItemsByOffer = []; // nested list\n\n        offers.forEach(offer => {\n\n            // Store ID\n            offerIds.push(offer.OfferID);\n\n            // Extract OfferItem list\n            let items = offer.OfferItem;\n            if (!Array.isArray(items)) {\n                items = [items];\n            }\n\n            // Extract OfferItemID for this offer\n            let itemIds = items.map(i => i.OfferItemID);\n\n            offerItemsByOffer.push(itemIds);\n        });\n\n        // Save to environment\n        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));\n        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));\n\n\n        offerIds.forEach((id, index) => {\n            pm.environment.set(`offerId${index}`, id);\n        });\n\n        for (let i = 0; i < offerItemsByOffer.length; i++) {\n            for (let j = 0; j < offerItemsByOffer[i].length; j++) {\n                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);\n                console.log(offerItemsByOffer[i][j]);\n            }\n        }\n\n        console.log(\"Offer IDs:\", offerIds);\n        console.log(\"Offer Items By Offer:\", offerItemsByOffer);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                        ]
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\npm.environment.set(\"today_th\", th);\n\ndate.setDate(date.getDate() + 2);\n\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nlet departureDate = `${year}-${month}-${day}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearD = date.getFullYear();\nlet monthD = String(date.getMonth() + 1).padStart(2, '0');\nlet dayD = String(date.getDate()).padStart(2, '0');\n\nlet arrivalDate = `${yearD}-${monthD}-${dayD}`;\n\ndate.setDate(date.getDate() + 5);\nlet yearND = date.getFullYear();\nlet monthND = String(date.getMonth() + 1).padStart(2, '0');\nlet dayND = String(date.getDate()).padStart(2, '0');\n\nlet nextDepartureDate = `${yearND}-${monthND}-${dayND}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearNA = date.getFullYear();\nlet monthNA = String(date.getMonth() + 1).padStart(2, '0');\nlet dayNA = String(date.getDate()).padStart(2, '0');\n\nlet nextArrivalDate = `${yearNA}-${monthNA}-${dayNA}`;\n\npm.environment.set(\"arrivalDate\", arrivalDate);\npm.environment.set(\"departureDate\", departureDate);\npm.environment.set(\"nextArrivalDate\", nextArrivalDate);\npm.environment.set(\"nextDepartureDate\", nextDepartureDate);"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <!-- KRP to CPH -->\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [OW] [1ADT,  1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parser = new xml2js.Parser({",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false,",
                          "    attrkey: '$',",
                          "    charkey: '_',",
                          "    tagNameProcessors: [xml2js.processors.stripPrefix]",
                          "});",
                          "",
                          "parser.parseString(xmlContent, (err, result) => {",
                          "    if (err) {",
                          "        console.error('XML parse error:', err);",
                          "        pm.test('XML parsed successfully', () => {",
                          "            throw err;",
                          "        });",
                          "        return;",
                          "    }",
                          "",
                          "    const root = result.IATA_OfferPriceRS;",
                          "    const pricedOffer = root?.Response?.PricedOffer;",
                          "",
                          "    pm.test('PricedOffer exists', () => {",
                          "        pm.expect(pricedOffer).to.not.be.undefined;",
                          "    });",
                          "",
                          "    const offerId = pricedOffer?.OfferID;",
                          "    if (offerId) {",
                          "        pm.environment.set('selectedOfferId', offerId);",
                          "        console.log('selectedOfferId =', offerId);",
                          "    }",
                          "",
                          "    let offerItems = pricedOffer?.OfferItem ?? [];",
                          "    if (!Array.isArray(offerItems)) {",
                          "        offerItems = [offerItems];",
                          "    }",
                          "",
                          "    const previousCount = parseInt(pm.environment.get('selectedOfferItemCount') || '0', 10);",
                          "    for (let i = offerItems.length; i < previousCount; i++) {",
                          "        pm.environment.unset(`selectedOfferItemId_${i}`);",
                          "    }",
                          "",
                          "    offerItems.forEach((item, index) => {",
                          "        const offerItemId = item?.OfferItemID;",
                          "        if (offerItemId) {",
                          "            pm.environment.set(`selectedOfferItemId_${index}`, offerItemId);",
                          "            console.log(`selectedOfferItemId_${index} =`, offerItemId);",
                          "        }",
                          "    });",
                          "",
                          "    pm.environment.set('selectedOfferItemCount', String(offerItems.length));",
                          "",
                          "    // TotalPrice",
                          "    const totalAmountNode = pricedOffer?.TotalPrice?.TotalAmount;",
                          "    let totalPrice = null;",
                          "    let totalCurCode = null;",
                          "",
                          "    if (totalAmountNode != null) {",
                          "        if (typeof totalAmountNode === 'string' || typeof totalAmountNode === 'number') {",
                          "            totalPrice = String(totalAmountNode);",
                          "        } else {",
                          "            totalPrice = totalAmountNode._ != null ? String(totalAmountNode._) : null;",
                          "            totalCurCode = totalAmountNode.$?.CurCode ?? null;",
                          "        }",
                          "    }",
                          "",
                          "    if (totalPrice) {",
                          "        pm.environment.set('totalPrice', totalPrice);",
                          "        console.log('totalPrice =', totalPrice);",
                          "    }",
                          "",
                          "    if (totalCurCode) {",
                          "        pm.environment.set('totalCurCode', totalCurCode);",
                          "        console.log('totalCurCode =', totalCurCode);",
                          "    }",
                          "",
                          "    pm.test('Offer IDs extracted', () => {",
                          "        pm.expect(offerId).to.be.a('string').and.not.empty;",
                          "        pm.expect(offerItems.length).to.be.above(0);",
                          "        offerItems.forEach((item) => {",
                          "            pm.expect(item.OfferItemID).to.be.a('string').and.not.empty;",
                          "        });",
                          "    });",
                          "",
                          "    pm.test('Total price extracted', () => {",
                          "        pm.expect(totalPrice).to.be.a('string').and.not.empty;",
                          "        pm.expect(totalCurCode).to.be.a('string').and.not.empty;",
                          "    });",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay Later]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    try {",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((item, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "        });",
                          "",
                          "        // Extract BookingID (PNR) from first OrderItem that has one",
                          "        const bookingId = orderItems",
                          "            .map(item => {",
                          "                const service = item.Service;",
                          "                const services = Array.isArray(service) ? service : [service];",
                          "                return services",
                          "                    .map(s => s?.BookingRef?.BookingID)",
                          "                    .find(Boolean);",
                          "            })",
                          "            .find(Boolean);",
                          "",
                          "        if (bookingId) {",
                          "            pm.environment.set('bookingId', bookingId);",
                          "            console.log('BookingID: ' + bookingId);",
                          "        } else {",
                          "            console.warn('BookingID not found in OrderItems');",
                          "        }",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "function formatDateOnly(date) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate())",
                          "    );",
                          "}",
                          "",
                          "function subtractYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() - years);",
                          "    return result;",
                          "}",
                          "",
                          "function subtractMonths(date, months) {",
                          "    const result = new Date(date);",
                          "    result.setMonth(result.getMonth() - months);",
                          "    return result;",
                          "}",
                          "",
                          "function addYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() + years);",
                          "    return result;",
                          "}",
                          "",
                          "let today = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(today, 420);",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "// Birthdates: YYYY-MM-DD",
                          "let adultBirthDate = formatDateOnly(subtractYears(today, 30));",
                          "let childBirthDate = formatDateOnly(subtractYears(today, 3));",
                          "let infantBirthDate = formatDateOnly(subtractMonths(today, 1));",
                          "let expiryDate = formatDateOnly(addYears(today, 10));",
                          "",
                          "pm.environment.set(\"adultBirthDate\", adultBirthDate);",
                          "pm.environment.set(\"childBirthDate\", childBirthDate);",
                          "pm.environment.set(\"infantBirthDate\", infantBirthDate);",
                          "pm.environment.set(\"expiryDate\", expiryDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n            <ns2:SalesAgent>\n                <ns2:SalesAgentID>{{salesAgentId}}</ns2:SalesAgentID>\n            </ns2:SalesAgent>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{childBirthDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    try {",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((item, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "        });",
                          "",
                          "        // Extract BookingID (PNR) from first OrderItem that has one",
                          "        const bookingId = orderItems",
                          "            .map(item => {",
                          "                const service = item.Service;",
                          "                const services = Array.isArray(service) ? service : [service];",
                          "                return services",
                          "                    .map(s => s?.BookingRef?.BookingID)",
                          "                    .find(Boolean);",
                          "            })",
                          "            .find(Boolean);",
                          "",
                          "        if (bookingId) {",
                          "            pm.environment.set('bookingId', bookingId);",
                          "            console.log('BookingID: ' + bookingId);",
                          "        } else {",
                          "            console.warn('BookingID not found in OrderItems');",
                          "        }",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderQuote [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6.1. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions> \n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6.2. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [DEBIT]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentMethodCriteria>\n                <ns2:PaymentCriteriaAddlInfo>\n                    <ns2:PaymentOtherMethodAddlInfo>\n                        <ns2:Remark>\n                            <ns2:RemarkText>ACCOUNT_REF:{{debitCreditAccount}}</ns2:RemarkText>\n                        </ns2:Remark>\n                    </ns2:PaymentOtherMethodAddlInfo>\n                </ns2:PaymentCriteriaAddlInfo>\n                <ns2:PaymentTypeCode>OT</ns2:PaymentTypeCode>\n            </ns2:PaymentMethodCriteria>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>OT</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6.3. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [Credit]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:PaymentCard>\n                        <ns2:CardBrandCode>VI</ns2:CardBrandCode>\n                        <ns2:CardHolderName>JANE DOE</ns2:CardHolderName>\n                        <!-- PCI Filter Push: tokenize these three fields -->\n                        <ns2:CardNumber>4242424242424242</ns2:CardNumber>\n                        <ns2:CardSecurityCode>123</ns2:CardSecurityCode>\n                        <ns2:ExpirationDate>0628</ns2:ExpirationDate>\n                        <!-- 3DS result — pass through, do not tokenize -->\n                        <ns2:SecurePaymentVersion2>\n                            <ns2:AuthenticationValue>{{cavv}}</ns2:AuthenticationValue>\n                            <ns2:DirectoryServerTrxID>{{xid}}</ns2:DirectoryServerTrxID>\n                            <ns2:ElectronicCommerceInd>{{eci}}</ns2:ElectronicCommerceInd>\n                            <ns2:ProgramProtocolText>2.2.0</ns2:ProgramProtocolText>\n                            <ns2:TrxStatusText>Y</ns2:TrxStatusText>\n                        </ns2:SecurePaymentVersion2>\n                    </ns2:PaymentCard>\n                </ns2:PaymentMethod>\n                <!-- PCI transactionId from 3DS init — pass through, do not tokenize -->\n                <ns2:PaymentRefID>251120183950618353</ns2:PaymentRefID>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "RT - 1ADT, 1CHD, 1INF",
              "item": [
                {
                  "name": "1. AirShopping [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: true\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;\n\n        // Always array\n        if (!Array.isArray(offers)) {\n            offers = [offers];\n        }\n\n        let offerIds = [];\n        let offerItemsByOffer = []; // nested list\n\n        offers.forEach(offer => {\n\n            // Store ID\n            offerIds.push(offer.OfferID);\n\n            // Extract OfferItem list\n            let items = offer.OfferItem;\n            if (!Array.isArray(items)) {\n                items = [items];\n            }\n\n            // Extract OfferItemID for this offer\n            let itemIds = items.map(i => i.OfferItemID);\n\n            offerItemsByOffer.push(itemIds);\n        });\n\n        // Save to environment\n        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));\n        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));\n\n\n        offerIds.forEach((id, index) => {\n            pm.environment.set(`offerId${index}`, id);\n        });\n\n        for (let i = 0; i < offerItemsByOffer.length; i++) {\n            for (let j = 0; j < offerItemsByOffer[i].length; j++) {\n                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);\n                console.log(offerItemsByOffer[i][j]);\n            }\n        }\n\n        console.log(\"Offer IDs:\", offerIds);\n        console.log(\"Offer Items By Offer:\", offerItemsByOffer);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                        ]
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\npm.environment.set(\"today_th\", th);\n\ndate.setDate(date.getDate() + 3);\n\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nlet departureDate = `${year}-${month}-${day}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearD = date.getFullYear();\nlet monthD = String(date.getMonth() + 1).padStart(2, '0');\nlet dayD = String(date.getDate()).padStart(2, '0');\n\nlet arrivalDate = `${yearD}-${monthD}-${dayD}`;\n\ndate.setDate(date.getDate() + 5);\nlet yearND = date.getFullYear();\nlet monthND = String(date.getMonth() + 1).padStart(2, '0');\nlet dayND = String(date.getDate()).padStart(2, '0');\n\nlet nextDepartureDate = `${yearND}-${monthND}-${dayND}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearNA = date.getFullYear();\nlet monthNA = String(date.getMonth() + 1).padStart(2, '0');\nlet dayNA = String(date.getDate()).padStart(2, '0');\n\nlet nextArrivalDate = `${yearNA}-${monthNA}-${dayNA}`;\n\npm.environment.set(\"arrivalDate\", arrivalDate);\npm.environment.set(\"departureDate\", departureDate);\npm.environment.set(\"nextArrivalDate\", nextArrivalDate);\npm.environment.set(\"nextDepartureDate\", nextDepartureDate);"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{nextArrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{nextDepartureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        \n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n    \n</IATA_AirShoppingRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parser = new xml2js.Parser({",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false,",
                          "    attrkey: '$',",
                          "    charkey: '_',",
                          "    tagNameProcessors: [xml2js.processors.stripPrefix]",
                          "});",
                          "",
                          "parser.parseString(xmlContent, (err, result) => {",
                          "    if (err) {",
                          "        console.error('XML parse error:', err);",
                          "        pm.test('XML parsed successfully', () => {",
                          "            throw err;",
                          "        });",
                          "        return;",
                          "    }",
                          "",
                          "    const root = result.IATA_OfferPriceRS;",
                          "    const pricedOffer = root?.Response?.PricedOffer;",
                          "",
                          "    pm.test('PricedOffer exists', () => {",
                          "        pm.expect(pricedOffer).to.not.be.undefined;",
                          "    });",
                          "",
                          "    const offerId = pricedOffer?.OfferID;",
                          "    if (offerId) {",
                          "        pm.environment.set('selectedOfferId', offerId);",
                          "        console.log('selectedOfferId =', offerId);",
                          "    }",
                          "",
                          "    let offerItems = pricedOffer?.OfferItem ?? [];",
                          "    if (!Array.isArray(offerItems)) {",
                          "        offerItems = [offerItems];",
                          "    }",
                          "",
                          "    const previousCount = parseInt(pm.environment.get('selectedOfferItemCount') || '0', 10);",
                          "    for (let i = offerItems.length; i < previousCount; i++) {",
                          "        pm.environment.unset(`selectedOfferItemId_${i}`);",
                          "    }",
                          "",
                          "    offerItems.forEach((item, index) => {",
                          "        const offerItemId = item?.OfferItemID;",
                          "        if (offerItemId) {",
                          "            pm.environment.set(`selectedOfferItemId_${index}`, offerItemId);",
                          "            console.log(`selectedOfferItemId_${index} =`, offerItemId);",
                          "        }",
                          "    });",
                          "",
                          "    pm.environment.set('selectedOfferItemCount', String(offerItems.length));",
                          "",
                          "    // TotalPrice",
                          "    const totalAmountNode = pricedOffer?.TotalPrice?.TotalAmount;",
                          "    let totalPrice = null;",
                          "    let totalCurCode = null;",
                          "",
                          "    if (totalAmountNode != null) {",
                          "        if (typeof totalAmountNode === 'string' || typeof totalAmountNode === 'number') {",
                          "            totalPrice = String(totalAmountNode);",
                          "        } else {",
                          "            totalPrice = totalAmountNode._ != null ? String(totalAmountNode._) : null;",
                          "            totalCurCode = totalAmountNode.$?.CurCode ?? null;",
                          "        }",
                          "    }",
                          "",
                          "    if (totalPrice) {",
                          "        pm.environment.set('totalPrice', totalPrice);",
                          "        console.log('totalPrice =', totalPrice);",
                          "    }",
                          "",
                          "    if (totalCurCode) {",
                          "        pm.environment.set('totalCurCode', totalCurCode);",
                          "        console.log('totalCurCode =', totalCurCode);",
                          "    }",
                          "",
                          "    pm.test('Offer IDs extracted', () => {",
                          "        pm.expect(offerId).to.be.a('string').and.not.empty;",
                          "        pm.expect(offerItems.length).to.be.above(0);",
                          "        offerItems.forEach((item) => {",
                          "            pm.expect(item.OfferItemID).to.be.a('string').and.not.empty;",
                          "        });",
                          "    });",
                          "",
                          "    pm.test('Total price extracted', () => {",
                          "        pm.expect(totalPrice).to.be.a('string').and.not.empty;",
                          "        pm.expect(totalCurCode).to.be.a('string').and.not.empty;",
                          "    });",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_3}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_4}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_5}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [RT] [1ADT, 1CHD, 1INF] [Pay Later]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    try {",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((item, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "        });",
                          "",
                          "        // Extract BookingID (PNR) from first OrderItem that has one",
                          "        const bookingId = orderItems",
                          "            .map(item => {",
                          "                const service = item.Service;",
                          "                const services = Array.isArray(service) ? service : [service];",
                          "                return services",
                          "                    .map(s => s?.BookingRef?.BookingID)",
                          "                    .find(Boolean);",
                          "            })",
                          "            .find(Boolean);",
                          "",
                          "        if (bookingId) {",
                          "            pm.environment.set('bookingId', bookingId);",
                          "            console.log('BookingID: ' + bookingId);",
                          "        } else {",
                          "            console.warn('BookingID not found in OrderItems');",
                          "        }",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "function formatDateOnly(date) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate())",
                          "    );",
                          "}",
                          "",
                          "function subtractYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() - years);",
                          "    return result;",
                          "}",
                          "",
                          "function subtractMonths(date, months) {",
                          "    const result = new Date(date);",
                          "    result.setMonth(result.getMonth() - months);",
                          "    return result;",
                          "}",
                          "",
                          "function addYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() + years);",
                          "    return result;",
                          "}",
                          "",
                          "let today = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(today, 420);",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "// Birthdates: YYYY-MM-DD",
                          "let adultBirthDate = formatDateOnly(subtractYears(today, 30));",
                          "let childBirthDate = formatDateOnly(subtractYears(today, 3));",
                          "let infantBirthDate = formatDateOnly(subtractMonths(today, 1));",
                          "let expiryDate = formatDateOnly(addYears(today, 10));",
                          "",
                          "pm.environment.set(\"adultBirthDate\", adultBirthDate);",
                          "pm.environment.set(\"childBirthDate\", childBirthDate);",
                          "pm.environment.set(\"infantBirthDate\", infantBirthDate);",
                          "pm.environment.set(\"expiryDate\", expiryDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n            <ns2:SalesAgent>\n                <ns2:SalesAgentID>{{salesAgentId}}</ns2:SalesAgentID>\n            </ns2:SalesAgent>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!--\n                SIT_ECO_PNLTY = 24\n                -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_3}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_4}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_4}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        // Always array",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((id, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                          "        });",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderQuote [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n    </Payload>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n</IATA_OrderQuoteRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6.1. OrderChange [RT] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "Content-Type",
                        "value": "application/xml"
                      },
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions> \n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6.2. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [DEBIT]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentMethodCriteria>\n                <ns2:PaymentCriteriaAddlInfo>\n                    <ns2:PaymentOtherMethodAddlInfo>\n                        <ns2:Remark>\n                            <ns2:RemarkText>ACCOUNT_REF:{{debitCreditAccount}}</ns2:RemarkText>\n                        </ns2:Remark>\n                    </ns2:PaymentOtherMethodAddlInfo>\n                </ns2:PaymentCriteriaAddlInfo>\n                <ns2:PaymentTypeCode>OT</ns2:PaymentTypeCode>\n            </ns2:PaymentMethodCriteria>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>OT</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ]
        },
        {
          "name": "Create paid booking",
          "item": [
            {
              "name": "OW - 1ADT 1CHD 1INF",
              "item": [
                {
                  "name": "1. AirShopping [OW] [1 ADT, 1 CHD, 1 INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: true",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;",
                          "",
                          "        // Always array",
                          "        if (!Array.isArray(offers)) {",
                          "            offers = [offers];",
                          "        }",
                          "",
                          "        let offerIds = [];",
                          "        let offerItemsByOffer = []; // nested list",
                          "",
                          "        offers.forEach(offer => {",
                          "",
                          "            // Store ID",
                          "            offerIds.push(offer.OfferID);",
                          "",
                          "            // Extract OfferItem list",
                          "            let items = offer.OfferItem;",
                          "            if (!Array.isArray(items)) {",
                          "                items = [items];",
                          "            }",
                          "",
                          "            // Extract OfferItemID for this offer",
                          "            let itemIds = items.map(i => i.OfferItemID);",
                          "",
                          "            offerItemsByOffer.push(itemIds);",
                          "        });",
                          "",
                          "        // Save to environment",
                          "        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));",
                          "        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));",
                          "",
                          "",
                          "        offerIds.forEach((id, index) => {",
                          "            pm.environment.set(`offerId${index}`, id);",
                          "        });",
                          "",
                          "        for (let i = 0; i < offerItemsByOffer.length; i++) {",
                          "            for (let j = 0; j < offerItemsByOffer[i].length; j++) {",
                          "                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);",
                          "                console.log(offerItemsByOffer[i][j]);",
                          "            }",
                          "        }",
                          "",
                          "        console.log(\"Offer IDs:\", offerIds);",
                          "        console.log(\"Offer Items By Offer:\", offerItemsByOffer);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "let departureDate = new Date();",
                          "departureDate.setDate(departureDate.getDate() + 7);",
                          "",
                          "let returnDate = new Date(departureDate);",
                          "returnDate.setDate(returnDate.getDate() + 7);",
                          "",
                          "// Format to YYYY-MM-DD",
                          "pm.variables.set('departureDate', departureDate.toISOString().split('T')[0]);",
                          "pm.variables.set('returnDate', returnDate.toISOString().split('T')[0]);",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <!-- KRP to CPH -->\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        \n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n    \n</IATA_AirShoppingRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [OW] [1 ADT, 1 CHD, 1 INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parser = new xml2js.Parser({",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false,",
                          "    attrkey: '$',",
                          "    charkey: '_',",
                          "    tagNameProcessors: [xml2js.processors.stripPrefix]",
                          "});",
                          "",
                          "parser.parseString(xmlContent, (err, result) => {",
                          "    if (err) {",
                          "        console.error('XML parse error:', err);",
                          "        pm.test('XML parsed successfully', () => {",
                          "            throw err;",
                          "        });",
                          "        return;",
                          "    }",
                          "",
                          "    const root = result.IATA_OfferPriceRS;",
                          "    const pricedOffer = root?.Response?.PricedOffer;",
                          "",
                          "    pm.test('PricedOffer exists', () => {",
                          "        pm.expect(pricedOffer).to.not.be.undefined;",
                          "    });",
                          "",
                          "    const offerId = pricedOffer?.OfferID;",
                          "    if (offerId) {",
                          "        pm.environment.set('selectedOfferId', offerId);",
                          "        console.log('selectedOfferId =', offerId);",
                          "    }",
                          "",
                          "    let offerItems = pricedOffer?.OfferItem ?? [];",
                          "    if (!Array.isArray(offerItems)) {",
                          "        offerItems = [offerItems];",
                          "    }",
                          "",
                          "    const previousCount = parseInt(pm.environment.get('selectedOfferItemCount') || '0', 10);",
                          "    for (let i = offerItems.length; i < previousCount; i++) {",
                          "        pm.environment.unset(`selectedOfferItemId_${i}`);",
                          "    }",
                          "",
                          "    offerItems.forEach((item, index) => {",
                          "        const offerItemId = item?.OfferItemID;",
                          "        if (offerItemId) {",
                          "            pm.environment.set(`selectedOfferItemId_${index}`, offerItemId);",
                          "            console.log(`selectedOfferItemId_${index} =`, offerItemId);",
                          "        }",
                          "    });",
                          "",
                          "    pm.environment.set('selectedOfferItemCount', String(offerItems.length));",
                          "",
                          "    // TotalPrice",
                          "    const totalAmountNode = pricedOffer?.TotalPrice?.TotalAmount;",
                          "    let totalPrice = null;",
                          "    let totalCurCode = null;",
                          "",
                          "    if (totalAmountNode != null) {",
                          "        if (typeof totalAmountNode === 'string' || typeof totalAmountNode === 'number') {",
                          "            totalPrice = String(totalAmountNode);",
                          "        } else {",
                          "            totalPrice = totalAmountNode._ != null ? String(totalAmountNode._) : null;",
                          "            totalCurCode = totalAmountNode.$?.CurCode ?? null;",
                          "        }",
                          "    }",
                          "",
                          "    if (totalPrice) {",
                          "        pm.environment.set('totalPrice', totalPrice);",
                          "        console.log('totalPrice =', totalPrice);",
                          "    }",
                          "",
                          "    if (totalCurCode) {",
                          "        pm.environment.set('totalCurCode', totalCurCode);",
                          "        console.log('totalCurCode =', totalCurCode);",
                          "    }",
                          "",
                          "    pm.test('Offer IDs extracted', () => {",
                          "        pm.expect(offerId).to.be.a('string').and.not.empty;",
                          "        pm.expect(offerItems.length).to.be.above(0);",
                          "        offerItems.forEach((item) => {",
                          "            pm.expect(item.OfferItemID).to.be.a('string').and.not.empty;",
                          "        });",
                          "    });",
                          "",
                          "    pm.test('Total price extracted', () => {",
                          "        pm.expect(totalPrice).to.be.a('string').and.not.empty;",
                          "        pm.expect(totalCurCode).to.be.a('string').and.not.empty;",
                          "    });",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [OW] [1ADT., 1CHD, 1INF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "function formatDateOnly(date) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate())",
                          "    );",
                          "}",
                          "",
                          "function subtractYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() - years);",
                          "    return result;",
                          "}",
                          "",
                          "function subtractMonths(date, months) {",
                          "    const result = new Date(date);",
                          "    result.setMonth(result.getMonth() - months);",
                          "    return result;",
                          "}",
                          "",
                          "function addYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() + years);",
                          "    return result;",
                          "}",
                          "",
                          "let today = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(today, 420);",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "// Birthdates: YYYY-MM-DD",
                          "let adultBirthDate = formatDateOnly(subtractYears(today, 30));",
                          "let childBirthDate = formatDateOnly(subtractYears(today, 3));",
                          "let infantBirthDate = formatDateOnly(subtractMonths(today, 1));",
                          "let expiryDate = formatDateOnly(addYears(today, 10));",
                          "",
                          "pm.environment.set(\"adultBirthDate\", adultBirthDate);",
                          "pm.environment.set(\"childBirthDate\", childBirthDate);",
                          "pm.environment.set(\"infantBirthDate\", infantBirthDate);",
                          "pm.environment.set(\"expiryDate\", expiryDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3.1. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay] [DEPOSIT]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "function formatDateOnly(date) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate())",
                          "    );",
                          "}",
                          "",
                          "function subtractYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() - years);",
                          "    return result;",
                          "}",
                          "",
                          "function subtractMonths(date, months) {",
                          "    const result = new Date(date);",
                          "    result.setMonth(result.getMonth() - months);",
                          "    return result;",
                          "}",
                          "",
                          "function addYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() + years);",
                          "    return result;",
                          "}",
                          "",
                          "let today = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(today, 420);",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "// Birthdates: YYYY-MM-DD",
                          "let adultBirthDate = formatDateOnly(subtractYears(today, 30));",
                          "let childBirthDate = formatDateOnly(subtractYears(today, 3));",
                          "let infantBirthDate = formatDateOnly(subtractMonths(today, 1));",
                          "let expiryDate = formatDateOnly(addYears(today, 10));",
                          "",
                          "pm.environment.set(\"adultBirthDate\", adultBirthDate);",
                          "pm.environment.set(\"childBirthDate\", childBirthDate);",
                          "pm.environment.set(\"infantBirthDate\", infantBirthDate);",
                          "pm.environment.set(\"expiryDate\", expiryDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n            <ns2:SalesAgent>\n                <ns2:SalesAgentID>{{salesAgentId}}</ns2:SalesAgentID>\n            </ns2:SalesAgent>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{selectedOfferItemId_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentMethodCriteria>\n                <ns2:PaymentCriteriaAddlInfo>\n                    <ns2:PaymentOtherMethodAddlInfo>\n                        <ns2:Remark>\n                            <ns2:RemarkText>ACCOUNT_REF:{{debitCreditAccount}}</ns2:RemarkText>\n                        </ns2:Remark>\n                    </ns2:PaymentOtherMethodAddlInfo>\n                </ns2:PaymentCriteriaAddlInfo>\n                <ns2:PaymentTypeCode>OT</ns2:PaymentTypeCode>\n            </ns2:PaymentMethodCriteria>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>OT</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    },
                    "description": "Instant payment from an agency deposit account on an AeroCRS airline.\n\nSet `partnerId` (your Partner ID, the `OrgID` of your own link), `salesAgentId` (an AeroCRS agent user of the agency that owns the deposit) and `debitCreditAccount` (the AeroCRS agency ID, or `<agency ID>-<currency code>`; the request sends it as `ACCOUNT_REF:{{debitCreditAccount}}`). `SalesAgentID` is read on OrderCreate only, so a booking you will pay from the deposit later must also be created with it. Use the `OrgRole` your agreement allows (`Seller` or `Distributor`)."
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n\n        <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "RT - 1ADT 1CHD 1INF",
              "item": [
                {
                  "name": "1. AirShopping [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: true\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;\n\n        // Always array\n        if (!Array.isArray(offers)) {\n            offers = [offers];\n        }\n\n        let offerIds = [];\n        let offerItemsByOffer = []; // nested list\n\n        offers.forEach(offer => {\n\n            // Store ID\n            offerIds.push(offer.OfferID);\n\n            // Extract OfferItem list\n            let items = offer.OfferItem;\n            if (!Array.isArray(items)) {\n                items = [items];\n            }\n\n            // Extract OfferItemID for this offer\n            let itemIds = items.map(i => i.OfferItemID);\n\n            offerItemsByOffer.push(itemIds);\n        });\n\n        // Save to environment\n        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));\n        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));\n\n\n        offerIds.forEach((id, index) => {\n            pm.environment.set(`offerId${index}`, id);\n        });\n\n        for (let i = 0; i < offerItemsByOffer.length; i++) {\n            for (let j = 0; j < offerItemsByOffer[i].length; j++) {\n                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);\n                console.log(offerItemsByOffer[i][j]);\n            }\n        }\n\n        console.log(\"Offer IDs:\", offerIds);\n        console.log(\"Offer Items By Offer:\", offerItemsByOffer);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                        ]
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\npm.environment.set(\"today_th\", th);\n\ndate.setDate(date.getDate() + 8);\n\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nlet departureDate = `${year}-${month}-${day}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearD = date.getFullYear();\nlet monthD = String(date.getMonth() + 1).padStart(2, '0');\nlet dayD = String(date.getDate()).padStart(2, '0');\n\nlet arrivalDate = `${yearD}-${monthD}-${dayD}`;\n\ndate.setDate(date.getDate() + 5);\nlet yearND = date.getFullYear();\nlet monthND = String(date.getMonth() + 1).padStart(2, '0');\nlet dayND = String(date.getDate()).padStart(2, '0');\n\nlet nextDepartureDate = `${yearND}-${monthND}-${dayND}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearNA = date.getFullYear();\nlet monthNA = String(date.getMonth() + 1).padStart(2, '0');\nlet dayNA = String(date.getDate()).padStart(2, '0');\n\nlet nextArrivalDate = `${yearNA}-${monthNA}-${dayNA}`;\n\npm.environment.set(\"arrivalDate\", arrivalDate);\npm.environment.set(\"departureDate\", departureDate);\npm.environment.set(\"nextArrivalDate\", nextArrivalDate);\npm.environment.set(\"nextDepartureDate\", nextDepartureDate);"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <!-- KRP to CPH -->\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{nextArrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{nextDepartureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        \n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n    \n</IATA_AirShoppingRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parser = new xml2js.Parser({",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false,",
                          "    attrkey: '$',",
                          "    charkey: '_',",
                          "    tagNameProcessors: [xml2js.processors.stripPrefix]",
                          "});",
                          "",
                          "parser.parseString(xmlContent, (err, result) => {",
                          "    if (err) {",
                          "        console.error('XML parse error:', err);",
                          "        pm.test('XML parsed successfully', () => {",
                          "            throw err;",
                          "        });",
                          "        return;",
                          "    }",
                          "",
                          "    const root = result.IATA_OfferPriceRS;",
                          "    const pricedOffer = root?.Response?.PricedOffer;",
                          "",
                          "    pm.test('PricedOffer exists', () => {",
                          "        pm.expect(pricedOffer).to.not.be.undefined;",
                          "    });",
                          "",
                          "    const offerId = pricedOffer?.OfferID;",
                          "    if (offerId) {",
                          "        pm.environment.set('selectedOfferId', offerId);",
                          "        console.log('selectedOfferId =', offerId);",
                          "    }",
                          "",
                          "    let offerItems = pricedOffer?.OfferItem ?? [];",
                          "    if (!Array.isArray(offerItems)) {",
                          "        offerItems = [offerItems];",
                          "    }",
                          "",
                          "    const previousCount = parseInt(pm.environment.get('selectedOfferItemCount') || '0', 10);",
                          "    for (let i = offerItems.length; i < previousCount; i++) {",
                          "        pm.environment.unset(`selectedOfferItemId_${i}`);",
                          "    }",
                          "",
                          "    offerItems.forEach((item, index) => {",
                          "        const offerItemId = item?.OfferItemID;",
                          "        if (offerItemId) {",
                          "            pm.environment.set(`selectedOfferItemId_${index}`, offerItemId);",
                          "            console.log(`selectedOfferItemId_${index} =`, offerItemId);",
                          "        }",
                          "    });",
                          "",
                          "    pm.environment.set('selectedOfferItemCount', String(offerItems.length));",
                          "",
                          "    // TotalPrice",
                          "    const totalAmountNode = pricedOffer?.TotalPrice?.TotalAmount;",
                          "    let totalPrice = null;",
                          "    let totalCurCode = null;",
                          "",
                          "    if (totalAmountNode != null) {",
                          "        if (typeof totalAmountNode === 'string' || typeof totalAmountNode === 'number') {",
                          "            totalPrice = String(totalAmountNode);",
                          "        } else {",
                          "            totalPrice = totalAmountNode._ != null ? String(totalAmountNode._) : null;",
                          "            totalCurCode = totalAmountNode.$?.CurCode ?? null;",
                          "        }",
                          "    }",
                          "",
                          "    if (totalPrice) {",
                          "        pm.environment.set('totalPrice', totalPrice);",
                          "        console.log('totalPrice =', totalPrice);",
                          "    }",
                          "",
                          "    if (totalCurCode) {",
                          "        pm.environment.set('totalCurCode', totalCurCode);",
                          "        console.log('totalCurCode =', totalCurCode);",
                          "    }",
                          "",
                          "    pm.test('Offer IDs extracted', () => {",
                          "        pm.expect(offerId).to.be.a('string').and.not.empty;",
                          "        pm.expect(offerItems.length).to.be.above(0);",
                          "        offerItems.forEach((item) => {",
                          "            pm.expect(item.OfferItemID).to.be.a('string').and.not.empty;",
                          "        });",
                          "    });",
                          "",
                          "    pm.test('Total price extracted', () => {",
                          "        pm.expect(totalPrice).to.be.a('string').and.not.empty;",
                          "        pm.expect(totalCurCode).to.be.a('string').and.not.empty;",
                          "    });",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_3}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_4}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_5}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [RT] [1ADT, 1CHD, 1NF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_3}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_4}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_5}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ]
        },
        {
          "name": "Retrieve booking",
          "item": [
            {
              "name": "OrderRetrieve by OrderId",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "const parseString = xml2js.parseString;",
                      "const stripPrefix = xml2js.processors.stripPrefix;",
                      "",
                      "function toArray(value) {",
                      "    if (!value) return [];",
                      "    return Array.isArray(value) ? value : [value];",
                      "}",
                      "",
                      "parseString(xmlContent, {",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "",
                      "    try {",
                      "        // --- OfferPriceRS ---",
                      "        if (result.IATA_OfferPriceRS) {",
                      "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                      "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                      "",
                      "            pm.environment.set('totalPrice', totalAmount._);",
                      "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                      "            pm.environment.set('offerId', pricedOffer.OfferID);",
                      "",
                      "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                      "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                      "            });",
                      "",
                      "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                      "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                      "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                      "        }",
                      "",
                      "        // --- OrderViewRS ---",
                      "        if (result.IATA_OrderViewRS) {",
                      "            const order = result.IATA_OrderViewRS.Response.Order;",
                      "            const totalAmount = order.TotalPrice.TotalAmount;",
                      "",
                      "            pm.environment.set('orderId', order.OrderID);",
                      "            pm.environment.set('totalPrice', totalAmount._);",
                      "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                      "",
                      "            const orderItems = toArray(order.OrderItem);",
                      "            orderItems.forEach((item, index) => {",
                      "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                      "            });",
                      "",
                      "            const bookingId = orderItems",
                      "                .map(item => {",
                      "                    return toArray(item.Service)",
                      "                        .map(s => s?.BookingRef?.BookingID)",
                      "                        .find(Boolean);",
                      "                })",
                      "                .find(Boolean);",
                      "",
                      "            if (bookingId) {",
                      "                pm.environment.set('bookingId', bookingId);",
                      "            }",
                      "",
                      "            console.log('OrderViewRS → orderId:', order.OrderID);",
                      "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                      "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                      "            console.log('OrderViewRS → bookingId:', bookingId);",
                      "        }",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result);",
                      "    }",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 → 420 minutes",
                      "let th = formatWithTimezone(date, 420);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderRetrieve"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "OrderRetrieve By Record Locator",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "const parseString = xml2js.parseString;",
                      "const stripPrefix = xml2js.processors.stripPrefix;",
                      "",
                      "function toArray(value) {",
                      "    if (!value) return [];",
                      "    return Array.isArray(value) ? value : [value];",
                      "}",
                      "",
                      "parseString(xmlContent, {",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "",
                      "    try {",
                      "        // --- OfferPriceRS ---",
                      "        if (result.IATA_OfferPriceRS) {",
                      "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                      "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                      "",
                      "            pm.environment.set('totalPrice', totalAmount._);",
                      "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                      "            pm.environment.set('offerId', pricedOffer.OfferID);",
                      "",
                      "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                      "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                      "            });",
                      "",
                      "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                      "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                      "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                      "        }",
                      "",
                      "        // --- OrderViewRS ---",
                      "        if (result.IATA_OrderViewRS) {",
                      "            const order = result.IATA_OrderViewRS.Response.Order;",
                      "            const totalAmount = order.TotalPrice.TotalAmount;",
                      "",
                      "            pm.environment.set('orderId', order.OrderID);",
                      "            pm.environment.set('totalPrice', totalAmount._);",
                      "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                      "",
                      "            const orderItems = toArray(order.OrderItem);",
                      "            orderItems.forEach((item, index) => {",
                      "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                      "            });",
                      "",
                      "            const bookingId = orderItems",
                      "                .map(item => {",
                      "                    return toArray(item.Service)",
                      "                        .map(s => s?.BookingRef?.BookingID)",
                      "                        .find(Boolean);",
                      "                })",
                      "                .find(Boolean);",
                      "",
                      "            if (bookingId) {",
                      "                pm.environment.set('bookingId', bookingId);",
                      "            }",
                      "",
                      "            console.log('OrderViewRS → orderId:', order.OrderID);",
                      "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                      "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                      "            console.log('OrderViewRS → bookingId:', bookingId);",
                      "        }",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result);",
                      "    }",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 → 420 minutes",
                      "let th = formatWithTimezone(date, 420);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    \n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:BookingRefFilterCriteria>\n                <ns2:BookingID>{{bookingId}}</ns2:BookingID>\n            </ns2:BookingRefFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderRetrieve"
                  ]
                }
              },
              "response": []
            }
          ]
        },
        {
          "name": "Manage booking - Cancel",
          "item": [
            {
              "name": "Cancel Booking",
              "item": [
                {
                  "name": "OW [1ADT, 1CHD, 1INF]",
                  "item": [
                    {
                      "name": "1. OrderRetrieve by OrderId",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: false",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "    console.log(result);",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                              "        pm.environment.set(`orderId`, orderId);",
                              "",
                              "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                              "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                              "",
                              "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                              "        // Always array",
                              "        if (!Array.isArray(orderItems)) {",
                              "            orderItems = [orderItems];",
                              "        }",
                              "",
                              "        orderItems.forEach((id, index) => {",
                              "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                              "        });",
                              "",
                              "        console.log('TotalPrice: ' + totalPrice);",
                              "        console.log('Currency Code:' + totalCurCode);",
                              "        pm.environment.set(`totalPrice`, totalPrice);",
                              "        pm.environment.set(`totalCurCode`, totalCurCode);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "let date = new Date();",
                              "date.setDate(date.getDate() + 10);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"arrivalDate\", arrivalDate);",
                              "pm.environment.set(\"departureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderRetrieve"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "2. OrderReshop [OW] [Cancel]",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: true",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let reshopOffers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                              "",
                              "        // Always array",
                              "        if (!Array.isArray(reshopOffers)) {",
                              "            reshopOffers = [reshopOffers];",
                              "        }",
                              "",
                              "        let reshopOfferIds = [];",
                              "        let reshopOfferItemsByOffer = []; // nested list",
                              "",
                              "        reshopOffers.forEach(reshopOffer => {",
                              "",
                              "            // Store ID",
                              "            reshopOfferIds.push(reshopOffer.OfferID);",
                              "",
                              "            // Extract OfferItem list",
                              "            let items = reshopOffer.AddedOfferItem;",
                              "            if (!Array.isArray(items)) {",
                              "                items = [items];",
                              "            }",
                              "",
                              "            // Extract OfferItemID for this offer",
                              "            let itemIds = items.map(i => i.OfferItemID);",
                              "",
                              "            reshopOfferItemsByOffer.push(itemIds);",
                              "        });",
                              "",
                              "        // Save to environment",
                              "        pm.environment.set(\"reshopOfferIds\", JSON.stringify(reshopOfferIds));",
                              "        pm.environment.set(\"reshopOfferItemsByOffer\", JSON.stringify(reshopOfferItemsByOffer));",
                              "",
                              "",
                              "        reshopOfferIds.forEach((id, index) => {",
                              "            pm.environment.set(`reshopOfferId${index}`, id);",
                              "        });",
                              "",
                              "        for (let i = 0; i < reshopOfferItemsByOffer.length; i++) {",
                              "            for (let j = 0; j < reshopOfferItemsByOffer[i].length; j++) {",
                              "                pm.environment.set(`reshopOfferItemId${i}_${j}`, reshopOfferItemsByOffer[i][j]);",
                              "                console.log(reshopOfferItemsByOffer[i][j]);",
                              "            }",
                              "        }",
                              "",
                              "        console.log(\"Reshop Offer IDs:\", reshopOfferIds);",
                              "        console.log(\"Offer Items By Offer:\", reshopOfferItemsByOffer);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {",
                              "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                              "",
                              "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                              "    const abs = Math.abs(tzOffsetMinutes);",
                              "    const offsetHours = pad(Math.floor(abs / 60));",
                              "    const offsetMinutes = pad(abs % 60);",
                              "",
                              "    return (",
                              "        date.getFullYear() +",
                              "        \"-\" + pad(date.getMonth() + 1) +",
                              "        \"-\" + pad(date.getDate()) +",
                              "        \"T\" + pad(date.getHours()) +",
                              "        \":\" + pad(date.getMinutes()) +",
                              "        \":\" + pad(date.getSeconds()) +",
                              "        \".\" + pad(date.getMilliseconds(), 3) +",
                              "        sign + offsetHours + \":\" + offsetMinutes",
                              "    );",
                              "}",
                              "",
                              "let date = new Date();",
                              "",
                              "// Thailand timezone = +07:00 → 420 minutes",
                              "let th = formatWithTimezone(date, 420);",
                              "",
                              "pm.environment.set(\"today_th\", th);",
                              "",
                              "date.setDate(date.getDate() + 15);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"rebookArrivalDate\", arrivalDate);",
                              "pm.environment.set(\"rebookDepartureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:CancelOrderRef>\n                <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n            </ns2:CancelOrderRef>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>\n",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderReshop"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "3. OrderQuote [OW] [Cancel]",
                      "event": [
                        {
                          "listen": "prerequest",
                          "script": {
                            "type": "text/javascript",
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\ndate.setDate(date.getDate() + 10);\n\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nlet arrivalDate = `${year}-${month}-${day}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearD = date.getFullYear();\nlet monthD = String(date.getMonth() + 1).padStart(2, '0');\nlet dayD = String(date.getDate()).padStart(2, '0');\n\nlet departureDate = `${yearD}-${monthD}-${dayD}`;\n\npm.environment.set(\"arrivalDate\", arrivalDate);\npm.environment.set(\"departureDate\", departureDate);"
                            ]
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "bearer",
                          "bearer": [
                            {
                              "key": "token",
                              "value": "{{bearer_token}}",
                              "type": "string"
                            }
                          ]
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{reshopOfferId0}}</cns:OfferRefID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_0}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX1</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_1}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX2</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_2}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX3</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderQuote"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "4. OrderChange [OW] [Cancel]",
                      "event": [
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {",
                              "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                              "",
                              "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                              "    const abs = Math.abs(tzOffsetMinutes);",
                              "    const offsetHours = pad(Math.floor(abs / 60));",
                              "    const offsetMinutes = pad(abs % 60);",
                              "",
                              "    return (",
                              "        date.getFullYear() +",
                              "        \"-\" + pad(date.getMonth() + 1) +",
                              "        \"-\" + pad(date.getDate()) +",
                              "        \"T\" + pad(date.getHours()) +",
                              "        \":\" + pad(date.getMinutes()) +",
                              "        \":\" + pad(date.getSeconds()) +",
                              "        \".\" + pad(date.getMilliseconds(), 3) +",
                              "        sign + offsetHours + \":\" + offsetMinutes",
                              "    );",
                              "}",
                              "",
                              "let date = new Date();",
                              "",
                              "// Thailand timezone = +07:00 → 420 minutes",
                              "let th = formatWithTimezone(date, 420);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "method": "POST",
                        "header": [
                          {
                            "key": "Content-Type",
                            "value": "application/xml"
                          },
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:ChangeOrderChoice>\n            <ns2:AcceptCancelledOffer>\n                <ns2:OfferID>{{reshopOfferId0}}</ns2:OfferID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:AcceptCancelledOffer>\n        </ns2:ChangeOrderChoice>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>VS</ns2:OwnerCode>\n        </ns2:Order>\n    </Request>\n</IATA_OrderChangeRQ>\n",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderChange"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "5. OrderRetrieve by OrderId",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: false",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "    console.log(result);",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                              "        pm.environment.set(`orderId`, orderId);",
                              "",
                              "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                              "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                              "",
                              "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                              "        // Always array",
                              "        if (!Array.isArray(orderItems)) {",
                              "            orderItems = [orderItems];",
                              "        }",
                              "",
                              "        orderItems.forEach((id, index) => {",
                              "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                              "        });",
                              "",
                              "        console.log('TotalPrice: ' + totalPrice);",
                              "        console.log('Currency Code:' + totalCurCode);",
                              "        pm.environment.set(`totalPrice`, totalPrice);",
                              "        pm.environment.set(`totalCurCode`, totalCurCode);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "let date = new Date();",
                              "date.setDate(date.getDate() + 10);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"arrivalDate\", arrivalDate);",
                              "pm.environment.set(\"departureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderRetrieve"
                          ]
                        }
                      },
                      "response": []
                    }
                  ]
                },
                {
                  "name": "RT [1ADT, 1CHD, 1INF]",
                  "item": [
                    {
                      "name": "1. OrderRetrieve by OrderId",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: false",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "    console.log(result);",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                              "        pm.environment.set(`orderId`, orderId);",
                              "",
                              "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                              "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                              "",
                              "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                              "        // Always array",
                              "        if (!Array.isArray(orderItems)) {",
                              "            orderItems = [orderItems];",
                              "        }",
                              "",
                              "        orderItems.forEach((id, index) => {",
                              "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                              "        });",
                              "",
                              "        console.log('TotalPrice: ' + totalPrice);",
                              "        console.log('Currency Code:' + totalCurCode);",
                              "        pm.environment.set(`totalPrice`, totalPrice);",
                              "        pm.environment.set(`totalCurCode`, totalCurCode);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "let date = new Date();",
                              "date.setDate(date.getDate() + 10);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"arrivalDate\", arrivalDate);",
                              "pm.environment.set(\"departureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderRetrieve"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "2. OrderReshop [RT] [Cancel]",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: true",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let reshopOffers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                              "",
                              "        // Always array",
                              "        if (!Array.isArray(reshopOffers)) {",
                              "            reshopOffers = [reshopOffers];",
                              "        }",
                              "",
                              "        let reshopOfferIds = [];",
                              "        let reshopOfferItemsByOffer = []; // nested list",
                              "",
                              "        reshopOffers.forEach(reshopOffer => {",
                              "",
                              "            // Store ID",
                              "            reshopOfferIds.push(reshopOffer.OfferID);",
                              "",
                              "            // Extract OfferItem list",
                              "            let items = reshopOffer.AddedOfferItem;",
                              "            if (!Array.isArray(items)) {",
                              "                items = [items];",
                              "            }",
                              "",
                              "            // Extract OfferItemID for this offer",
                              "            let itemIds = items.map(i => i.OfferItemID);",
                              "",
                              "            reshopOfferItemsByOffer.push(itemIds);",
                              "        });",
                              "",
                              "        // Save to environment",
                              "        pm.environment.set(\"reshopOfferIds\", JSON.stringify(reshopOfferIds));",
                              "        pm.environment.set(\"reshopOfferItemsByOffer\", JSON.stringify(reshopOfferItemsByOffer));",
                              "",
                              "",
                              "        reshopOfferIds.forEach((id, index) => {",
                              "            pm.environment.set(`reshopOfferId${index}`, id);",
                              "        });",
                              "",
                              "        for (let i = 0; i < reshopOfferItemsByOffer.length; i++) {",
                              "            for (let j = 0; j < reshopOfferItemsByOffer[i].length; j++) {",
                              "                pm.environment.set(`reshopOfferItemId${i}_${j}`, reshopOfferItemsByOffer[i][j]);",
                              "                console.log(reshopOfferItemsByOffer[i][j]);",
                              "            }",
                              "        }",
                              "",
                              "        console.log(\"Reshop Offer IDs:\", reshopOfferIds);",
                              "        console.log(\"Offer Items By Offer:\", reshopOfferItemsByOffer);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {",
                              "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                              "",
                              "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                              "    const abs = Math.abs(tzOffsetMinutes);",
                              "    const offsetHours = pad(Math.floor(abs / 60));",
                              "    const offsetMinutes = pad(abs % 60);",
                              "",
                              "    return (",
                              "        date.getFullYear() +",
                              "        \"-\" + pad(date.getMonth() + 1) +",
                              "        \"-\" + pad(date.getDate()) +",
                              "        \"T\" + pad(date.getHours()) +",
                              "        \":\" + pad(date.getMinutes()) +",
                              "        \":\" + pad(date.getSeconds()) +",
                              "        \".\" + pad(date.getMilliseconds(), 3) +",
                              "        sign + offsetHours + \":\" + offsetMinutes",
                              "    );",
                              "}",
                              "",
                              "let date = new Date();",
                              "",
                              "// Thailand timezone = +07:00 → 420 minutes",
                              "let th = formatWithTimezone(date, 420);",
                              "",
                              "pm.environment.set(\"today_th\", th);",
                              "",
                              "date.setDate(date.getDate() + 15);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"rebookArrivalDate\", arrivalDate);",
                              "pm.environment.set(\"rebookDepartureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:CancelOrderRef>\n                <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n            </ns2:CancelOrderRef>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>\n",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderReshop"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "3. OrderQuote [RT] [Cancel]",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {",
                              "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                              "",
                              "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                              "    const abs = Math.abs(tzOffsetMinutes);",
                              "    const offsetHours = pad(Math.floor(abs / 60));",
                              "    const offsetMinutes = pad(abs % 60);",
                              "",
                              "    return (",
                              "        date.getFullYear() +",
                              "        \"-\" + pad(date.getMonth() + 1) +",
                              "        \"-\" + pad(date.getDate()) +",
                              "        \"T\" + pad(date.getHours()) +",
                              "        \":\" + pad(date.getMinutes()) +",
                              "        \":\" + pad(date.getSeconds()) +",
                              "        \".\" + pad(date.getMilliseconds(), 3) +",
                              "        sign + offsetHours + \":\" + offsetMinutes",
                              "    );",
                              "}",
                              "",
                              "let date = new Date();",
                              "",
                              "// Thailand timezone = +07:00 → 420 minutes",
                              "let th = formatWithTimezone(date, 420);",
                              "",
                              "date.setDate(date.getDate() + 10);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"arrivalDate\", arrivalDate);",
                              "pm.environment.set(\"departureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "bearer",
                          "bearer": [
                            {
                              "key": "token",
                              "value": "{{bearer_token}}",
                              "type": "string"
                            }
                          ]
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{reshopOfferId0}}</cns:OfferRefID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_0}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX1</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_1}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX1</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_2}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX2</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_3}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX2</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_4}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX3</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_5}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX3</cns:PaxRefID>\n            </cns:SelectedOfferItem>\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderQuote"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "4. OrderChange [RT] [Cancel]",
                      "event": [
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {",
                              "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                              "",
                              "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                              "    const abs = Math.abs(tzOffsetMinutes);",
                              "    const offsetHours = pad(Math.floor(abs / 60));",
                              "    const offsetMinutes = pad(abs % 60);",
                              "",
                              "    return (",
                              "        date.getFullYear() +",
                              "        \"-\" + pad(date.getMonth() + 1) +",
                              "        \"-\" + pad(date.getDate()) +",
                              "        \"T\" + pad(date.getHours()) +",
                              "        \":\" + pad(date.getMinutes()) +",
                              "        \":\" + pad(date.getSeconds()) +",
                              "        \".\" + pad(date.getMilliseconds(), 3) +",
                              "        sign + offsetHours + \":\" + offsetMinutes",
                              "    );",
                              "}",
                              "",
                              "let date = new Date();",
                              "",
                              "// Thailand timezone = +07:00 → 420 minutes",
                              "let th = formatWithTimezone(date, 420);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "method": "POST",
                        "header": [
                          {
                            "key": "Content-Type",
                            "value": "application/xml"
                          },
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:ChangeOrderChoice>\n            <ns2:AcceptCancelledOffer>\n                <ns2:OfferID>{{reshopOfferId0}}</ns2:OfferID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:AcceptCancelledOffer>\n        </ns2:ChangeOrderChoice>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>VS</ns2:OwnerCode>\n        </ns2:Order>\n    </Request>\n</IATA_OrderChangeRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderChange"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "5. OrderRetrieve by OrderId",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: false",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "    console.log(result);",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                              "        pm.environment.set(`orderId`, orderId);",
                              "",
                              "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                              "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                              "",
                              "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                              "        // Always array",
                              "        if (!Array.isArray(orderItems)) {",
                              "            orderItems = [orderItems];",
                              "        }",
                              "",
                              "        orderItems.forEach((id, index) => {",
                              "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                              "        });",
                              "",
                              "        console.log('TotalPrice: ' + totalPrice);",
                              "        console.log('Currency Code:' + totalCurCode);",
                              "        pm.environment.set(`totalPrice`, totalPrice);",
                              "        pm.environment.set(`totalCurCode`, totalCurCode);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "let date = new Date();",
                              "date.setDate(date.getDate() + 10);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"arrivalDate\", arrivalDate);",
                              "pm.environment.set(\"departureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderRetrieve"
                          ]
                        }
                      },
                      "response": []
                    }
                  ]
                }
              ]
            },
            {
              "name": "Cancel Segment",
              "item": [
                {
                  "name": "RT",
                  "item": [
                    {
                      "name": "1. OrderRetrieve by OrderId",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: false",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "    console.log(result);",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                              "        pm.environment.set(`orderId`, orderId);",
                              "",
                              "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                              "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                              "",
                              "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                              "        // Always array",
                              "        if (!Array.isArray(orderItems)) {",
                              "            orderItems = [orderItems];",
                              "        }",
                              "",
                              "        orderItems.forEach((id, index) => {",
                              "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                              "        });",
                              "",
                              "        console.log('TotalPrice: ' + totalPrice);",
                              "        console.log('Currency Code:' + totalCurCode);",
                              "        pm.environment.set(`totalPrice`, totalPrice);",
                              "        pm.environment.set(`totalCurCode`, totalCurCode);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "let date = new Date();",
                              "date.setDate(date.getDate() + 10);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"arrivalDate\", arrivalDate);",
                              "pm.environment.set(\"departureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderRetrieve"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "2. OrderReshop [RT] [Cancel Segment]",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: true",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let reshopOffers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                              "",
                              "        // Always array",
                              "        if (!Array.isArray(reshopOffers)) {",
                              "            reshopOffers = [reshopOffers];",
                              "        }",
                              "",
                              "        let reshopOfferIds = [];",
                              "        let reshopOfferItemsByOffer = []; // nested list",
                              "",
                              "        reshopOffers.forEach(reshopOffer => {",
                              "",
                              "            // Store ID",
                              "            reshopOfferIds.push(reshopOffer.OfferID);",
                              "",
                              "            // Extract OfferItem list",
                              "            let items = reshopOffer.AddedOfferItem;",
                              "            if (!Array.isArray(items)) {",
                              "                items = [items];",
                              "            }",
                              "",
                              "            // Extract OfferItemID for this offer",
                              "            let itemIds = items.map(i => i.OfferItemID);",
                              "",
                              "            reshopOfferItemsByOffer.push(itemIds);",
                              "        });",
                              "",
                              "        // Save to environment",
                              "        pm.environment.set(\"reshopOfferIds\", JSON.stringify(reshopOfferIds));",
                              "        pm.environment.set(\"reshopOfferItemsByOffer\", JSON.stringify(reshopOfferItemsByOffer));",
                              "",
                              "",
                              "        reshopOfferIds.forEach((id, index) => {",
                              "            pm.environment.set(`reshopOfferId${index}`, id);",
                              "        });",
                              "",
                              "        for (let i = 0; i < reshopOfferItemsByOffer.length; i++) {",
                              "            for (let j = 0; j < reshopOfferItemsByOffer[i].length; j++) {",
                              "                pm.environment.set(`reshopOfferItemId${i}_${j}`, reshopOfferItemsByOffer[i][j]);",
                              "                console.log(reshopOfferItemsByOffer[i][j]);",
                              "            }",
                              "        }",
                              "",
                              "        console.log(\"Reshop Offer IDs:\", reshopOfferIds);",
                              "        console.log(\"Offer Items By Offer:\", reshopOfferItemsByOffer);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {",
                              "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                              "",
                              "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                              "    const abs = Math.abs(tzOffsetMinutes);",
                              "    const offsetHours = pad(Math.floor(abs / 60));",
                              "    const offsetMinutes = pad(abs % 60);",
                              "",
                              "    return (",
                              "        date.getFullYear() +",
                              "        \"-\" + pad(date.getMonth() + 1) +",
                              "        \"-\" + pad(date.getDate()) +",
                              "        \"T\" + pad(date.getHours()) +",
                              "        \":\" + pad(date.getMinutes()) +",
                              "        \":\" + pad(date.getSeconds()) +",
                              "        \".\" + pad(date.getMilliseconds(), 3) +",
                              "        sign + offsetHours + \":\" + offsetMinutes",
                              "    );",
                              "}",
                              "",
                              "let date = new Date();",
                              "",
                              "// Thailand timezone = +07:00 → 420 minutes",
                              "let th = formatWithTimezone(date, 420);",
                              "",
                              "pm.environment.set(\"today_th\", th);",
                              "",
                              "date.setDate(date.getDate() + 15);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"rebookArrivalDate\", arrivalDate);",
                              "pm.environment.set(\"rebookDepartureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:ReshopOrder>\n        \t\t<ns2:ReshopOrderChoice>\n        \t\t\t<ns2:ServiceOrder>\n        \t\t\t\t<ns2:DeleteOrderItem>\n        \t\t\t\t\t<ns2:OrderItemRefID>{{orderItemId0}}</ns2:OrderItemRefID>\n        \t\t\t\t\t<ns2:RespendInd>false</ns2:RespendInd>\n        \t\t\t\t</ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n        \t\t\t\t\t<ns2:OrderItemRefID>{{orderItemId4}}</ns2:OrderItemRefID>\n        \t\t\t\t\t<ns2:RespendInd>false</ns2:RespendInd>\n        \t\t\t\t</ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n        \t\t\t\t\t<ns2:OrderItemRefID>{{orderItemId5}}</ns2:OrderItemRefID>\n        \t\t\t\t\t<ns2:RespendInd>false</ns2:RespendInd>\n        \t\t\t\t</ns2:DeleteOrderItem>\n        \t\t\t</ns2:ServiceOrder>\n        \t\t</ns2:ReshopOrderChoice>\n            </ns2:ReshopOrder>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>\n",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderReshop"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "3. OrderChange [RT] [Cancel Segment",
                      "event": [
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "function formatWithTimezone(date, tzOffsetMinutes) {",
                              "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                              "",
                              "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                              "    const abs = Math.abs(tzOffsetMinutes);",
                              "    const offsetHours = pad(Math.floor(abs / 60));",
                              "    const offsetMinutes = pad(abs % 60);",
                              "",
                              "    return (",
                              "        date.getFullYear() +",
                              "        \"-\" + pad(date.getMonth() + 1) +",
                              "        \"-\" + pad(date.getDate()) +",
                              "        \"T\" + pad(date.getHours()) +",
                              "        \":\" + pad(date.getMinutes()) +",
                              "        \":\" + pad(date.getSeconds()) +",
                              "        \".\" + pad(date.getMilliseconds(), 3) +",
                              "        sign + offsetHours + \":\" + offsetMinutes",
                              "    );",
                              "}",
                              "",
                              "let date = new Date();",
                              "",
                              "// Thailand timezone = +07:00 → 420 minutes",
                              "let th = formatWithTimezone(date, 420);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "method": "POST",
                        "header": [
                          {
                            "key": "Content-Type",
                            "value": "application/xml"
                          },
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:ChangeOrderChoice>\n            <ns2:AcceptCancelledOffer>\n                <ns2:OfferID>{{reshopOfferId0}}</ns2:OfferID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:AcceptCancelledOffer>\n        </ns2:ChangeOrderChoice>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>VS</ns2:OwnerCode>\n        </ns2:Order>\n    </Request>\n</IATA_OrderChangeRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderChange"
                          ]
                        }
                      },
                      "response": []
                    },
                    {
                      "name": "4. OrderRetrieve by OrderId",
                      "event": [
                        {
                          "listen": "test",
                          "script": {
                            "exec": [
                              "const xml2js = require('xml2js');",
                              "const xmlContent = pm.response.text();",
                              "",
                              "// Require the necessary xml2js components",
                              "const parseString = require('xml2js').parseString;",
                              "const stripPrefix = require('xml2js').processors.stripPrefix;",
                              "",
                              "parseString(xmlContent, {",
                              "    // Optional configuration for cleaner access",
                              "    tagNameProcessors: [stripPrefix],",
                              "    explicitArray: false,",
                              "    ignoreAttrs: false",
                              "}, function (err, result) {",
                              "    if (err) {",
                              "        console.error('Error parsing XML:', err);",
                              "        return;",
                              "    }",
                              "    console.log(result);",
                              "",
                              "    // Now 'result' is your fully parsed JavaScript object.",
                              "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                              "    try {",
                              "        // Navigate to Offer list",
                              "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                              "        pm.environment.set(`orderId`, orderId);",
                              "",
                              "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                              "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                              "",
                              "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                              "        // Always array",
                              "        if (!Array.isArray(orderItems)) {",
                              "            orderItems = [orderItems];",
                              "        }",
                              "",
                              "        orderItems.forEach((id, index) => {",
                              "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                              "        });",
                              "",
                              "        console.log('TotalPrice: ' + totalPrice);",
                              "        console.log('Currency Code:' + totalCurCode);",
                              "        pm.environment.set(`totalPrice`, totalPrice);",
                              "        pm.environment.set(`totalCurCode`, totalCurCode);",
                              "",
                              "    } catch (e) {",
                              "        console.error('Could not find the expected path in the XML structure:', e.message);",
                              "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                              "    }",
                              "});",
                              ""
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        },
                        {
                          "listen": "prerequest",
                          "script": {
                            "exec": [
                              "let date = new Date();",
                              "date.setDate(date.getDate() + 10);",
                              "",
                              "let year = date.getFullYear();",
                              "let month = String(date.getMonth() + 1).padStart(2, '0');",
                              "let day = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let arrivalDate = `${year}-${month}-${day}`;",
                              "",
                              "date.setDate(date.getDate() + 1);",
                              "let yearD = date.getFullYear();",
                              "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                              "let dayD = String(date.getDate()).padStart(2, '0');",
                              "",
                              "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                              "",
                              "pm.environment.set(\"arrivalDate\", arrivalDate);",
                              "pm.environment.set(\"departureDate\", departureDate);"
                            ],
                            "type": "text/javascript",
                            "packages": {},
                            "requests": {}
                          }
                        }
                      ],
                      "request": {
                        "auth": {
                          "type": "noauth"
                        },
                        "method": "POST",
                        "header": [
                          {
                            "key": "x-api-key",
                            "value": "{{x-api-key}}",
                            "type": "text"
                          }
                        ],
                        "body": {
                          "mode": "raw",
                          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                          "options": {
                            "raw": {
                              "language": "xml"
                            }
                          }
                        },
                        "url": {
                          "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                          "host": [
                            "{{ndc-gateway-url}}"
                          ],
                          "path": [
                            "v21.3.5",
                            "OrderRetrieve"
                          ]
                        }
                      },
                      "response": []
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "Manage booking - Rebook",
          "item": [
            {
              "name": "OW - 1ADT 1CHD 1INF",
              "item": [
                {
                  "name": "1. AirShopping [OW] [1 ADT, 1 CHD, 1 INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: true\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;\n\n        // Always array\n        if (!Array.isArray(offers)) {\n            offers = [offers];\n        }\n\n        let offerIds = [];\n        let offerItemsByOffer = []; // nested list\n\n        offers.forEach(offer => {\n\n            // Store ID\n            offerIds.push(offer.OfferID);\n\n            // Extract OfferItem list\n            let items = offer.OfferItem;\n            if (!Array.isArray(items)) {\n                items = [items];\n            }\n\n            // Extract OfferItemID for this offer\n            let itemIds = items.map(i => i.OfferItemID);\n\n            offerItemsByOffer.push(itemIds);\n        });\n\n        // Save to environment\n        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));\n        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));\n\n\n        offerIds.forEach((id, index) => {\n            pm.environment.set(`offerId${index}`, id);\n        });\n\n        for (let i = 0; i < offerItemsByOffer.length; i++) {\n            for (let j = 0; j < offerItemsByOffer[i].length; j++) {\n                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);\n                console.log(offerItemsByOffer[i][j]);\n            }\n        }\n\n        console.log(\"Offer IDs:\", offerIds);\n        console.log(\"Offer Items By Offer:\", offerItemsByOffer);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                        ]
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\nlet departureDate = new Date();\ndepartureDate.setDate(departureDate.getDate() + 7);\n\nlet returnDate = new Date(departureDate);\nreturnDate.setDate(returnDate.getDate() + 7);\n\n// Format to YYYY-MM-DD\npm.variables.set('departureDate', departureDate.toISOString().split('T')[0]);\npm.variables.set('returnDate', returnDate.toISOString().split('T')[0]);\npm.environment.set(\"today_th\", th);"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <!-- KRP to CPH -->\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        \n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n    \n</IATA_AirShoppingRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [OW] [1 ADT, 1 CHD, 1 INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "        const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "        // Total price",
                          "        pm.environment.set('totalPrice', totalAmount._);",
                          "        pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "        // Offer ID",
                          "        pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "        // Offer items (by index)",
                          "        const offerItems = toArray(pricedOffer.OfferItem);",
                          "        offerItems.forEach((item, index) => {",
                          "            pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "",
                          "            // Also by PTC: ADT / CHD / INF",
                          "            const paxRefId = item.FareDetail?.PaxRefID || item.Service?.PaxRefID;",
                          "            if (paxRefId) {",
                          "                const ptc = paxRefId.replace(/\\d+$/, ''); // ADT1 → ADT",
                          "                pm.environment.set(`offerItemId_${ptc}`, item.OfferItemID);",
                          "                pm.environment.set(`paxRefId_${ptc}`, paxRefId);",
                          "            }",
                          "        });",
                          "",
                          "        console.log('totalPrice:', totalAmount._);",
                          "        console.log('totalCurCode:', totalAmount.$.CurCode);",
                          "        console.log('offerId:', pricedOffer.OfferID);",
                          "        offerItems.forEach((item, i) => console.log(`offerItemId${i}:`, item.OfferItemID));",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not parse OfferPriceRS:', e.message);",
                          "        console.log('Full parsed object:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId2}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId2_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId2_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId2_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [OW] [1ADT., 1CHD, 1INF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "function formatDateOnly(date) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate())",
                          "    );",
                          "}",
                          "",
                          "function subtractYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() - years);",
                          "    return result;",
                          "}",
                          "",
                          "function subtractMonths(date, months) {",
                          "    const result = new Date(date);",
                          "    result.setMonth(result.getMonth() - months);",
                          "    return result;",
                          "}",
                          "",
                          "function addYears(date, years) {",
                          "    const result = new Date(date);",
                          "    result.setFullYear(result.getFullYear() + years);",
                          "    return result;",
                          "}",
                          "",
                          "let today = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(today, 420);",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "// Birthdates: YYYY-MM-DD",
                          "let adultBirthDate = formatDateOnly(subtractYears(today, 30));",
                          "let childBirthDate = formatDateOnly(subtractYears(today, 3));",
                          "let infantBirthDate = formatDateOnly(subtractMonths(today, 1));",
                          "let expiryDate = formatDateOnly(addYears(today, 10));",
                          "",
                          "pm.environment.set(\"adultBirthDate\", adultBirthDate);",
                          "pm.environment.set(\"childBirthDate\", childBirthDate);",
                          "pm.environment.set(\"infantBirthDate\", infantBirthDate);",
                          "pm.environment.set(\"expiryDate\", expiryDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        // Always array",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((id, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                          "        });",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderReshop [OW] [1ADT 1CHD 1INF] [Rebook]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: true",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let reshopOffers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                          "",
                          "        // Always array",
                          "        if (!Array.isArray(reshopOffers)) {",
                          "            reshopOffers = [reshopOffers];",
                          "        }",
                          "",
                          "        let reshopOfferIds = [];",
                          "        let reshopOfferItemsByOffer = []; // nested list",
                          "",
                          "        reshopOffers.forEach(reshopOffer => {",
                          "",
                          "            // Store ID",
                          "            reshopOfferIds.push(reshopOffer.OfferID);",
                          "",
                          "            // Extract OfferItem list",
                          "            let items = reshopOffer.AddedOfferItem;",
                          "            if (!Array.isArray(items)) {",
                          "                items = [items];",
                          "            }",
                          "",
                          "            // Extract OfferItemID for this offer",
                          "            let itemIds = items.map(i => i.OfferItemID);",
                          "",
                          "            reshopOfferItemsByOffer.push(itemIds);",
                          "        });",
                          "",
                          "        // Save to environment",
                          "        pm.environment.set(\"reshopOfferIds\", JSON.stringify(reshopOfferIds));",
                          "        pm.environment.set(\"reshopOfferItemsByOffer\", JSON.stringify(reshopOfferItemsByOffer));",
                          "",
                          "",
                          "        reshopOfferIds.forEach((id, index) => {",
                          "            pm.environment.set(`reshopOfferId${index}`, id);",
                          "        });",
                          "",
                          "        for (let i = 0; i < reshopOfferItemsByOffer.length; i++) {",
                          "            for (let j = 0; j < reshopOfferItemsByOffer[i].length; j++) {",
                          "                pm.environment.set(`reshopOfferItemId${i}_${j}`, reshopOfferItemsByOffer[i][j]);",
                          "                console.log(reshopOfferItemsByOffer[i][j]);",
                          "            }",
                          "        }",
                          "",
                          "        console.log(\"Reshop Offer IDs:\", reshopOfferIds);",
                          "        console.log(\"Offer Items By Offer:\", reshopOfferItemsByOffer);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "date.setDate(date.getDate() + 20);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"rebookArrivalDate\", arrivalDate);",
                          "pm.environment.set(\"rebookDepartureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:ReshopOrder>\n                <ns2:ReshopOrderChoice>\n                    <ns2:ServiceOrder>\n                        <ns2:AddOfferItems>\n                            <ns2:FlightRequest>\n                                <ns2:FlightRequestOriginDestinationsCriteria>\n                                    <ns2:OriginDestCriteria>\n                                        <ns2:DestArrivalCriteria>\n                                            <ns2:Date>{{rebookArrivalDate}}</ns2:Date>\n                                            <ns2:IATA_LocationCode>{{arrivalCode}}</ns2:IATA_LocationCode>\n                                            <!--\n                                            <ns2:Time>12:30:00</ns2:Time>\n                                            -->\n                                        </ns2:DestArrivalCriteria>\n                                        <ns2:OriginDepCriteria>\n                                            <ns2:Date>{{rebookDepartureDate}}</ns2:Date>\n                                            <ns2:IATA_LocationCode>{{departureCode}}</ns2:IATA_LocationCode>\n                                            <!--\n                                            <ns2:Time>14:30:00</ns2:Time>\n                                            -->\n                                        </ns2:OriginDepCriteria>\n                                    </ns2:OriginDestCriteria>\n                                </ns2:FlightRequestOriginDestinationsCriteria>\n                            </ns2:FlightRequest>\n                        </ns2:AddOfferItems>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId0}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId1}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId2}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                    </ns2:ServiceOrder>\n                </ns2:ReshopOrderChoice>\n            </ns2:ReshopOrder>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderReshop"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6. OrderQuote [OW] [1ADT 1CHD 1INF] [Rebook]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const response = result.IATA_OrderReshopRS.Response;",
                          "        const offer = response.ReshopResults.ReshopOffers.Offer;",
                          "        const totalAmount = offer.TotalPrice.TotalAmount;",
                          "",
                          "        pm.environment.set('totalPrice', totalAmount._);",
                          "        pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "        pm.environment.set('offerId', offer.OfferID);",
                          "        pm.environment.set('orderId', response.Order.OrderID);",
                          "",
                          "        toArray(offer.AddedOfferItem).forEach((item, index) => {",
                          "            pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "",
                          "            const paxRefId = item.FareDetail?.PaxRefID || item.Service?.PaxRefID;",
                          "            if (paxRefId) {",
                          "                const ptc = paxRefId.replace(/\\d+$/, ''); // ADT1 → ADT",
                          "                pm.environment.set(`offerItemId_${ptc}_${index}`, item.OfferItemID);",
                          "            }",
                          "        });",
                          "",
                          "        console.log('totalPrice:', totalAmount._);",
                          "        console.log('totalCurCode:', totalAmount.$.CurCode);",
                          "        console.log('offerId:', offer.OfferID);",
                          "        console.log('orderId:', response.Order.OrderID);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not parse OrderReshopRS:', e.message);",
                          "        console.log('Full parsed object:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "bearer",
                      "bearer": [
                        {
                          "key": "token",
                          "value": "{{bearer_token}}",
                          "type": "string"
                        }
                      ]
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <ns2:ExistingOrder>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>VS</ns2:OwnerCode>\n        </ns2:ExistingOrder>\n        <ns2:SelectedOffers>\n            <ns2:OfferRefID>{{reshopOfferId0}}</ns2:OfferRefID>\n            <ns2:OwnerCode>VS</ns2:OwnerCode>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_0}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_1}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_2}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n        </ns2:SelectedOffers>\n    </Payload>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "7. OrderChange [OW] [1ADT 1CHD 1INF] [Rebook] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "Content-Type",
                        "value": "application/xml"
                      },
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:ChangeOrderChoice>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{reshopOfferId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>ADT1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>CHD1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>INF1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:ChangeOrderChoice>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "RT - 1ADT 1CHD 1INF",
              "item": [
                {
                  "name": "1. AirShopping [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: true",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;",
                          "",
                          "        // Always array",
                          "        if (!Array.isArray(offers)) {",
                          "            offers = [offers];",
                          "        }",
                          "",
                          "        let offerIds = [];",
                          "        let offerItemsByOffer = []; // nested list",
                          "",
                          "        offers.forEach(offer => {",
                          "",
                          "            // Store ID",
                          "            offerIds.push(offer.OfferID);",
                          "",
                          "            // Extract OfferItem list",
                          "            let items = offer.OfferItem;",
                          "            if (!Array.isArray(items)) {",
                          "                items = [items];",
                          "            }",
                          "",
                          "            // Extract OfferItemID for this offer",
                          "            let itemIds = items.map(i => i.OfferItemID);",
                          "",
                          "            offerItemsByOffer.push(itemIds);",
                          "        });",
                          "",
                          "        // Save to environment",
                          "        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));",
                          "        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));",
                          "",
                          "",
                          "        offerIds.forEach((id, index) => {",
                          "            pm.environment.set(`offerId${index}`, id);",
                          "        });",
                          "",
                          "        for (let i = 0; i < offerItemsByOffer.length; i++) {",
                          "            for (let j = 0; j < offerItemsByOffer[i].length; j++) {",
                          "                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);",
                          "                console.log(offerItemsByOffer[i][j]);",
                          "            }",
                          "        }",
                          "",
                          "        console.log(\"Offer IDs:\", offerIds);",
                          "        console.log(\"Offer Items By Offer:\", offerItemsByOffer);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "date.setDate(date.getDate() + 5);",
                          "let yearND = date.getFullYear();",
                          "let monthND = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayND = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let nextDepartureDate = `${yearND}-${monthND}-${dayND}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearNA = date.getFullYear();",
                          "let monthNA = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayNA = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let nextArrivalDate = `${yearNA}-${monthNA}-${dayNA}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);",
                          "pm.environment.set(\"nextArrivalDate\", nextArrivalDate);",
                          "pm.environment.set(\"nextDepartureDate\", nextDepartureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <!-- KRP to CPH -->\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{nextArrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{nextDepartureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        \n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n    \n</IATA_AirShoppingRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "        const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "        // Total price",
                          "        pm.environment.set('totalPrice', totalAmount._);",
                          "        pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "        // Offer ID",
                          "        pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "        // Offer items (by index)",
                          "        const offerItems = toArray(pricedOffer.OfferItem);",
                          "        offerItems.forEach((item, index) => {",
                          "            pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "",
                          "            // Also by PTC: ADT / CHD / INF",
                          "            const paxRefId = item.FareDetail?.PaxRefID || item.Service?.PaxRefID;",
                          "            if (paxRefId) {",
                          "                const ptc = paxRefId.replace(/\\d+$/, ''); // ADT1 → ADT",
                          "                pm.environment.set(`offerItemId_${ptc}`, item.OfferItemID);",
                          "                pm.environment.set(`paxRefId_${ptc}`, paxRefId);",
                          "            }",
                          "        });",
                          "",
                          "        console.log('totalPrice:', totalAmount._);",
                          "        console.log('totalCurCode:', totalAmount.$.CurCode);",
                          "        console.log('offerId:', pricedOffer.OfferID);",
                          "        offerItems.forEach((item, i) => console.log(`offerItemId${i}:`, item.OfferItemID));",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not parse OfferPriceRS:', e.message);",
                          "        console.log('Full parsed object:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId3}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId3_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId3_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId3_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId3_3}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId3_4}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId3_5}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [RT] [1ADT, 1CHD, 1NF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId3}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId4}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId5}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <!--\n                    <ns2:ContactInfoRefID>CTCPAX1_1</ns2:ContactInfoRefID>\n                    -->\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        // Always array",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((id, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                          "        });",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "let date = new Date();",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderReshop [RT] [1ADT, 1CHD, 1INF] [Rebook]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: true",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let reshopOffers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                          "",
                          "        // Always array",
                          "        if (!Array.isArray(reshopOffers)) {",
                          "            reshopOffers = [reshopOffers];",
                          "        }",
                          "",
                          "        let reshopOfferIds = [];",
                          "        let reshopOfferItemsByOffer = []; // nested list",
                          "",
                          "        reshopOffers.forEach(reshopOffer => {",
                          "",
                          "            // Store ID",
                          "            reshopOfferIds.push(reshopOffer.OfferID);",
                          "",
                          "            // Extract OfferItem list",
                          "            let items = reshopOffer.AddedOfferItem;",
                          "            if (!Array.isArray(items)) {",
                          "                items = [items];",
                          "            }",
                          "",
                          "            // Extract OfferItemID for this offer",
                          "            let itemIds = items.map(i => i.OfferItemID);",
                          "",
                          "            reshopOfferItemsByOffer.push(itemIds);",
                          "        });",
                          "",
                          "        // Save to environment",
                          "        pm.environment.set(\"reshopOfferIds\", JSON.stringify(reshopOfferIds));",
                          "        pm.environment.set(\"reshopOfferItemsByOffer\", JSON.stringify(reshopOfferItemsByOffer));",
                          "",
                          "",
                          "        reshopOfferIds.forEach((id, index) => {",
                          "            pm.environment.set(`reshopOfferId${index}`, id);",
                          "        });",
                          "",
                          "        for (let i = 0; i < reshopOfferItemsByOffer.length; i++) {",
                          "            for (let j = 0; j < reshopOfferItemsByOffer[i].length; j++) {",
                          "                pm.environment.set(`reshopOfferItemId${i}_${j}`, reshopOfferItemsByOffer[i][j]);",
                          "                console.log(reshopOfferItemsByOffer[i][j]);",
                          "            }",
                          "        }",
                          "",
                          "        console.log(\"Reshop Offer IDs:\", reshopOfferIds);",
                          "        console.log(\"Offer Items By Offer:\", reshopOfferItemsByOffer);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);",
                          "",
                          "date.setDate(date.getDate() + 15);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "date.setDate(date.getDate() + 2);",
                          "",
                          "let yearND = date.getFullYear();",
                          "let monthND = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayND = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let nextDepartureDate = `${yearND}-${monthND}-${dayND}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "",
                          "let yearNA = date.getFullYear();",
                          "let monthNA = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayNA = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let nextArrivalDate = `${yearNA}-${monthNA}-${dayNA}`;",
                          "",
                          "pm.environment.set(\"rebookArrivalDate\", arrivalDate);",
                          "pm.environment.set(\"rebookDepartureDate\", departureDate);",
                          "pm.environment.set(\"nextRebookArrivalDate\", nextArrivalDate);",
                          "pm.environment.set(\"nextRebookDepartureDate\", nextDepartureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:ReshopOrder>\n                <ns2:ReshopOrderChoice>\n                    <ns2:ServiceOrder>\n                        <ns2:AddOfferItems>\n                            <ns2:FlightRequest>\n                                <ns2:FlightRequestOriginDestinationsCriteria>\n                                    <ns2:OriginDestCriteria>\n                                        <ns2:DestArrivalCriteria>\n                                            <ns2:Date>{{rebookArrivalDate}}</ns2:Date>\n                                            <ns2:IATA_LocationCode>{{arrivalCode}}</ns2:IATA_LocationCode>\n                                            <!--\n                                            <ns2:Time>12:30:00</ns2:Time>\n                                            -->\n                                        </ns2:DestArrivalCriteria>\n                                        <ns2:OriginDepCriteria>\n                                            <ns2:Date>{{rebookDepartureDate}}</ns2:Date>\n                                            <ns2:IATA_LocationCode>{{departureCode}}</ns2:IATA_LocationCode>\n                                            <!--\n                                            <ns2:Time>14:30:00</ns2:Time>\n                                            -->\n                                        </ns2:OriginDepCriteria>\n                                    </ns2:OriginDestCriteria>\n                                    <ns2:OriginDestCriteria>\n                                        <ns2:DestArrivalCriteria>\n                                            <ns2:Date>{{nextRebookArrivalDate}}</ns2:Date>\n                                            <ns2:IATA_LocationCode>{{departureCode}}</ns2:IATA_LocationCode>\n                                        </ns2:DestArrivalCriteria>\n                                        <ns2:OriginDepCriteria>\n                                            <ns2:Date>{{nextRebookDepartureDate}}</ns2:Date>\n                                            <ns2:IATA_LocationCode>{{arrivalCode}}</ns2:IATA_LocationCode>\n                                        </ns2:OriginDepCriteria>\n                                    </ns2:OriginDestCriteria>\n                                </ns2:FlightRequestOriginDestinationsCriteria>\n                            </ns2:FlightRequest>\n                        </ns2:AddOfferItems>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId0}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId1}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId2}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId3}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId4}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                        <ns2:DeleteOrderItem>\n                            <ns2:OrderItemRefID>{{orderItemId5}}</ns2:OrderItemRefID>\n                        </ns2:DeleteOrderItem>\n                    </ns2:ServiceOrder>\n                </ns2:ReshopOrderChoice>\n            </ns2:ReshopOrder>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderReshop"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6. OrderQuote [RT] [1ADT, 1CHD, 1INF] [Rebook]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const response = result.IATA_OrderReshopRS.Response;",
                          "        const offer = response.ReshopResults.ReshopOffers.Offer;",
                          "        const totalAmount = offer.TotalPrice.TotalAmount;",
                          "",
                          "        pm.environment.set('totalPrice', totalAmount._);",
                          "        pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "        pm.environment.set('offerId', offer.OfferID);",
                          "        pm.environment.set('orderId', response.Order.OrderID);",
                          "",
                          "        toArray(offer.AddedOfferItem).forEach((item, index) => {",
                          "            pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "",
                          "            const paxRefId = item.FareDetail?.PaxRefID || item.Service?.PaxRefID;",
                          "            if (paxRefId) {",
                          "                const ptc = paxRefId.replace(/\\d+$/, ''); // ADT1 → ADT",
                          "                pm.environment.set(`offerItemId_${ptc}_${index}`, item.OfferItemID);",
                          "            }",
                          "        });",
                          "",
                          "        console.log('totalPrice:', totalAmount._);",
                          "        console.log('totalCurCode:', totalAmount.$.CurCode);",
                          "        console.log('offerId:', offer.OfferID);",
                          "        console.log('orderId:', response.Order.OrderID);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not parse OrderReshopRS:', e.message);",
                          "        console.log('Full parsed object:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n\n    <!-- Payload -->\n    <Payload>\n        <ns2:ExistingOrder>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>VS</ns2:OwnerCode>\n        </ns2:ExistingOrder>\n        <ns2:SelectedOffers>\n            <ns2:OfferRefID>{{reshopOfferId0}}</ns2:OfferRefID>\n            <ns2:OwnerCode>VS</ns2:OwnerCode>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_0}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_1}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_2}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_3}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_4}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n            <ns2:SelectedOfferItem>\n                <ns2:OfferItemRefID>{{reshopOfferItemId0_5}}</ns2:OfferItemRefID>\n                <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n            </ns2:SelectedOfferItem>\n        </ns2:SelectedOffers>\n    </Payload>\n\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "7. OrderChange [RT] [1ADT, 1CHD, 1INF] [Rebook] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "Content-Type",
                        "value": "application/xml"
                      },
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:ChangeOrderChoice>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{reshopOfferId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_3}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_4}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{reshopOfferItemId0_5}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:ChangeOrderChoice>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ]
        },
        {
          "name": "Manage booking - NameChange",
          "item": [
            {
              "name": "OW",
              "item": [
                {
                  "name": "1. OrderRetrieve by OrderId [1ADT,  1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const response = result.IATA_OrderViewRS.Response;",
                          "        const order = response.Order;",
                          "",
                          "        // --- existing: order / price / order items ---",
                          "        pm.environment.set('orderId', order.OrderID);",
                          "",
                          "        const totalAmount = order.TotalPrice.TotalAmount;",
                          "        pm.environment.set('totalPrice', totalAmount._ || totalAmount);",
                          "        pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "        let orderItems = order.OrderItem;",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "        orderItems.forEach((item, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "        });",
                          "",
                          "        // --- NEW: passenger names ---",
                          "        const dataLists = response.DataLists;",
                          "",
                          "        // Pax list (Bruce / Child / Baby in your sample)",
                          "        let paxList = dataLists.PaxList.Pax;",
                          "        if (!Array.isArray(paxList)) {",
                          "            paxList = [paxList];",
                          "        }",
                          "",
                          "        // Save every passenger (indexed)",
                          "        paxList.forEach((pax, index) => {",
                          "            const ind = pax.Individual;",
                          "            pm.environment.set(`paxId${index}`, pax.PaxID);",
                          "            pm.environment.set(`givenName${index}`, ind.GivenName);",
                          "            pm.environment.set(`surname${index}`, ind.Surname);",
                          "            pm.environment.set(`titleName${index}`, ind.TitleName);",
                          "            if (pax.PTC) pm.environment.set(`ptc${index}`, pax.PTC);",
                          "        });",
                          "",
                          "        // Primary passenger: first ADT, else first Pax",
                          "        const primaryPax = paxList.find(p => p.PTC === 'ADT') || paxList[0];",
                          "        const primary = primaryPax.Individual;",
                          "",
                          "        pm.environment.set('givenName', primary.GivenName);   // Bruce",
                          "        pm.environment.set('surname', primary.Surname);       // Wayne",
                          "        pm.environment.set('titleName', primary.TitleName);   // MR",
                          "        pm.environment.set('paxId', primaryPax.PaxID);        // PAX1",
                          "",
                          "        // Contact person (ContactInfoList — separate from Pax)",
                          "        const contact = dataLists.ContactInfoList?.ContactInfo?.Individual;",
                          "        if (contact) {",
                          "            pm.environment.set('contactGivenName', contact.GivenName); // Firstname",
                          "            pm.environment.set('contactSurname', contact.Surname);       // Surname",
                          "            pm.environment.set('contactTitleName', contact.TitleName);   // Mr",
                          "        }",
                          "",
                          "        console.log('Primary pax:', primary.GivenName, primary.Surname, primary.TitleName);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "let date = new Date();",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. OrderReshop Name Change on ADT",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xmlContent = pm.response.text();",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "function getAmountWithCurCode(node) {",
                          "    if (!node) {",
                          "        return { curCode: null, totalAmount: null };",
                          "    }",
                          "",
                          "    const curCode = node.$ && node.$.CurCode ? node.$.CurCode : null;",
                          "    const totalAmount = node._ !== undefined ? node._ : (typeof node === 'string' || typeof node === 'number' ? String(node) : null);",
                          "",
                          "    return { curCode, totalAmount };",
                          "}",
                          "",
                          "function asArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        let offers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                          "        offers = asArray(offers);",
                          "",
                          "        pm.test('OrderReshop has at least one Offer', () => {",
                          "            pm.expect(offers.length).to.be.above(0);",
                          "        });",
                          "",
                          "        offers.forEach((offer, offerIdx) => {",
                          "            const offerId = offer.OfferID;",
                          "            pm.environment.set(`reshopOfferId${offerIdx}`, offerId);",
                          "            console.log(`reshopOfferId${offerIdx}: ${offerId}`);",
                          "",
                          "            const offerTotal = getAmountWithCurCode(offer.TotalPrice && offer.TotalPrice.TotalAmount);",
                          "            pm.environment.set(`reshopOfferCurCode${offerIdx}`, offerTotal.curCode || '');",
                          "            pm.environment.set(`reshopOfferTotalAmount${offerIdx}`, offerTotal.totalAmount || '');",
                          "            console.log(`reshopOfferCurCode${offerIdx}: ${offerTotal.curCode}`);",
                          "            console.log(`reshopOfferTotalAmount${offerIdx}: ${offerTotal.totalAmount}`);",
                          "",
                          "            let addedItems = asArray(offer.AddedOfferItem);",
                          "",
                          "            addedItems.forEach((item, itemIdx) => {",
                          "                const itemId = item.OfferItemID;",
                          "                pm.environment.set(`reshopOfferItemId${offerIdx}_${itemIdx}`, itemId);",
                          "                console.log(`reshopOfferItem${offerIdx}_${itemIdx}: ${itemId}`);",
                          "",
                          "                const itemTotal = getAmountWithCurCode(",
                          "                    item.ReshopPrice &&",
                          "                    item.ReshopPrice.PriceDifferential &&",
                          "                    item.ReshopPrice.PriceDifferential.DiffPrice &&",
                          "                    item.ReshopPrice.PriceDifferential.DiffPrice.Price &&",
                          "                    item.ReshopPrice.PriceDifferential.DiffPrice.Price.TotalAmount",
                          "                );",
                          "",
                          "                pm.environment.set(`reshopOfferItemCurCode${offerIdx}_${itemIdx}`, itemTotal.curCode || '');",
                          "                pm.environment.set(`reshopOfferItemTotalAmount${offerIdx}_${itemIdx}`, itemTotal.totalAmount || '');",
                          "                console.log(`reshopOfferItemCurCode${offerIdx}_${itemIdx}: ${itemTotal.curCode}`);",
                          "                console.log(`reshopOfferItemTotalAmount${offerIdx}_${itemIdx}: ${itemTotal.totalAmount}`);",
                          "            });",
                          "",
                          "            pm.environment.set(`reshopOfferItemCount${offerIdx}`, String(addedItems.length));",
                          "        });",
                          "",
                          "        pm.environment.set('reshopOfferCount', String(offers.length));",
                          "",
                          "        // Convenience aliases for first offer/item",
                          "        pm.environment.set('reshopOfferId', pm.environment.get('reshopOfferId0'));",
                          "        pm.environment.set('reshopOfferItemId', pm.environment.get('reshopOfferItem0_0'));",
                          "        pm.environment.set('reshopOfferCurCode', pm.environment.get('reshopOfferCurCode0'));",
                          "        pm.environment.set('reshopOfferTotalAmount', pm.environment.get('reshopOfferTotalAmount0'));",
                          "        pm.environment.set('reshopOfferItemCurCode', pm.environment.get('reshopOfferItemCurCode0_0'));",
                          "        pm.environment.set('reshopOfferItemTotalAmount', pm.environment.get('reshopOfferItemTotalAmount0_0'));",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', JSON.stringify(result, null, 2));",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "let date = new Date();",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:ReshopOrder>\n                <ns2:ReshopOrderChoice>\n                    <ns2:UpdatePaxName>\n                        <ns2:GivenName>{{givenName0}}Update</ns2:GivenName>\n                        <ns2:PaxRefID>{{paxId0}}</ns2:PaxRefID>\n                        <ns2:Surname>{{surname0}}Update</ns2:Surname>\n                        <ns2:TitleName>{{titleName0}}</ns2:TitleName>\n                    </ns2:UpdatePaxName>\n                </ns2:ReshopOrderChoice>\n            </ns2:ReshopOrder>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderReshop"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. OrderReshop Name Change on INF",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xmlContent = pm.response.text();",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "function getAmountWithCurCode(node) {",
                          "    if (!node) {",
                          "        return { curCode: null, totalAmount: null };",
                          "    }",
                          "",
                          "    const curCode = node.$ && node.$.CurCode ? node.$.CurCode : null;",
                          "    const totalAmount = node._ !== undefined ? node._ : (typeof node === 'string' || typeof node === 'number' ? String(node) : null);",
                          "",
                          "    return { curCode, totalAmount };",
                          "}",
                          "",
                          "function asArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        let offers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                          "        offers = asArray(offers);",
                          "",
                          "        pm.test('OrderReshop has at least one Offer', () => {",
                          "            pm.expect(offers.length).to.be.above(0);",
                          "        });",
                          "",
                          "        offers.forEach((offer, offerIdx) => {",
                          "            const offerId = offer.OfferID;",
                          "            pm.environment.set(`reshopOfferId${offerIdx}`, offerId);",
                          "            console.log(`reshopOfferId${offerIdx}: ${offerId}`);",
                          "",
                          "            const offerTotal = getAmountWithCurCode(offer.TotalPrice && offer.TotalPrice.TotalAmount);",
                          "            pm.environment.set(`reshopOfferCurCode${offerIdx}`, offerTotal.curCode || '');",
                          "            pm.environment.set(`reshopOfferTotalAmount${offerIdx}`, offerTotal.totalAmount || '');",
                          "            console.log(`reshopOfferCurCode${offerIdx}: ${offerTotal.curCode}`);",
                          "            console.log(`reshopOfferTotalAmount${offerIdx}: ${offerTotal.totalAmount}`);",
                          "",
                          "            let addedItems = asArray(offer.AddedOfferItem);",
                          "",
                          "            addedItems.forEach((item, itemIdx) => {",
                          "                const itemId = item.OfferItemID;",
                          "                pm.environment.set(`reshopOfferItemId${offerIdx}_${itemIdx}`, itemId);",
                          "                console.log(`reshopOfferItem${offerIdx}_${itemIdx}: ${itemId}`);",
                          "",
                          "                const itemTotal = getAmountWithCurCode(",
                          "                    item.ReshopPrice &&",
                          "                    item.ReshopPrice.PriceDifferential &&",
                          "                    item.ReshopPrice.PriceDifferential.DiffPrice &&",
                          "                    item.ReshopPrice.PriceDifferential.DiffPrice.Price &&",
                          "                    item.ReshopPrice.PriceDifferential.DiffPrice.Price.TotalAmount",
                          "                );",
                          "",
                          "                pm.environment.set(`reshopOfferItemCurCode${offerIdx}_${itemIdx}`, itemTotal.curCode || '');",
                          "                pm.environment.set(`reshopOfferItemTotalAmount${offerIdx}_${itemIdx}`, itemTotal.totalAmount || '');",
                          "                console.log(`reshopOfferItemCurCode${offerIdx}_${itemIdx}: ${itemTotal.curCode}`);",
                          "                console.log(`reshopOfferItemTotalAmount${offerIdx}_${itemIdx}: ${itemTotal.totalAmount}`);",
                          "            });",
                          "",
                          "            pm.environment.set(`reshopOfferItemCount${offerIdx}`, String(addedItems.length));",
                          "        });",
                          "",
                          "        pm.environment.set('reshopOfferCount', String(offers.length));",
                          "",
                          "        // Convenience aliases for first offer/item",
                          "        pm.environment.set('reshopOfferId', pm.environment.get('reshopOfferId0'));",
                          "        pm.environment.set('reshopOfferItemId', pm.environment.get('reshopOfferItem0_0'));",
                          "        pm.environment.set('reshopOfferCurCode', pm.environment.get('reshopOfferCurCode0'));",
                          "        pm.environment.set('reshopOfferTotalAmount', pm.environment.get('reshopOfferTotalAmount0'));",
                          "        pm.environment.set('reshopOfferItemCurCode', pm.environment.get('reshopOfferItemCurCode0_0'));",
                          "        pm.environment.set('reshopOfferItemTotalAmount', pm.environment.get('reshopOfferItemTotalAmount0_0'));",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', JSON.stringify(result, null, 2));",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "let date = new Date();",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:ReshopOrder>\n                <ns2:ReshopOrderChoice>\n                    <ns2:UpdatePaxName>\n                        <ns2:GivenName>{{givenName0}}Inf</ns2:GivenName>\n                        <ns2:PaxRefID>{{paxId2}}</ns2:PaxRefID>\n                        <ns2:Surname>{{surname0}}Inf</ns2:Surname>\n                        <ns2:TitleName>{{titleName0}}</ns2:TitleName>\n                    </ns2:UpdatePaxName>\n                </ns2:ReshopOrderChoice>\n            </ns2:ReshopOrder>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderReshop"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderQuote [OW] [1ADT, 1CHD, 1INF] with ChangeName",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{reshopOfferId0}}</cns:OfferRefID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId0_0}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX1</cns:PaxRefID>\n                <cns:SelectedALaCarteOfferItem>\n                    <cns:Qty>1</cns:Qty>\n                </cns:SelectedALaCarteOfferItem>\n            </cns:SelectedOfferItem>\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4.1 OrderChange for NameChange [1ADT,  1CHD, 1INF] [Pay Later]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "const parseString = xml2js.parseString;",
                          "const stripPrefix = xml2js.processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        // --- OfferPriceRS ---",
                          "        if (result.IATA_OfferPriceRS) {",
                          "            const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                          "            const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "            pm.environment.set('offerId', pricedOffer.OfferID);",
                          "",
                          "            toArray(pricedOffer.OfferItem).forEach((item, index) => {",
                          "                pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                          "            });",
                          "",
                          "            console.log('OfferPriceRS → totalPrice:', totalAmount._);",
                          "            console.log('OfferPriceRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OfferPriceRS → offerId:', pricedOffer.OfferID);",
                          "        }",
                          "",
                          "        // --- OrderViewRS ---",
                          "        if (result.IATA_OrderViewRS) {",
                          "            const order = result.IATA_OrderViewRS.Response.Order;",
                          "            const totalAmount = order.TotalPrice.TotalAmount;",
                          "",
                          "            pm.environment.set('orderId', order.OrderID);",
                          "            pm.environment.set('totalPrice', totalAmount._);",
                          "            pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                          "",
                          "            const orderItems = toArray(order.OrderItem);",
                          "            orderItems.forEach((item, index) => {",
                          "                pm.environment.set(`orderItemId${index}`, item.OrderItemID);",
                          "            });",
                          "",
                          "            const bookingId = orderItems",
                          "                .map(item => {",
                          "                    return toArray(item.Service)",
                          "                        .map(s => s?.BookingRef?.BookingID)",
                          "                        .find(Boolean);",
                          "                })",
                          "                .find(Boolean);",
                          "",
                          "            if (bookingId) {",
                          "                pm.environment.set('bookingId', bookingId);",
                          "            }",
                          "",
                          "            console.log('OrderViewRS → orderId:', order.OrderID);",
                          "            console.log('OrderViewRS → totalPrice:', totalAmount._);",
                          "            console.log('OrderViewRS → totalCurCode:', totalAmount.$.CurCode);",
                          "            console.log('OrderViewRS → bookingId:', bookingId);",
                          "        }",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result);",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:ChangeOrderChoice>\n            <cns:AcceptSelectedQuotedOfferList>\n                <cns:SelectedPricedOffer>\n                    <cns:OfferRefID>{{reshopOfferId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{reshopOfferItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedPricedOffer>\n            </cns:AcceptSelectedQuotedOfferList>\n        </cns:ChangeOrderChoice>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4.2. OrderChange for NameChange [1ADT,  1CHD, 1INF] [Instant Pay CASH]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:ChangeOrderChoice>\n            <cns:AcceptSelectedQuotedOfferList>\n                <cns:SelectedPricedOffer>\n                    <cns:OfferRefID>{{reshopOfferId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{reshopOfferItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedPricedOffer>\n            </cns:AcceptSelectedQuotedOfferList>\n        </cns:ChangeOrderChoice>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n         <cns:PaymentFunctions>\n            <cns:PaymentProcessingDetails>\n                <cns:Amount CurCode=\"{{reshopOfferCurCode0}}\">{{reshopOfferTotalAmount0}}</cns:Amount>\n                <cns:PaymentMethod>\n                    <cns:OfflinePayment>\n                        <cns:PaymentTypeCode>CA</cns:PaymentTypeCode>\n                    </cns:OfflinePayment>\n                </cns:PaymentMethod>\n            </cns:PaymentProcessingDetails>\n        </cns:PaymentFunctions> \n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456790</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>W2</ns2:OwnerCode>\n        </ns2:Order>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{reshopOfferCurCode0}}\">{{reshopOfferTotalAmount0}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions> \n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "RT",
              "item": [
                {
                  "name": "1. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        // Always array",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((id, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                          "        });",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "let date = new Date();",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>2025-11-05T10:00:00Z</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "OrderReshop Name Change",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xmlContent = pm.response.text();",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        let offers = result.IATA_OrderReshopRS.Response.ReshopResults.ReshopOffers.Offer;",
                          "",
                          "        // Always array",
                          "        if (!Array.isArray(offers)) {",
                          "            offers = [offers];",
                          "        }",
                          "",
                          "        pm.test('OrderReshop has at least one Offer', () => {",
                          "            pm.expect(offers.length).to.be.above(0);",
                          "        });",
                          "",
                          "        offers.forEach((offer, offerIdx) => {",
                          "            const offerId = offer.OfferID;",
                          "            pm.environment.set(`reshopOfferId${offerIdx}`, offerId);",
                          "            console.log(`reshopOfferId${offerIdx}: ${offerId}`);",
                          "",
                          "            let addedItems = offer.AddedOfferItem;",
                          "",
                          "            // Always array",
                          "            if (!addedItems) {",
                          "                addedItems = [];",
                          "            } else if (!Array.isArray(addedItems)) {",
                          "                addedItems = [addedItems];",
                          "            }",
                          "",
                          "            // Uncomment if you also need DeletedOfferItem:",
                          "            // let deletedItems = offer.DeletedOfferItem;",
                          "            // if (deletedItems && !Array.isArray(deletedItems)) deletedItems = [deletedItems];",
                          "            // addedItems = [...addedItems, ...(deletedItems || [])];",
                          "",
                          "            addedItems.forEach((item, itemIdx) => {",
                          "                const itemId = item.OfferItemID;",
                          "                pm.environment.set(`reshopOfferItemId${offerIdx}_${itemIdx}`, itemId);",
                          "                console.log(`reshopOfferItem${offerIdx}_${itemIdx}: ${itemId}`);",
                          "            });",
                          "",
                          "            pm.environment.set(`reshopOfferItemCount${offerIdx}`, String(addedItems.length));",
                          "        });",
                          "",
                          "        pm.environment.set('reshopOfferCount', String(offers.length));",
                          "",
                          "        // Convenience aliases for first offer/item",
                          "        pm.environment.set('reshopOfferId', pm.environment.get('reshopOfferId0'));",
                          "        pm.environment.set('reshopOfferItemId', pm.environment.get('reshopOfferItem0_0'));",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', JSON.stringify(result, null, 2));",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "let date = new Date();",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderReshopRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:TrxID>{{today_th}}</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderRefID>{{orderId}}</ns2:OrderRefID>\n        <ns2:UpdateOrder>\n            <ns2:ReshopOrder>\n                <ns2:ReshopOrderChoice>\n                    <ns2:UpdatePaxName>\n                        <ns2:GivenName>testU</ns2:GivenName>\n                        <ns2:PaxRefID>1</ns2:PaxRefID>\n                        <ns2:Surname>TestU</ns2:Surname>\n                    </ns2:UpdatePaxName>\n                </ns2:ReshopOrderChoice>\n            </ns2:ReshopOrder>\n        </ns2:UpdateOrder>\n    </Request>\n</IATA_OrderReshopRQ>\n",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderReshop",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderReshop"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ]
        },
        {
          "name": "Ancillary Order - Seats",
          "item": [
            {
              "name": "OW",
              "item": [
                {
                  "name": "1. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: false\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n    console.log(result);\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;\n        pm.environment.set(`orderId`, orderId);\n\n        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;\n        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;\n\n        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;\n        // Always array\n        if (!Array.isArray(orderItems)) {\n            orderItems = [orderItems];\n        }\n\n        orderItems.forEach((id, index) => {\n            pm.environment.set(`orderItemId${index}`, id.OrderItemID);\n        });\n\n        console.log('TotalPrice: ' + totalPrice);\n        console.log('Currency Code:' + totalCurCode);\n        pm.environment.set(`totalPrice`, totalPrice);\n        pm.environment.set(`totalCurCode`, totalCurCode);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                        ]
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\npm.environment.set(\"today_th\", th);"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. SeatAvailability [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "const parseString = require(\"xml2js\").parseString;\nconst stripPrefix = require(\"xml2js\").processors.stripPrefix;\nconst xmlContent = pm.response.text();\n\n// Rows the airline does not open for seat selection. Override per environment with\n// `excludedSeatRows` (e.g. \"1,2,3,10\"); set it to \"\" to disable.\nconst DEFAULT_EXCLUDED_SEAT_ROWS = '1,2,3';\n\n// PADIS 9825 code 1 = \"Restricted seat - General\": the seat cannot be booked.\nconst RESTRICTED_SEAT_CHARACTERISTIC = '1';\n\n// Accepts either a PTC (ADT / CHD / INF) or a literal PaxID (PAX1, PAX2, ...). PTC is the safer\n// default: the adult is not always PAX1, and only DataLists/PaxList says which PaxID is the adult.\nconst DEFAULT_PAX_REF = 'ADT';\n\nfunction asArray(val) {\n    if (val == null) return [];\n    return Array.isArray(val) ? val : [val];\n}\n\nfunction textValue(node) {\n    if (node == null) return null;\n    if (typeof node === 'string') return node;\n    if (typeof node === 'object' && node._ != null) return node._;\n    return String(node);\n}\n\nfunction excludedSeatRows() {\n    const raw = pm.environment.get('excludedSeatRows');\n    const value = raw == null ? DEFAULT_EXCLUDED_SEAT_ROWS : String(raw);\n    return new Set(value.split(',').map(row => row.trim()).filter(Boolean));\n}\n\n// ALaCarteOffer is the only place that says which passenger an OfferItemID belongs to, and it is\n// also the list the gateway validates the request against (OrderQuoteValidator.getNotMatchRequestIds).\n// An id that is not in here comes back as IATA error 911 \"ReshopOffer items do not match\".\nfunction indexOfferItems(aLaCarteOffer) {\n    const byId = new Map();\n    asArray(aLaCarteOffer.OfferItem).forEach(item => {\n        if (!item.OfferItemID) return;\n        byId.set(String(item.OfferItemID), {\n            id: String(item.OfferItemID),\n            paxRefIds: asArray(item?.Eligibility?.PaxRefID).map(String),\n            price: textValue(item?.UnitPrice?.TotalAmount),\n            currency: item?.UnitPrice?.TotalAmount?.$?.CurCode || null\n        });\n    });\n    return byId;\n}\n\n// Every free seat carries one OfferItemRefID PER ELIGIBLE PASSENGER, in seat-map order — which is\n// NOT the pax order of the request. Taking OfferItemRefID[0] therefore books whichever passenger\n// happens to be listed first (PAX2 on this carrier) while the RQ still says PaxRefID PAX1.\n// Expand each seat into one candidate per offer item so the pax can actually drive the pick.\nfunction collectSeatCandidates(response, offerItemById) {\n    const candidates = [];\n\n    asArray(response.SeatMap).forEach((seatMap, mapIndex) => {\n        asArray(seatMap.CabinCompartment).forEach((cabin, cabinIndex) => {\n            const firstRow = Number(cabin.FirstRowNumber);\n            const lastRow = Number(cabin.LastRowNumber);\n            const hasCabinRange = !Number.isNaN(firstRow) && !Number.isNaN(lastRow);\n\n            asArray(cabin.SeatRow).forEach(seatRow => {\n                asArray(seatRow.Seat).forEach(seat => {\n                    if (seat.OccupationStatusCode !== 'F') return;\n                    if (!seat.ColumnID || !seat.RowNumber) return;\n\n                    const characteristics = asArray(seat.SeatCharacteristicCode).map(textValue);\n                    if (characteristics.includes(RESTRICTED_SEAT_CHARACTERISTIC)) return;\n\n                    const row = Number(seat.RowNumber);\n\n                    asArray(seat.OfferItemRefID).map(textValue).filter(Boolean).forEach(offerItemRefId => {\n                        const offerItem = offerItemById.get(offerItemRefId);\n                        // Drop refs the ALaCarteOffer does not carry — the gateway would reject them.\n                        if (!offerItem) return;\n\n                        candidates.push({\n                            mapIndex,\n                            cabinIndex,\n                            row: String(seat.RowNumber),\n                            column: String(seat.ColumnID),\n                            label: String(seat.RowNumber) + seat.ColumnID,\n                            offerItemRefId,\n                            paxRefIds: offerItem.paxRefIds,\n                            price: offerItem.price,\n                            currency: offerItem.currency,\n                            // The same physical seat repeats in every CabinCompartment with different\n                            // OfferItemRefIDs. Only the compartment whose declared row range covers the\n                            // row carries the ids that belong to that seat.\n                            inCabinRange: hasCabinRange ? row >= firstRow && row <= lastRow : true\n                        });\n                    });\n                });\n            });\n        });\n    });\n\n    return candidates;\n}\n\n// `seat_pax_ref` may be a PTC or a PaxID. Resolve it to the set of PaxIDs it covers so the pick\n// follows the passenger type rather than the order the seat map happens to list items in.\nfunction resolvePaxIds(response, targetPax) {\n    const wanted = String(targetPax).trim().toUpperCase();\n    const paxList = asArray(response?.DataLists?.PaxList?.Pax);\n\n    const byPaxId = paxList.filter(pax => String(pax.PaxID).trim().toUpperCase() === wanted);\n    if (byPaxId.length) {\n        return { paxIds: new Set(byPaxId.map(pax => String(pax.PaxID))), matchedBy: 'PaxID' };\n    }\n\n    const byPtc = paxList.filter(pax => String(pax.PTC).trim().toUpperCase() === wanted);\n    if (byPtc.length) {\n        return { paxIds: new Set(byPtc.map(pax => String(pax.PaxID))), matchedBy: 'PTC' };\n    }\n\n    // No PaxList (or an unknown token): fall back to matching the ref literally.\n    return { paxIds: new Set([wanted]), matchedBy: 'literal' };\n}\n\nfunction matchesPax(candidate, paxIds) {\n    return candidate.paxRefIds.some(pax => paxIds.has(String(pax).trim()));\n}\n\n// The same physical seat is repeated in every CabinCompartment with a different OfferItemRefID.\n// reshop-service binds the seat to the copy from the FIRST compartment block: picking the\n// row-range copy instead yields \"Selected seat 7/A doesn't belong to offer item ...\" on\n// reserve-seats, even though OrderQuote accepts it (OrderQuote only checks the id exists).\n// Set seatCabinBlock=range to prefer the compartment whose declared row range covers the row.\nfunction pickPreferred(candidates) {\n    if (!candidates.length) return null;\n    if (String(pm.environment.get(\"seatCabinBlock\") || \"first\").toLowerCase() === \"range\") {\n        return candidates.find(c => c.inCabinRange) || candidates[0];\n    }\n    return candidates.slice().sort((a, b) => a.cabinIndex - b.cabinIndex)[0];\n}\n\nparseString(xmlContent, {\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: false\n}, function (err, result) {\n    if (err) {\n        console.error(\"Error parsing XML:\", err);\n        pm.test(\"XML parsed successfully\", () => pm.expect.fail(err.message));\n        return;\n    }\n\n    try {\n        const response = result.IATA_SeatAvailabilityRS?.Response;\n        const aLaCarteOffer = response?.ALaCarteOffer;\n\n        if (!aLaCarteOffer?.OfferID) {\n            throw new Error(\"Missing ALaCarteOffer.OfferID\");\n        }\n\n        const offerItemById = indexOfferItems(aLaCarteOffer);\n        const offerItemIds = [...offerItemById.keys()];\n\n        if (!offerItemIds.length) {\n            throw new Error(\"No OfferItemID found in ALaCarteOffer\");\n        }\n\n        const allCandidates = collectSeatCandidates(response, offerItemById);\n        const skipRows = excludedSeatRows();\n        const selectable = allCandidates.filter(c => !skipRows.has(c.row));\n\n        // Pick by pax (default ADT). Accepts a PTC (ADT/CHD/INF) or a PaxID (PAX1, PAX2, ...).\n        // Pin an exact seat with targetSeatRow + targetSeatColumn.\n        const targetPax = pm.environment.get(\"seat_pax_ref\") || DEFAULT_PAX_REF;\n        const target = resolvePaxIds(response, targetPax);\n        const targetRow = pm.environment.get(\"targetSeatRow\");\n        const targetCol = pm.environment.get(\"targetSeatColumn\");\n        const targetSegmentIndex = Number(pm.environment.get(\"targetSegmentIndex\") || 0);\n\n        const inSegment = c => c.mapIndex === targetSegmentIndex;\n        const forTargetPax = c => matchesPax(c, target.paxIds);\n\n        let selected = null;\n\n        if (targetRow && targetCol) {\n            // Explicit target wins over excludedSeatRows so a closed row can still be tested on purpose.\n            const atTarget = allCandidates.filter(c =>\n                inSegment(c) &&\n                c.row === String(targetRow) &&\n                c.column.toUpperCase() === String(targetCol).toUpperCase());\n\n            selected = pickPreferred(atTarget.filter(forTargetPax));\n\n                pm.test(`seat ${targetRow}${targetCol} is bookable for ${targetPax}`, () => {\n                pm.expect(atTarget.length,\n                    `Seat ${targetRow}${targetCol} not free on segment ${targetSegmentIndex}`).to.be.above(0);\n                pm.expect(selected,\n                    `Seat ${targetRow}${targetCol} has no offer item for ${targetPax}`).to.exist;\n            });\n\n            if (selected && skipRows.has(selected.row)) {\n                console.warn(`targetSeatRow ${targetRow} is in excludedSeatRows — the airline may not open this row for booking`);\n            }\n        } else {\n            selected = pickPreferred(selectable.filter(c => inSegment(c) && forTargetPax(c)))\n                || pickPreferred(selectable.filter(forTargetPax));\n        }\n\n        if (!selected) {\n            const paxSeen = [...new Set(allCandidates.flatMap(c => c.paxRefIds))].join(',') || '(none)';\n            throw new Error(\n                `No selectable seat for ${targetPax} (resolved by ${target.matchedBy} to ` +\n                `[${[...target.paxIds].join(',')}]) — pax in this seat map: [${paxSeen}]. ` +\n                `Check seat_pax_ref / excludedSeatRows / targetSeatRow / targetSeatColumn`);\n        }\n\n        pm.test(\"OfferID is present\", () => {\n            pm.expect(aLaCarteOffer.OfferID).to.be.a(\"string\").and.not.empty;\n        });\n        pm.test(\"At least one OfferItemID\", () => {\n            pm.expect(offerItemIds.length).to.be.above(0);\n        });\n        pm.test(\"at least one seat outside the excluded rows\", () => {\n            pm.expect(selectable.length,\n                `All free seats are in excluded rows [${[...skipRows].join(',')}]`).to.be.above(0);\n        });\n        // Mirrors OrderQuoteValidator: a seat ref outside the ALaCarteOffer returns IATA 911.\n        pm.test(\"selected OfferItemRefID belongs to the ALaCarteOffer\", () => {\n            pm.expect(offerItemById.has(selected.offerItemRefId),\n                `${selected.offerItemRefId} is not an OfferItemID of offer ${aLaCarteOffer.OfferID}`).to.be.true;\n        });\n        pm.test(`selected seat belongs to ${targetPax}`, () => {\n            pm.expect(matchesPax(selected, target.paxIds),\n                `${selected.offerItemRefId} is for [${selected.paxRefIds.join(',')}], wanted ${targetPax} ` +\n                `(${[...target.paxIds].join(',')})`).to.be.true;\n        });\n\n        pm.environment.set(\"seatOfferID\", aLaCarteOffer.OfferID);\n        pm.environment.set(\"seatOfferItemId\", selected.offerItemRefId);\n        // Stamp which offer this item came from, so the OrderQuote/OrderChange pre-request can catch\n        // a seatOfferID left over from an earlier SeatAvailability run (IATA 911 \"items do not match\").\n        pm.environment.set(\"seatOfferItemOwner\", aLaCarteOffer.OfferID);\n        if (aLaCarteOffer.OfferExpirationTimeLimitDateTime) {\n            pm.environment.set(\"seatOfferExpiry\", textValue(aLaCarteOffer.OfferExpirationTimeLimitDateTime));\n        }\n        pm.environment.set(\"seatOfferItemIds\", JSON.stringify(offerItemIds));\n        // OrderQuote/OrderChange send ColumnID/SeatRowNumber from these, so they must come from the\n        // same Seat as seatOfferItemId — the gateway takes the seat from the request and the price\n        // from the item.\n        pm.environment.set(\"seatRow\", selected.row);\n        pm.environment.set(\"seatColumn\", selected.column);\n        pm.environment.set(\"seatLabel\", selected.label);\n        // Use {{seatPaxRefId}} in the RQ instead of a hardcoded PAX1.\n        pm.environment.set(\"seatPaxRefId\",\n            selected.paxRefIds.find(pax => target.paxIds.has(String(pax).trim())) || selected.paxRefIds[0]);\n\n        if (selected.price) {\n            pm.environment.set(\"seatPrice\", selected.price);\n        }\n        if (selected.currency) {\n            pm.environment.set(\"seatCurrency\", selected.currency);\n        }\n\n        console.log(\"OfferID          =\", aLaCarteOffer.OfferID,\n            \"(expires\", pm.environment.get(\"seatOfferExpiry\") || \"n/a\", \"UTC)\");\n        console.log(\"pax              =\", targetPax, \"→\", [...target.paxIds].join(',') , \"(by \" + target.matchedBy + \")\");\n        console.log(\"OfferItemId      =\", selected.offerItemRefId, \"(pax:\", selected.paxRefIds.join(',') + \")\");\n        console.log(\"seat             =\", selected.label, \"cabin#\" + selected.cabinIndex,\n            selected.inCabinRange ? \"\" : \"(row outside declared cabin range)\");\n        console.log(\"seatPrice        =\", selected.price, selected.currency);\n        console.log(\"excludedSeatRows =\", [...skipRows].join(',') || '(none)');\n        console.log(\"free seat refs   =\", allCandidates.length, \"→ selectable\", selectable.length,\n            \"→ for\", targetPax, selectable.filter(forTargetPax).length);\n        console.log(\"OfferItemIds     =\", offerItemIds.length);\n\n    } catch (e) {\n        console.error(e.message);\n        // Clear seat vars so stale values cannot leak into OrderQuote / OrderChange\n        [\"seatOfferID\", \"seatOfferItemId\", \"seatOfferItemIds\", \"seatRow\", \"seatColumn\", \"seatLabel\", \"seatPrice\", \"seatCurrency\", \"seatPaxRefId\", \"seatOfferItemOwner\", \"seatOfferExpiry\"]\n            .forEach(k => pm.environment.unset(k));\n        pm.test(\"SeatAvailability data extracted\", () => pm.expect.fail(e.message));\n    }\n});\n"
                        ]
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\npm.environment.set(\"today_th\", th);"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_SeatAvailabilityRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:SeatAvailCoreRequest>\n            <cns:OrderRequest>\n                <cns:Order>\n                    <cns:OrderID>{{orderId}}</cns:OrderID>\n                    <cns:OrderItem>\n                        <cns:OrderItemID>{{orderItemId0}}</cns:OrderItemID>\n                    </cns:OrderItem>\n                    <cns:OrderItem>\n                        <cns:OrderItemID>{{orderItemId1}}</cns:OrderItemID>\n                    </cns:OrderItem>\n                    <cns:OrderItem>\n                        <cns:OrderItemID>{{orderItemId2}}</cns:OrderItemID>\n                    </cns:OrderItem>\n                    <cns:OwnerCode>DX</cns:OwnerCode>\n                </cns:Order>\n            </cns:OrderRequest>\n        </cns:SeatAvailCoreRequest>\n    </Request>\n</IATA_SeatAvailabilityRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/SeatAvailability",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "SeatAvailability"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderQuote [OW] [1ADT, 1CHD, 1INF] with Seat",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "// Pre-request for OrderQuote (seat) and OrderChange (add seat).\n// The seat OfferRefID and OfferItemRefID must come from the SAME SeatAvailabilityRS run. Mixing a\n// stale seatOfferID with a fresh seatOfferItemId is what produces IATA 911:\n//   \"ReshopOffer items do not match for offerId: <offer>, not match list: [<item>]\"\nconst offerId = pm.environment.get(\"seatOfferID\");\nconst itemId = pm.environment.get(\"seatOfferItemId\");\nconst owner = pm.environment.get(\"seatOfferItemOwner\");\nconst expiry = pm.environment.get(\"seatOfferExpiry\");\n\nif (!offerId || !itemId) {\n    throw new Error(\"seatOfferID / seatOfferItemId not set — run SeatAvailability first\");\n}\nif (owner && owner !== offerId) {\n    throw new Error(\n        `Seat vars are from different SeatAvailability runs: item ${itemId} belongs to offer ${owner}, ` +\n        `but seatOfferID is ${offerId}. Re-run SeatAvailability, and make sure the request body uses ` +\n        `{{seatOfferID}} for OfferRefID.`);\n}\n// SeatAvailabilityRS stamps the expiry in UTC without a zone suffix.\nif (expiry) {\n    const expiresAt = new Date(expiry.endsWith(\"Z\") ? expiry : expiry + \"Z\");\n    if (!Number.isNaN(expiresAt.getTime()) && expiresAt <= new Date()) {\n        throw new Error(`Seat offer ${offerId} expired at ${expiry}Z — re-run SeatAvailability`);\n    }\n}\nconsole.log(\"seat offer =\", offerId, \"| item =\", itemId, \"| pax =\", pm.environment.get(\"seatPaxRefId\"));\n"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{seatOfferID}}</cns:OfferRefID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{seatOfferItemId}}</cns:OfferItemRefID>\n                <cns:PaxRefID>{{seatPaxRefId}}</cns:PaxRefID>\n                <cns:SelectedSeat>\n                    <cns:ColumnID>{{seatColumn}}</cns:ColumnID>\n                    <cns:SeatRowNumber>{{seatRow}}</cns:SeatRowNumber>\n                </cns:SelectedSeat>\n            </cns:SelectedOfferItem>\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderChange [OW] [1ADT] [ADD SEAT]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: false\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n    console.log(result);\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;\n        pm.environment.set(`orderId`, orderId);\n\n        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;\n        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;\n\n        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;\n        // Always array\n        if (!Array.isArray(orderItems)) {\n            orderItems = [orderItems];\n        }\n\n        orderItems.forEach((id, index) => {\n            pm.environment.set(`orderItemId${index}`, id.OrderItemID);\n        });\n\n        console.log('TotalPrice: ' + totalPrice);\n        console.log('Currency Code:' + totalCurCode);\n        pm.environment.set(`totalPrice`, totalPrice);\n        pm.environment.set(`totalCurCode`, totalCurCode);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                        ]
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "exec": [
                          "// Pre-request for OrderQuote (seat) and OrderChange (add seat).\n// The seat OfferRefID and OfferItemRefID must come from the SAME SeatAvailabilityRS run. Mixing a\n// stale seatOfferID with a fresh seatOfferItemId is what produces IATA 911:\n//   \"ReshopOffer items do not match for offerId: <offer>, not match list: [<item>]\"\nconst offerId = pm.environment.get(\"seatOfferID\");\nconst itemId = pm.environment.get(\"seatOfferItemId\");\nconst owner = pm.environment.get(\"seatOfferItemOwner\");\nconst expiry = pm.environment.get(\"seatOfferExpiry\");\n\nif (!offerId || !itemId) {\n    throw new Error(\"seatOfferID / seatOfferItemId not set — run SeatAvailability first\");\n}\nif (owner && owner !== offerId) {\n    throw new Error(\n        `Seat vars are from different SeatAvailability runs: item ${itemId} belongs to offer ${owner}, ` +\n        `but seatOfferID is ${offerId}. Re-run SeatAvailability, and make sure the request body uses ` +\n        `{{seatOfferID}} for OfferRefID.`);\n}\n// SeatAvailabilityRS stamps the expiry in UTC without a zone suffix.\nif (expiry) {\n    const expiresAt = new Date(expiry.endsWith(\"Z\") ? expiry : expiry + \"Z\");\n    if (!Number.isNaN(expiresAt.getTime()) && expiresAt <= new Date()) {\n        throw new Error(`Seat offer ${offerId} expired at ${expiry}Z — re-run SeatAvailability`);\n    }\n}\nconsole.log(\"seat offer =\", offerId, \"| item =\", itemId, \"| pax =\", pm.environment.get(\"seatPaxRefId\"));\n"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:ChangeOrderChoice>\n            <cns:AcceptSelectedQuotedOfferList>\n                <cns:SelectedPricedOffer>\n                    <cns:OfferRefID>{{seatOfferID}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <!-- optional -->\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{seatOfferItemId}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>{{seatPaxRefId}}</cns:PaxRefID>\n                        <cns:SelectedSeat>\n                            <cns:ColumnID>{{seatColumn}}</cns:ColumnID>\n                            <cns:SeatRowNumber>{{seatRow}}</cns:SeatRowNumber>\n                        </cns:SelectedSeat>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedPricedOffer>\n            </cns:AcceptSelectedQuotedOfferList>\n        </cns:ChangeOrderChoice>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderChange [OW] [1ADT] [PAY]",
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n        <cns:PaymentFunctions>\n            <cns:PaymentProcessingDetails>\n                <cns:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</cns:Amount>\n                <cns:PaymentMethod>\n                    <cns:OfflinePayment>\n                        <cns:PaymentTypeCode>CA</cns:PaymentTypeCode>\n                    </cns:OfflinePayment>\n                </cns:PaymentMethod>\n            </cns:PaymentProcessingDetails>\n        </cns:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ]
        },
        {
          "name": "Ancillary Order - Services",
          "item": [
            {
              "name": "OW",
              "item": [
                {
                  "name": "1. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        // Always array",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((id, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                          "        });",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <!-- optional -->\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2.1. ServiceList For Order [OW] [1 ADT, 1 CHD, 1 INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xmlContent = pm.response.text();",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "function getText(node) {",
                          "    if (node == null) return null;",
                          "    if (typeof node === 'string') return node;",
                          "    if (typeof node === 'object' && node._ != null) return node._;",
                          "    return String(node);",
                          "}",
                          "",
                          "function getAmount(node) {",
                          "    if (!node) return { amount: null, curCode: null };",
                          "    return {",
                          "        amount: getText(node),",
                          "        curCode: node.$ ? node.$.CurCode : null",
                          "    };",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const rs = result.IATA_ServiceListRS;",
                          "        if (!rs || !rs.Response || !rs.Response.ALaCarteOffer) {",
                          "            throw new Error('IATA_ServiceListRS / ALaCarteOffer not found');",
                          "        }",
                          "",
                          "        const offer = rs.Response.ALaCarteOffer;",
                          "        const offerId = getText(offer.OfferID);",
                          "        const offerItems = toArray(offer.OfferItem);",
                          "",
                          "        // --- Offer ID ---",
                          "        pm.environment.set('reshopOfferId', offerId);",
                          "",
                          "        // --- Offer item IDs (indexed) ---",
                          "        offerItems.forEach((item, index) => {",
                          "            const offerItemId = getText(item.OfferItemID);",
                          "            const paxRefId = getText(item.Eligibility?.PaxRefID);",
                          "            const serviceDefRefId = getText(item.Service?.ServiceDefinitionRefID);",
                          "            const unitTotal = getAmount(item.UnitPrice?.TotalAmount);",
                          "",
                          "            pm.environment.set(`reshopOfferItemId0_${index}`, offerItemId);",
                          "            pm.environment.set(`reshopOfferItemId_${index}`, offerItemId);",
                          "",
                          "            if (paxRefId) {",
                          "                pm.environment.set(`reshopOfferItemId_${paxRefId}_${index}`, offerItemId);",
                          "            }",
                          "            if (paxRefId && serviceDefRefId) {",
                          "                pm.environment.set(`reshopOfferItemId_${paxRefId}_${serviceDefRefId}`, offerItemId);",
                          "            }",
                          "",
                          "            console.log(`[${index}] ${paxRefId} ${serviceDefRefId} -> ${offerItemId} (${unitTotal.amount} ${unitTotal.curCode})`);",
                          "        });",
                          "",
                          "        pm.environment.set('reshopOfferItemCount', String(offerItems.length));",
                          "",
                          "        // --- Total price from ALaCarteOffer.TotalPrice ---",
                          "        const totalAmount = offer.TotalPrice?.TotalAmount;",
                          "        const totalPrice = getText(totalAmount);",
                          "        const totalCurCode = totalAmount?.$?.CurCode;",
                          "",
                          "        pm.environment.set('totalPrice', totalPrice);",
                          "        pm.environment.set('totalCurCode', totalCurCode);",
                          "",
                          "        // --- Optional: pick ADT items for OrderQuote/OrderChange (first 2 by default) ---",
                          "        const adtItems = offerItems.filter(item =>",
                          "            getText(item.Eligibility?.PaxRefID) === 'ADT1'",
                          "        );",
                          "",
                          "        // Optional filter: set env \"targetServiceCode\" = \"XBAG\" (or comma-separated)",
                          "        const targetServiceCodes = (pm.environment.get('targetServiceCode') || '')",
                          "            .split(',')",
                          "            .map(s => s.trim())",
                          "            .filter(Boolean);",
                          "",
                          "        let selectedAdtItems = adtItems;",
                          "",
                          "        if (targetServiceCodes.length > 0) {",
                          "            const serviceDefs = toArray(rs.Response.DataLists?.ServiceDefinitionList?.ServiceDefinition);",
                          "            const sdById = {};",
                          "            serviceDefs.forEach(sd => {",
                          "                sdById[getText(sd.ServiceDefinitionID)] = getText(sd.ServiceCode);",
                          "            });",
                          "",
                          "            selectedAdtItems = adtItems.filter(item => {",
                          "                const sdId = getText(item.Service?.ServiceDefinitionRefID);",
                          "                const serviceCode = sdById[sdId];",
                          "                return targetServiceCodes.includes(serviceCode);",
                          "            });",
                          "        }",
                          "",
                          "        // Fallback: first 2 ADT items (matches your OrderQuote template)",
                          "        if (selectedAdtItems.length === 0) {",
                          "            selectedAdtItems = adtItems.slice(0, 2);",
                          "        } else {",
                          "            selectedAdtItems = selectedAdtItems.slice(0, 2);",
                          "        }",
                          "",
                          "        selectedAdtItems.forEach((item, i) => {",
                          "            pm.environment.set(`reshopOfferItemId0_${i}`, getText(item.OfferItemID));",
                          "        });",
                          "",
                          "        // Sum of selected items (use this for payment if not buying entire catalog)",
                          "        let selectedTotal = 0;",
                          "        let selectedCurCode = totalCurCode;",
                          "        selectedAdtItems.forEach(item => {",
                          "            const unit = getAmount(item.UnitPrice?.TotalAmount);",
                          "            selectedTotal += parseFloat(unit.amount || 0);",
                          "            if (unit.curCode) selectedCurCode = unit.curCode;",
                          "        });",
                          "",
                          "        pm.environment.set('selectedTotalPrice', String(selectedTotal));",
                          "        pm.environment.set('selectedTotalCurCode', selectedCurCode);",
                          "",
                          "        console.log('reshopOfferId0:', offerId);",
                          "        console.log('totalPrice:', totalPrice, totalCurCode);",
                          "        console.log('selectedTotalPrice:', selectedTotal, selectedCurCode);",
                          "        console.log('reshopOfferItemId0_0:', pm.environment.get('reshopOfferItemId0_0'));",
                          "        console.log('reshopOfferItemId0_1:', pm.environment.get('reshopOfferItemId0_1'));",
                          "",
                          "        pm.test('ServiceListRS parsed', () => {",
                          "            pm.expect(offerId).to.be.a('string').and.not.empty;",
                          "            pm.expect(offerItems.length).to.be.above(0);",
                          "            pm.expect(totalPrice).to.be.a('string').and.not.empty;",
                          "            pm.expect(totalCurCode).to.be.a('string').and.not.empty;",
                          "        });",
                          "",
                          "    } catch (e) {",
                          "        console.error('ServiceListRS extraction failed:', e);",
                          "        pm.test('ServiceListRS extraction failed', () => {",
                          "            throw e;",
                          "        });",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_ServiceListRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- Response Parameters -->\n        <cns:ResponseParameters>\n            <cns:CurParameter>\n                <cns:CurCode>USD</cns:CurCode>\n            </cns:CurParameter>\n            <cns:LangUsage>\n                <cns:LangCode>en</cns:LangCode>\n            </cns:LangUsage>\n        </cns:ResponseParameters>\n        <cns:ServiceListCoreRequest>\n            <cns:OrderRequest>\n                <cns:Order>\n                    <cns:OrderID>{{orderId}}</cns:OrderID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                </cns:Order>\n            </cns:OrderRequest>\n        </cns:ServiceListCoreRequest>\n    </Request>\n</IATA_ServiceListRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/ServiceList",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "ServiceList"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2.2. ServiceList For Order [OW] [1 ADT, 1 CHD, 1 INF] with OrderItemId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xmlContent = pm.response.text();",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "function getText(node) {",
                          "    if (node == null) return null;",
                          "    if (typeof node === 'string') return node;",
                          "    if (typeof node === 'object' && node._ != null) return node._;",
                          "    return String(node);",
                          "}",
                          "",
                          "function getAmount(node) {",
                          "    if (!node) return { amount: null, curCode: null };",
                          "    return {",
                          "        amount: getText(node),",
                          "        curCode: node.$ ? node.$.CurCode : null",
                          "    };",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const rs = result.IATA_ServiceListRS;",
                          "        if (!rs || !rs.Response || !rs.Response.ALaCarteOffer) {",
                          "            throw new Error('IATA_ServiceListRS / ALaCarteOffer not found');",
                          "        }",
                          "",
                          "        const offer = rs.Response.ALaCarteOffer;",
                          "        const offerId = getText(offer.OfferID);",
                          "        const offerItems = toArray(offer.OfferItem);",
                          "",
                          "        // --- Offer ID ---",
                          "        pm.environment.set('reshopOfferId', offerId);",
                          "",
                          "        // --- Offer item IDs (indexed) ---",
                          "        offerItems.forEach((item, index) => {",
                          "            const offerItemId = getText(item.OfferItemID);",
                          "            const paxRefId = getText(item.Eligibility?.PaxRefID);",
                          "            const serviceDefRefId = getText(item.Service?.ServiceDefinitionRefID);",
                          "            const unitTotal = getAmount(item.UnitPrice?.TotalAmount);",
                          "",
                          "            pm.environment.set(`reshopOfferItemId0_${index}`, offerItemId);",
                          "            pm.environment.set(`reshopOfferItemId_${index}`, offerItemId);",
                          "",
                          "            if (paxRefId) {",
                          "                pm.environment.set(`reshopOfferItemId_${paxRefId}_${index}`, offerItemId);",
                          "            }",
                          "            if (paxRefId && serviceDefRefId) {",
                          "                pm.environment.set(`reshopOfferItemId_${paxRefId}_${serviceDefRefId}`, offerItemId);",
                          "            }",
                          "",
                          "            console.log(`[${index}] ${paxRefId} ${serviceDefRefId} -> ${offerItemId} (${unitTotal.amount} ${unitTotal.curCode})`);",
                          "        });",
                          "",
                          "        pm.environment.set('reshopOfferItemCount', String(offerItems.length));",
                          "",
                          "        // --- Total price from ALaCarteOffer.TotalPrice ---",
                          "        const totalAmount = offer.TotalPrice?.TotalAmount;",
                          "        const totalPrice = getText(totalAmount);",
                          "        const totalCurCode = totalAmount?.$?.CurCode;",
                          "",
                          "        pm.environment.set('totalPrice', totalPrice);",
                          "        pm.environment.set('totalCurCode', totalCurCode);",
                          "",
                          "        // --- Optional: pick ADT items for OrderQuote/OrderChange (first 2 by default) ---",
                          "        const adtItems = offerItems.filter(item =>",
                          "            getText(item.Eligibility?.PaxRefID) === 'ADT1'",
                          "        );",
                          "",
                          "        // Optional filter: set env \"targetServiceCode\" = \"XBAG\" (or comma-separated)",
                          "        const targetServiceCodes = (pm.environment.get('targetServiceCode') || '')",
                          "            .split(',')",
                          "            .map(s => s.trim())",
                          "            .filter(Boolean);",
                          "",
                          "        let selectedAdtItems = adtItems;",
                          "",
                          "        if (targetServiceCodes.length > 0) {",
                          "            const serviceDefs = toArray(rs.Response.DataLists?.ServiceDefinitionList?.ServiceDefinition);",
                          "            const sdById = {};",
                          "            serviceDefs.forEach(sd => {",
                          "                sdById[getText(sd.ServiceDefinitionID)] = getText(sd.ServiceCode);",
                          "            });",
                          "",
                          "            selectedAdtItems = adtItems.filter(item => {",
                          "                const sdId = getText(item.Service?.ServiceDefinitionRefID);",
                          "                const serviceCode = sdById[sdId];",
                          "                return targetServiceCodes.includes(serviceCode);",
                          "            });",
                          "        }",
                          "",
                          "        // Fallback: first 2 ADT items (matches your OrderQuote template)",
                          "        if (selectedAdtItems.length === 0) {",
                          "            selectedAdtItems = adtItems.slice(0, 2);",
                          "        } else {",
                          "            selectedAdtItems = selectedAdtItems.slice(0, 2);",
                          "        }",
                          "",
                          "        selectedAdtItems.forEach((item, i) => {",
                          "            pm.environment.set(`reshopOfferItemId0_${i}`, getText(item.OfferItemID));",
                          "        });",
                          "",
                          "        // Sum of selected items (use this for payment if not buying entire catalog)",
                          "        let selectedTotal = 0;",
                          "        let selectedCurCode = totalCurCode;",
                          "        selectedAdtItems.forEach(item => {",
                          "            const unit = getAmount(item.UnitPrice?.TotalAmount);",
                          "            selectedTotal += parseFloat(unit.amount || 0);",
                          "            if (unit.curCode) selectedCurCode = unit.curCode;",
                          "        });",
                          "",
                          "        pm.environment.set('selectedTotalPrice', String(selectedTotal));",
                          "        pm.environment.set('selectedTotalCurCode', selectedCurCode);",
                          "",
                          "        console.log('reshopOfferId0:', offerId);",
                          "        console.log('totalPrice:', totalPrice, totalCurCode);",
                          "        console.log('selectedTotalPrice:', selectedTotal, selectedCurCode);",
                          "        console.log('reshopOfferItemId0_0:', pm.environment.get('reshopOfferItemId0_0'));",
                          "        console.log('reshopOfferItemId0_1:', pm.environment.get('reshopOfferItemId0_1'));",
                          "",
                          "        pm.test('ServiceListRS parsed', () => {",
                          "            pm.expect(offerId).to.be.a('string').and.not.empty;",
                          "            pm.expect(offerItems.length).to.be.above(0);",
                          "            pm.expect(totalPrice).to.be.a('string').and.not.empty;",
                          "            pm.expect(totalCurCode).to.be.a('string').and.not.empty;",
                          "        });",
                          "",
                          "    } catch (e) {",
                          "        console.error('ServiceListRS extraction failed:', e);",
                          "        pm.test('ServiceListRS extraction failed', () => {",
                          "            throw e;",
                          "        });",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_ServiceListRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- Response Parameters -->\n        <cns:ResponseParameters>\n            <cns:CurParameter>\n                <cns:CurCode>USD</cns:CurCode>\n            </cns:CurParameter>\n            <cns:LangUsage>\n                <cns:LangCode>en</cns:LangCode>\n            </cns:LangUsage>\n        </cns:ResponseParameters>\n        <cns:ServiceListCoreRequest>\n            <cns:OrderRequest>\n                <cns:Order>\n                    <cns:OrderID>{{orderId}}</cns:OrderID>\n                    <cns:OrderItem>\n                        <cns:OrderItemID>{{orderItemId0}}</cns:OrderItemID>\n                    </cns:OrderItem>\n                    <cns:OrderItem>\n                        <cns:OrderItemID>{{orderItemId1}}</cns:OrderItemID>\n                    </cns:OrderItem>\n                    <cns:OrderItem>\n                        <cns:OrderItemID>{{orderItemId2}}</cns:OrderItemID>\n                    </cns:OrderItem>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                </cns:Order>\n            </cns:OrderRequest>\n        </cns:ServiceListCoreRequest>\n    </Request>\n</IATA_ServiceListRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/ServiceList",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "ServiceList"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderQuote [OW] [1ADT, 1CHD, 1INF] with Service",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{reshopOfferId}}</cns:OfferRefID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId_0}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX1</cns:PaxRefID>\n                <cns:SelectedALaCarteOfferItem>\n                    <cns:Qty>1</cns:Qty>\n                </cns:SelectedALaCarteOfferItem>\n            </cns:SelectedOfferItem>\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderChange for ServiceList [OW] [1 ADT, 1 CHD, 1 INF] [ADD SERVICE]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        // Always array",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((id, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                          "        });",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:ChangeOrderChoice>\n            <cns:AcceptSelectedQuotedOfferList>\n                <cns:SelectedPricedOffer>\n                    <cns:OfferRefID>{{reshopOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <!-- optional -->\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{reshopOfferItemId_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                        <cns:SelectedALaCarteOfferItem>\n                            <cns:Qty>1</cns:Qty>\n                        </cns:SelectedALaCarteOfferItem>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedPricedOffer>\n            </cns:AcceptSelectedQuotedOfferList>\n        </cns:ChangeOrderChoice>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderChange for ServiceList [OW] [1 ADT, 1 CHD, 1 INF] [PAY]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n        <cns:PaymentFunctions>\n            <cns:PaymentProcessingDetails>\n                <cns:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</cns:Amount>\n                <cns:PaymentMethod>\n                    <cns:OfflinePayment>\n                        <cns:PaymentTypeCode>CA</cns:PaymentTypeCode>\n                    </cns:OfflinePayment>\n                </cns:PaymentMethod>\n            </cns:PaymentProcessingDetails>\n        </cns:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "RT",
              "item": [
                {
                  "name": "1. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const xmlContent = pm.response.text();",
                          "",
                          "// Require the necessary xml2js components",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "parseString(xmlContent, {",
                          "    // Optional configuration for cleaner access",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "    console.log(result);",
                          "",
                          "    // Now 'result' is your fully parsed JavaScript object.",
                          "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                          "    try {",
                          "        // Navigate to Offer list",
                          "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                          "        pm.environment.set(`orderId`, orderId);",
                          "",
                          "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                          "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                          "",
                          "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                          "        // Always array",
                          "        if (!Array.isArray(orderItems)) {",
                          "            orderItems = [orderItems];",
                          "        }",
                          "",
                          "        orderItems.forEach((id, index) => {",
                          "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                          "        });",
                          "",
                          "        console.log('TotalPrice: ' + totalPrice);",
                          "        console.log('Currency Code:' + totalCurCode);",
                          "        pm.environment.set(`totalPrice`, totalPrice);",
                          "        pm.environment.set(`totalCurCode`, totalCurCode);",
                          "",
                          "    } catch (e) {",
                          "        console.error('Could not find the expected path in the XML structure:', e.message);",
                          "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                          "    }",
                          "});",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <!-- optional -->\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>VS</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. ServiceList For Order [RT] [1 ADT, 1 CHD, 1 INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const xmlContent = pm.response.text();",
                          "const parseString = require('xml2js').parseString;",
                          "const stripPrefix = require('xml2js').processors.stripPrefix;",
                          "",
                          "function toArray(value) {",
                          "    if (!value) return [];",
                          "    return Array.isArray(value) ? value : [value];",
                          "}",
                          "",
                          "function getText(node) {",
                          "    if (node == null) return null;",
                          "    if (typeof node === 'string') return node;",
                          "    if (typeof node === 'object' && node._ != null) return node._;",
                          "    return String(node);",
                          "}",
                          "",
                          "function getAmount(node) {",
                          "    if (!node) return { amount: null, curCode: null };",
                          "    return {",
                          "        amount: getText(node),",
                          "        curCode: node.$ ? node.$.CurCode : null",
                          "    };",
                          "}",
                          "",
                          "parseString(xmlContent, {",
                          "    tagNameProcessors: [stripPrefix],",
                          "    explicitArray: false,",
                          "    ignoreAttrs: false",
                          "}, function (err, result) {",
                          "    if (err) {",
                          "        console.error('Error parsing XML:', err);",
                          "        return;",
                          "    }",
                          "",
                          "    try {",
                          "        const rs = result.IATA_ServiceListRS;",
                          "        if (!rs || !rs.Response || !rs.Response.ALaCarteOffer) {",
                          "            throw new Error('IATA_ServiceListRS / ALaCarteOffer not found');",
                          "        }",
                          "",
                          "        const offer = rs.Response.ALaCarteOffer;",
                          "        const offerId = getText(offer.OfferID);",
                          "        const offerItems = toArray(offer.OfferItem);",
                          "",
                          "        // --- Offer ID ---",
                          "        pm.environment.set('reshopOfferId', offerId);",
                          "",
                          "        // --- Offer item IDs (indexed) ---",
                          "        offerItems.forEach((item, index) => {",
                          "            const offerItemId = getText(item.OfferItemID);",
                          "            const paxRefId = getText(item.Eligibility?.PaxRefID);",
                          "            const serviceDefRefId = getText(item.Service?.ServiceDefinitionRefID);",
                          "            const unitTotal = getAmount(item.UnitPrice?.TotalAmount);",
                          "",
                          "            pm.environment.set(`reshopOfferItemId0_${index}`, offerItemId);",
                          "            pm.environment.set(`reshopOfferItemId_${index}`, offerItemId);",
                          "",
                          "            if (paxRefId) {",
                          "                pm.environment.set(`reshopOfferItemId_${paxRefId}_${index}`, offerItemId);",
                          "            }",
                          "            if (paxRefId && serviceDefRefId) {",
                          "                pm.environment.set(`reshopOfferItemId_${paxRefId}_${serviceDefRefId}`, offerItemId);",
                          "            }",
                          "",
                          "            console.log(`[${index}] ${paxRefId} ${serviceDefRefId} -> ${offerItemId} (${unitTotal.amount} ${unitTotal.curCode})`);",
                          "        });",
                          "",
                          "        pm.environment.set('reshopOfferItemCount', String(offerItems.length));",
                          "",
                          "        // --- Total price from ALaCarteOffer.TotalPrice ---",
                          "        const totalAmount = offer.TotalPrice?.TotalAmount;",
                          "        const totalPrice = getText(totalAmount);",
                          "        const totalCurCode = totalAmount?.$?.CurCode;",
                          "",
                          "        pm.environment.set('totalPrice', totalPrice);",
                          "        pm.environment.set('totalCurCode', totalCurCode);",
                          "",
                          "        // --- Optional: pick ADT items for OrderQuote/OrderChange (first 2 by default) ---",
                          "        const adtItems = offerItems.filter(item =>",
                          "            getText(item.Eligibility?.PaxRefID) === 'ADT1'",
                          "        );",
                          "",
                          "        // Optional filter: set env \"targetServiceCode\" = \"XBAG\" (or comma-separated)",
                          "        const targetServiceCodes = (pm.environment.get('targetServiceCode') || '')",
                          "            .split(',')",
                          "            .map(s => s.trim())",
                          "            .filter(Boolean);",
                          "",
                          "        let selectedAdtItems = adtItems;",
                          "",
                          "        if (targetServiceCodes.length > 0) {",
                          "            const serviceDefs = toArray(rs.Response.DataLists?.ServiceDefinitionList?.ServiceDefinition);",
                          "            const sdById = {};",
                          "            serviceDefs.forEach(sd => {",
                          "                sdById[getText(sd.ServiceDefinitionID)] = getText(sd.ServiceCode);",
                          "            });",
                          "",
                          "            selectedAdtItems = adtItems.filter(item => {",
                          "                const sdId = getText(item.Service?.ServiceDefinitionRefID);",
                          "                const serviceCode = sdById[sdId];",
                          "                return targetServiceCodes.includes(serviceCode);",
                          "            });",
                          "        }",
                          "",
                          "        // Fallback: first 2 ADT items (matches your OrderQuote template)",
                          "        if (selectedAdtItems.length === 0) {",
                          "            selectedAdtItems = adtItems.slice(0, 2);",
                          "        } else {",
                          "            selectedAdtItems = selectedAdtItems.slice(0, 2);",
                          "        }",
                          "",
                          "        selectedAdtItems.forEach((item, i) => {",
                          "            pm.environment.set(`reshopOfferItemId0_${i}`, getText(item.OfferItemID));",
                          "        });",
                          "",
                          "        // Sum of selected items (use this for payment if not buying entire catalog)",
                          "        let selectedTotal = 0;",
                          "        let selectedCurCode = totalCurCode;",
                          "        selectedAdtItems.forEach(item => {",
                          "            const unit = getAmount(item.UnitPrice?.TotalAmount);",
                          "            selectedTotal += parseFloat(unit.amount || 0);",
                          "            if (unit.curCode) selectedCurCode = unit.curCode;",
                          "        });",
                          "",
                          "        pm.environment.set('selectedTotalPrice', String(selectedTotal));",
                          "        pm.environment.set('selectedTotalCurCode', selectedCurCode);",
                          "",
                          "        console.log('reshopOfferId0:', offerId);",
                          "        console.log('totalPrice:', totalPrice, totalCurCode);",
                          "        console.log('selectedTotalPrice:', selectedTotal, selectedCurCode);",
                          "        console.log('reshopOfferItemId0_0:', pm.environment.get('reshopOfferItemId0_0'));",
                          "        console.log('reshopOfferItemId0_1:', pm.environment.get('reshopOfferItemId0_1'));",
                          "",
                          "        pm.test('ServiceListRS parsed', () => {",
                          "            pm.expect(offerId).to.be.a('string').and.not.empty;",
                          "            pm.expect(offerItems.length).to.be.above(0);",
                          "            pm.expect(totalPrice).to.be.a('string').and.not.empty;",
                          "            pm.expect(totalCurCode).to.be.a('string').and.not.empty;",
                          "        });",
                          "",
                          "    } catch (e) {",
                          "        console.error('ServiceListRS extraction failed:', e);",
                          "        pm.test('ServiceListRS extraction failed', () => {",
                          "            throw e;",
                          "        });",
                          "    }",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_ServiceListRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- Response Parameters -->\n        <cns:ResponseParameters>\n            <cns:CurParameter>\n                <cns:CurCode>USD</cns:CurCode>\n            </cns:CurParameter>\n            <cns:LangUsage>\n                <cns:LangCode>en</cns:LangCode>\n            </cns:LangUsage>\n        </cns:ResponseParameters>\n        <cns:ServiceListCoreRequest>\n            <cns:OrderRequest>\n                <cns:Order>\n                    <cns:OrderID>{{orderId}}</cns:OrderID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                </cns:Order>\n            </cns:OrderRequest>\n        </cns:ServiceListCoreRequest>\n    </Request>\n</IATA_ServiceListRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/ServiceList",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "ServiceList"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderQuote [RT] [1ADT, 1CHD, 1INF] with Service",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "date.setDate(date.getDate() + 10);",
                          "",
                          "let year = date.getFullYear();",
                          "let month = String(date.getMonth() + 1).padStart(2, '0');",
                          "let day = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let arrivalDate = `${year}-${month}-${day}`;",
                          "",
                          "date.setDate(date.getDate() + 1);",
                          "let yearD = date.getFullYear();",
                          "let monthD = String(date.getMonth() + 1).padStart(2, '0');",
                          "let dayD = String(date.getDate()).padStart(2, '0');",
                          "",
                          "let departureDate = `${yearD}-${monthD}-${dayD}`;",
                          "",
                          "pm.environment.set(\"arrivalDate\", arrivalDate);",
                          "pm.environment.set(\"departureDate\", departureDate);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload -->\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{reshopOfferId}}</cns:OfferRefID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{reshopOfferItemId_0}}</cns:OfferItemRefID>\n                <cns:PaxRefID>PAX1</cns:PaxRefID>\n                <cns:SelectedALaCarteOfferItem>\n                    <cns:Qty>1</cns:Qty>\n                </cns:SelectedALaCarteOfferItem>\n            </cns:SelectedOfferItem>\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderChange for ServiceList [RT] [1 ADT, 1 CHD, 1 INF] [Instant Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "function formatWithTimezone(date, tzOffsetMinutes) {",
                          "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                          "",
                          "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                          "    const abs = Math.abs(tzOffsetMinutes);",
                          "    const offsetHours = pad(Math.floor(abs / 60));",
                          "    const offsetMinutes = pad(abs % 60);",
                          "",
                          "    return (",
                          "        date.getFullYear() +",
                          "        \"-\" + pad(date.getMonth() + 1) +",
                          "        \"-\" + pad(date.getDate()) +",
                          "        \"T\" + pad(date.getHours()) +",
                          "        \":\" + pad(date.getMinutes()) +",
                          "        \":\" + pad(date.getSeconds()) +",
                          "        \".\" + pad(date.getMilliseconds(), 3) +",
                          "        sign + offsetHours + \":\" + offsetMinutes",
                          "    );",
                          "}",
                          "",
                          "let date = new Date();",
                          "",
                          "// Thailand timezone = +07:00 → 420 minutes",
                          "let th = formatWithTimezone(date, 420);",
                          "",
                          "pm.environment.set(\"today_th\", th);"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:ChangeOrderChoice>\n            <cns:AcceptSelectedQuotedOfferList>\n                <cns:SelectedPricedOffer>\n                    <cns:OfferRefID>{{reshopOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <!-- optional -->\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{reshopOfferItemId_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                        <cns:SelectedALaCarteOfferItem>\n                            <cns:Qty>1</cns:Qty>\n                        </cns:SelectedALaCarteOfferItem>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedPricedOffer>\n            </cns:AcceptSelectedQuotedOfferList>\n        </cns:ChangeOrderChoice>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n        <cns:PaymentFunctions>\n            <cns:PaymentProcessingDetails>\n                <cns:Amount CurCode=\"{{selectedTotalCurCode}}\">{{selectedTotalPrice}}</cns:Amount>\n                <cns:PaymentMethod>\n                    <cns:OfflinePayment>\n                        <cns:PaymentTypeCode>CA</cns:PaymentTypeCode>\n                    </cns:OfflinePayment>\n                </cns:PaymentMethod>\n            </cns:PaymentProcessingDetails>\n        </cns:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ]
        },
        {
          "name": "Ancillary Offer - Seats",
          "item": [
            {
              "name": "1. AirShopping [OW] [1 ADT, 1 CHD, 1 INF]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: true\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;\n\n        // Always array\n        if (!Array.isArray(offers)) {\n            offers = [offers];\n        }\n\n        let offerIds = [];\n        let offerItemsByOffer = []; // nested list\n\n        offers.forEach(offer => {\n\n            // Store ID\n            offerIds.push(offer.OfferID);\n\n            // Extract OfferItem list\n            let items = offer.OfferItem;\n            if (!Array.isArray(items)) {\n                items = [items];\n            }\n\n            // Extract OfferItemID for this offer\n            let itemIds = items.map(i => i.OfferItemID);\n\n            offerItemsByOffer.push(itemIds);\n        });\n\n        // Save to environment\n        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));\n        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));\n\n\n        offerIds.forEach((id, index) => {\n            pm.environment.set(`offerId${index}`, id);\n        });\n\n        for (let i = 0; i < offerItemsByOffer.length; i++) {\n            for (let j = 0; j < offerItemsByOffer[i].length; j++) {\n                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);\n                console.log(offerItemsByOffer[i][j]);\n            }\n        }\n\n        console.log(\"Offer IDs:\", offerIds);\n        console.log(\"Offer Items By Offer:\", offerItemsByOffer);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                    ]
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\npm.environment.set(\"today_th\", th);\n\ndate.setDate(date.getDate() + 6);\n\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nlet departureDate = `${year}-${month}-${day}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearD = date.getFullYear();\nlet monthD = String(date.getMonth() + 1).padStart(2, '0');\nlet dayD = String(date.getDate()).padStart(2, '0');\n\nlet arrivalDate = `${yearD}-${monthD}-${dayD}`;\n\ndate.setDate(date.getDate() + 5);\nlet yearND = date.getFullYear();\nlet monthND = String(date.getMonth() + 1).padStart(2, '0');\nlet dayND = String(date.getDate()).padStart(2, '0');\n\nlet nextDepartureDate = `${yearND}-${monthND}-${dayND}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearNA = date.getFullYear();\nlet monthNA = String(date.getMonth() + 1).padStart(2, '0');\nlet dayNA = String(date.getDate()).padStart(2, '0');\n\nlet nextArrivalDate = `${yearNA}-${monthNA}-${dayNA}`;\n\npm.environment.set(\"arrivalDate\", arrivalDate);\npm.environment.set(\"departureDate\", departureDate);\npm.environment.set(\"nextArrivalDate\", nextArrivalDate);\npm.environment.set(\"nextDepartureDate\", nextDepartureDate);"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>2025-11-05T10:00:00Z</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <!-- KRP to CPH -->\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        \n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n    \n</IATA_AirShoppingRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "AirShopping"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "2. SeatAvailability For Offer [OW] [1ADT, 1CHD, 1INF]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\nconst parseString = xml2js.parseString;\nconst stripPrefix = xml2js.processors.stripPrefix;\n\n// Rows the airline does not open for seat selection. SeatAvailabilityRS still returns them with\n// OccupationStatusCode=F, but the SMS seat map shows row 1-3 closed, so booking them fails later.\n// Override per environment with `excludedSeatRows` (e.g. \"1,2,3,10\"); set it to \"\" to disable.\nconst DEFAULT_EXCLUDED_SEAT_ROWS = '1,2,3';\n\n// PADIS 9825 code 1 = \"Restricted seat - General\": the seat cannot be booked.\nconst RESTRICTED_SEAT_CHARACTERISTIC = '1';\n\n// Passengers to seat, in order, one distinct seat each. Step 2 asks for a seat offer per flight\n// offer item, so every seat in the response carries one OfferItemRefID per requested passenger and\n// the right one is picked by Eligibility/PaxRefID. PAX3 (INF) is absent on purpose - no seat.\n// Override per environment with `targetPaxRefIds` (e.g. \"PAX1\").\nconst DEFAULT_TARGET_PAX_REF_IDS = 'PAX1,PAX2';\n\n// Wide enough to clear anything a previous run could have left behind.\nconst ALL_PAX_KEYS = ['PAX1', 'PAX2', 'PAX3', 'PAX4', 'PAX5', 'PAX6', 'PAX7', 'PAX8', 'PAX9'];\nconst PER_PAX_VARS = ['seatOfferItemId', 'seatRow', 'seatColumn', 'seatLabel', 'seatPrice', 'seatCurrency'];\nconst BASE_VARS = ['seatOfferId', 'seatOfferItemId', 'seatRow', 'seatColumn', 'seatLabel',\n    'seatPrice', 'seatCurrency', 'seatPaxRefId', 'seatTotalPrice', 'seatPaxRefIds'];\n\nfunction toArray(value) {\n    if (!value) return [];\n    return Array.isArray(value) ? value : [value];\n}\n\nfunction textValue(node) {\n    if (node == null) return null;\n    if (typeof node === 'string') return node;\n    if (typeof node === 'object' && node._ != null) return node._;\n    return String(node);\n}\n\nfunction csvValues(name, fallback) {\n    const raw = pm.environment.get(name);\n    const value = raw == null ? fallback : String(raw);\n    return value.split(',').map(entry => entry.trim()).filter(Boolean);\n}\n\nfunction excludedSeatRows() {\n    return new Set(csvValues('excludedSeatRows', DEFAULT_EXCLUDED_SEAT_ROWS));\n}\n\n// Clear every seat variable up front so a failed or narrower run cannot leak stale values into\n// OfferPrice / OrderCreate - those would be silently accepted and price the wrong seat.\nfunction clearSeatVars() {\n    BASE_VARS.forEach(key => pm.environment.unset(key));\n    ALL_PAX_KEYS.forEach(pax => PER_PAX_VARS.forEach(key => pm.environment.unset(key + '_' + pax)));\n}\n\nfunction collectBookableSeats(response) {\n    const seats = [];\n\n    toArray(response.SeatMap).forEach((seatMap, mapIndex) => {\n        toArray(seatMap.CabinCompartment).forEach((cabin, compartmentIndex) => {\n            toArray(cabin.SeatRow).forEach(seatRow => {\n                toArray(seatRow.Seat).forEach(seat => {\n                    const offerItemRefIds = toArray(seat.OfferItemRefID).map(textValue).filter(Boolean);\n                    const characteristics = toArray(seat.SeatCharacteristicCode).map(textValue);\n\n                    if (\n                        seat.OccupationStatusCode === 'F' &&\n                        seat.ColumnID &&\n                        seat.RowNumber &&\n                        offerItemRefIds.length &&\n                        !characteristics.includes(RESTRICTED_SEAT_CHARACTERISTIC)\n                    ) {\n                        seats.push({\n                            mapIndex,\n                            compartmentIndex,\n                            row: String(seat.RowNumber),\n                            column: String(seat.ColumnID),\n                            // One OfferItemRefID per requested passenger, in response order.\n                            offerItemRefIds,\n                            label: String(seat.RowNumber) + seat.ColumnID\n                        });\n                    }\n                });\n            });\n        });\n    });\n\n    return seats;\n}\n\n// Hub repeats the WHOLE seat list in every CabinCompartment, so each physical seat appears more than\n// once, each copy carrying a DIFFERENT OfferItemRefID - and only the first compartment's id is\n// bookable. reshop's ReserveSeatsHandler.validateSeat resolves the seat with findFirst() over the\n// flattened compartments and then asserts seat.getOfferItems().contains(item), so an id taken from a\n// later compartment always loses:\n//     \"Selected seat 4/A doesn't belong to offer item ...\" (422, surfaced to NDC as error 911)\n// Seats are collected in document order, so seats[0] is the first compartment's copy - the one that\n// matches what reshop will look at. The compartment's declared FirstRowNumber/LastRowNumber does NOT\n// predict which copy is valid, so it is deliberately ignored.\n// Evidence: local/test/11_gh-7652_ndc-seat-flow/00_result.md, local/test/07_MMB-flow/02/00_result.md\nfunction pickBookable(seats) {\n    return seats[0] || null;\n}\n\nfunction seatKey(seat) {\n    return seat.mapIndex + ':' + seat.label;\n}\n\nparseString(xmlContent, {\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: false\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        clearSeatVars();\n        return;\n    }\n\n    clearSeatVars();\n\n    try {\n        const response = result.IATA_SeatAvailabilityRS.Response;\n        const aLaCarteOffer = response.ALaCarteOffer;\n\n        pm.test('SeatAvailability HTTP 200', function () {\n            pm.response.to.have.status(200);\n        });\n\n        pm.test('ALaCarteOffer present', function () {\n            pm.expect(aLaCarteOffer, 'ALaCarteOffer missing').to.exist;\n            pm.expect(aLaCarteOffer.OfferID, 'OfferID missing').to.be.a('string').and.not.empty;\n        });\n\n        const seatOfferId = aLaCarteOffer.OfferID;\n        pm.environment.set('seatOfferId', seatOfferId);\n\n        // --- offer item -> eligible passengers ---\n        // The response carries one offer item per (passenger x seat), so there are hundreds of them.\n        // Only the ones referenced by the chosen seats matter; index them and look them up by ID.\n        const offerItems = toArray(aLaCarteOffer.OfferItem);\n        const offerItemById = {};\n        offerItems.forEach(item => {\n            offerItemById[item.OfferItemID] = item;\n        });\n\n        function paxRefsOf(offerItemId) {\n            const item = offerItemById[offerItemId];\n            if (!item) return [];\n            return toArray(item.Eligibility && item.Eligibility.PaxRefID).map(textValue).filter(Boolean).map(String);\n        }\n\n        // Older gateway builds omitted Eligibility. Without it a seat's OfferItemRefIDs can only be\n        // matched to passengers positionally - flagged loudly, because a wrong guess books the seat\n        // for the wrong passenger.\n        const hasEligibility = offerItems.some(item =>\n            toArray(item.Eligibility && item.Eligibility.PaxRefID).length > 0);\n        if (!hasEligibility) {\n            console.warn('No Eligibility/PaxRefID in ALaCarteOffer - falling back to positional OfferItemRefID matching');\n        }\n\n        function offerItemFor(seat, paxRefId, paxIndex) {\n            if (!hasEligibility) return seat.offerItemRefIds[paxIndex] || null;\n            return seat.offerItemRefIds.find(ref => paxRefsOf(ref).indexOf(paxRefId) !== -1) || null;\n        }\n\n        // --- collect the seats we are allowed to pick from ---\n        const bookableSeats = collectBookableSeats(response);\n        const skipRows = excludedSeatRows();\n        const selectableSeats = bookableSeats.filter(seat => !skipRows.has(seat.row));\n\n        pm.test('at least one bookable seat', function () {\n            pm.expect(bookableSeats.length, 'No free seats (OccupationStatusCode=F)').to.be.above(0);\n        });\n\n        pm.test('at least one seat outside the excluded rows', function () {\n            pm.expect(selectableSeats.length,\n                `All free seats are in excluded rows [${[...skipRows].join(',')}]`).to.be.above(0);\n        });\n\n        const targetPaxRefIds = csvValues('targetPaxRefIds', DEFAULT_TARGET_PAX_REF_IDS);\n        const targetRow = pm.environment.get('targetSeatRow');\n        const targetCol = pm.environment.get('targetSeatColumn');\n        const targetSegmentIndex = Number(pm.environment.get('targetSegmentIndex') || 0);\n\n        pm.test('at least as many selectable seats as passengers', function () {\n            pm.expect(selectableSeats.length,\n                `Need ${targetPaxRefIds.length} seats, only ${selectableSeats.length} selectable`)\n                .to.be.at.least(targetPaxRefIds.length);\n        });\n\n        // --- one distinct seat per passenger ---\n        const taken = new Set();\n        const selections = [];\n\n        targetPaxRefIds.forEach((paxRefId, paxIndex) => {\n            let selectedSeat = null;\n\n            // An explicit target pins the FIRST passenger's seat and wins over excludedSeatRows,\n            // so a closed row can still be tested on purpose. The rest are picked automatically.\n            if (paxIndex === 0 && targetRow && targetCol) {\n                selectedSeat = pickBookable(bookableSeats.filter(seat =>\n                    seat.mapIndex === targetSegmentIndex &&\n                    seat.row === String(targetRow) &&\n                    seat.column.toUpperCase() === String(targetCol).toUpperCase()\n                ));\n\n                if (selectedSeat && skipRows.has(selectedSeat.row)) {\n                    console.warn(`targetSeatRow ${targetRow} is in excludedSeatRows — the airline may not open this row for booking`);\n                }\n\n                pm.test(`seat ${targetRow}${targetCol} is bookable`, function () {\n                    pm.expect(selectedSeat, `Seat ${targetRow}${targetCol} not free on segment ${targetSegmentIndex}`).to.exist;\n                });\n            }\n\n            if (!selectedSeat) {\n                const candidates = selectableSeats.filter(seat =>\n                    !taken.has(seatKey(seat)) && offerItemFor(seat, paxRefId, paxIndex));\n                selectedSeat = pickBookable(candidates.filter(seat => seat.mapIndex === targetSegmentIndex))\n                    || pickBookable(candidates);\n            }\n\n            const offerItemId = selectedSeat ? offerItemFor(selectedSeat, paxRefId, paxIndex) : null;\n\n            pm.test(`seat selected for ${paxRefId}`, function () {\n                pm.expect(selectedSeat, `No free seat left for ${paxRefId}`).to.exist;\n                pm.expect(offerItemId, `No seat offer item eligible for ${paxRefId}`).to.exist;\n            });\n\n            if (!selectedSeat || !offerItemId) return;\n\n            taken.add(seatKey(selectedSeat));\n            selections.push({ paxRefId, seat: selectedSeat, offerItemId });\n        });\n\n        if (selections.length !== targetPaxRefIds.length) {\n            throw new Error(`Seated ${selections.length}/${targetPaxRefIds.length} passengers — check excludedSeatRows / targetSeatRow / targetSeatColumn`);\n        }\n\n        // --- export one set of variables per passenger, plus the first passenger unsuffixed ---\n        // The unsuffixed names are what the single-seat requests in the other folders still read.\n        let seatTotal = 0;\n        selections.forEach((selection, index) => {\n            const suffix = '_' + selection.paxRefId;\n            const totalAmount = (offerItemById[selection.offerItemId] || {}).UnitPrice;\n            const amount = totalAmount && totalAmount.TotalAmount;\n\n            const values = {\n                seatOfferItemId: selection.offerItemId,\n                seatRow: selection.seat.row,\n                seatColumn: selection.seat.column,\n                seatLabel: selection.seat.label\n            };\n            if (amount) {\n                values.seatPrice = textValue(amount);\n                if (amount.$ && amount.$.CurCode) values.seatCurrency = amount.$.CurCode;\n                seatTotal += Number(textValue(amount)) || 0;\n            }\n\n            Object.keys(values).forEach(key => {\n                pm.environment.set(key + suffix, values[key]);\n                if (index === 0) pm.environment.set(key, values[key]);\n            });\n            if (index === 0) pm.environment.set('seatPaxRefId', selection.paxRefId);\n        });\n\n        pm.environment.set('seatPaxRefIds', selections.map(s => s.paxRefId).join(','));\n        pm.environment.set('seatTotalPrice', String(seatTotal));\n\n        console.log('seatOfferId    =', seatOfferId);\n        console.log('seatTotalPrice =', seatTotal, pm.environment.get('seatCurrency'));\n        selections.forEach(selection => console.log(\n            `  ${selection.paxRefId} -> seat ${selection.seat.label}`,\n            `(seg ${selection.seat.mapIndex}, compartment ${selection.seat.compartmentIndex})`,\n            `@ ${pm.environment.get('seatPrice_' + selection.paxRefId)}`,\n            `item ${selection.offerItemId}`));\n        console.log('excludedSeatRows =', [...skipRows].join(',') || '(none)');\n        console.log('free seats       =', bookableSeats.length, '→ selectable', selectableSeats.length);\n\n    } catch (e) {\n        console.error('Could not parse SeatAvailabilityRS:', e.message);\n        clearSeatVars();\n        console.log('Full parsed object:', JSON.stringify(result, null, 2));\n    }\n});\n"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_SeatAvailabilityRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>2025-11-05T10:00:00Z</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:SeatAvailCoreRequest xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n            <cns:OfferRequest>\n                <cns:Offer>\n                    <cns:OfferID>{{offerId0}}</cns:OfferID>\n                    <!-- One OfferItem per passenger that should get a seat offer.\n                         AirShopping returns the flight offer items in PaxList order, so\n                         offerItemId0_0 = PAX1 (ADT) and offerItemId0_1 = PAX2 (CHD).\n                         PAX3 (INF) is left out on purpose - an infant does not take a seat. -->\n                    <cns:OfferItem>\n                        <cns:OfferItemID>{{offerItemId0_0}}</cns:OfferItemID>\n                    </cns:OfferItem>\n                    <cns:OfferItem>\n                        <cns:OfferItemID>{{offerItemId0_1}}</cns:OfferItemID>\n                    </cns:OfferItem>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                </cns:Offer>\n            </cns:OfferRequest>\n        </cns:SeatAvailCoreRequest>\n    </Request>\n</IATA_SeatAvailabilityRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/SeatAvailability",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "SeatAvailability"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "3. AirOfferPrice OW [1 ADT, 1 CHD, 1 INF]",
              "event": [
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 → 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "const parseString = xml2js.parseString;",
                      "const stripPrefix = xml2js.processors.stripPrefix;",
                      "",
                      "function toArray(value) {",
                      "    if (!value) return [];",
                      "    return Array.isArray(value) ? value : [value];",
                      "}",
                      "",
                      "function textValue(node) {",
                      "    if (node == null) return null;",
                      "    return typeof node === 'object' ? node._ : node;",
                      "}",
                      "",
                      "parseString(xmlContent, {",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "",
                      "    try {",
                      "        const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                      "",
                      "        pm.test('OfferPrice HTTP 200', function () {",
                      "            pm.response.to.have.status(200);",
                      "        });",
                      "",
                      "        pm.test('PricedOffer present', function () {",
                      "            pm.expect(pricedOffer, 'PricedOffer missing').to.exist;",
                      "            pm.expect(pricedOffer.OfferID, 'OfferID missing').to.be.a('string').and.not.empty;",
                      "        });",
                      "",
                      "        pm.environment.set('offerId', pricedOffer.OfferID);",
                      "",
                      "        // The request prices the flight offer and the seat offer together, so this total already",
                      "        // includes every selected seat. Step 5 pays exactly this amount.",
                      "        const totalAmount = pricedOffer.TotalPrice?.TotalAmount;",
                      "",
                      "        pm.test('TotalPrice present', function () {",
                      "            pm.expect(totalAmount, 'TotalPrice/TotalAmount missing').to.exist;",
                      "        });",
                      "",
                      "        if (totalAmount) {",
                      "            pm.environment.set('totalPrice', textValue(totalAmount));",
                      "            pm.environment.set('totalCurCode', totalAmount.$?.CurCode);",
                      "        }",
                      "",
                      "        console.log('offerId      =', pricedOffer.OfferID);",
                      "        console.log('totalPrice   =', textValue(totalAmount), totalAmount?.$?.CurCode, '(flight + seat)');",
                      "        const seatedPaxRefIds = (pm.environment.get('seatPaxRefIds') || '').split(',').filter(Boolean);",
                      "        console.log('seatTotal    =', pm.environment.get('seatTotalPrice'), pm.environment.get('seatCurrency'),",
                      "            'over', seatedPaxRefIds.length, 'seat(s)');",
                      "        seatedPaxRefIds.forEach(paxRefId => console.log(",
                      "            `  ${paxRefId} -> seat`, pm.environment.get('seatLabel_' + paxRefId),",
                      "            '@', pm.environment.get('seatPrice_' + paxRefId)));",
                      "        toArray(pricedOffer.OfferItem).forEach((item, index) =>",
                      "            console.log(`offerItem${index} =`, item.OfferItemID)",
                      "        );",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not parse OfferPriceRS:', e.message);",
                      "        // Clear the payment vars so step 5 cannot pay a stale amount from a previous run",
                      "        ['totalPrice', 'totalCurCode'].forEach(k => pm.environment.unset(k));",
                      "        console.log('Full parsed object:', JSON.stringify(result, null, 2));",
                      "    }",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>2025-11-05T10:00:00Z</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n                <!-- Seat offer. One SelectedOfferItem per seated passenger, each with the\n                     OfferItemRefID that step 2 resolved from Eligibility/PaxRefID for that\n                     passenger - a seat carries one offer item per passenger and they are not\n                     interchangeable (the CHD seat is priced differently from the ADT one).\n                     PAX3 (INF) is not seated. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{seatOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{seatOfferItemId_PAX1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                        <cns:SelectedSeat>\n                            <cns:ColumnID>{{seatColumn_PAX1}}</cns:ColumnID>\n                            <cns:SeatRowNumber>{{seatRow_PAX1}}</cns:SeatRowNumber>\n                        </cns:SelectedSeat>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{seatOfferItemId_PAX2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                        <cns:SelectedSeat>\n                            <cns:ColumnID>{{seatColumn_PAX2}}</cns:ColumnID>\n                            <cns:SeatRowNumber>{{seatRow_PAX2}}</cns:SeatRowNumber>\n                        </cns:SelectedSeat>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OfferPrice"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay Later]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "// Require the necessary xml2js components",
                      "const parseString = require('xml2js').parseString;",
                      "const stripPrefix = require('xml2js').processors.stripPrefix;",
                      "",
                      "parseString(xmlContent, {",
                      "    // Optional configuration for cleaner access",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "    console.log(result);",
                      "",
                      "    // Now 'result' is your fully parsed JavaScript object.",
                      "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                      "    try {",
                      "        // Navigate to Offer list",
                      "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                      "        pm.environment.set(`orderId`, orderId);",
                      "",
                      "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                      "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                      "",
                      "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                      "        ",
                      "        // Always array",
                      "        if (!Array.isArray(orderItems)) {",
                      "            orderItems = [orderItems];",
                      "        }",
                      "",
                      "        orderItems.forEach((id, index) => {",
                      "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                      "        });",
                      "",
                      "        console.log('TotalPrice: ' + totalPrice);",
                      "        console.log('Currency Code:' + totalCurCode);",
                      "        pm.environment.set(`totalPrice`, totalPrice);",
                      "        pm.environment.set(`totalCurCode`, totalCurCode);",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                      "    }",
                      "});",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 → 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n                <!-- Seat offer. Must select exactly the same seat offer items that step 3\n                     priced, or the order total will not match the amount OfferPrice quoted.\n                     Each passenger has their own OfferItemRefID for their own seat; PAX3 (INF)\n                     is not seated. -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{seatOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{seatOfferItemId_PAX1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                        <ns2:SelectedSeat>\n                            <ns2:ColumnID>{{seatColumn_PAX1}}</ns2:ColumnID>\n                            <ns2:SeatRowNumber>{{seatRow_PAX1}}</ns2:SeatRowNumber>\n                        </ns2:SelectedSeat>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{seatOfferItemId_PAX2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                        <ns2:SelectedSeat>\n                            <ns2:ColumnID>{{seatColumn_PAX2}}</ns2:ColumnID>\n                            <ns2:SeatRowNumber>{{seatRow_PAX2}}</ns2:SeatRowNumber>\n                        </ns2:SelectedSeat>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-02-02</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>1994-12-08</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2020-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4.1. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Instant Pay]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "// Require the necessary xml2js components",
                      "const parseString = require('xml2js').parseString;",
                      "const stripPrefix = require('xml2js').processors.stripPrefix;",
                      "",
                      "parseString(xmlContent, {",
                      "    // Optional configuration for cleaner access",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "    console.log(result);",
                      "",
                      "    // Now 'result' is your fully parsed JavaScript object.",
                      "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                      "    try {",
                      "        // Navigate to Offer list",
                      "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                      "        pm.environment.set(`orderId`, orderId);",
                      "",
                      "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                      "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                      "",
                      "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                      "        ",
                      "        // Always array",
                      "        if (!Array.isArray(orderItems)) {",
                      "            orderItems = [orderItems];",
                      "        }",
                      "",
                      "        orderItems.forEach((id, index) => {",
                      "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                      "        });",
                      "",
                      "        console.log('TotalPrice: ' + totalPrice);",
                      "        console.log('Currency Code:' + totalCurCode);",
                      "        pm.environment.set(`totalPrice`, totalPrice);",
                      "        pm.environment.set(`totalCurCode`, totalCurCode);",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                      "    }",
                      "});",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 → 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n                <!-- Seat offer. Must select exactly the same seat offer items that step 3\n                     priced, or the order total will not match the amount OfferPrice quoted.\n                     Each passenger has their own OfferItemRefID for their own seat; PAX3 (INF)\n                     is not seated. -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{seatOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{seatOfferItemId_PAX1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                        <ns2:SelectedSeat>\n                            <ns2:ColumnID>{{seatColumn_PAX1}}</ns2:ColumnID>\n                            <ns2:SeatRowNumber>{{seatRow_PAX1}}</ns2:SeatRowNumber>\n                        </ns2:SelectedSeat>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{seatOfferItemId_PAX2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX2</ns2:PaxRefID>\n                        <ns2:SelectedSeat>\n                            <ns2:ColumnID>{{seatColumn_PAX2}}</ns2:ColumnID>\n                            <ns2:SeatRowNumber>{{seatRow_PAX2}}</ns2:SeatRowNumber>\n                        </ns2:SelectedSeat>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-02-02</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>1994-12-08</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2020-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5. OrderChange [OW] [1ADT, 1CHD, 1INF] [PAY]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "const parseString = xml2js.parseString;",
                      "const stripPrefix = xml2js.processors.stripPrefix;",
                      "",
                      "function toArray(value) {",
                      "    if (!value) return [];",
                      "    return Array.isArray(value) ? value : [value];",
                      "}",
                      "",
                      "parseString(xmlContent, {",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "",
                      "    try {",
                      "        const order = result.IATA_OrderViewRS.Response.Order;",
                      "",
                      "        pm.test('OrderChange HTTP 200', function () {",
                      "            pm.response.to.have.status(200);",
                      "        });",
                      "",
                      "        pm.test('Order returned', function () {",
                      "            pm.expect(order, 'Order missing').to.exist;",
                      "            pm.expect(order.OrderID, 'OrderID missing').to.be.a('string').and.not.empty;",
                      "        });",
                      "",
                      "        pm.environment.set('orderId', order.OrderID);",
                      "",
                      "        const totalAmount = order.TotalPrice.TotalAmount;",
                      "        pm.environment.set('totalPrice', totalAmount._);",
                      "        pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                      "",
                      "        const orderItems = toArray(order.OrderItem);",
                      "        orderItems.forEach((item, index) => pm.environment.set(`orderItemId${index}`, item.OrderItemID));",
                      "",
                      "        // The amount paid came from OfferPrice, which priced the flight offer and the seat offer",
                      "        // together. If the order total differs, the seat did not make it onto the order.",
                      "        const paidAmount = pm.environment.get('paidAmount');",
                      "        if (paidAmount) {",
                      "            pm.test('order total matches the amount paid', function () {",
                      "                pm.expect(Number(totalAmount._),",
                      "                    `Paid ${paidAmount} but the order totals ${totalAmount._} — the seat price is likely missing from the order`)",
                      "                    .to.equal(Number(paidAmount));",
                      "            });",
                      "        }",
                      "",
                      "        console.log('orderId    =', order.OrderID);",
                      "        console.log('paidAmount =', paidAmount, pm.environment.get('totalCurCode'));",
                      "        console.log('orderTotal =', totalAmount._, totalAmount.$.CurCode);",
                      "        console.log('seat       =', pm.environment.get('seatLabel'), '@', pm.environment.get('seatPrice'));",
                      "        orderItems.forEach((item, index) => console.log(`orderItemId${index} =`, item.OrderItemID));",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not parse OrderViewRS:', e.message);",
                      "        console.log('Full parsed object:', JSON.stringify(result, null, 2));",
                      "    }",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 → 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "pm.environment.set(\"today_th\", th);",
                      "",
                      "// Snapshot what this request is about to pay — step 3 set it from OfferPriceRS (flight + seat).",
                      "// The test script compares it against the order total returned by OrderChange.",
                      "pm.environment.set(\"paidAmount\", pm.environment.get(\"totalPrice\"));"
                    ],
                    "type": "text/javascript",
                    "packages": {}
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n        <cns:PaymentFunctions>\n            <cns:PaymentProcessingDetails>\n                <cns:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</cns:Amount>\n                <cns:PaymentMethod>\n                    <cns:OfflinePayment>\n                        <cns:PaymentTypeCode>CA</cns:PaymentTypeCode>\n                    </cns:OfflinePayment>\n                </cns:PaymentMethod>\n            </cns:PaymentProcessingDetails>\n        </cns:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderChange"
                  ]
                }
              },
              "response": []
            }
          ]
        },
        {
          "name": "Ancillary Offer - Services",
          "item": [
            {
              "name": "1. AirShopping OW [1 ADT, 1 CHD, 1 INF]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "const xml2js = require('xml2js');\nconst xmlContent = pm.response.text();\n\n// Require the necessary xml2js components\nconst parseString = require('xml2js').parseString;\nconst stripPrefix = require('xml2js').processors.stripPrefix;\n\nparseString(xmlContent, {\n    // Optional configuration for cleaner access\n    tagNameProcessors: [stripPrefix],\n    explicitArray: false,\n    ignoreAttrs: true\n}, function (err, result) {\n    if (err) {\n        console.error('Error parsing XML:', err);\n        return;\n    }\n\n    // Now 'result' is your fully parsed JavaScript object.\n    // We wrap this in a try-catch block in case the path is missing in some responses.\n    try {\n        // Navigate to Offer list\n        let offers = result.IATA_AirShoppingRS.Response.OffersGroup.CarrierOffers.Offer;\n\n        // Always array\n        if (!Array.isArray(offers)) {\n            offers = [offers];\n        }\n\n        let offerIds = [];\n        let offerItemsByOffer = []; // nested list\n\n        offers.forEach(offer => {\n\n            // Store ID\n            offerIds.push(offer.OfferID);\n\n            // Extract OfferItem list\n            let items = offer.OfferItem;\n            if (!Array.isArray(items)) {\n                items = [items];\n            }\n\n            // Extract OfferItemID for this offer\n            let itemIds = items.map(i => i.OfferItemID);\n\n            offerItemsByOffer.push(itemIds);\n        });\n\n        // Save to environment\n        pm.environment.set(\"offerIds\", JSON.stringify(offerIds));\n        pm.environment.set(\"offerItemsByOffer\", JSON.stringify(offerItemsByOffer));\n\n\n        offerIds.forEach((id, index) => {\n            pm.environment.set(`offerId${index}`, id);\n        });\n\n        for (let i = 0; i < offerItemsByOffer.length; i++) {\n            for (let j = 0; j < offerItemsByOffer[i].length; j++) {\n                pm.environment.set(`offerItemId${i}_${j}`, offerItemsByOffer[i][j]);\n                console.log(offerItemsByOffer[i][j]);\n            }\n        }\n\n        console.log(\"Offer IDs:\", offerIds);\n        console.log(\"Offer Items By Offer:\", offerItemsByOffer);\n\n    } catch (e) {\n        console.error('Could not find the expected path in the XML structure:', e.message);\n        console.log('Full parsed object structure:', result); // Log the whole object to debug the path\n    }\n});\n"
                    ]
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {\n    const pad = (n, width = 2) => String(n).padStart(width, '0');\n\n    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";\n    const abs = Math.abs(tzOffsetMinutes);\n    const offsetHours = pad(Math.floor(abs / 60));\n    const offsetMinutes = pad(abs % 60);\n\n    return (\n        date.getFullYear() +\n        \"-\" + pad(date.getMonth() + 1) +\n        \"-\" + pad(date.getDate()) +\n        \"T\" + pad(date.getHours()) +\n        \":\" + pad(date.getMinutes()) +\n        \":\" + pad(date.getSeconds()) +\n        \".\" + pad(date.getMilliseconds(), 3) +\n        sign + offsetHours + \":\" + offsetMinutes\n    );\n}\n\nlet date = new Date();\n\n// Thailand timezone = +07:00 → 420 minutes\nlet th = formatWithTimezone(date, 420);\n\npm.environment.set(\"today_th\", th);\n\ndate.setDate(date.getDate() + 7);\n\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nlet departureDate = `${year}-${month}-${day}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearD = date.getFullYear();\nlet monthD = String(date.getMonth() + 1).padStart(2, '0');\nlet dayD = String(date.getDate()).padStart(2, '0');\n\nlet arrivalDate = `${yearD}-${monthD}-${dayD}`;\n\ndate.setDate(date.getDate() + 5);\nlet yearND = date.getFullYear();\nlet monthND = String(date.getMonth() + 1).padStart(2, '0');\nlet dayND = String(date.getDate()).padStart(2, '0');\n\nlet nextDepartureDate = `${yearND}-${monthND}-${dayND}`;\n\ndate.setDate(date.getDate() + 1);\nlet yearNA = date.getFullYear();\nlet monthNA = String(date.getMonth() + 1).padStart(2, '0');\nlet dayNA = String(date.getDate()).padStart(2, '0');\n\nlet nextArrivalDate = `${yearNA}-${monthNA}-${dayNA}`;\n\npm.environment.set(\"arrivalDate\", arrivalDate);\npm.environment.set(\"departureDate\", departureDate);\npm.environment.set(\"nextArrivalDate\", nextArrivalDate);\npm.environment.set(\"nextDepartureDate\", nextDepartureDate);"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    \n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    \n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n\n    <!-- Request -->\n    <Request>\n        <!-- Flight Request -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <!-- KRP to CPH -->\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        \n        <!-- Passenger List -->\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n    \n</IATA_AirShoppingRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "AirShopping"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "2. ServiceList For Offer [OW] [1ADT, 1CHD, 1INF]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const parseString = xml2js.parseString;",
                      "const stripPrefix = xml2js.processors.stripPrefix;",
                      "",
                      "function toArray(value) {",
                      "    if (value === undefined || value === null) return [];",
                      "    return Array.isArray(value) ? value : [value];",
                      "}",
                      "",
                      "function getText(node) {",
                      "    if (node === undefined || node === null) return null;",
                      "    if (typeof node === 'string' || typeof node === 'number') return String(node);",
                      "    return node._ !== undefined ? node._ : null;",
                      "}",
                      "",
                      "function getAmount(node) {",
                      "    if (!node) return { totalAmount: null, curCode: null };",
                      "    return { totalAmount: getText(node), curCode: node.$ ? node.$.CurCode : null };",
                      "}",
                      "",
                      "// Write to the collection scope, and keep any same-named Environment/Global variable in sync.",
                      "// An Environment variable outranks the collection value when {{key}} is resolved, so without",
                      "// this a stale Environment 'serviceOfferId' would shadow the value we compute here.",
                      "function persistVar(key, value) {",
                      "    const v = value === undefined || value === null ? '' : value;",
                      "    pm.collectionVariables.set(key, v);",
                      "    if (pm.environment && pm.environment.has && pm.environment.has(key)) {",
                      "        pm.environment.set(key, v);",
                      "    }",
                      "    if (pm.globals && pm.globals.has && pm.globals.has(key)) {",
                      "        pm.globals.set(key, v);",
                      "    }",
                      "}",
                      "",
                      "parseString(pm.response.text(), {",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing ServiceListRS:', err);",
                      "        return;",
                      "    }",
                      "",
                      "    try {",
                      "        const response = result.IATA_ServiceListRS && result.IATA_ServiceListRS.Response;",
                      "        const offers = toArray(response && response.ALaCarteOffer);",
                      "        if (offers.length === 0) {",
                      "            throw new Error('No ALaCarteOffer found in IATA_ServiceListRS');",
                      "        }",
                      "",
                      "        // ServiceDefinitionID -> ServiceCode, used to pick an offer item by 'service-code'",
                      "        const serviceDefinitions = toArray(response.DataLists && response.DataLists.ServiceDefinitionList && response.DataLists.ServiceDefinitionList.ServiceDefinition);",
                      "        const serviceCodeByDefinitionId = {};",
                      "        serviceDefinitions.forEach(def => {",
                      "            serviceCodeByDefinitionId[getText(def.ServiceDefinitionID)] = getText(def.ServiceCode);",
                      "        });",
                      "",
                      "        // Flatten every offer item, remembering the OfferID of the offer that CONTAINS it",
                      "        const flatItems = [];",
                      "        offers.forEach(offer => {",
                      "            const parentOfferId = getText(offer.OfferID);",
                      "            const offerTotal = getAmount(offer.TotalPrice && offer.TotalPrice.TotalAmount);",
                      "            toArray(offer.OfferItem).forEach(item => {",
                      "                flatItems.push({ parentOfferId, offerTotal, item });",
                      "            });",
                      "        });",
                      "",
                      "        if (flatItems.length === 0) {",
                      "            throw new Error('No OfferItem found in any ALaCarteOffer');",
                      "        }",
                      "",
                      "        const wantedServiceCode = pm.collectionVariables.get('service-code');",
                      "        let selectedIndex = 0;",
                      "        let selectedIndexFound = false;",
                      "",
                      "        flatItems.forEach((entry, index) => {",
                      "            const item = entry.item;",
                      "            const itemTotal = getAmount(item.UnitPrice && item.UnitPrice.TotalAmount);",
                      "            const serviceCode = item.Service && serviceCodeByDefinitionId[getText(item.Service.ServiceDefinitionRefID)];",
                      "",
                      "            pm.collectionVariables.set(`serviceOfferItemId${index}`, getText(item.OfferItemID));",
                      "            pm.collectionVariables.set(`serviceOfferItemTotalAmount${index}`, itemTotal.totalAmount || '');",
                      "            pm.collectionVariables.set(`serviceOfferItemCurCode${index}`, itemTotal.curCode || '');",
                      "",
                      "            console.log(`serviceOfferItemId${index}: ${getText(item.OfferItemID)} (${serviceCode}) offer=${entry.parentOfferId}`);",
                      "",
                      "            if (!selectedIndexFound && wantedServiceCode && serviceCode === wantedServiceCode) {",
                      "                selectedIndex = index;",
                      "                selectedIndexFound = true;",
                      "            }",
                      "        });",
                      "",
                      "        pm.collectionVariables.set('serviceOfferItemCount', String(flatItems.length));",
                      "",
                      "        if (wantedServiceCode && !selectedIndexFound) {",
                      "            console.warn(`service-code '${wantedServiceCode}' not found in ServiceList response; falling back to the first offer item`);",
                      "        }",
                      "",
                      "        // Selected item, and the offer that ACTUALLY contains it (matched by 'service-code', falls back to the first item)",
                      "        const selected = flatItems[selectedIndex];",
                      "        const selectedItemTotal = getAmount(selected.item.UnitPrice && selected.item.UnitPrice.TotalAmount);",
                      "",
                      "        persistVar('serviceOfferId', selected.parentOfferId);",
                      "        persistVar('serviceOfferTotalAmount', selected.offerTotal.totalAmount || '');",
                      "        persistVar('serviceOfferCurCode', selected.offerTotal.curCode || '');",
                      "",
                      "        persistVar('serviceOfferItemId', getText(selected.item.OfferItemID));",
                      "        persistVar('serviceOfferItemTotalAmount', selectedItemTotal.totalAmount || '');",
                      "        persistVar('serviceOfferItemCurCode', selectedItemTotal.curCode || '');",
                      "",
                      "        console.log(`Selected service item for code '${wantedServiceCode}': serviceOfferItemId=${getText(selected.item.OfferItemID)}, serviceOfferId=${selected.parentOfferId}`);",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not parse ServiceListRS:', e.message);",
                      "        // Clear these in every scope so stale values from a previous run cannot leak into OrderCreate",
                      "        ['serviceOfferId', 'serviceOfferItemId', 'serviceOfferTotalAmount', 'serviceOfferCurCode', 'serviceOfferItemTotalAmount', 'serviceOfferItemCurCode'].forEach(k => {",
                      "            pm.collectionVariables.unset(k);",
                      "            if (pm.environment && pm.environment.has && pm.environment.has(k)) pm.environment.unset(k);",
                      "            if (pm.globals && pm.globals.has && pm.globals.has(k)) pm.globals.unset(k);",
                      "        });",
                      "    }",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_ServiceListRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- Response Parameters -->\n        <cns:ResponseParameters>\n            <cns:CurParameter>\n                <cns:CurCode>USD</cns:CurCode>\n            </cns:CurParameter>\n            <cns:LangUsage>\n                <cns:LangCode>en</cns:LangCode>\n            </cns:LangUsage>\n        </cns:ResponseParameters>\n        <cns:ServiceListCoreRequest>\n            <cns:OfferRequest>\n                <cns:Offer>\n                    <cns:OfferID>{{offerId0}}</cns:OfferID>\n                    <cns:OfferItem>\n                        <cns:OfferItemID>{{offerItemId0_0}}</cns:OfferItemID>\n                    </cns:OfferItem>\n                    <cns:OfferItem>\n                        <cns:OfferItemID>{{offerItemId0_1}}</cns:OfferItemID>\n                    </cns:OfferItem>\n                    <cns:OfferItem>\n                        <cns:OfferItemID>{{offerItemId0_2}}</cns:OfferItemID>\n                    </cns:OfferItem>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                </cns:Offer>\n            </cns:OfferRequest>\n        </cns:ServiceListCoreRequest>\n    </Request>\n</IATA_ServiceListRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/ServiceList",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "ServiceList"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "3. AirOfferPrice [OW] [1 ADT, 1 CHD, 1 INF]",
              "event": [
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, '0');",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 → 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "const parseString = xml2js.parseString;",
                      "const stripPrefix = xml2js.processors.stripPrefix;",
                      "",
                      "function toArray(value) {",
                      "    if (!value) return [];",
                      "    return Array.isArray(value) ? value : [value];",
                      "}",
                      "",
                      "parseString(xmlContent, {",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "",
                      "    try {",
                      "        const pricedOffer = result.IATA_OfferPriceRS.Response.PricedOffer;",
                      "        const totalAmount = pricedOffer.TotalPrice.TotalAmount;",
                      "",
                      "        // Total price",
                      "        pm.environment.set('totalPrice', totalAmount._);",
                      "        pm.environment.set('totalCurCode', totalAmount.$.CurCode);",
                      "",
                      "        // Offer ID",
                      "        pm.environment.set('offerId', pricedOffer.OfferID);",
                      "",
                      "        // Offer items (by index)",
                      "        const offerItems = toArray(pricedOffer.OfferItem);",
                      "        offerItems.forEach((item, index) => {",
                      "            pm.environment.set(`offerItemId${index}`, item.OfferItemID);",
                      "",
                      "            // Also by PTC: ADT / CHD / INF",
                      "            const paxRefId = item.FareDetail?.PaxRefID || item.Service?.PaxRefID;",
                      "            if (paxRefId) {",
                      "                const ptc = paxRefId.replace(/\\d+$/, ''); // ADT1 → ADT",
                      "                pm.environment.set(`offerItemId_${ptc}`, item.OfferItemID);",
                      "                pm.environment.set(`paxRefId_${ptc}`, paxRefId);",
                      "            }",
                      "        });",
                      "",
                      "        console.log('totalPrice:', totalAmount._);",
                      "        console.log('totalCurCode:', totalAmount.$.CurCode);",
                      "        console.log('offerId:', pricedOffer.OfferID);",
                      "        offerItems.forEach((item, i) => console.log(`offerItemId${i}:`, item.OfferItemID));",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not parse OfferPriceRS:', e.message);",
                      "        console.log('Full parsed object:', result);",
                      "    }",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" \n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <!-- optional -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <!-- PricedOffer -->\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId0}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_0}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_1}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX2</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{offerItemId0_2}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX3</cns:PaxRefID>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{serviceOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>VS</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{serviceOfferItemId}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>PAX1</cns:PaxRefID>\n                        <cns:SelectedALaCarteOfferItem>\n                            <cns:Qty>1</cns:Qty>\n                        </cns:SelectedALaCarteOfferItem>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OfferPrice"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4.1. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay Later] [Multiple Offer]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "// Require the necessary xml2js components",
                      "const parseString = require('xml2js').parseString;",
                      "const stripPrefix = require('xml2js').processors.stripPrefix;",
                      "",
                      "parseString(xmlContent, {",
                      "    // Optional configuration for cleaner access",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "    console.log(result);",
                      "",
                      "    // Now 'result' is your fully parsed JavaScript object.",
                      "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                      "    try {",
                      "        // Navigate to Offer list",
                      "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                      "        pm.environment.set(`orderId`, orderId);",
                      "",
                      "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                      "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                      "",
                      "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                      "        ",
                      "        // Always array",
                      "        if (!Array.isArray(orderItems)) {",
                      "            orderItems = [orderItems];",
                      "        }",
                      "",
                      "        orderItems.forEach((id, index) => {",
                      "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                      "        });",
                      "",
                      "        console.log('TotalPrice: ' + totalPrice);",
                      "        console.log('Currency Code:' + totalCurCode);",
                      "        pm.environment.set(`totalPrice`, totalPrice);",
                      "        pm.environment.set(`totalCurCode`, totalCurCode);",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                      "    }",
                      "});",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, \"0\");",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 -> 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{serviceOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <!-- optional -->\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{serviceOfferItemId}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                        <ns2:SelectedALaCarteOfferItem>\n                            <ns2:Qty>1</ns2:Qty>\n                        </ns2:SelectedALaCarteOfferItem>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-02-02</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>1994-12-08</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2020-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4.2. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay Later] [Single Offer]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "// Require the necessary xml2js components",
                      "const parseString = require('xml2js').parseString;",
                      "const stripPrefix = require('xml2js').processors.stripPrefix;",
                      "",
                      "parseString(xmlContent, {",
                      "    // Optional configuration for cleaner access",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "    console.log(result);",
                      "",
                      "    // Now 'result' is your fully parsed JavaScript object.",
                      "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                      "    try {",
                      "        // Navigate to Offer list",
                      "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                      "        pm.environment.set(`orderId`, orderId);",
                      "",
                      "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                      "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                      "",
                      "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                      "        ",
                      "        // Always array",
                      "        if (!Array.isArray(orderItems)) {",
                      "            orderItems = [orderItems];",
                      "        }",
                      "",
                      "        orderItems.forEach((id, index) => {",
                      "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                      "        });",
                      "",
                      "        console.log('TotalPrice: ' + totalPrice);",
                      "        console.log('Currency Code:' + totalCurCode);",
                      "        pm.environment.set(`totalPrice`, totalPrice);",
                      "        pm.environment.set(`totalCurCode`, totalCurCode);",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                      "    }",
                      "});",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, \"0\");",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 -> 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId3}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                        <ns2:SelectedALaCarteOfferItem>\n                            <ns2:Qty>1</ns2:Qty>\n                        </ns2:SelectedALaCarteOfferItem>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-02-02</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>1994-12-08</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2020-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4.3. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay] [Multiple Offer]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "// Require the necessary xml2js components",
                      "const parseString = require('xml2js').parseString;",
                      "const stripPrefix = require('xml2js').processors.stripPrefix;",
                      "",
                      "parseString(xmlContent, {",
                      "    // Optional configuration for cleaner access",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "    console.log(result);",
                      "",
                      "    // Now 'result' is your fully parsed JavaScript object.",
                      "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                      "    try {",
                      "        // Navigate to Offer list",
                      "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                      "        pm.environment.set(`orderId`, orderId);",
                      "",
                      "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                      "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                      "",
                      "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                      "        ",
                      "        // Always array",
                      "        if (!Array.isArray(orderItems)) {",
                      "            orderItems = [orderItems];",
                      "        }",
                      "",
                      "        orderItems.forEach((id, index) => {",
                      "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                      "        });",
                      "",
                      "        console.log('TotalPrice: ' + totalPrice);",
                      "        console.log('Currency Code:' + totalCurCode);",
                      "        pm.environment.set(`totalPrice`, totalPrice);",
                      "        pm.environment.set(`totalCurCode`, totalCurCode);",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                      "    }",
                      "});",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, \"0\");",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 -> 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId0}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0_2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{serviceOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <!-- optional -->\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{serviceOfferItemId}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                        <ns2:SelectedALaCarteOfferItem>\n                            <ns2:Qty>1</ns2:Qty>\n                        </ns2:SelectedALaCarteOfferItem>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-02-02</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>1994-12-08</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2020-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4.4. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay] [Single Offer]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const xmlContent = pm.response.text();",
                      "",
                      "// Require the necessary xml2js components",
                      "const parseString = require('xml2js').parseString;",
                      "const stripPrefix = require('xml2js').processors.stripPrefix;",
                      "",
                      "parseString(xmlContent, {",
                      "    // Optional configuration for cleaner access",
                      "    tagNameProcessors: [stripPrefix],",
                      "    explicitArray: false,",
                      "    ignoreAttrs: false",
                      "}, function (err, result) {",
                      "    if (err) {",
                      "        console.error('Error parsing XML:', err);",
                      "        return;",
                      "    }",
                      "    console.log(result);",
                      "",
                      "    // Now 'result' is your fully parsed JavaScript object.",
                      "    // We wrap this in a try-catch block in case the path is missing in some responses.",
                      "    try {",
                      "        // Navigate to Offer list",
                      "        let orderId = result.IATA_OrderViewRS.Response.Order.OrderID;",
                      "        pm.environment.set(`orderId`, orderId);",
                      "",
                      "        let totalPrice = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount._;",
                      "        let totalCurCode = result.IATA_OrderViewRS.Response.Order.TotalPrice.TotalAmount.$.CurCode;",
                      "",
                      "        let orderItems = result.IATA_OrderViewRS.Response.Order.OrderItem;",
                      "        ",
                      "        // Always array",
                      "        if (!Array.isArray(orderItems)) {",
                      "            orderItems = [orderItems];",
                      "        }",
                      "",
                      "        orderItems.forEach((id, index) => {",
                      "            pm.environment.set(`orderItemId${index}`, id.OrderItemID);",
                      "        });",
                      "",
                      "        console.log('TotalPrice: ' + totalPrice);",
                      "        console.log('Currency Code:' + totalCurCode);",
                      "        pm.environment.set(`totalPrice`, totalPrice);",
                      "        pm.environment.set(`totalCurCode`, totalCurCode);",
                      "",
                      "    } catch (e) {",
                      "        console.error('Could not find the expected path in the XML structure:', e.message);",
                      "        console.log('Full parsed object structure:', result); // Log the whole object to debug the path",
                      "    }",
                      "});",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      "function formatWithTimezone(date, tzOffsetMinutes) {",
                      "    const pad = (n, width = 2) => String(n).padStart(width, \"0\");",
                      "",
                      "    const sign = tzOffsetMinutes >= 0 ? \"+\" : \"-\";",
                      "    const abs = Math.abs(tzOffsetMinutes);",
                      "    const offsetHours = pad(Math.floor(abs / 60));",
                      "    const offsetMinutes = pad(abs % 60);",
                      "",
                      "    return (",
                      "        date.getFullYear() +",
                      "        \"-\" + pad(date.getMonth() + 1) +",
                      "        \"-\" + pad(date.getDate()) +",
                      "        \"T\" + pad(date.getHours()) +",
                      "        \":\" + pad(date.getMinutes()) +",
                      "        \":\" + pad(date.getSeconds()) +",
                      "        \".\" + pad(date.getMilliseconds(), 3) +",
                      "        sign + offsetHours + \":\" + offsetMinutes",
                      "    );",
                      "}",
                      "",
                      "let date = new Date();",
                      "",
                      "// Thailand timezone = +07:00 -> 420 minutes",
                      "let th = formatWithTimezone(date, 420);",
                      "pm.environment.set(\"today_th\", th);"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>VS</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId0}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId1}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId2}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    </ns2:SelectedOfferItem>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{offerItemId3}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>PAX1</ns2:PaxRefID>\n                        <ns2:SelectedALaCarteOfferItem>\n                            <ns2:Qty>1</ns2:Qty>\n                        </ns2:SelectedALaCarteOfferItem>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>sample@a.com</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-02-02</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>1994-12-08</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2020-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>2029-08-13</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>2026-01-01</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>\n",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5. OrderChange [OW] [1ADT] [PAY]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <!-- Distribution Chain -->\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <!-- Payload Attributes -->\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <!-- Request -->\n    <Request>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>VS</cns:OwnerCode>\n        </cns:Order>\n        <cns:PaymentFunctions>\n            <cns:PaymentProcessingDetails>\n                <cns:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</cns:Amount>\n                <cns:PaymentMethod>\n                    <cns:OfflinePayment>\n                        <cns:PaymentTypeCode>CA</cns:PaymentTypeCode>\n                    </cns:OfflinePayment>\n                </cns:PaymentMethod>\n            </cns:PaymentProcessingDetails>\n        </cns:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderChange"
                  ]
                }
              },
              "response": []
            }
          ]
        }
      ]
    },
    {
      "name": "UseCase - VI",
      "item": [
        {
          "name": "Create & confirm on-hold booking",
          "item": [
            {
              "name": "OW - 1ADT, 1CHD, 1INF",
              "item": [
                {
                  "name": "1. AirShopping [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                          "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                          "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                          "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                        ]
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                          "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                          "// OrderCreate must select all of them.",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_AirShoppingRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                          "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                          "    if (!offers.length) return;",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "",
                          "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                          "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                          "    const items = toArray(offer.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        const comp = toArray(fare.FareComponent)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                          "        pm.expect(items.length).to.be.above(0);",
                          "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                          "    });",
                          "    pm.test('one offer item per passenger per leg', () => {",
                          "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                          "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                          "    });",
                          "",
                          "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                          "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                          "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                          "    pm.environment.set('offerId', text(offer.OfferID));",
                          "    pm.environment.set('offerOwnerCode', ownerCode);",
                          "    pm.environment.set('offerItemCount', String(items.length));",
                          "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                          "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                          "",
                          "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                          "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                          "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                          "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                          "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                          "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                          "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                          "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                          "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                          "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                          "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                          "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                          "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                          "",
                          "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                          "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0);",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OfferPriceRS || {};",
                          "    const priced = rs.Response && rs.Response.PricedOffer;",
                          "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                          "    if (!priced) return;",
                          "",
                          "    const items = toArray(priced.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                          "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                          "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "",
                          "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                          "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                          "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                          "",
                          "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                          "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay Later]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = true;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The priced offer from OfferPrice, with every priced item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{pricedSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderQuote [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// The gateway answers OrderQuote with IATA_OrderReshopRS: the order as it stands plus ReshopResults.",
                          "const EXPECT_ADDED_ITEM = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderReshopRS || result.IATA_OrderQuoteRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('quoted order returned', () => { pm.expect(order, 'no Order in the response').to.exist; pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')); });",
                          "    const results = resp.ReshopResults || {};",
                          "    if (EXPECT_ADDED_ITEM) {",
                          "        const added = toArray(results.ReshopOffers).flatMap(r => toArray(r.RequotedOffer)).flatMap(r => toArray(r.AddedOfferItem));",
                          "        pm.test('quote contains the added offer item', () => { pm.expect(added.length, 'no RequotedOffer/AddedOfferItem').to.be.above(0); added.forEach(a => pm.expect(text(a.OfferItemID)).to.be.a('string').and.not.empty); });",
                          "        added.forEach(a => { const diff = a.ReshopPrice && a.ReshopPrice.PriceDifferential && a.ReshopPrice.PriceDifferential.DiffPrice && a.ReshopPrice.PriceDifferential.DiffPrice.Price && a.ReshopPrice.PriceDifferential.DiffPrice.Price.TotalAmount; console.log('added item', text(a.OfferItemID), text(a.PaxRefID || (a.FareDetail && a.FareDetail.PaxRefID)), 'to pay', text(diff), curOf(diff)); });",
                          "    } else {",
                          "        const noChange = results.NoChangeInd && (text(results.NoChangeInd.NoChangeInd) || text(results.NoChangeInd));",
                          "        pm.test('no change on the quoted order (NoChangeInd)', () => pm.expect(String(noChange), 'ReshopResults/NoChangeInd').to.equal('true'));",
                          "    }",
                          "    if (order) console.log('quoted order', text(order.OrderID), '| status', text(order.StatusCode), '| total', text(order.TotalPrice && order.TotalPrice.TotalAmount), curOf(order.TotalPrice && order.TotalPrice.TotalAmount));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n        </cns:ExistingOrder>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = true;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n        </ns2:Order>\n        <!-- Pays the pending purchase: {{paymentAmount}} is the order total that the OrderCreate [Pay Later] /\n             OrderChange [ADD ...] response returned, and is cleared once paid (a second [Pay] is not sent).\n             Cash (CA) is the payment method supported on VI. Debit account is not supported on VI and a card\n             payment needs a PCI-Proxy token (see Order Change -> payment in the partner guide). -->\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{paymentCurCode}}\">{{paymentAmount}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "RT - 1ADT, 1CHD, 1INF",
              "item": [
                {
                  "name": "1. AirShopping [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                          "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                          "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                          "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                        ]
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                          "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                          "// OrderCreate must select all of them.",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_AirShoppingRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                          "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                          "    if (!offers.length) return;",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "",
                          "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                          "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                          "    const items = toArray(offer.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        const comp = toArray(fare.FareComponent)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                          "        pm.expect(items.length).to.be.above(0);",
                          "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                          "    });",
                          "    pm.test('one offer item per passenger per leg', () => {",
                          "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                          "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                          "    });",
                          "",
                          "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                          "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                          "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                          "    pm.environment.set('offerId', text(offer.OfferID));",
                          "    pm.environment.set('offerOwnerCode', ownerCode);",
                          "    pm.environment.set('offerItemCount', String(items.length));",
                          "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                          "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                          "",
                          "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                          "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                          "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                          "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                          "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                          "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                          "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                          "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                          "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                          "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                          "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                          "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                          "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                          "",
                          "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                          "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{nextArrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{nextDepartureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0);",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OfferPriceRS || {};",
                          "    const priced = rs.Response && rs.Response.PricedOffer;",
                          "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                          "    if (!priced) return;",
                          "",
                          "    const items = toArray(priced.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                          "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                          "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "",
                          "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                          "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                          "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                          "",
                          "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                          "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [RT] [1ADT, 1CHD, 1INF] [Pay Later]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = true;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The priced offer from OfferPrice, with every priced item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{pricedSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderQuote [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// The gateway answers OrderQuote with IATA_OrderReshopRS: the order as it stands plus ReshopResults.",
                          "const EXPECT_ADDED_ITEM = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderReshopRS || result.IATA_OrderQuoteRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('quoted order returned', () => { pm.expect(order, 'no Order in the response').to.exist; pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')); });",
                          "    const results = resp.ReshopResults || {};",
                          "    if (EXPECT_ADDED_ITEM) {",
                          "        const added = toArray(results.ReshopOffers).flatMap(r => toArray(r.RequotedOffer)).flatMap(r => toArray(r.AddedOfferItem));",
                          "        pm.test('quote contains the added offer item', () => { pm.expect(added.length, 'no RequotedOffer/AddedOfferItem').to.be.above(0); added.forEach(a => pm.expect(text(a.OfferItemID)).to.be.a('string').and.not.empty); });",
                          "        added.forEach(a => { const diff = a.ReshopPrice && a.ReshopPrice.PriceDifferential && a.ReshopPrice.PriceDifferential.DiffPrice && a.ReshopPrice.PriceDifferential.DiffPrice.Price && a.ReshopPrice.PriceDifferential.DiffPrice.Price.TotalAmount; console.log('added item', text(a.OfferItemID), text(a.PaxRefID || (a.FareDetail && a.FareDetail.PaxRefID)), 'to pay', text(diff), curOf(diff)); });",
                          "    } else {",
                          "        const noChange = results.NoChangeInd && (text(results.NoChangeInd.NoChangeInd) || text(results.NoChangeInd));",
                          "        pm.test('no change on the quoted order (NoChangeInd)', () => pm.expect(String(noChange), 'ReshopResults/NoChangeInd').to.equal('true'));",
                          "    }",
                          "    if (order) console.log('quoted order', text(order.OrderID), '| status', text(order.StatusCode), '| total', text(order.TotalPrice && order.TotalPrice.TotalAmount), curOf(order.TotalPrice && order.TotalPrice.TotalAmount));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n        </cns:ExistingOrder>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6. OrderChange [RT] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = true;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n        </ns2:Order>\n        <!-- Pays the pending purchase: {{paymentAmount}} is the order total that the OrderCreate [Pay Later] /\n             OrderChange [ADD ...] response returned, and is cleared once paid (a second [Pay] is not sent).\n             Cash (CA) is the payment method supported on VI. Debit account is not supported on VI and a card\n             payment needs a PCI-Proxy token (see Order Change -> payment in the partner guide). -->\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{paymentCurCode}}\">{{paymentAmount}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ],
          "description": "Shop -> price -> create an **on-hold** order -> retrieve -> quote -> pay by **cash**.\n\nExpected: AirShopping returns VI offers for {{departureCode}} -> {{arrivalCode}}; OfferPrice prices all items of the chosen offer (OW 6 / RT 12); OrderCreate [Pay Later] returns an order with one PNR per carrier and a payment time limit; OrderQuote reports `NoChangeInd = true`; OrderChange [Pay] [CASH] returns the order with one ticket per passenger and carrier (6 ticket numbers for 1 ADT + 1 CHD + 1 INF).\n\nPayment variants: cash only - debit account is not supported on VI, card payment requires a PCI-Proxy token."
        },
        {
          "name": "Create paid booking",
          "item": [
            {
              "name": "OW - 1ADT, 1CHD, 1INF",
              "item": [
                {
                  "name": "1. AirShopping [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                          "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                          "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                          "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                        ]
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                          "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                          "// OrderCreate must select all of them.",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_AirShoppingRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                          "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                          "    if (!offers.length) return;",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "",
                          "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                          "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                          "    const items = toArray(offer.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        const comp = toArray(fare.FareComponent)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                          "        pm.expect(items.length).to.be.above(0);",
                          "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                          "    });",
                          "    pm.test('one offer item per passenger per leg', () => {",
                          "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                          "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                          "    });",
                          "",
                          "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                          "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                          "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                          "    pm.environment.set('offerId', text(offer.OfferID));",
                          "    pm.environment.set('offerOwnerCode', ownerCode);",
                          "    pm.environment.set('offerItemCount', String(items.length));",
                          "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                          "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                          "",
                          "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                          "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                          "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                          "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                          "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                          "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                          "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                          "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                          "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                          "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                          "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                          "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                          "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                          "",
                          "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                          "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0);",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OfferPriceRS || {};",
                          "    const priced = rs.Response && rs.Response.PricedOffer;",
                          "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                          "    if (!priced) return;",
                          "",
                          "    const items = toArray(priced.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                          "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                          "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "",
                          "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                          "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                          "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                          "",
                          "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                          "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = true;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The priced offer from OfferPrice, with every priced item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{pricedSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "RT - 1ADT, 1CHD, 1INF",
              "item": [
                {
                  "name": "1. AirShopping [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                          "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                          "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                          "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                        ]
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                          "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                          "// OrderCreate must select all of them.",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_AirShoppingRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                          "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                          "    if (!offers.length) return;",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "",
                          "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                          "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                          "    const items = toArray(offer.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        const comp = toArray(fare.FareComponent)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                          "        pm.expect(items.length).to.be.above(0);",
                          "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                          "    });",
                          "    pm.test('one offer item per passenger per leg', () => {",
                          "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                          "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                          "    });",
                          "",
                          "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                          "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                          "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                          "    pm.environment.set('offerId', text(offer.OfferID));",
                          "    pm.environment.set('offerOwnerCode', ownerCode);",
                          "    pm.environment.set('offerItemCount', String(items.length));",
                          "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                          "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                          "",
                          "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                          "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                          "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                          "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                          "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                          "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                          "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                          "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                          "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                          "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                          "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                          "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                          "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                          "",
                          "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                          "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{nextArrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{nextDepartureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [RT] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0);",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OfferPriceRS || {};",
                          "    const priced = rs.Response && rs.Response.PricedOffer;",
                          "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                          "    if (!priced) return;",
                          "",
                          "    const items = toArray(priced.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                          "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                          "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "",
                          "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                          "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                          "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                          "",
                          "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                          "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [RT] [1ADT, 1CHD, 1INF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = true;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The priced offer from OfferPrice, with every priced item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{pricedSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ],
          "description": "Shop -> price -> create and pay in one OrderCreate (**instant cash payment**) -> retrieve.\n\nExpected: OrderCreate [Instant CASH Pay] returns the order with one PNR per carrier and one ticket per passenger and carrier (6 ticket numbers for 1 ADT + 1 CHD + 1 INF); OrderRetrieve shows the same."
        },
        {
          "name": "Retrieve booking",
          "item": [
            {
              "name": "OrderRetrieve by OrderId",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = 0;",
                      "const EXPECT_TICKETS = false;",
                      "const EXPECT_SERVICE_ITEM = false;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = true;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderRetrieve"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "OrderRetrieve By Record Locator",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = 0;",
                      "const EXPECT_TICKETS = false;",
                      "const EXPECT_SERVICE_ITEM = false;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = true;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:BookingRefFilterCriteria>\n                <!-- Record locator returned by OrderCreate / OrderRetrieve (Service/BookingRef/BookingID).\n                     A VI order has one PNR per carrier; either one finds the order. -->\n                <ns2:BookingID>{{bookingId}}</ns2:BookingID>\n            </ns2:BookingRefFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderRetrieve"
                  ]
                }
              },
              "response": []
            }
          ],
          "description": "Retrieve a booking by HUB **OrderID** and by **record locator** (PNR).\n\nPrecondition: run a create use case first in the same session - both requests use the `orderId` / `bookingId` that the last OrderCreate stored. A VI order has one PNR per carrier; `bookingId` is the first one returned, either finds the order."
        },
        {
          "name": "Ancillary Offer - Services",
          "item": [
            {
              "name": "1. AirShopping [OW] [1ADT, 1CHD, 1INF]",
              "event": [
                {
                  "listen": "prerequest",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                      "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                      "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                      "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                    ]
                  }
                },
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                      "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                      "// OrderCreate must select all of them.",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_AirShoppingRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                      "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                      "    if (!offers.length) return;",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "",
                      "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                      "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                      "    const items = toArray(offer.OfferItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const fare = toArray(it.FareDetail)[0] || {};",
                      "        const comp = toArray(fare.FareComponent)[0] || {};",
                      "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                      "    });",
                      "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                      "        pm.expect(items.length).to.be.above(0);",
                      "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                      "    });",
                      "    pm.test('one offer item per passenger per leg', () => {",
                      "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                      "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                      "    });",
                      "",
                      "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                      "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                      "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                      "    pm.environment.set('offerId', text(offer.OfferID));",
                      "    pm.environment.set('offerOwnerCode', ownerCode);",
                      "    pm.environment.set('offerItemCount', String(items.length));",
                      "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                      "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                      "",
                      "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                      "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                      "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                      "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                      "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                      "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                      "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                      "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                      "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                      "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                      "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                      "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                      "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                      "",
                      "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                      "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "AirShopping"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "2. ServiceList For Offer [OW] [1ADT, 1CHD, 1INF]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Picks one service offer item for the adult: service code from env serviceCode (default XBAG), falling",
                      "// back to the first item available for the adult, and exports it for OfferPrice / OrderCreate /",
                      "// OrderQuote / OrderChange. Written to the ENVIRONMENT, like every other variable of this folder.",
                      "const wantedCode = pm.variables.get('serviceCode') || 'XBAG';",
                      "const flightCurrency = pm.environment.get('offerTotalCurCode');",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_ServiceListRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const offers = toArray(resp.ALaCarteOffer);",
                      "    pm.test('ALaCarteOffer with an OfferID', () => { pm.expect(offers.length, 'no ALaCarteOffer in ServiceListRS').to.be.above(0); offers.forEach(o => pm.expect(text(o.OfferID)).to.be.a('string').and.not.empty); });",
                      "    if (!offers.length) return;",
                      "",
                      "    const defs = {};",
                      "    toArray(resp.DataLists && resp.DataLists.ServiceDefinitionList && resp.DataLists.ServiceDefinitionList.ServiceDefinition).forEach(d => { defs[text(d.ServiceDefinitionID)] = { code: text(d.ServiceCode), name: text(d.Name) }; });",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const adult = text((paxList.find(p => text(p.PTC) === 'ADT') || {}).PaxID);",
                      "    const items = offers.flatMap(o => toArray(o.OfferItem).map(it => {",
                      "        const def = defs[text(it.Service && it.Service.ServiceDefinitionRefID)] || {};",
                      "        return { offerId: text(o.OfferID), owner: text(o.OwnerCode), id: text(it.OfferItemID), pax: text(toArray(it.Eligibility && it.Eligibility.PaxRefID)[0]), code: def.code, name: def.name, price: it.UnitPrice && it.UnitPrice.TotalAmount };",
                      "    }));",
                      "    const codes = [...new Set(items.map(i => i.code).filter(Boolean))];",
                      "    const pick = items.find(i => i.code === wantedCode && (!adult || i.pax === adult)) || items.find(i => i.code === wantedCode) || items.find(i => !adult || i.pax === adult) || items[0];",
                      "    pm.test('a service offer item is available for the adult (wanted ' + wantedCode + ', available ' + codes.join('/') + ')', () => { pm.expect(pick, 'no OfferItem in any ALaCarteOffer').to.exist; pm.expect(pick.id).to.be.a('string').and.not.empty; });",
                      "    if (!pick) return;",
                      "    if (pick.code !== wantedCode) console.warn('service code', wantedCode, 'not offered - using', pick.code);",
                      "    if (flightCurrency) pm.test('service priced in the currency of the flight offer (' + flightCurrency + ')', () => pm.expect(curOf(pick.price), 'service currency').to.equal(flightCurrency));",
                      "",
                      "    pm.environment.set('serviceOfferId', pick.offerId);",
                      "    pm.environment.set('serviceOfferOwnerCode', pick.owner || pm.variables.get('ownerCode'));",
                      "    pm.environment.set('serviceOfferItemId', pick.id);",
                      "    pm.environment.set('servicePaxRefId', pick.pax);",
                      "    pm.environment.set('serviceCodeSelected', pick.code || '');",
                      "    if (pick.price) { pm.environment.set('servicePrice', text(pick.price)); pm.environment.set('serviceCurCode', curOf(pick.price)); }",
                      "    pm.environment.set('serviceOfferItemCount', String(items.length));",
                      "    pm.environment.set('serviceCodesAvailable', codes.join(','));",
                      "",
                      "    console.log('serviceOfferId =', pick.offerId, '| items', items.length, '| codes', codes.join(','), '| picked', pick.code, pick.name, 'for', pick.pax, text(pick.price), curOf(pick.price), pick.id);",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_ServiceListRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:ResponseParameters>\n            <!-- Ask for the services in the currency of the flight offer (EUR on the VI dev route). -->\n            <cns:CurParameter>\n                <cns:CurCode>{{offerTotalCurCode}}</cns:CurCode>\n            </cns:CurParameter>\n            <cns:LangUsage>\n                <cns:LangCode>en</cns:LangCode>\n            </cns:LangUsage>\n        </cns:ResponseParameters>\n        <cns:ServiceListCoreRequest>\n            <cns:OfferRequest>\n                <cns:Offer>\n                    <cns:OfferID>{{offerId}}</cns:OfferID>\n                    <!-- Flight offer items of the leg chosen by env ancillaryLeg ({{ancillaryLegSegment}}), built by the\n                         AirShopping test script. Ancillaries on VI are per leg: each carrier sells its own services. -->\n                    {{shopOfferItemRefsXml_cns}}\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                </cns:Offer>\n            </cns:OfferRequest>\n        </cns:ServiceListCoreRequest>\n    </Request>\n</IATA_ServiceListRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/ServiceList",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "ServiceList"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "3. AirOfferPrice [OW] [1ADT, 1CHD, 1INF] [Flight + Service]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                      "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0) + 1;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OfferPriceRS || {};",
                      "    const priced = rs.Response && rs.Response.PricedOffer;",
                      "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                      "    if (!priced) return;",
                      "",
                      "    const items = toArray(priced.OfferItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const fare = toArray(it.FareDetail)[0] || {};",
                      "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                      "    });",
                      "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                      "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                      "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "",
                      "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                      "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                      "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                      "",
                      "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                      "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n                <!-- Service offer from ServiceList (one item, picked by env serviceCode for the adult). -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{serviceOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{serviceOfferOwnerCode}}</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{serviceOfferItemId}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>{{servicePaxRefId}}</cns:PaxRefID>\n                        <cns:SelectedALaCarteOfferItem>\n                            <cns:Qty>1</cns:Qty>\n                        </cns:SelectedALaCarteOfferItem>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OfferPrice"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay Later] [Flight + Service]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0) + 1;",
                      "const EXPECT_TICKETS = false;",
                      "const EXPECT_SERVICE_ITEM = true;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = true;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = false;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The flight offer from AirShopping with every offer item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{shopSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n                <!-- Service offer from ServiceList (one item for the adult). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{serviceOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{serviceOfferOwnerCode}}</ns2:OwnerCode>\n                    <ns2:SelectedOfferItem>\n                        <ns2:OfferItemRefID>{{serviceOfferItemId}}</ns2:OfferItemRefID>\n                        <ns2:PaxRefID>{{servicePaxRefId}}</ns2:PaxRefID>\n                        <ns2:SelectedALaCarteOfferItem>\n                            <ns2:Qty>1</ns2:Qty>\n                        </ns2:SelectedALaCarteOfferItem>\n                    </ns2:SelectedOfferItem>\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = 0;",
                      "const EXPECT_TICKETS = true;",
                      "const EXPECT_SERVICE_ITEM = false;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = true;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = false;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n        </ns2:Order>\n        <!-- Pays the pending purchase: {{paymentAmount}} is the order total that the OrderCreate [Pay Later] /\n             OrderChange [ADD ...] response returned, and is cleared once paid (a second [Pay] is not sent).\n             Cash (CA) is the payment method supported on VI. Debit account is not supported on VI and a card\n             payment needs a PCI-Proxy token (see Order Change -> payment in the partner guide). -->\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{paymentCurCode}}\">{{paymentAmount}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderChange"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "6. OrderRetrieve by OrderId",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = 0;",
                      "const EXPECT_TICKETS = false;",
                      "const EXPECT_SERVICE_ITEM = false;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = true;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderRetrieve"
                  ]
                }
              },
              "response": []
            }
          ],
          "description": "Pre-booking **service** (SSR) on a new booking: shop -> ServiceList by offer -> OfferPrice (flight + service) -> OrderCreate [Pay Later] (flight + service) -> pay by cash -> retrieve.\n\nServiceList asks for the services of the leg chosen by `ancillaryLeg` (default 1 = the AeroCRS leg) **in the currency of the flight offer**; its test script picks one item for the adult by `serviceCode` (default XBAG).\n\nExpected: ServiceList returns one ALaCarteOffer (on dev: CBBG, XBAG, AVIH, VGML, UMNR, WCHR, DSLB, in EUR); OfferPrice prices flight + service in one PricedOffer (6 + 1 items); OrderCreate [Pay Later] returns 7 order items; OrderChange [Pay] [CASH] returns one ticket per passenger and carrier.\n\nKnown limits (dev, 2026-10-06): services for the SMS leg (`ancillaryLeg` = 2) answer 422 / 911 `No segment attributes found for segment key ...`; asking ServiceList in another currency than the flight offer ends in `Currency mismatch: EUR/USD` at OfferPrice / OrderCreate."
        },
        {
          "name": "Ancillary Offer - Seats",
          "item": [
            {
              "name": "1. AirShopping [OW] [1ADT, 1CHD, 1INF]",
              "event": [
                {
                  "listen": "prerequest",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                      "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                      "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                      "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                    ]
                  }
                },
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                      "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                      "// OrderCreate must select all of them.",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_AirShoppingRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                      "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                      "    if (!offers.length) return;",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "",
                      "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                      "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                      "    const items = toArray(offer.OfferItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const fare = toArray(it.FareDetail)[0] || {};",
                      "        const comp = toArray(fare.FareComponent)[0] || {};",
                      "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                      "    });",
                      "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                      "        pm.expect(items.length).to.be.above(0);",
                      "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                      "    });",
                      "    pm.test('one offer item per passenger per leg', () => {",
                      "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                      "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                      "    });",
                      "",
                      "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                      "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                      "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                      "    pm.environment.set('offerId', text(offer.OfferID));",
                      "    pm.environment.set('offerOwnerCode', ownerCode);",
                      "    pm.environment.set('offerItemCount', String(items.length));",
                      "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                      "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                      "",
                      "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                      "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                      "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                      "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                      "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                      "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                      "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                      "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                      "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                      "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                      "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                      "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                      "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                      "",
                      "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                      "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "AirShopping"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "2. SeatAvailability For Offer [OW] [1ADT, 1CHD, 1INF]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Picks one free seat per seated passenger (every passenger that is not an infant) and per seat map,",
                      "// using the OfferItemRefID that belongs to that passenger (ALaCarteOffer/OfferItem/Eligibility/PaxRefID),",
                      "// and exports a ready <SelectedOfferItem> fragment for OfferPrice / OrderCreate / OrderQuote / OrderChange.",
                      "// Rows in excludedSeatRows (default 1,2,3) are skipped; a seat with characteristic 1 (restricted) too.",
                      "// The first copy of a seat in document order is the one the backend binds the seat to, so seats are",
                      "// taken in that order.",
                      "const RESTRICTED_SEAT = '1';",
                      "const skipRows = new Set(String(pm.variables.get('excludedSeatRows') == null ? '1,2,3' : pm.variables.get('excludedSeatRows')).split(',').map(s => s.trim()).filter(Boolean));",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_SeatAvailabilityRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const offer = resp.ALaCarteOffer;",
                      "    pm.test('ALaCarteOffer with an OfferID', () => { pm.expect(offer, 'no ALaCarteOffer in SeatAvailabilityRS').to.exist; pm.expect(text(offer.OfferID)).to.be.a('string').and.not.empty; });",
                      "    if (!offer) return;",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const seatPax = paxList.filter(p => text(p.PTC) !== 'INF').map(p => text(p.PaxID));",
                      "    const itemById = {};",
                      "    toArray(offer.OfferItem).forEach(it => {",
                      "        const el = it.Eligibility || {};",
                      "        itemById[text(it.OfferItemID)] = { pax: toArray(el.PaxRefID).map(text), price: it.UnitPrice && it.UnitPrice.TotalAmount };",
                      "    });",
                      "    const seatMaps = toArray(resp.SeatMap);",
                      "    const seats = [];",
                      "    seatMaps.forEach((map, mapIndex) => toArray(map.CabinCompartment).forEach((cabin, cabinIndex) => toArray(cabin.SeatRow).forEach(row => toArray(row.Seat).forEach(seat => {",
                      "        const refs = toArray(seat.OfferItemRefID).map(text).filter(r => itemById[r]);",
                      "        if (text(seat.OccupationStatusCode) !== 'F' || !seat.ColumnID || !seat.RowNumber || !refs.length) return;",
                      "        if (toArray(seat.SeatCharacteristicCode).map(text).includes(RESTRICTED_SEAT)) return;",
                      "        seats.push({ mapIndex, cabinIndex, row: text(seat.RowNumber), column: text(seat.ColumnID), refs });",
                      "    }))));",
                      "    const selectable = seats.filter(s => !skipRows.has(s.row));",
                      "    pm.test('at least one free seat outside the excluded rows [' + [...skipRows].join(',') + ']', () => pm.expect(selectable.length, 'free seats: ' + seats.length).to.be.above(0));",
                      "",
                      "    const selections = [];",
                      "    seatMaps.forEach((map, mapIndex) => {",
                      "        const taken = new Set();",
                      "        seatPax.forEach(pax => {",
                      "            const seat = selectable.find(s => s.mapIndex === mapIndex && !taken.has(s.row + s.column) && s.refs.some(r => itemById[r].pax.includes(pax)));",
                      "            if (!seat) return;",
                      "            const ref = seat.refs.find(r => itemById[r].pax.includes(pax));",
                      "            taken.add(seat.row + seat.column);",
                      "            selections.push({ pax, mapIndex, seat, ref, price: itemById[ref].price });",
                      "        });",
                      "    });",
                      "    pm.test('one seat selected per seated passenger (' + seatPax.join(',') + ') and per seat map (' + seatMaps.length + ')', () => pm.expect(selections.length).to.equal(seatPax.length * seatMaps.length));",
                      "    if (!selections.length) return;",
                      "",
                      "    const frag = p => block(selections.flatMap(s => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + s.ref + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + s.pax + '</' + p + ':PaxRefID>', '    <' + p + ':SelectedSeat>', '        <' + p + ':ColumnID>' + s.seat.column + '</' + p + ':ColumnID>', '        <' + p + ':SeatRowNumber>' + s.seat.row + '</' + p + ':SeatRowNumber>', '    </' + p + ':SelectedSeat>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                      "    const seatTotal = selections.reduce((sum, s) => sum + (Number(text(s.price)) || 0), 0);",
                      "    pm.environment.set('seatOfferId', text(offer.OfferID));",
                      "    pm.environment.set('seatOfferOwnerCode', text(offer.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    pm.environment.set('seatCount', String(selections.length));",
                      "    pm.environment.set('seatSelectedOfferItemsXml_cns', frag('cns'));",
                      "    pm.environment.set('seatSelectedOfferItemsXml_ns2', frag('ns2'));",
                      "    pm.environment.set('seatTotalPrice', String(seatTotal));",
                      "    const cur = selections.map(s => curOf(s.price)).find(Boolean);",
                      "    if (cur) pm.environment.set('seatCurrency', cur);",
                      "    pm.environment.set('seatSummary', selections.map(s => s.pax + ' ' + s.seat.row + s.seat.column + ' (map ' + s.mapIndex + ')').join(', '));",
                      "    selections.forEach(s => { pm.environment.set('seatOfferItemId_' + s.pax, s.ref); pm.environment.set('seatLabel_' + s.pax, s.seat.row + s.seat.column); });",
                      "",
                      "    console.log('seatOfferId =', text(offer.OfferID), '| seat maps', seatMaps.length, '| free seats', seats.length, '| selectable', selectable.length, '| seat total', seatTotal, cur || '');",
                      "    selections.forEach(s => console.log('  ' + s.pax, 'seat', s.seat.row + s.seat.column, 'map', s.mapIndex, 'compartment', s.seat.cabinIndex, text(s.price), curOf(s.price), s.ref));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_SeatAvailabilityRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:SeatAvailCoreRequest>\n            <cns:OfferRequest>\n                <cns:Offer>\n                    <cns:OfferID>{{offerId}}</cns:OfferID>\n                    <!-- Flight offer items of the leg chosen by env ancillaryLeg ({{ancillaryLegSegment}}) for every seated\n                         passenger (the infant is left out), built by the AirShopping test script. Ancillaries on VI are per leg. -->\n                    {{seatOfferItemRefsXml_cns}}\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                </cns:Offer>\n            </cns:OfferRequest>\n        </cns:SeatAvailCoreRequest>\n    </Request>\n</IATA_SeatAvailabilityRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/SeatAvailability",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "SeatAvailability"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "3. AirOfferPrice [OW] [1ADT, 1CHD, 1INF] [Flight + Seats]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                      "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0) + Number(pm.environment.get('seatCount') || 0);",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OfferPriceRS || {};",
                      "    const priced = rs.Response && rs.Response.PricedOffer;",
                      "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                      "    if (!priced) return;",
                      "",
                      "    const items = toArray(priced.OfferItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const fare = toArray(it.FareDetail)[0] || {};",
                      "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                      "    });",
                      "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                      "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                      "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "",
                      "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                      "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                      "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                      "",
                      "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                      "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "X-API-Key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n                <!-- Seat offer from SeatAvailability: one SelectedOfferItem per seated passenger, built by the\n                     SeatAvailability test script from the seat's own OfferItemRefID for that passenger. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{seatOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{seatOfferOwnerCode}}</cns:OwnerCode>\n                    {{seatSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OfferPrice"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "4. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Pay Later] [Flight + Seats]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0) + Number(pm.environment.get('seatCount') || 0);",
                      "const EXPECT_TICKETS = false;",
                      "const EXPECT_SERVICE_ITEM = false;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = true;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = false;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The flight offer from AirShopping with every offer item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{offerId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{shopSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n                <!-- Seat offer from SeatAvailability: the same seats OfferPrice priced, one item per seated\n                     passenger with its own OfferItemRefID (the CHD seat item is not the ADT seat item). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{seatOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{seatOfferOwnerCode}}</ns2:OwnerCode>\n                    {{seatSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n    </Request>\n</IATA_OrderCreateRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderCreate"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = 0;",
                      "const EXPECT_TICKETS = true;",
                      "const EXPECT_SERVICE_ITEM = false;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = true;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = false;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n        </ns2:Order>\n        <!-- Pays the pending purchase: {{paymentAmount}} is the order total that the OrderCreate [Pay Later] /\n             OrderChange [ADD ...] response returned, and is cleared once paid (a second [Pay] is not sent).\n             Cash (CA) is the payment method supported on VI. Debit account is not supported on VI and a card\n             payment needs a PCI-Proxy token (see Order Change -> payment in the partner guide). -->\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{paymentCurCode}}\">{{paymentAmount}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderChange"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "6. OrderRetrieve by OrderId",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "packages": {},
                    "exec": [
                      "const xml2js = require('xml2js');",
                      "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                      "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                      "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                      "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                      "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                      "function parse(xml, cb) {",
                      "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                      "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                      "        cb(result);",
                      "    });",
                      "}",
                      "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                      "// ticket numbers and the total, and exports them for the next steps.",
                      "const EXPECT_MIN_ITEMS = 0;",
                      "const EXPECT_TICKETS = false;",
                      "const EXPECT_SERVICE_ITEM = false;",
                      "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                      "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                      "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                      "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                      "const MUST_MATCH_ORDER_ID = true;",
                      "parse(pm.response.text(), result => {",
                      "    const rs = result.IATA_OrderViewRS || {};",
                      "    const resp = rs.Response || {};",
                      "    const order = resp.Order;",
                      "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                      "    if (!order) return;",
                      "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                      "",
                      "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                      "    const ptcOf = {};",
                      "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                      "    const items = toArray(order.OrderItem).map(it => {",
                      "        const svc = toArray(it.Service)[0] || {};",
                      "        const assoc = svc.OrderServiceAssociation || {};",
                      "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                      "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                      "    });",
                      "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                      "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                      "    const ticketDocs = toArray(resp.TicketDocInfo);",
                      "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                      "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                      "",
                      "    pm.environment.set('orderId', text(order.OrderID));",
                      "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                      "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                      "    pm.environment.set('orderItemCount', String(items.length));",
                      "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                      "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                      "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                      "    pm.environment.set('ticketCount', String(tickets.length));",
                      "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                      "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                      "",
                      "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                      "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                      "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                      "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                      "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                      "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                      "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                      "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                      "    });",
                      "    if (CHECK_PAID_AMOUNT) {",
                      "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                      "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                      "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                      "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                      "    }",
                      "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                      "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                      "",
                      "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                      "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                      "});"
                    ]
                  }
                }
              ],
              "request": {
                "auth": {
                  "type": "noauth"
                },
                "method": "POST",
                "header": [
                  {
                    "key": "x-api-key",
                    "value": "{{x-api-key}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                  "options": {
                    "raw": {
                      "language": "xml"
                    }
                  }
                },
                "url": {
                  "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                  "host": [
                    "{{ndc-gateway-url}}"
                  ],
                  "path": [
                    "v21.3.5",
                    "OrderRetrieve"
                  ]
                }
              },
              "response": []
            }
          ],
          "description": "Pre-booking **seats** on a new booking: shop -> SeatAvailability by offer -> OfferPrice (flight + seats) -> OrderCreate [Pay Later] (flight + seats) -> pay by cash -> retrieve.\n\nSeatAvailability asks for the seat map of the leg chosen by `ancillaryLeg` (default 1 = the AeroCRS leg); its test script seats every passenger except the infant, one free seat each outside `excludedSeatRows`, with the seat's own offer item for that passenger.\n\nExpected: one SeatMap with free seats (0.00 EUR on dev); OfferPrice prices flight + seats (6 + 2 items); OrderCreate [Pay Later] returns 8 order items, the two seat items REQUESTED.\n\nKnown limits (dev, 2026-10-06): OrderChange [Pay] [CASH] on that order answers 200 **without** ticket numbers - the order stays OPEN, the seat items REQUESTED. Do not send the payment again. The seat map of the SMS leg (`ancillaryLeg` = 2) answers 422 / 911 `No OfferItemSegmentAttributes found for key ...`."
        },
        {
          "name": "Ancillary Order - Services",
          "item": [
            {
              "name": "OW",
              "item": [
                {
                  "name": "1. AirShopping [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                          "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                          "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                          "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                        ]
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                          "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                          "// OrderCreate must select all of them.",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_AirShoppingRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                          "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                          "    if (!offers.length) return;",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "",
                          "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                          "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                          "    const items = toArray(offer.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        const comp = toArray(fare.FareComponent)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                          "        pm.expect(items.length).to.be.above(0);",
                          "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                          "    });",
                          "    pm.test('one offer item per passenger per leg', () => {",
                          "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                          "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                          "    });",
                          "",
                          "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                          "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                          "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                          "    pm.environment.set('offerId', text(offer.OfferID));",
                          "    pm.environment.set('offerOwnerCode', ownerCode);",
                          "    pm.environment.set('offerItemCount', String(items.length));",
                          "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                          "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                          "",
                          "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                          "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                          "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                          "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                          "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                          "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                          "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                          "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                          "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                          "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                          "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                          "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                          "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                          "",
                          "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                          "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0);",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OfferPriceRS || {};",
                          "    const priced = rs.Response && rs.Response.PricedOffer;",
                          "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                          "    if (!priced) return;",
                          "",
                          "    const items = toArray(priced.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                          "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                          "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "",
                          "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                          "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                          "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                          "",
                          "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                          "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = true;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The priced offer from OfferPrice, with every priced item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{pricedSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. ServiceList For Order [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one service offer item for the adult: service code from env serviceCode (default XBAG), falling",
                          "// back to the first item available for the adult, and exports it for OfferPrice / OrderCreate /",
                          "// OrderQuote / OrderChange. Written to the ENVIRONMENT, like every other variable of this folder.",
                          "const wantedCode = pm.variables.get('serviceCode') || 'XBAG';",
                          "const flightCurrency = pm.environment.get('totalCurCode');",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_ServiceListRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offers = toArray(resp.ALaCarteOffer);",
                          "    pm.test('ALaCarteOffer with an OfferID', () => { pm.expect(offers.length, 'no ALaCarteOffer in ServiceListRS').to.be.above(0); offers.forEach(o => pm.expect(text(o.OfferID)).to.be.a('string').and.not.empty); });",
                          "    if (!offers.length) return;",
                          "",
                          "    const defs = {};",
                          "    toArray(resp.DataLists && resp.DataLists.ServiceDefinitionList && resp.DataLists.ServiceDefinitionList.ServiceDefinition).forEach(d => { defs[text(d.ServiceDefinitionID)] = { code: text(d.ServiceCode), name: text(d.Name) }; });",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const adult = text((paxList.find(p => text(p.PTC) === 'ADT') || {}).PaxID);",
                          "    const items = offers.flatMap(o => toArray(o.OfferItem).map(it => {",
                          "        const def = defs[text(it.Service && it.Service.ServiceDefinitionRefID)] || {};",
                          "        return { offerId: text(o.OfferID), owner: text(o.OwnerCode), id: text(it.OfferItemID), pax: text(toArray(it.Eligibility && it.Eligibility.PaxRefID)[0]), code: def.code, name: def.name, price: it.UnitPrice && it.UnitPrice.TotalAmount };",
                          "    }));",
                          "    const codes = [...new Set(items.map(i => i.code).filter(Boolean))];",
                          "    const pick = items.find(i => i.code === wantedCode && (!adult || i.pax === adult)) || items.find(i => i.code === wantedCode) || items.find(i => !adult || i.pax === adult) || items[0];",
                          "    pm.test('a service offer item is available for the adult (wanted ' + wantedCode + ', available ' + codes.join('/') + ')', () => { pm.expect(pick, 'no OfferItem in any ALaCarteOffer').to.exist; pm.expect(pick.id).to.be.a('string').and.not.empty; });",
                          "    if (!pick) return;",
                          "    if (pick.code !== wantedCode) console.warn('service code', wantedCode, 'not offered - using', pick.code);",
                          "    if (flightCurrency) pm.test('service priced in the currency of the flight offer (' + flightCurrency + ')', () => pm.expect(curOf(pick.price), 'service currency').to.equal(flightCurrency));",
                          "",
                          "    pm.environment.set('serviceOfferId', pick.offerId);",
                          "    pm.environment.set('serviceOfferOwnerCode', pick.owner || pm.variables.get('ownerCode'));",
                          "    pm.environment.set('serviceOfferItemId', pick.id);",
                          "    pm.environment.set('servicePaxRefId', pick.pax);",
                          "    pm.environment.set('serviceCodeSelected', pick.code || '');",
                          "    if (pick.price) { pm.environment.set('servicePrice', text(pick.price)); pm.environment.set('serviceCurCode', curOf(pick.price)); }",
                          "    pm.environment.set('serviceOfferItemCount', String(items.length));",
                          "    pm.environment.set('serviceCodesAvailable', codes.join(','));",
                          "",
                          "    console.log('serviceOfferId =', pick.offerId, '| items', items.length, '| codes', codes.join(','), '| picked', pick.code, pick.name, 'for', pick.pax, text(pick.price), curOf(pick.price), pick.id);",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_ServiceListRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:ResponseParameters>\n            <!-- Ask for the services in the currency of the order (EUR on the VI dev route). -->\n            <cns:CurParameter>\n                <cns:CurCode>{{totalCurCode}}</cns:CurCode>\n            </cns:CurParameter>\n            <cns:LangUsage>\n                <cns:LangCode>en</cns:LangCode>\n            </cns:LangUsage>\n        </cns:ResponseParameters>\n        <cns:ServiceListCoreRequest>\n            <cns:OrderRequest>\n                <cns:Order>\n                    <cns:OrderID>{{orderId}}</cns:OrderID>\n                    <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n                </cns:Order>\n            </cns:OrderRequest>\n        </cns:ServiceListCoreRequest>\n    </Request>\n</IATA_ServiceListRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/ServiceList",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "ServiceList"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderQuote [OW] [1ADT, 1CHD, 1INF] with Service",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// The gateway answers OrderQuote with IATA_OrderReshopRS: the order as it stands plus ReshopResults.",
                          "const EXPECT_ADDED_ITEM = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderReshopRS || result.IATA_OrderQuoteRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('quoted order returned', () => { pm.expect(order, 'no Order in the response').to.exist; pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')); });",
                          "    const results = resp.ReshopResults || {};",
                          "    if (EXPECT_ADDED_ITEM) {",
                          "        const added = toArray(results.ReshopOffers).flatMap(r => toArray(r.RequotedOffer)).flatMap(r => toArray(r.AddedOfferItem));",
                          "        pm.test('quote contains the added offer item', () => { pm.expect(added.length, 'no RequotedOffer/AddedOfferItem').to.be.above(0); added.forEach(a => pm.expect(text(a.OfferItemID)).to.be.a('string').and.not.empty); });",
                          "        added.forEach(a => { const diff = a.ReshopPrice && a.ReshopPrice.PriceDifferential && a.ReshopPrice.PriceDifferential.DiffPrice && a.ReshopPrice.PriceDifferential.DiffPrice.Price && a.ReshopPrice.PriceDifferential.DiffPrice.Price.TotalAmount; console.log('added item', text(a.OfferItemID), text(a.PaxRefID || (a.FareDetail && a.FareDetail.PaxRefID)), 'to pay', text(diff), curOf(diff)); });",
                          "    } else {",
                          "        const noChange = results.NoChangeInd && (text(results.NoChangeInd.NoChangeInd) || text(results.NoChangeInd));",
                          "        pm.test('no change on the quoted order (NoChangeInd)', () => pm.expect(String(noChange), 'ReshopResults/NoChangeInd').to.equal('true'));",
                          "    }",
                          "    if (order) console.log('quoted order', text(order.OrderID), '| status', text(order.StatusCode), '| total', text(order.TotalPrice && order.TotalPrice.TotalAmount), curOf(order.TotalPrice && order.TotalPrice.TotalAmount));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{serviceOfferId}}</cns:OfferRefID>\n            <cns:OwnerCode>{{serviceOfferOwnerCode}}</cns:OwnerCode>\n            <cns:SelectedOfferItem>\n                <cns:OfferItemRefID>{{serviceOfferItemId}}</cns:OfferItemRefID>\n                <cns:PaxRefID>{{servicePaxRefId}}</cns:PaxRefID>\n                <cns:SelectedALaCarteOfferItem>\n                    <cns:Qty>1</cns:Qty>\n                </cns:SelectedALaCarteOfferItem>\n            </cns:SelectedOfferItem>\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6. OrderChange [OW] [1ADT, 1CHD, 1INF] [ADD SERVICE]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = true;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = true;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:ChangeOrderChoice>\n            <cns:AcceptSelectedQuotedOfferList>\n                <!-- Service offer item from ServiceList by order (the one OrderQuote just quoted). -->\n                <cns:SelectedPricedOffer>\n                    <cns:OfferRefID>{{serviceOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{serviceOfferOwnerCode}}</cns:OwnerCode>\n                    <cns:SelectedOfferItem>\n                        <cns:OfferItemRefID>{{serviceOfferItemId}}</cns:OfferItemRefID>\n                        <cns:PaxRefID>{{servicePaxRefId}}</cns:PaxRefID>\n                        <cns:SelectedALaCarteOfferItem>\n                            <cns:Qty>1</cns:Qty>\n                        </cns:SelectedALaCarteOfferItem>\n                    </cns:SelectedOfferItem>\n                </cns:SelectedPricedOffer>\n            </cns:AcceptSelectedQuotedOfferList>\n        </cns:ChangeOrderChoice>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n        </cns:Order>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "7. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = true;",
                          "const CHECK_PAID_AMOUNT = true;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n        </ns2:Order>\n        <!-- Pays the pending purchase: {{paymentAmount}} is the order total that the OrderCreate [Pay Later] /\n             OrderChange [ADD ...] response returned, and is cleared once paid (a second [Pay] is not sent).\n             Cash (CA) is the payment method supported on VI. Debit account is not supported on VI and a card\n             payment needs a PCI-Proxy token (see Order Change -> payment in the partner guide). -->\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{paymentCurCode}}\">{{paymentAmount}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "8. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = true;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ],
          "description": "Post-booking **service** (SSR) on an existing paid booking. The folder creates its own paid order first: shop -> price -> OrderCreate [Instant CASH Pay] -> ServiceList by order -> OrderQuote (service) -> OrderChange [ADD SERVICE] -> OrderChange [PAY] [CASH] -> retrieve.\n\nServiceList by order asks **in the currency of the order**; the test script picks one item for the adult by `serviceCode` (default XBAG).\n\nExpected: OrderQuote shows the added item with the amount to pay; OrderChange [ADD SERVICE] returns the new service item(s) REQUESTED and the amount of the new purchase; OrderChange [Pay] [CASH] pays exactly that amount and the service item becomes CONFIRMED; OrderRetrieve shows the order total = flights + service.\n\nKnown limits (dev, 2026-10-06): asking ServiceList in another currency than the order leaves the order unreadable afterwards (`Bad Request - Currency mismatch: EUR/USD`) - this folder asks in the order currency. On one of two runs the order view after the payment was incomplete: OrderRetrieve returned only the two service items (PaxList with the adult only, ticket numbers without PaxRefID, total = service price), while the other run returned the whole order (flights + service, 879.90 EUR)."
        },
        {
          "name": "Ancillary Order - Seats",
          "item": [
            {
              "name": "OW",
              "item": [
                {
                  "name": "1. AirShopping [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "// Start of a use case: forget every id an earlier run left behind, so that a failing step can never",
                          "// fall back on an old order, offer, seat or service id. Connection settings and inputs are kept.",
                          "const RUNTIME = /^(offerId|offerOwnerCode|offerItemCount|offerItemId_\\d+|offerItemPaxRefId_\\d+|offerTotalPrice|offerTotalCurCode|shop\\w+Xml_\\w+|priced\\w+Xml_\\w+|selectedOffer\\w*|totalPrice|totalCurCode|orderId|orderOwnerCode|orderStatus|orderItemCount|orderItemId\\d+|orderItemRefsXml_\\w+|ancillaryLegSegment|payment\\w+|paidBefore|bookingId|bookingIds|ticketCount|seat\\w*|service(?!Code$)\\w+|paidAmount)$/;",
                          "Object.keys(pm.environment.toObject()).filter(k => RUNTIME.test(k)).forEach(k => pm.environment.unset(k));"
                        ]
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one VI offer (env offerIndex, default 0) and exports EVERY offer item with the PaxRefID the",
                          "// response gives it. A VI offer has one item per passenger per leg (OW 6, RT 12) and OfferPrice /",
                          "// OrderCreate must select all of them.",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_AirShoppingRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offers = toArray(resp.OffersGroup && resp.OffersGroup.CarrierOffers).flatMap(c => toArray(c.Offer));",
                          "    pm.test('at least one offer returned', () => pm.expect(offers.length, 'No Offer in AirShoppingRS - check route / dates / VI availability').to.be.above(0));",
                          "    if (!offers.length) return;",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "",
                          "    const wanted = Number(pm.variables.get('offerIndex') || 0);",
                          "    const offer = offers[Math.min(wanted, offers.length - 1)];",
                          "    const items = toArray(offer.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        const comp = toArray(fare.FareComponent)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), seg: text(comp.PaxSegmentRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    pm.test('every offer item has an OfferItemID and a PaxRefID', () => {",
                          "        pm.expect(items.length).to.be.above(0);",
                          "        items.forEach(i => { pm.expect(i.id, 'OfferItemID').to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; });",
                          "    });",
                          "    pm.test('one offer item per passenger per leg', () => {",
                          "        const segs = new Set(items.map(i => i.seg).filter(Boolean));",
                          "        pm.expect(items.length, 'items = passengers x legs').to.equal(paxList.length * Math.max(segs.size, 1));",
                          "    });",
                          "",
                          "    // AirShoppingRS carries no OwnerCode on VI; the gateway resolves the carriers from the API key.",
                          "    const ownerCode = text(offer.OwnerCode) || pm.variables.get('ownerCode');",
                          "    const total = offer.TotalPrice && offer.TotalPrice.TotalAmount;",
                          "    pm.environment.set('offerId', text(offer.OfferID));",
                          "    pm.environment.set('offerOwnerCode', ownerCode);",
                          "    pm.environment.set('offerItemCount', String(items.length));",
                          "    if (total) { pm.environment.set('offerTotalPrice', text(total)); pm.environment.set('offerTotalCurCode', curOf(total)); }",
                          "    items.forEach((i, n) => { pm.environment.set('offerItemId_' + n, i.id); pm.environment.set('offerItemPaxRefId_' + n, i.pax); });",
                          "",
                          "    const selected = p => block(items.flatMap(i => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + i.id + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + i.pax + '</' + p + ':PaxRefID>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                          "    const refs = list => block(list.flatMap(i => ['<cns:OfferItem>', '    <cns:OfferItemID>' + i.id + '</cns:OfferItemID>', '</cns:OfferItem>']), '                    ');",
                          "    pm.environment.set('shopSelectedOfferItemsXml_cns', selected('cns'));   // OfferPrice",
                          "    pm.environment.set('shopSelectedOfferItemsXml_ns2', selected('ns2'));   // OrderCreate from the shopping offer",
                          "    // Ancillaries on VI are requested per leg - each carrier sells its own seats and services. The",
                          "    // ServiceList / SeatAvailability by-offer requests send the items of leg {{ancillaryLeg}} (default 1).",
                          "    const legs = [...new Set(items.map(i => i.seg).filter(Boolean))];",
                          "    const legIndex = Math.min(Math.max(Number(pm.variables.get('ancillaryLeg') || 1), 1), Math.max(legs.length, 1)) - 1;",
                          "    const legItems = legs.length ? items.filter(i => i.seg === legs[legIndex]) : items;",
                          "    pm.environment.set('ancillaryLegSegment', legs[legIndex] || '');",
                          "    pm.environment.set('shopOfferItemRefsXml_cns', refs(legItems));         // ServiceList by offer",
                          "    const seatable = legItems.filter(i => ptcOf[i.pax] !== 'INF');         // an infant has no seat",
                          "    pm.environment.set('seatOfferItemRefsXml_cns', refs(seatable));         // SeatAvailability by offer",
                          "",
                          "    console.log('offers =', offers.length, '| picked offerIndex', wanted, '->', text(offer.OfferID), total ? text(total) + ' ' + curOf(total) : '', '| legs', legs.join(','), '| ancillaries for leg', legIndex + 1, legs[legIndex] || '');",
                          "    items.forEach((i, n) => console.log('  offerItemId_' + n, i.pax, i.seg, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirShoppingRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <!-- VI route: {{departureCode}} -> {{arrivalCode}} is sold as ONE itinerary stitched from two carriers.\n             Dates are computed by the folder pre-request: today + daysToDeparture (return: today + daysToReturn). -->\n        <cns:FlightRequest>\n            <cns:FlightRequestOriginDestinationsCriteria>\n                <cns:OriginDestCriteria>\n                    <cns:DestArrivalCriteria>\n                        <cns:Date>{{arrivalDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{arrivalCode}}</cns:IATA_LocationCode>\n                    </cns:DestArrivalCriteria>\n                    <cns:OriginDepCriteria>\n                        <cns:Date>{{departureDate}}</cns:Date>\n                        <cns:IATA_LocationCode>{{departureCode}}</cns:IATA_LocationCode>\n                    </cns:OriginDepCriteria>\n                </cns:OriginDestCriteria>\n            </cns:FlightRequestOriginDestinationsCriteria>\n        </cns:FlightRequest>\n        <cns:PaxList>\n            <cns:Pax>\n                <cns:PaxID>PAX1</cns:PaxID>\n                <cns:PTC>ADT</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX2</cns:PaxID>\n                <cns:PTC>CHD</cns:PTC>\n            </cns:Pax>\n            <cns:Pax>\n                <cns:PaxID>PAX3</cns:PaxID>\n                <cns:PTC>INF</cns:PTC>\n            </cns:Pax>\n        </cns:PaxList>\n    </Request>\n</IATA_AirShoppingRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/AirShopping",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "AirShopping"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "2. AirOfferPrice [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Exports the priced offer: id, every priced item with its PaxRefID, and the total to pay.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('offerItemCount') || 0);",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OfferPriceRS || {};",
                          "    const priced = rs.Response && rs.Response.PricedOffer;",
                          "    pm.test('PricedOffer with an OfferID', () => { pm.expect(priced, 'no PricedOffer in OfferPriceRS').to.exist; pm.expect(text(priced.OfferID)).to.be.a('string').and.not.empty; });",
                          "    if (!priced) return;",
                          "",
                          "    const items = toArray(priced.OfferItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const fare = toArray(it.FareDetail)[0] || {};",
                          "        return { id: text(it.OfferItemID), pax: text(svc.PaxRefID) || text(fare.PaxRefID), price: it.Price && it.Price.TotalAmount };",
                          "    });",
                          "    const total = priced.TotalPrice && priced.TotalPrice.TotalAmount;",
                          "    pm.test('priced offer carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('every priced item has an OfferItemID and a PaxRefID', () => items.forEach(i => { pm.expect(i.id).to.be.a('string').and.not.empty; pm.expect(i.pax, 'PaxRefID of ' + i.id).to.be.a('string').and.not.empty; }));",
                          "    pm.test('total price with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "",
                          "    pm.environment.set('selectedOfferId', text(priced.OfferID));",
                          "    pm.environment.set('selectedOfferItemCount', String(items.length));",
                          "    items.forEach((i, n) => { pm.environment.set('selectedOfferItemId_' + n, i.id); pm.environment.set('selectedOfferItemPaxRefId_' + n, i.pax); });",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    pm.environment.set('pricedSelectedOfferItemsXml_ns2', block(items.flatMap(i => ['<ns2:SelectedOfferItem>', '    <ns2:OfferItemRefID>' + i.id + '</ns2:OfferItemRefID>', '    <ns2:PaxRefID>' + i.pax + '</ns2:PaxRefID>', '</ns2:SelectedOfferItem>']), '                    '));",
                          "",
                          "    console.log('selectedOfferId =', text(priced.OfferID), '| items =', items.length, '| total =', text(total), curOf(total));",
                          "    items.forEach((i, n) => console.log('  selectedOfferItemId_' + n, i.pax, i.price ? text(i.price) + ' ' + curOf(i.price) : '', i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "X-API-Key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_OfferPriceRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                     xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:PricedOffer>\n            <cns:SelectedOfferList>\n                <!-- Flight offer from AirShopping. ALL offer items must be selected: a VI offer has one item\n                     per passenger per leg (OW 6, RT 12). The AirShopping test script builds this list. -->\n                <cns:SelectedOffer>\n                    <cns:OfferRefID>{{offerId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{offerOwnerCode}}</cns:OwnerCode>\n                    {{shopSelectedOfferItemsXml_cns}}\n                </cns:SelectedOffer>\n            </cns:SelectedOfferList>\n        </cns:PricedOffer>\n    </Request>\n</IATA_OfferPriceRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OfferPrice",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OfferPrice"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "3. OrderCreate [OW] [1ADT, 1CHD, 1INF] [Instant CASH Pay]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = Number(pm.environment.get('selectedOfferItemCount') || 0);",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = true;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderCreateRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:CreateOrder>\n            <ns2:AcceptSelectedQuotedOfferList>\n                <!-- The priced offer from OfferPrice, with every priced item (one per passenger per leg). -->\n                <ns2:SelectedPricedOffer>\n                    <ns2:OfferRefID>{{selectedOfferId}}</ns2:OfferRefID>\n                    <ns2:OwnerCode>{{offerOwnerCode}}</ns2:OwnerCode>\n                    {{pricedSelectedOfferItemsXml_ns2}}\n                </ns2:SelectedPricedOffer>\n            </ns2:AcceptSelectedQuotedOfferList>\n        </ns2:CreateOrder>\n        <ns2:DataLists>\n            <ns2:ContactInfoList>\n                <ns2:ContactInfo>\n                    <ns2:ContactInfoID>CTCPAX1_1</ns2:ContactInfoID>\n                    <ns2:EmailAddress>\n                        <ns2:ContactTypeText>Home</ns2:ContactTypeText>\n                        <ns2:EmailAddressText>{{myEmail}}</ns2:EmailAddressText>\n                    </ns2:EmailAddress>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GivenName>Firstname</ns2:GivenName>\n                        <ns2:Surname>Surname</ns2:Surname>\n                        <ns2:TitleName>Mr</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:Phone>\n                        <ns2:CountryDialingCode>66</ns2:CountryDialingCode>\n                        <ns2:PhoneNumber>12345960</ns2:PhoneNumber>\n                    </ns2:Phone>\n                    <ns2:PostalAddress>\n                        <ns2:CityName>TEST</ns2:CityName>\n                        <ns2:CountryCode>TH</ns2:CountryCode>\n                        <ns2:PostalCode>10210</ns2:PostalCode>\n                    </ns2:PostalAddress>\n                </ns2:ContactInfo>\n            </ns2:ContactInfoList>\n            <ns2:PaxList>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456789</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{adultBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Bruce</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX1</ns2:PaxID>\n                    <ns2:PaxRefID>PAX3</ns2:PaxRefID>\n                    <ns2:PTC>ADT</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456788</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{childBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Child</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX2</ns2:PaxID>\n                    <ns2:PTC>CHD</ns2:PTC>\n                </ns2:Pax>\n                <ns2:Pax>\n                    <ns2:IdentityDoc>\n                        <ns2:ExpiryDate>{{expiryDate}}</ns2:ExpiryDate>\n                        <ns2:IdentityDocID>0123456780</ns2:IdentityDocID>\n                        <ns2:IdentityDocTypeCode>PP</ns2:IdentityDocTypeCode>\n                        <ns2:IssuingCountryCode>GB</ns2:IssuingCountryCode>\n                        <ns2:ResidenceCountryCode>GB</ns2:ResidenceCountryCode>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                    </ns2:IdentityDoc>\n                    <ns2:Individual>\n                        <ns2:Birthdate>{{infantBirthDate}}</ns2:Birthdate>\n                        <ns2:GenderCode>M</ns2:GenderCode>\n                        <ns2:GivenName>Baby</ns2:GivenName>\n                        <ns2:Surname>Wayne</ns2:Surname>\n                        <ns2:TitleName>MR</ns2:TitleName>\n                    </ns2:Individual>\n                    <ns2:LangUsage>\n                        <ns2:LangCode>FR</ns2:LangCode>\n                    </ns2:LangUsage>\n                    <ns2:PaxID>PAX3</ns2:PaxID>\n                    <ns2:PTC>INF</ns2:PTC>\n                </ns2:Pax>\n            </ns2:PaxList>\n        </ns2:DataLists>\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{totalCurCode}}\">{{totalPrice}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderCreateRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderCreate",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderCreate"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "4. SeatAvailability For Order [OW] [1ADT, 1CHD, 1INF]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Picks one free seat per seated passenger (every passenger that is not an infant) and per seat map,",
                          "// using the OfferItemRefID that belongs to that passenger (ALaCarteOffer/OfferItem/Eligibility/PaxRefID),",
                          "// and exports a ready <SelectedOfferItem> fragment for OfferPrice / OrderCreate / OrderQuote / OrderChange.",
                          "// Rows in excludedSeatRows (default 1,2,3) are skipped; a seat with characteristic 1 (restricted) too.",
                          "// The first copy of a seat in document order is the one the backend binds the seat to, so seats are",
                          "// taken in that order.",
                          "const RESTRICTED_SEAT = '1';",
                          "const skipRows = new Set(String(pm.variables.get('excludedSeatRows') == null ? '1,2,3' : pm.variables.get('excludedSeatRows')).split(',').map(s => s.trim()).filter(Boolean));",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_SeatAvailabilityRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const offer = resp.ALaCarteOffer;",
                          "    pm.test('ALaCarteOffer with an OfferID', () => { pm.expect(offer, 'no ALaCarteOffer in SeatAvailabilityRS').to.exist; pm.expect(text(offer.OfferID)).to.be.a('string').and.not.empty; });",
                          "    if (!offer) return;",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const seatPax = paxList.filter(p => text(p.PTC) !== 'INF').map(p => text(p.PaxID));",
                          "    const itemById = {};",
                          "    toArray(offer.OfferItem).forEach(it => {",
                          "        const el = it.Eligibility || {};",
                          "        itemById[text(it.OfferItemID)] = { pax: toArray(el.PaxRefID).map(text), price: it.UnitPrice && it.UnitPrice.TotalAmount };",
                          "    });",
                          "    const seatMaps = toArray(resp.SeatMap);",
                          "    const seats = [];",
                          "    seatMaps.forEach((map, mapIndex) => toArray(map.CabinCompartment).forEach((cabin, cabinIndex) => toArray(cabin.SeatRow).forEach(row => toArray(row.Seat).forEach(seat => {",
                          "        const refs = toArray(seat.OfferItemRefID).map(text).filter(r => itemById[r]);",
                          "        if (text(seat.OccupationStatusCode) !== 'F' || !seat.ColumnID || !seat.RowNumber || !refs.length) return;",
                          "        if (toArray(seat.SeatCharacteristicCode).map(text).includes(RESTRICTED_SEAT)) return;",
                          "        seats.push({ mapIndex, cabinIndex, row: text(seat.RowNumber), column: text(seat.ColumnID), refs });",
                          "    }))));",
                          "    const selectable = seats.filter(s => !skipRows.has(s.row));",
                          "    pm.test('at least one free seat outside the excluded rows [' + [...skipRows].join(',') + ']', () => pm.expect(selectable.length, 'free seats: ' + seats.length).to.be.above(0));",
                          "",
                          "    const selections = [];",
                          "    seatMaps.forEach((map, mapIndex) => {",
                          "        const taken = new Set();",
                          "        seatPax.forEach(pax => {",
                          "            const seat = selectable.find(s => s.mapIndex === mapIndex && !taken.has(s.row + s.column) && s.refs.some(r => itemById[r].pax.includes(pax)));",
                          "            if (!seat) return;",
                          "            const ref = seat.refs.find(r => itemById[r].pax.includes(pax));",
                          "            taken.add(seat.row + seat.column);",
                          "            selections.push({ pax, mapIndex, seat, ref, price: itemById[ref].price });",
                          "        });",
                          "    });",
                          "    pm.test('one seat selected per seated passenger (' + seatPax.join(',') + ') and per seat map (' + seatMaps.length + ')', () => pm.expect(selections.length).to.equal(seatPax.length * seatMaps.length));",
                          "    if (!selections.length) return;",
                          "",
                          "    const frag = p => block(selections.flatMap(s => ['<' + p + ':SelectedOfferItem>', '    <' + p + ':OfferItemRefID>' + s.ref + '</' + p + ':OfferItemRefID>', '    <' + p + ':PaxRefID>' + s.pax + '</' + p + ':PaxRefID>', '    <' + p + ':SelectedSeat>', '        <' + p + ':ColumnID>' + s.seat.column + '</' + p + ':ColumnID>', '        <' + p + ':SeatRowNumber>' + s.seat.row + '</' + p + ':SeatRowNumber>', '    </' + p + ':SelectedSeat>', '</' + p + ':SelectedOfferItem>']), '                    ');",
                          "    const seatTotal = selections.reduce((sum, s) => sum + (Number(text(s.price)) || 0), 0);",
                          "    pm.environment.set('seatOfferId', text(offer.OfferID));",
                          "    pm.environment.set('seatOfferOwnerCode', text(offer.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    pm.environment.set('seatCount', String(selections.length));",
                          "    pm.environment.set('seatSelectedOfferItemsXml_cns', frag('cns'));",
                          "    pm.environment.set('seatSelectedOfferItemsXml_ns2', frag('ns2'));",
                          "    pm.environment.set('seatTotalPrice', String(seatTotal));",
                          "    const cur = selections.map(s => curOf(s.price)).find(Boolean);",
                          "    if (cur) pm.environment.set('seatCurrency', cur);",
                          "    pm.environment.set('seatSummary', selections.map(s => s.pax + ' ' + s.seat.row + s.seat.column + ' (map ' + s.mapIndex + ')').join(', '));",
                          "    selections.forEach(s => { pm.environment.set('seatOfferItemId_' + s.pax, s.ref); pm.environment.set('seatLabel_' + s.pax, s.seat.row + s.seat.column); });",
                          "",
                          "    console.log('seatOfferId =', text(offer.OfferID), '| seat maps', seatMaps.length, '| free seats', seats.length, '| selectable', selectable.length, '| seat total', seatTotal, cur || '');",
                          "    selections.forEach(s => console.log('  ' + s.pax, 'seat', s.seat.row + s.seat.column, 'map', s.mapIndex, 'compartment', s.seat.cabinIndex, text(s.price), curOf(s.price), s.ref));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_SeatAvailabilityRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                    xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:SeatAvailCoreRequest>\n            <cns:OrderRequest>\n                <cns:Order>\n                    <cns:OrderID>{{orderId}}</cns:OrderID>\n                    <!-- The flight order items of every seated passenger (the infant is left out), from OrderRetrieve. -->\n                    {{orderItemRefsXml_cns}}\n                    <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n                </cns:Order>\n            </cns:OrderRequest>\n        </cns:SeatAvailCoreRequest>\n    </Request>\n</IATA_SeatAvailabilityRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/SeatAvailability",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "SeatAvailability"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "5. OrderQuote [OW] [1ADT, 1CHD, 1INF] with Seat",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// The gateway answers OrderQuote with IATA_OrderReshopRS: the order as it stands plus ReshopResults.",
                          "const EXPECT_ADDED_ITEM = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderReshopRS || result.IATA_OrderQuoteRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('quoted order returned', () => { pm.expect(order, 'no Order in the response').to.exist; pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')); });",
                          "    const results = resp.ReshopResults || {};",
                          "    if (EXPECT_ADDED_ITEM) {",
                          "        const added = toArray(results.ReshopOffers).flatMap(r => toArray(r.RequotedOffer)).flatMap(r => toArray(r.AddedOfferItem));",
                          "        pm.test('quote contains the added offer item', () => { pm.expect(added.length, 'no RequotedOffer/AddedOfferItem').to.be.above(0); added.forEach(a => pm.expect(text(a.OfferItemID)).to.be.a('string').and.not.empty); });",
                          "        added.forEach(a => { const diff = a.ReshopPrice && a.ReshopPrice.PriceDifferential && a.ReshopPrice.PriceDifferential.DiffPrice && a.ReshopPrice.PriceDifferential.DiffPrice.Price && a.ReshopPrice.PriceDifferential.DiffPrice.Price.TotalAmount; console.log('added item', text(a.OfferItemID), text(a.PaxRefID || (a.FareDetail && a.FareDetail.PaxRefID)), 'to pay', text(diff), curOf(diff)); });",
                          "    } else {",
                          "        const noChange = results.NoChangeInd && (text(results.NoChangeInd.NoChangeInd) || text(results.NoChangeInd));",
                          "        pm.test('no change on the quoted order (NoChangeInd)', () => pm.expect(String(noChange), 'ReshopResults/NoChangeInd').to.equal('true'));",
                          "    }",
                          "    if (order) console.log('quoted order', text(order.OrderID), '| status', text(order.StatusCode), '| total', text(order.TotalPrice && order.TotalPrice.TotalAmount), curOf(order.TotalPrice && order.TotalPrice.TotalAmount));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderQuoteRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <Payload>\n        <cns:ExistingOrder>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n        </cns:ExistingOrder>\n        <cns:SelectedOffers>\n            <cns:OfferRefID>{{seatOfferId}}</cns:OfferRefID>\n            <cns:OwnerCode>{{seatOfferOwnerCode}}</cns:OwnerCode>\n            {{seatSelectedOfferItemsXml_cns}}\n        </cns:SelectedOffers>\n    </Payload>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n</IATA_OrderQuoteRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderQuote",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderQuote"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "6. OrderChange [OW] [1ADT, 1CHD, 1INF] [ADD SEAT]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = true;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>{{$randomUUID}}</cns:CorrelationID>\n        <cns:Timestamp>{{today_th}}</cns:Timestamp>\n        <cns:TrxID>TRX-123456789</cns:TrxID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:ChangeOrderChoice>\n            <cns:AcceptSelectedQuotedOfferList>\n                <!-- Seat offer items from SeatAvailability by order (the ones OrderQuote just quoted). -->\n                <cns:SelectedPricedOffer>\n                    <cns:OfferRefID>{{seatOfferId}}</cns:OfferRefID>\n                    <cns:OwnerCode>{{seatOfferOwnerCode}}</cns:OwnerCode>\n                    {{seatSelectedOfferItemsXml_cns}}\n                </cns:SelectedPricedOffer>\n            </cns:AcceptSelectedQuotedOfferList>\n        </cns:ChangeOrderChoice>\n        <cns:Order>\n            <cns:OrderID>{{orderId}}</cns:OrderID>\n            <cns:OwnerCode>{{orderOwnerCode}}</cns:OwnerCode>\n        </cns:Order>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "7. OrderChange [OW] [1ADT, 1CHD, 1INF] [Pay] [CASH]",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = false;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = true;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = false;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderChangeRQ\n        xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n        xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\"\n        xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <POS>\n        <ns2:Country>\n            <ns2:CountryCode>FR</ns2:CountryCode>\n        </ns2:Country>\n    </POS>\n    <Request>\n        <ns2:Order>\n            <ns2:OrderID>{{orderId}}</ns2:OrderID>\n            <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n        </ns2:Order>\n        <!-- Pays the pending purchase: {{paymentAmount}} is the order total that the OrderCreate [Pay Later] /\n             OrderChange [ADD ...] response returned, and is cleared once paid (a second [Pay] is not sent).\n             Cash (CA) is the payment method supported on VI. Debit account is not supported on VI and a card\n             payment needs a PCI-Proxy token (see Order Change -> payment in the partner guide). -->\n        <ns2:PaymentFunctions>\n            <ns2:PaymentProcessingDetails>\n                <ns2:Amount CurCode=\"{{paymentCurCode}}\">{{paymentAmount}}</ns2:Amount>\n                <ns2:PaymentMethod>\n                    <ns2:OfflinePayment>\n                        <ns2:PaymentTypeCode>CA</ns2:PaymentTypeCode>\n                    </ns2:OfflinePayment>\n                </ns2:PaymentMethod>\n            </ns2:PaymentProcessingDetails>\n        </ns2:PaymentFunctions>\n    </Request>\n</IATA_OrderChangeRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderChange",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderChange"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "8. OrderRetrieve by OrderId",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "type": "text/javascript",
                        "packages": {},
                        "exec": [
                          "const xml2js = require('xml2js');",
                          "const toArray = v => (v == null ? [] : (Array.isArray(v) ? v : [v]));",
                          "const text = n => (n == null ? null : (typeof n === 'object' ? (n._ != null ? String(n._) : null) : String(n)));",
                          "const curOf = n => (n && n.$ && n.$.CurCode) || null;",
                          "// Multi-line XML fragment for a {{variable}} that sits alone on an indented line of the body.",
                          "const block = (lines, indent) => lines.map((l, i) => (i ? indent : '') + l).join('\\n');",
                          "function parse(xml, cb) {",
                          "    xml2js.parseString(xml, { tagNameProcessors: [xml2js.processors.stripPrefix], explicitArray: false, ignoreAttrs: false }, (err, result) => {",
                          "        if (err) { pm.test('response is well-formed XML', () => { throw err; }); return; }",
                          "        cb(result);",
                          "    });",
                          "}",
                          "// Reads IATA_OrderViewRS: order id and owner, items, booking references (one PNR per carrier on VI),",
                          "// ticket numbers and the total, and exports them for the next steps.",
                          "const EXPECT_MIN_ITEMS = 0;",
                          "const EXPECT_TICKETS = true;",
                          "const EXPECT_SERVICE_ITEM = false;",
                          "const EXPECT_CONFIRMED_SERVICE_ITEM = false;",
                          "const CHECK_PAID_AMOUNT = false;          // this request paid {{paymentAmount}}: the order total must grow by exactly that",
                          "const SET_PAYMENT = false;                // the order now has a pending purchase: the next [Pay] request pays this total",
                          "const RECORD_PAID = false;                // the order was paid in this request: remember the total for the post-booking payment check",
                          "const MUST_MATCH_ORDER_ID = true;",
                          "parse(pm.response.text(), result => {",
                          "    const rs = result.IATA_OrderViewRS || {};",
                          "    const resp = rs.Response || {};",
                          "    const order = resp.Order;",
                          "    pm.test('OrderViewRS with an OrderID', () => { pm.expect(order, 'no Order in OrderViewRS').to.exist; pm.expect(text(order.OrderID)).to.be.a('string').and.not.empty; });",
                          "    if (!order) return;",
                          "    if (MUST_MATCH_ORDER_ID) pm.test('the order asked for is the order returned', () => pm.expect(text(order.OrderID)).to.equal(pm.environment.get('orderId')));",
                          "",
                          "    const paxList = toArray(resp.DataLists && resp.DataLists.PaxList && resp.DataLists.PaxList.Pax);",
                          "    const ptcOf = {};",
                          "    paxList.forEach(p => { ptcOf[text(p.PaxID)] = text(p.PTC); });",
                          "    const items = toArray(order.OrderItem).map(it => {",
                          "        const svc = toArray(it.Service)[0] || {};",
                          "        const assoc = svc.OrderServiceAssociation || {};",
                          "        // Two statuses per item: OrderItem/StatusCode (ACTIVE once booked) and Service/StatusCode (REQUESTED -> CONFIRMED once paid).",
                          "        return { id: text(it.OrderItemID), pax: text(svc.PaxRefID), pnr: text(svc.BookingRef && svc.BookingRef.BookingID), status: text(it.StatusCode), serviceStatus: text(svc.StatusCode), service: !!assoc.ServiceDefinitionRef, owner: text(it.OwnerCode) };",
                          "    });",
                          "    const total = order.TotalPrice && order.TotalPrice.TotalAmount;",
                          "    const pnrs = [...new Set(items.map(i => i.pnr).filter(Boolean))];",
                          "    const ticketDocs = toArray(resp.TicketDocInfo);",
                          "    const tickets = [...new Set(ticketDocs.map(t => text((toArray(t.Ticket)[0] || {}).TicketNumber)).filter(Boolean))];",
                          "    const ticketedPax = new Set(ticketDocs.map(t => text(t.PaxRefID)));",
                          "",
                          "    pm.environment.set('orderId', text(order.OrderID));",
                          "    pm.environment.set('orderOwnerCode', text(order.OwnerCode) || pm.variables.get('ownerCode'));",
                          "    if (text(order.StatusCode)) pm.environment.set('orderStatus', text(order.StatusCode));",
                          "    pm.environment.set('orderItemCount', String(items.length));",
                          "    items.forEach((i, n) => pm.environment.set('orderItemId' + n, i.id));",
                          "    if (total) { pm.environment.set('totalPrice', text(total)); pm.environment.set('totalCurCode', curOf(total)); }",
                          "    if (pnrs.length) { pm.environment.set('bookingId', pnrs[0]); pm.environment.set('bookingIds', pnrs.join(',')); }",
                          "    pm.environment.set('ticketCount', String(tickets.length));",
                          "    const seatable = items.filter(i => !i.service && ptcOf[i.pax] !== 'INF');",
                          "    pm.environment.set('orderItemRefsXml_cns', block(seatable.flatMap(i => ['<cns:OrderItem>', '    <cns:OrderItemID>' + i.id + '</cns:OrderItemID>', '</cns:OrderItem>']), '                    '));",
                          "",
                          "    pm.test('order total with currency present', () => { pm.expect(text(total), 'TotalAmount').to.be.a('string').and.not.empty; pm.expect(curOf(total), 'CurCode').to.be.a('string').and.not.empty; });",
                          "    if (EXPECT_MIN_ITEMS > 0) pm.test('order carries every selected item (' + EXPECT_MIN_ITEMS + ')', () => pm.expect(items.length).to.be.at.least(EXPECT_MIN_ITEMS));",
                          "    pm.test('booking reference (PNR) present', () => pm.expect(pnrs.length, 'no Service/BookingRef/BookingID on any order item').to.be.above(0));",
                          "    if (EXPECT_SERVICE_ITEM) pm.test('order contains the added service item', () => pm.expect(items.some(i => i.service), 'no order item with a ServiceDefinitionRef').to.be.true);",
                          "    if (EXPECT_CONFIRMED_SERVICE_ITEM) pm.test('the added service item is CONFIRMED', () => pm.expect(items.filter(i => i.service).map(i => i.serviceStatus), 'Service/StatusCode of the service items').to.include('CONFIRMED'));",
                          "    if (EXPECT_TICKETS) pm.test('ticket issued for every passenger', () => {",
                          "        pm.expect(tickets.length, 'no TicketDocInfo/Ticket/TicketNumber in the response').to.be.above(0);",
                          "        paxList.forEach(p => pm.expect(ticketedPax.has(text(p.PaxID)), 'no ticket for ' + text(p.PaxID) + ' (' + text(p.PTC) + ')').to.be.true);",
                          "    });",
                          "    if (CHECK_PAID_AMOUNT) {",
                          "        const paid = Number(pm.environment.get('paymentAmount')), before = Number(pm.environment.get('paidBefore') || 0);",
                          "        pm.test('order total equals what was paid before (' + before + ') plus this payment (' + paid + ')', () => pm.expect(Number(text(total)), 'order total ' + text(total)).to.equal(Math.round((before + paid) * 100) / 100));",
                          "        // Paid: forget the amount so that running [Pay] again is skipped instead of charging the order twice.",
                          "        if (pm.response.code === 200) { pm.environment.unset('paymentAmount'); pm.environment.unset('paymentCurCode'); pm.environment.set('paidBefore', text(total)); }",
                          "    }",
                          "    if (SET_PAYMENT && total) { pm.environment.set('paymentAmount', text(total)); pm.environment.set('paymentCurCode', curOf(total)); }",
                          "    if (RECORD_PAID && total) pm.environment.set('paidBefore', text(total));",
                          "",
                          "    console.log('orderId =', text(order.OrderID), '| owner', text(order.OwnerCode), '| status', text(order.StatusCode), '| total', text(total), curOf(total), '| PNR', pnrs.join('/'), '| tickets', tickets.length);",
                          "    items.forEach((i, n) => console.log('  orderItemId' + n, i.owner, i.pax, i.service ? 'service' : 'flight', i.status + '/' + i.serviceStatus, i.pnr, i.id));",
                          "});"
                        ]
                      }
                    }
                  ],
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-api-key",
                        "value": "{{x-api-key}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<IATA_OrderRetrieveRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\" xmlns:ns2=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n    <DistributionChain>\n        <ns2:DistributionChainLink>\n            <ns2:Ordinal>1</ns2:Ordinal>\n            <ns2:OrgRole>{{OrgRole}}</ns2:OrgRole>\n            <ns2:ParticipatingOrg>\n                <ns2:Name>{{partnerName}}</ns2:Name>\n                <ns2:OrgID>{{partnerId}}</ns2:OrgID>\n            </ns2:ParticipatingOrg>\n        </ns2:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <ns2:CorrelationID>{{$randomUUID}}</ns2:CorrelationID>\n        <ns2:Timestamp>{{today_th}}</ns2:Timestamp>\n        <ns2:TrxID>TRX-123456789</ns2:TrxID>\n        <ns2:VersionNumber>21.3</ns2:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <ns2:OrderValidationFilterCriteria>\n            <ns2:OrderFilterCriteria>\n                <ns2:OrderID>{{orderId}}</ns2:OrderID>\n                <ns2:OwnerCode>{{orderOwnerCode}}</ns2:OwnerCode>\n            </ns2:OrderFilterCriteria>\n        </ns2:OrderValidationFilterCriteria>\n    </Request>\n</IATA_OrderRetrieveRQ>",
                      "options": {
                        "raw": {
                          "language": "xml"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{ndc-gateway-url}}/v21.3.5/OrderRetrieve",
                      "host": [
                        "{{ndc-gateway-url}}"
                      ],
                      "path": [
                        "v21.3.5",
                        "OrderRetrieve"
                      ]
                    }
                  },
                  "response": []
                }
              ]
            }
          ],
          "description": "Post-booking **seat** on an existing paid booking. The folder creates its own paid order first: shop -> price -> OrderCreate [Instant CASH Pay] -> SeatAvailability by order -> OrderQuote (seat) -> OrderChange [ADD SEAT] -> OrderChange [PAY] [CASH] -> retrieve.\n\nKnown limit (dev, 2026-10-06): SeatAvailability by order answers 422 / 911 `Unprocessable Entity - Can't find company code`; the seat steps that follow are skipped because no seat offer exists."
        }
      ],
      "description": "# UseCase - VI (Virtual Interline over NDC)\n\nThe same NDC 21.3.5 messages as the **UseCase** folder, adapted to a **Virtual Interline (VI)** sale: one itinerary stitched from two carriers on two different reservation systems, sold and paid as **one** NDC order. On the dev route **TLV -> LBV** leg 1 (TLV-POG) is flown by the AeroCRS carrier and leg 2 (POG-LBV) by the SMS carrier; the order comes back with one PNR and one ticket per carrier.\n\nWhat is different on VI, and what these requests take care of:\n\n- A VI offer carries **one offer item per passenger per leg** (OW: 6, RT: 12). OfferPrice and OrderCreate must select **all** of them with the PaxRefID the offer gives each item - the AirShopping / OfferPrice test scripts build that list (`{{shopSelectedOfferItemsXml_*}}`, `{{pricedSelectedOfferItemsXml_ns2}}`) so the bodies never hard-code item counts or passengers.\n- Every id a step needs is read from the previous response and stored in the **environment**; nothing is hard-coded. If a variable is missing (an earlier step failed) the request is **not sent** and fails with a \"precondition\" test instead of hitting the server with a stale id.\n- Payment is **cash (CA)** only. Debit-account payment is not supported on VI; card payment needs a PCI-Proxy token (see *Order Change -> payment* in the partner guide), so neither is included here.\n\n## Preconditions\n\n- Environment **NDC-VI** (`NDC-VI.postman_environment.json`): set `x-api-key` to your VI key - the key selects the tenant (`vindc-aero`) and the sales channel (`VI`). Optional inputs: `daysToDeparture` (default 2), `daysToReturn` (default 9), `myEmail`, `serviceCode` (default XBAG), `ancillaryLeg` (default 1), `excludedSeatRows` (default 1,2,3), `offerIndex` (default 0).\n- Travel dates are computed when a request runs: departure = today + daysToDeparture, return = today + daysToReturn. Passengers: 1 ADT + 1 CHD + 1 INF.\n- Run a use case **top to bottom** (Collection Runner or newman); the later requests of a use case depend on the earlier ones. *Retrieve booking* needs a create use case run first in the same session.\n\n## Not included - not supported on VI as of 2026-10-06\n\n- **Cancel booking** - OrderReshop (cancel) answers 404 / 911 `Not Found - No static resource reshop/cancel`.\n- **Cancel segment** - OrderReshop is rejected before any reshop (a VI origin-destination has 6 items); partial cancel is not available.\n- **Rebook** - OrderReshop (reshop) answers 422 / 911 `No reservation flight matches the journey segment for rebook search`.\n- **Name change** - OrderReshop (passenger change) answers 404 / 911 `Not Found - No static resource reshop/passenger-changes`.\n\n## Known limits in the included use cases (dev, 2026-10-06)\n\nSee the description of each use case folder. In short:\n\n- Ancillaries by offer (ServiceList / SeatAvailability) are available for the AeroCRS leg (`ancillaryLeg` = 1). Asking for the SMS leg (`ancillaryLeg` = 2) or for both legs at once answers 422 / 911 `Unprocessable Entity - No segment attributes found for segment key: FlightSegmentEventKey{flightDesignator=W10113, ...}` (ServiceList) / `No OfferItemSegmentAttributes found for key FlightSegmentEventKey{...}` (SeatAvailability).\n- Ancillary services must be requested in the currency of the flight offer / order (these requests do). Asking in another currency ends in `Currency mismatch: EUR/USD` at OfferPrice, OrderCreate or OrderRetrieve.\n- Paying an order that carries **seats**: OrderChange [Pay] answers 200 **without** ticket numbers; the order stays OPEN with the seat items REQUESTED. Do not send the payment again.\n- **SeatAvailability by order** answers 422 / 911 `Unprocessable Entity - Can't find company code`.\n- After paying a service added to an existing order, OrderRetrieve sometimes returns only the service items (flights, passengers CHD/INF and ticket PaxRefIDs missing from the view).\n- Dev inventory: a flight has a finite infant allotment. After several runs on the same date OrderCreate answers 422 / 911 `Failed to create reservation - 422 Number of INFT SSR is exhausted on this flight.` - change `daysToDeparture`.",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "packages": {},
            "exec": [
              "// ---- UseCase - VI : shared pre-request (runs before every request of this folder) ----",
              "// 1. Timestamp, travel dates and passenger dates used by the request bodies.",
              "// 2. Guard: when a {{variable}} used by this request is not set, the request is NOT sent. A missing",
              "//    variable means an earlier step failed (or no create flow has run yet), and sending the body",
              "//    anyway would hit the server with a literal \"{{orderId}}\" or with a stale id.",
              "const pad = (n, w = 2) => String(n).padStart(w, '0');",
              "const fmtDate = d => d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate());",
              "const fmtTs = (d, tzMin) => {",
              "    const s = tzMin >= 0 ? '+' : '-', a = Math.abs(tzMin);",
              "    return fmtDate(d) + 'T' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()) + '.' + pad(d.getMilliseconds(), 3) + s + pad(Math.floor(a / 60)) + ':' + pad(a % 60);",
              "};",
              "const now = new Date();",
              "const addDays = n => { const d = new Date(now); d.setDate(d.getDate() + n); return d; };",
              "const shift = (years, months) => { const d = new Date(now); d.setFullYear(d.getFullYear() + years); d.setMonth(d.getMonth() + months); return d; };",
              "const daysToDeparture = Number(pm.variables.get('daysToDeparture') || 2);",
              "const daysToReturn = Number(pm.variables.get('daysToReturn') || 9);",
              "",
              "pm.environment.set('today_th', fmtTs(now, 420));",
              "pm.environment.set('departureDate', fmtDate(addDays(daysToDeparture)));",
              "pm.environment.set('arrivalDate', fmtDate(addDays(daysToDeparture + 1)));",
              "pm.environment.set('nextDepartureDate', fmtDate(addDays(daysToReturn)));",
              "pm.environment.set('nextArrivalDate', fmtDate(addDays(daysToReturn + 1)));",
              "pm.environment.set('adultBirthDate', fmtDate(shift(-30, 0)));",
              "pm.environment.set('childBirthDate', fmtDate(shift(-3, 0)));",
              "pm.environment.set('infantBirthDate', fmtDate(shift(0, -1)));",
              "pm.environment.set('expiryDate', fmtDate(shift(10, 0)));",
              "",
              "const raw = (pm.request.body && pm.request.body.raw) || '';",
              "const used = [...new Set((raw.match(/\\{\\{([^}]+)\\}\\}/g) || []).map(v => v.slice(2, -2).trim()))].filter(n => !n.startsWith('$'));",
              "const missing = used.filter(n => { const v = pm.variables.get(n); return v === undefined || v === null || String(v) === ''; });",
              "if (missing.length) {",
              "    pm.test('precondition: every {{variable}} used by this request is set', () => {",
              "        pm.expect.fail('Request NOT sent - unresolved variable(s): ' + missing.join(', ') + '. An earlier step of this use case failed, or run a create use case first.');",
              "    });",
              "    pm.execution.skipRequest();",
              "}"
            ]
          }
        },
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "packages": {},
            "exec": [
              "// ---- UseCase - VI : shared tests (run after every request of this folder) ----",
              "pm.test('HTTP 200', () => pm.response.to.have.status(200));",
              "",
              "pm.test('no unresolved {{variable}} reached the server', () => {",
              "    const sent = (pm.request.body && pm.request.body.raw) || '';",
              "    const left = sent.match(/\\{\\{[^}]+\\}\\}/g) || [];",
              "    pm.expect(left, 'unresolved: ' + left.join(', ')).to.be.empty;",
              "});",
              "",
              "// Every NDC error carries <ErrorID>, which equals the gateway CorrelationId - quote it to support.",
              "const body = pm.response.text();",
              "const ndcError = body.match(/<(?:\\w+:)?Error>[\\s\\S]*?<(?:\\w+:)?Code>([^<]*)<\\/(?:\\w+:)?Code>[\\s\\S]*?<(?:\\w+:)?DescText>([^<]*)<\\/(?:\\w+:)?DescText>(?:[\\s\\S]*?<(?:\\w+:)?ErrorID>([^<]*)<\\/(?:\\w+:)?ErrorID>)?/);",
              "pm.test('no NDC <Error> in the response', () => {",
              "    pm.expect(ndcError, ndcError ? 'NDC error ' + ndcError[1] + ': ' + ndcError[2] + (ndcError[3] ? ' (ErrorID ' + ndcError[3] + ')' : '') : '').to.be.null;",
              "});",
              "if (ndcError) console.warn('NDC error', ndcError[1], '-', ndcError[2], ndcError[3] ? '| ErrorID ' + ndcError[3] : '');"
            ]
          }
        }
      ]
    },
    {
      "name": "AirlineProfile",
      "request": {
        "auth": {
          "type": "noauth"
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/xml"
          },
          {
            "key": "x-api-key",
            "value": "{{x-api-key}}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<IATA_AirlineProfileRQ xmlns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersMessage\"\n                       xmlns:cns=\"http://www.iata.org/IATA/2015/EASD/00/IATA_OffersAndOrdersCommonTypes\">\n    <DistributionChain>\n        <cns:DistributionChainLink>\n            <cns:Ordinal>1</cns:Ordinal>\n            <cns:OrgRole>{{OrgRole}}</cns:OrgRole>\n            <cns:ParticipatingOrg>\n                <cns:Name>{{partnerName}}</cns:Name>\n                <cns:OrgID>{{partnerId}}</cns:OrgID>\n            </cns:ParticipatingOrg>\n        </cns:DistributionChainLink>\n    </DistributionChain>\n    <PayloadAttributes>\n        <cns:CorrelationID>AP-001-2026</cns:CorrelationID>\n        <cns:VersionNumber>21.3</cns:VersionNumber>\n    </PayloadAttributes>\n    <Request>\n        <cns:AirlineProfileFilterCriteria>\n            <cns:AllProfilesInd>true</cns:AllProfilesInd>\n        </cns:AirlineProfileFilterCriteria>\n    </Request>\n</IATA_AirlineProfileRQ>",
          "options": {
            "raw": {
              "language": "xml"
            }
          }
        },
        "url": {
          "raw": "{{ndc-gateway-url}}/v21.3.5/AirlineProfile",
          "host": [
            "{{ndc-gateway-url}}"
          ],
          "path": [
            "v21.3.5",
            "AirlineProfile"
          ]
        }
      },
      "response": []
    }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "service-code",
      "value": "XBAG"
    },
    {
      "key": "ndc-gateway-url",
      "value": ""
    },
    {
      "key": "reshopOfferId",
      "value": ""
    },
    {
      "key": "reshopOfferItemId0",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice0",
      "value": ""
    },
    {
      "key": "reshopOfferItemId1",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice1",
      "value": ""
    },
    {
      "key": "reshopOfferItemId2",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice2",
      "value": ""
    },
    {
      "key": "reshopOfferItemId3",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice3",
      "value": ""
    },
    {
      "key": "reshopOfferItemId4",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice4",
      "value": ""
    },
    {
      "key": "reshopOfferItemId5",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice5",
      "value": ""
    },
    {
      "key": "reshopOfferItemId6",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice6",
      "value": ""
    },
    {
      "key": "reshopOfferItemId7",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice7",
      "value": ""
    },
    {
      "key": "reshopOfferItemId8",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice8",
      "value": ""
    },
    {
      "key": "reshopOfferItemId9",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice9",
      "value": ""
    },
    {
      "key": "reshopOfferItemId10",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice10",
      "value": ""
    },
    {
      "key": "reshopOfferItemId11",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice11",
      "value": ""
    },
    {
      "key": "reshopOfferItemId12",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice12",
      "value": ""
    },
    {
      "key": "reshopOfferItemId13",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice13",
      "value": ""
    },
    {
      "key": "reshopOfferItemId14",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice14",
      "value": ""
    },
    {
      "key": "reshopOfferItemId15",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice15",
      "value": ""
    },
    {
      "key": "reshopOfferItemId16",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice16",
      "value": ""
    },
    {
      "key": "serviceOfferItemId0",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice0",
      "value": ""
    },
    {
      "key": "serviceOfferItemId1",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice1",
      "value": ""
    },
    {
      "key": "serviceOfferItemId2",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice2",
      "value": ""
    },
    {
      "key": "serviceOfferItemId3",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice3",
      "value": ""
    },
    {
      "key": "serviceOfferItemId4",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice4",
      "value": ""
    },
    {
      "key": "serviceOfferItemId5",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice5",
      "value": ""
    },
    {
      "key": "serviceOfferItemId6",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice6",
      "value": ""
    },
    {
      "key": "serviceOfferItemId7",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice7",
      "value": ""
    },
    {
      "key": "serviceOfferItemId8",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice8",
      "value": ""
    },
    {
      "key": "serviceOfferItemId9",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice9",
      "value": ""
    },
    {
      "key": "serviceOfferItemId10",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice10",
      "value": ""
    },
    {
      "key": "serviceOfferItemId11",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice11",
      "value": ""
    },
    {
      "key": "serviceOfferItemId12",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice12",
      "value": ""
    },
    {
      "key": "serviceOfferItemId13",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice13",
      "value": ""
    },
    {
      "key": "serviceOfferItemId14",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice14",
      "value": ""
    },
    {
      "key": "serviceOfferItemId15",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice15",
      "value": ""
    },
    {
      "key": "serviceOfferItemId16",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice16",
      "value": ""
    },
    {
      "key": "reshopOfferItemId17",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice17",
      "value": ""
    },
    {
      "key": "reshopOfferItemId18",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice18",
      "value": ""
    },
    {
      "key": "reshopOfferItemId19",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice19",
      "value": ""
    },
    {
      "key": "reshopOfferItemId20",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice20",
      "value": ""
    },
    {
      "key": "reshopOfferItemId21",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice21",
      "value": ""
    },
    {
      "key": "reshopOfferItemId22",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice22",
      "value": ""
    },
    {
      "key": "reshopOfferItemId23",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice23",
      "value": ""
    },
    {
      "key": "reshopOfferItemId24",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice24",
      "value": ""
    },
    {
      "key": "reshopOfferItemId25",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice25",
      "value": ""
    },
    {
      "key": "reshopOfferItemId26",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice26",
      "value": ""
    },
    {
      "key": "reshopOfferItemId27",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice27",
      "value": ""
    },
    {
      "key": "reshopOfferItemId28",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice28",
      "value": ""
    },
    {
      "key": "reshopOfferItemId29",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice29",
      "value": ""
    },
    {
      "key": "reshopOfferItemId30",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice30",
      "value": ""
    },
    {
      "key": "reshopOfferItemId31",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice31",
      "value": ""
    },
    {
      "key": "reshopOfferItemId32",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice32",
      "value": ""
    },
    {
      "key": "reshopOfferItemId33",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice33",
      "value": ""
    },
    {
      "key": "reshopOfferItemId34",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice34",
      "value": ""
    },
    {
      "key": "reshopOfferItemId35",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice35",
      "value": ""
    },
    {
      "key": "reshopOfferItemId36",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice36",
      "value": ""
    },
    {
      "key": "reshopOfferItemId37",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice37",
      "value": ""
    },
    {
      "key": "reshopOfferItemId38",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice38",
      "value": ""
    },
    {
      "key": "reshopOfferItemId39",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice39",
      "value": ""
    },
    {
      "key": "reshopOfferItemId40",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice40",
      "value": ""
    },
    {
      "key": "reshopOfferItemId41",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice41",
      "value": ""
    },
    {
      "key": "reshopOfferItemId42",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice42",
      "value": ""
    },
    {
      "key": "reshopOfferItemId43",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice43",
      "value": ""
    },
    {
      "key": "reshopOfferItemId44",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice44",
      "value": ""
    },
    {
      "key": "reshopOfferItemId45",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice45",
      "value": ""
    },
    {
      "key": "reshopOfferItemId46",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice46",
      "value": ""
    },
    {
      "key": "reshopOfferItemId47",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice47",
      "value": ""
    },
    {
      "key": "reshopOfferItemId48",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice48",
      "value": ""
    },
    {
      "key": "reshopOfferItemId49",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice49",
      "value": ""
    },
    {
      "key": "reshopOfferItemId50",
      "value": ""
    },
    {
      "key": "reshopOfferItemPrice50",
      "value": ""
    },
    {
      "key": "serviceOfferItemId17",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice17",
      "value": ""
    },
    {
      "key": "serviceOfferItemId18",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice18",
      "value": ""
    },
    {
      "key": "serviceOfferItemId19",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice19",
      "value": ""
    },
    {
      "key": "serviceOfferItemId20",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice20",
      "value": ""
    },
    {
      "key": "serviceOfferItemId21",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice21",
      "value": ""
    },
    {
      "key": "serviceOfferItemId22",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice22",
      "value": ""
    },
    {
      "key": "serviceOfferItemId23",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice23",
      "value": ""
    },
    {
      "key": "serviceOfferItemId24",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice24",
      "value": ""
    },
    {
      "key": "serviceOfferItemId25",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice25",
      "value": ""
    },
    {
      "key": "serviceOfferItemId26",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice26",
      "value": ""
    },
    {
      "key": "serviceOfferItemId27",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice27",
      "value": ""
    },
    {
      "key": "serviceOfferItemId28",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice28",
      "value": ""
    },
    {
      "key": "serviceOfferItemId29",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice29",
      "value": ""
    },
    {
      "key": "serviceOfferItemId30",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice30",
      "value": ""
    },
    {
      "key": "serviceOfferItemId31",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice31",
      "value": ""
    },
    {
      "key": "serviceOfferItemId32",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice32",
      "value": ""
    },
    {
      "key": "serviceOfferItemId33",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice33",
      "value": ""
    },
    {
      "key": "serviceOfferItemId34",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice34",
      "value": ""
    },
    {
      "key": "serviceOfferItemId35",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice35",
      "value": ""
    },
    {
      "key": "serviceOfferItemId36",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice36",
      "value": ""
    },
    {
      "key": "serviceOfferItemId37",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice37",
      "value": ""
    },
    {
      "key": "serviceOfferItemId38",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice38",
      "value": ""
    },
    {
      "key": "serviceOfferItemId39",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice39",
      "value": ""
    },
    {
      "key": "serviceOfferItemId40",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice40",
      "value": ""
    },
    {
      "key": "serviceOfferItemId41",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice41",
      "value": ""
    },
    {
      "key": "serviceOfferItemId42",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice42",
      "value": ""
    },
    {
      "key": "serviceOfferItemId43",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice43",
      "value": ""
    },
    {
      "key": "serviceOfferItemId44",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice44",
      "value": ""
    },
    {
      "key": "serviceOfferItemId45",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice45",
      "value": ""
    },
    {
      "key": "serviceOfferItemId46",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice46",
      "value": ""
    },
    {
      "key": "serviceOfferItemId47",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice47",
      "value": ""
    },
    {
      "key": "serviceOfferItemId48",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice48",
      "value": ""
    },
    {
      "key": "serviceOfferItemId49",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice49",
      "value": ""
    },
    {
      "key": "serviceOfferItemId50",
      "value": ""
    },
    {
      "key": "serviceOfferItemPrice50",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount0",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode0",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount1",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode1",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount2",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode2",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount3",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode3",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount4",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode4",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount5",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode5",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount6",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode6",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount7",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode7",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount8",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode8",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount9",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode9",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount10",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode10",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount11",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode11",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount12",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode12",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount13",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode13",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount14",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode14",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount15",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode15",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount16",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode16",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount17",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode17",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount18",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode18",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount19",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode19",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount20",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode20",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount21",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode21",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount22",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode22",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount23",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode23",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount24",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode24",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount25",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode25",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount26",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode26",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount27",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode27",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount28",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode28",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount29",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode29",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount30",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode30",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount31",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode31",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount32",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode32",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount33",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode33",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount34",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode34",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount35",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode35",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount36",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode36",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount37",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode37",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount38",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode38",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount39",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode39",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount40",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode40",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount41",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode41",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount42",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode42",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount43",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode43",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount44",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode44",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount45",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode45",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount46",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode46",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount47",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode47",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount48",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode48",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount49",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode49",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount50",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode50",
      "value": ""
    },
    {
      "key": "serviceOfferItemCount",
      "value": ""
    },
    {
      "key": "serviceOfferId",
      "value": ""
    },
    {
      "key": "serviceOfferTotalAmount",
      "value": ""
    },
    {
      "key": "serviceOfferCurCode",
      "value": ""
    },
    {
      "key": "serviceOfferItemId",
      "value": ""
    },
    {
      "key": "serviceOfferItemTotalAmount",
      "value": ""
    },
    {
      "key": "serviceOfferItemCurCode",
      "value": ""
    }
  ]
}