{
  "info": {
    "name": "Bank Bridge - YSP card API",
    "description": "Postman -> middle layer (/api/card/*) -> YSP card API (or the YSP simulator).\n\nGenerated from the endpoint table by docs/postman/generate.exs; do not edit by hand.\n\nStart the simulator (port 4180) and the middle layer with YSP_CARD_BASE_URL pointing at it, then run the collection top to bottom against a freshly reset simulator (request 0 resets it). Variables: baseUrl (middle layer), simUrl (simulator, used by request 0), proxyNumber (seed card).\n\nRequests 3a to 3b and C2 to C3 show replay protection (the same txnRefNo twice is applied once); request 2 has no txnRefNo on purpose, so each of its calls is a new load. Folders: A read-only, B card setup and settings, C money movement. The 14 active card endpoints are covered; the other 26 are switched off and answer 404 endpoint_not_enabled. Every value in it is a fake test value.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "0. Reset simulator (optional)",
      "request": {
        "method": "POST",
        "header": [],
        "url": {
          "raw": "{{simUrl}}/_sim/reset",
          "host": [
            "{{simUrl}}"
          ],
          "path": [
            "_sim",
            "reset"
          ]
        },
        "description": "Puts the YSP simulator back to its seed data so the run is repeatable. Talks to the simulator directly, not the middle layer. Skip it when pointing at anything but the simulator."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('simulator reset', function () {",
              "  pm.response.to.have.status(200);",
              "  pm.expect(pm.response.json().status).to.eql('reset');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "1. Balance",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "balance"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "standard endpoint. Sent to YSP as GET cardbalance (apikey APACBL)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('status 200 and YSP success', function () {",
              "  pm.response.to.have.status(200);",
              "  pm.expect(pm.response.json().responseCode).to.eql('00');",
              "});",
              "var details = pm.response.json().productInfo.details;",
              "pm.collectionVariables.set('startBalance', details.balanceAmount);",
              "pm.test('balance is returned', function () {",
              "  pm.expect(details.balanceAmount).to.be.a('string');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "2. Load card (+50 AED)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/load",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "load"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"productInfo\": {\n    \"productCode\": \"MCCAED\",\n    \"billingAmount\": \"50\",\n    \"billingCurrency\": \"AED\",\n    \"loadAmount\": \"50\",\n    \"loadCurrency\": \"AED\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "critical endpoint. Sent to YSP as POST accountfunding (apikey APLCRD). txnRefNo is left out on purpose: the middle layer generates a fresh one each call. YSP rejects a reused txnRefNo with TIDEXT."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('status 200 and YSP success', function () {",
              "  pm.response.to.have.status(200);",
              "  pm.expect(pm.response.json().responseCode).to.eql('00');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "3. Balance after load",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "balance"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "standard endpoint. Sent to YSP as GET cardbalance (apikey APACBL)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('balance went up by 50', function () {",
              "  var now = parseInt(pm.response.json().productInfo.details.balanceAmount, 10);",
              "  var before = parseInt(pm.collectionVariables.get('startBalance'), 10);",
              "  pm.expect(now).to.eql(before + 50);",
              "});",
              "pm.collectionVariables.set('balanceAfterLoad', pm.response.json().productInfo.details.balanceAmount);"
            ]
          }
        }
      ]
    },
    {
      "name": "3a. Load 10 AED with a fixed txnRefNo",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/load",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "load"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"txnRefNo\": \"{{loadRef}}\",\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"productInfo\": {\n    \"productCode\": \"MCCAED\",\n    \"billingAmount\": \"10\",\n    \"billingCurrency\": \"AED\",\n    \"loadAmount\": \"10\",\n    \"loadCurrency\": \"AED\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "critical endpoint. Sent to YSP as POST accountfunding (apikey APLCRD). Unlike request 2, this sends its own txnRefNo (made before sending), so 3b can repeat it. Without a txnRefNo the middle layer makes a new one each call, and every load goes through."
      },
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.collectionVariables.set('loadRef', 'PMLD' + Date.now());"
            ]
          }
        },
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('status 200 and YSP success', function () {",
              "  pm.response.to.have.status(200);",
              "  pm.expect(pm.response.json().responseCode).to.eql('00');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "3b. Send 3a again (TIDEXT, applied only once)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/load",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "load"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"txnRefNo\": \"{{loadRef}}\",\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"productInfo\": {\n    \"productCode\": \"MCCAED\",\n    \"billingAmount\": \"10\",\n    \"billingCurrency\": \"AED\",\n    \"loadAmount\": \"10\",\n    \"loadCurrency\": \"AED\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "critical endpoint. Sent to YSP as POST accountfunding (apikey APLCRD). The same txnRefNo as 3a: YSP refuses it, so the 10 AED is not loaded twice."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('status 200 and YSP code TIDEXT', function () {",
              "  pm.response.to.have.status(200);",
              "  pm.expect(pm.response.json().responseCode).to.eql('TIDEXT');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "3c. Balance: only 10 more than after request 3",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "balance"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "standard endpoint. Sent to YSP as GET cardbalance (apikey APACBL)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('the load was applied once, not twice', function () {",
              "  var now = parseInt(pm.response.json().productInfo.details.balanceAmount, 10);",
              "  var before = parseInt(pm.collectionVariables.get('balanceAfterLoad'), 10);",
              "  pm.expect(now).to.eql(before + 10);",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "A. Read-only endpoints",
      "description": "Batch A: the read-only endpoints. statusrequest needs a call to look up and transactiondetails needs a transaction, so A0 makes a small credit with a known txnRefNo; cardorderstatus needs an order, so A4 places one.",
      "item": [
        {
          "name": "A0. Credit 5 AED with a known txnRefNo (for A1 and A3)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/debitcreditaccount",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "debitcreditaccount"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"txnRefNo\": \"{{statusRef}}\",\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"productCode\": \"MCCAED\",\n  \"amount\": \"5\",\n  \"currency\": \"AED\",\n  \"flag\": \"C\",\n  \"remarks\": \"Postman setup\",\n  \"type\": \"BAT\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST debitcreditaccount (apikey APCRDR). Sets statusRef before sending. A txnRefNo can be used once, so a new one is made on every run. A1 looks this call up and A3 finds it in the transaction list."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.collectionVariables.set('statusRef', 'PMST' + Date.now());"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "A1. Status request (txnRefNo of A0)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/statusrequest",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "statusrequest"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"txnRefNo\": \"{{statusRef}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "standard endpoint. Sent to YSP as GET statusrequest (apikey APSTRQ). Looks up the earlier call by its txnRefNo."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "A2. Card details",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/carddetails",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "carddetails"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "standard endpoint. Sent to YSP as POST carddetails (apikey APCHDT)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});",
                  "pm.test('card is returned', function () { pm.expect(pm.response.json().proxyNumber).to.eql(pm.collectionVariables.get('proxyNumber')); });"
                ]
              }
            }
          ]
        },
        {
          "name": "A3. Transactions (yesterday to today)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/transactiondetails",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "transactiondetails"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"count\": \"5\",\n  \"fromDate\": \"{{fromDate}}\",\n  \"toDate\": \"{{toDate}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "standard endpoint. Sent to YSP as GET transactiondetails (apikey APXTXN). Dates are DDMMYYYY, computed before sending. YSP allows fromDate up to six months back and at most 90 days between the dates."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "function ddmmyyyy(d) { return ('0' + d.getUTCDate()).slice(-2) + ('0' + (d.getUTCMonth() + 1)).slice(-2) + d.getUTCFullYear(); }",
                  "var today = new Date();",
                  "pm.collectionVariables.set('toDate', ddmmyyyy(today));",
                  "pm.collectionVariables.set('fromDate', ddmmyyyy(new Date(today.getTime() - 86400000)));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "A4. Card order (for A5)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/cardorder",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "cardorder"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order\": {\n    \"productCode\": \"MCCAED\",\n    \"cardDesign\": \"BASEPL\",\n    \"quantity\": \"2\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "standard endpoint. Sent to YSP as POST cardorder (apikey APCROR)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});",
                  "pm.collectionVariables.set('invoiceNo', pm.response.json().invoiceNo);"
                ]
              }
            }
          ]
        },
        {
          "name": "A5. Card order status (invoice of A4)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/cardorderstatus",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "cardorderstatus"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"invoiceNo\": \"{{invoiceNo}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "standard endpoint. Sent to YSP as GET cardorderstatus (apikey APCOST)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "B. Card setup and settings",
      "description": "Batch B: purchase a card, activate it, update the customer and replace the card.",
      "item": [
        {
          "name": "B1. Purchase a card (customerregistration)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/customerregistration",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "customerregistration"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"customerId\": \"{{customerId}}\",\n  \"customerInfo\": {\n    \"emailAddress\": \"test@example.com\",\n    \"mobileNumber\": \"971500000000\"\n  },\n  \"loadDetails\": {\n    \"productCode\": \"MCCAED\",\n    \"billingAmount\": \"100\"\n  },\n  \"nameOnCard\": \"Test User\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST customerregistration (apikey APNCRD). Buys a new inactive card with 100 AED. Saves its proxy number and activation code for B2, B3 and B4."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.collectionVariables.set('customerId', 'PMCU' + Date.now());"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});",
                  "var b = pm.response.json();",
                  "pm.collectionVariables.set('newProxy', b.proxyNumber);",
                  "pm.collectionVariables.set('activationCode', b.activationCode);",
                  "pm.test('proxy number and activation code returned', function () { pm.expect(b.proxyNumber).to.match(/^\\d{12}$/); pm.expect(b.activationCode).to.match(/^\\d{6}$/); });"
                ]
              }
            }
          ]
        },
        {
          "name": "B2. Activate the new card",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/cardactivation",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "cardactivation"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"proxyNumber\": \"{{newProxy}}\",\n  \"activationCode\": \"{{activationCode}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST cardactivation (apikey APCDAC)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "B3. Update customer details",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/customerupdate",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "customerupdate"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"customerId\": \"{{customerId}}\",\n  \"customerInfo\": {\n    \"emailAddress\": \"new@example.com\",\n    \"mobileNumber\": \"971511111111\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "standard endpoint. Sent to YSP as POST customerupdate (apikey APUPCR)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "B4. Replace the new card (virtual to physical)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/cardreplacement",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "cardreplacement"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"proxyNumber\": \"{{newProxy}}\",\n  \"deliveryFlag\": \"B\",\n  \"type\": \"VP\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as GET cardreplacement (apikey APCDRP). The new card starts inactive and takes over the balance."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});",
                  "pm.test('a new proxy number is returned', function () { pm.expect(pm.response.json().newProxyNumber).to.match(/^\\d{12}$/); });"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "C. Money movement",
      "description": "Batch C (all critical): debit/credit and fund transfer. C2 and C3 show that a replayed txnRefNo is applied only once. Run before the card is locked.",
      "item": [
        {
          "name": "C1. Buy an active card to move money to",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/customerregistration",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "customerregistration"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"customerId\": \"{{moneyCustomerId}}\",\n  \"cardActivationFlag\": \"Y\",\n  \"customerInfo\": {\n    \"emailAddress\": \"test@example.com\",\n    \"mobileNumber\": \"971500000000\"\n  },\n  \"loadDetails\": {\n    \"productCode\": \"MCCAED\",\n    \"billingAmount\": \"100\"\n  },\n  \"nameOnCard\": \"Money Test\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST customerregistration (apikey APNCRD). Buys an active card with 100 AED to receive the transfer below. Saves its proxy number."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.collectionVariables.set('moneyCustomerId', 'PMMO' + Date.now());"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});",
                  "pm.collectionVariables.set('moneyProxy', pm.response.json().proxyNumber);"
                ]
              }
            }
          ]
        },
        {
          "name": "C2. Credit 25 AED (debitcreditaccount)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/debitcreditaccount",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "debitcreditaccount"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"txnRefNo\": \"{{adjustRef}}\",\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"productCode\": \"MCCAED\",\n  \"amount\": \"25\",\n  \"currency\": \"AED\",\n  \"flag\": \"C\",\n  \"remarks\": \"Postman adjustment\",\n  \"type\": \"BAT\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST debitcreditaccount (apikey APCRDR). Sets adjustRef before sending. C3 replays the same txnRefNo."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.collectionVariables.set('adjustRef', 'PMAD' + Date.now());"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "C3. Replay C2 (TIDEXT, applied only once)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/debitcreditaccount",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "debitcreditaccount"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"txnRefNo\": \"{{adjustRef}}\",\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"productCode\": \"MCCAED\",\n  \"amount\": \"25\",\n  \"currency\": \"AED\",\n  \"flag\": \"C\",\n  \"remarks\": \"Postman adjustment\",\n  \"type\": \"BAT\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST debitcreditaccount (apikey APCRDR). The same txnRefNo as C2: YSP refuses it and the 25 AED is not credited twice."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP code TIDEXT', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('TIDEXT');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "C4. Debit a 3 AED fee",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/debitcreditaccount",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "debitcreditaccount"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"productCode\": \"MCCAED\",\n  \"amount\": \"3\",\n  \"currency\": \"AED\",\n  \"flag\": \"D\",\n  \"remarks\": \"Postman fee\",\n  \"type\": \"FEE\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST debitcreditaccount (apikey APCRDR)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "C5. Transfer 30 AED to the new card (fundtransfer)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/card/fundtransfer",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "card",
                "fundtransfer"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sourceAccount\": {\n    \"proxyNumber\": \"{{proxyNumber}}\",\n    \"productCode\": \"MCCAED\",\n    \"accountCcy\": \"AED\"\n  },\n  \"destAccount\": {\n    \"proxyNumber\": \"{{moneyProxy}}\",\n    \"productCode\": \"MCCAED\",\n    \"accountCcy\": \"AED\",\n    \"amount\": \"30\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "critical endpoint. Sent to YSP as POST fundtransfer (apikey APFDTR)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('status 200 and YSP success', function () {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.json().responseCode).to.eql('00');",
                  "});",
                  "pm.test('destination amount is 30.00', function () { pm.expect(pm.response.json().destAccount.amount).to.eql('30.00'); });"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "4. Block (lock) card",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/block",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "block"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"flag\": \"L\",\n  \"reason\": \"Card reported lost\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "critical endpoint. Sent to YSP as POST cardlockunlock (apikey ACDSTS). flag: L lock, UL unlock, BL/BS/BD permanent block (lost/stolen/damaged)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('status 200 and YSP success', function () {",
              "  pm.response.to.have.status(200);",
              "  pm.expect(pm.response.json().responseCode).to.eql('00');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "5. Block again (YSP error passed through)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/block",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "block"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"proxyNumber\": \"{{proxyNumber}}\",\n  \"flag\": \"L\",\n  \"reason\": \"Card reported lost\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "critical endpoint. Sent to YSP as POST cardlockunlock (apikey ACDSTS)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('YSP error code comes back unchanged', function () {",
              "  pm.response.to.have.status(200);",
              "  var body = pm.response.json();",
              "  pm.expect(body.responseCode).to.eql('MATCRD');",
              "  pm.expect(body.responseText).to.be.a('string');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "6. Unknown card",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "balance"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"proxyNumber\": \"000000099999\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "standard endpoint. Sent to YSP as GET cardbalance (apikey APACBL)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('INVCRD for an unknown card', function () {",
              "  pm.expect(pm.response.json().responseCode).to.eql('INVCRD');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "7. Missing field (rejected before YSP)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/card/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "card",
            "balance"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "standard endpoint. Sent to YSP as GET cardbalance (apikey APACBL)."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('400 with a clear message', function () {",
              "  pm.response.to.have.status(400);",
              "  var body = pm.response.json();",
              "  pm.expect(body.error).to.eql('invalid_request');",
              "  pm.expect(body.message).to.include('proxyNumber');",
              "});"
            ]
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://localhost:4006"
    },
    {
      "key": "simUrl",
      "value": "http://localhost:4180"
    },
    {
      "key": "proxyNumber",
      "value": "000000012845"
    },
    {
      "key": "startBalance",
      "value": ""
    },
    {
      "key": "statusRef",
      "value": ""
    },
    {
      "key": "invoiceNo",
      "value": ""
    },
    {
      "key": "fromDate",
      "value": ""
    },
    {
      "key": "toDate",
      "value": ""
    },
    {
      "key": "customerId",
      "value": ""
    },
    {
      "key": "newProxy",
      "value": ""
    },
    {
      "key": "activationCode",
      "value": ""
    },
    {
      "key": "moneyCustomerId",
      "value": ""
    },
    {
      "key": "moneyProxy",
      "value": ""
    },
    {
      "key": "adjustRef",
      "value": ""
    },
    {
      "key": "loadRef",
      "value": ""
    },
    {
      "key": "balanceAfterLoad",
      "value": ""
    }
  ]
}
