{
  "info": {
    "_postman_id": "f34b6c81-c334-4595-8111-8214926d8c6f",
    "name": "Sharqiah — All Payment Methods",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "# Current Sharqiah customer payment API\n\nImport this collection and `sharqiah-payments.local.postman_environment.json`, then select **Sharqiah Payments — Local**. It targets this Laravel application's `/api/v1` endpoints, including all 13 electronic providers and cash, bank/company transfer, remittance and internal customer wallet. Legacy reward-point redemption is disabled pending its business rule.\n\n## Start\n1. Set `base_url` (includes `/api/v1`, no trailing slash), `app_key`, and a customer `access_token`. All requests inherit Bearer authentication and send `X-App-Key`. Alternatively use Setup's customer OTP requests: supply `phone`, request an OTP, set `login_otp`, then Verify to capture the token. Do not use a driver token.\n2. Run Setup's method/currency/catalog/address requests. Set `address_id`, `item_id`, `quantity` and, for a variant item, `item_variant_id`. Optional `coupon_code` starts blank. Input secrets start blank; no merchant credentials are included.\n3. Configure the provider's merchant fields in admin and publish the payment method. Seeded providers remain unpublished until configured. The discovery requests populate `<flow>_payment_method_id` from the published listing, without hard-coded database IDs.\n4. Open one payment folder and send its requests in numbered order. Each folder starts with discovery, so it can be run on its own once common inputs are set. Missing prerequisites skip a request with a named message in the Postman Console. A folder run is not complete until its requests were actually sent and any OTP/hosted-checkout step was finished.\n5. Set `<flow>_customer_identifier`, `<flow>_voucher`, `<flow>_pin` or `<flow>_verification_code` as listed in that folder. OTP/payment-code confirmations skip while blank: enter the real code and send Confirm manually. Mastercard saves `mastercard_checkout_url`; open it in a browser to finish hosted checkout, then Refresh status. Postman cannot run the checkout SDK or enter card details for you.\n\n## State and retries\nEach flow stores its own quote, order ID, payment UUID, status, stable `checkout_key` and stable `idempotency_key` in the selected environment. Repeat Create with an unchanged body/key to obtain the same order. The explicit electronic replay request resends the exact cached initiation body. After `502` / `outcome_unknown`, use replay to recover the transaction and check status; do not replace its key. Amount, currency and method come from the order and are prohibited in payment-initiation input.\n\nTo start another independent order after resolving the previous outcome, clear that flow's checkout_key, order_id, quote_total_minor, exchange_rate_id, order_total_minor, order_currency, order_payment_status, idempotency_key, payment_id, status, next_action, has_receipt, last_initiate_body and checkout_url where present; then Quote again. Keep the chosen method ID and customer inputs. Do not edit shared cart inputs halfway through an existing checkout.\n\n## Manual / cash / wallet\nBank transfer and remittance require `<flow>_reference` at order creation. Remittance submission also needs `remittance_company`. Submit evidence uses multipart form data; optional `receipt` is disabled initially. Enable it and select JPEG/PNG/WebP up to 4096 KB; retries must include the same file bytes. Transfers remain pending/unconfirmed until an authorized admin reviews them in Filament. There is no customer approval API.\n\nCash and customer wallet have no electronic initiation/confirmation requests. Cash is settled during collection; wallet funds are debited on order creation and may leave a cash remainder. The wallet must have a positive balance. All saved response examples are illustrative, not captured live provider results. Provider status inquiries may retain pending when the adapter cannot verify settlement; use the admin reconciliation workflow when needed.\n\n## Runner and negative cases\nRun one selected folder against your test setup; running the entire collection processes every available method with filled inputs. No background requests or automatic polling are used. Contract failures cover missing auth/key, required input, prohibited client amounts, changed idempotency payload and cross-user visibility. The last two require an existing transaction; cross-user visibility needs `other_access_token`. The optional method-change request requires explicitly filled change_order_id/change_payment_method_id and is unrelated to the per-provider test orders.\n\nUse Postman Desktop for local Herd URLs. Secrets and generated payloads remain in your selected environment; keep personal input values local. Use Postman's current scripting runtime for `pm.execution.skipRequest`. Official scripting reference: https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-reference/pm-execution/"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{access_token}}",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "{",
          "const missing = [\"base_url\", \"app_key\"].filter(key => !String(pm.environment.get(key) || '').trim());",
          "if (missing.length) {",
          "    console.warn(\"Import and select the provided environment, then configure base_url and app_key.\" + ' Missing: ' + missing.join(', '));",
          "    pm.execution.skipRequest();",
          "}",
          "}"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "00 — Setup / authentication / discovery",
      "description": "Set the selected environment values, then choose a payment folder. Login OTP is optional when you already have a customer token.",
      "item": [
        {
          "name": "01 - Request customer login OTP (optional)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/auth/otp/request",
            "description": "Skip if an access token is already provided. Enter the SMS code into login_otp before Verify. This is a real SMS request when sent to a configured server.",
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"phone\": \"{{phone}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.environment.get('access_token') || pm.environment.get('login_otp')) pm.execution.skipRequest();",
                  "",
                  "{",
                  "const missing = [\"phone\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([202]));",
                  "if ([202].includes(pm.response.code)) {",
                  "pm.test('OTP expiry is present', () => pm.expect(pm.response.json().expires_in).to.be.a('number'));",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/auth/otp/request",
                "description": "Skip if an access token is already provided. Enter the SMS code into login_otp before Verify. This is a real SMS request when sent to a configured server.",
                "auth": {
                  "type": "noauth"
                },
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"phone\": \"{{phone}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Accepted",
              "code": 202,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"message\": \"Verification code sent.\",\n  \"expires_in\": 300\n}"
            }
          ]
        },
        {
          "name": "02 - Verify customer OTP and save token (optional)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/auth/otp/verify",
            "description": "Uses customer phone OTP authentication, not driver login. Saves access_token in the selected environment. If you already have a customer token, enter it directly and skip OTP requests.",
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"phone\": \"{{phone}}\",\n  \"code\": \"{{login_otp}}\",\n  \"device_id\": \"{{device_id}}\",\n  \"os_type\": \"postman\",\n  \"device_name\": \"Postman payment testing\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.environment.get('access_token')) pm.execution.skipRequest();",
                  "",
                  "{",
                  "const missing = [\"phone\", \"login_otp\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "if (!pm.environment.get('device_id')) pm.environment.set('device_id', pm.variables.replaceIn('postman-{{$guid}}'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "const data = pm.response.json();",
                  "pm.test('Customer token exists', () => pm.expect(data.access_token).to.be.a('string'));",
                  "pm.environment.set('access_token', data.access_token);",
                  "pm.environment.unset('login_otp');",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Current customer",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/user",
            "description": "Use a completed customer profile, especially for Easy Wallet KYC name and phone fields."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "pm.test('Customer identity exists', () => pm.expect(pm.response.json().id).to.be.a('number'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Published payment methods and required inputs",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": "Populates a separate payment_method_id for every published provider/type. Unpublished providers are intentionally absent. Configure credentials and publish each method in admin first. If multiple methods share a type/provider, prefill the desired ID to retain that selection."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "05 - Checkout payment-method listing (alias)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/payment-methods",
            "description": "The order-specific listing exposes the same payment method contract."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "06 - My addresses",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/addresses",
            "description": "Copy an owned address ID into address_id. Its city and area must both be published."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "const data = pm.response.json();",
                  "const rows = Array.isArray(data) ? data : data.data;",
                  "pm.test('Address collection exists', () => pm.expect(rows).to.be.an('array'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "07 - Browse catalog for test item",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/items",
            "description": "Choose item_id, quantity and optionally item_variant_id. This request does not choose a purchase item automatically."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "pm.test('Catalog is paginated', () => pm.expect(pm.response.json().data).to.be.an('array'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "08 - Published currencies and exchange rates",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/currencies",
            "description": "Electronic wallets use YER; Mastercard uses USD. USD must have an available rate before quoting. Cash, transfer and internal wallet folders use base_currency."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "const data = pm.response.json();",
                  "const rows = Array.isArray(data) ? data : data.data;",
                  "const base = rows.find(c => c.is_base);",
                  "if (base) pm.environment.set('base_currency', base.code);",
                  "pm.test('Base currency is available', () => pm.expect(base).to.be.an('object'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "09 - Wallet balance and ledger",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/wallet",
            "description": "Check that the internal wallet has a positive balance before testing customer_wallet. Top-up/admin funding is outside this customer API."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "01 — Easy Wallet",
      "description": "**Flow prefix:** `easy_wallet`. **Order currency:** `YER`. **Customer inputs:** `easy_wallet_customer_identifier`.\n\nConfirmation uses `easy_wallet_verification_code` (OTP).\n\nServer-only merchant configuration in admin: `client_id`, `client_secret`, `merchant_id`, `organization_code`. Seeded provider base URL: `https://api-test.tharwatt.com:5223/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('easy_wallet_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{easy_wallet_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('easy_wallet_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('easy_wallet_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{easy_wallet_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{easy_wallet_checkout_key}}\",\n  \"exchange_rate_id\": {{easy_wallet_exchange_rate_id}},\n  \"expected_total_minor\": {{easy_wallet_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_payment_method_id\", \"easy_wallet_quote_total_minor\", \"easy_wallet_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('easy_wallet_checkout_key')) {",
                  "    pm.environment.set('easy_wallet_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('easy_wallet_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('easy_wallet_quote_total_minor')));",
                  "});",
                  "pm.environment.set('easy_wallet_order_id', String(data.id));",
                  "pm.environment.set('easy_wallet_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('easy_wallet_order_currency', data.currency);",
                  "pm.environment.set('easy_wallet_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{easy_wallet_order_id}},\n  \"idempotency_key\": \"{{easy_wallet_idempotency_key}}\",\n  \"customer_identifier\": \"{{easy_wallet_customer_identifier}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_order_id\", \"easy_wallet_customer_identifier\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('easy_wallet_idempotency_key')) {",
                  "    pm.environment.set('easy_wallet_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('easy_wallet_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('easy_wallet_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('easy_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('easy_wallet_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('easy_wallet_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('easy_wallet_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('easy_wallet_payment_id', data.id);",
                  "pm.environment.set('easy_wallet_status', data.status);",
                  "pm.environment.set('easy_wallet_next_action', data.next_action);",
                  "pm.environment.set('easy_wallet_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('easy_wallet_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{easy_wallet_order_id}},\n  \"idempotency_key\": \"{{easy_wallet_idempotency_key}}\",\n  \"customer_identifier\": \"{{easy_wallet_customer_identifier}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('easy_wallet_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('easy_wallet_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('easy_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('easy_wallet_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('easy_wallet_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('easy_wallet_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('easy_wallet_payment_id', data.id);",
                  "pm.environment.set('easy_wallet_status', data.status);",
                  "pm.environment.set('easy_wallet_next_action', data.next_action);",
                  "pm.environment.set('easy_wallet_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('easy_wallet_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{easy_wallet_payment_id}}/confirmation",
            "description": "Enter easy_wallet_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{easy_wallet_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('easy_wallet_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('easy_wallet_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('easy_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('easy_wallet_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('easy_wallet_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('easy_wallet_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('easy_wallet_payment_id', data.id);",
                  "pm.environment.set('easy_wallet_status', data.status);",
                  "pm.environment.set('easy_wallet_next_action', data.next_action);",
                  "pm.environment.set('easy_wallet_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('easy_wallet_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{easy_wallet_payment_id}}/confirmation",
                "description": "Enter easy_wallet_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{easy_wallet_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{easy_wallet_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('easy_wallet_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('easy_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('easy_wallet_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('easy_wallet_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('easy_wallet_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('easy_wallet_payment_id', data.id);",
                  "pm.environment.set('easy_wallet_status', data.status);",
                  "pm.environment.set('easy_wallet_next_action', data.next_action);",
                  "pm.environment.set('easy_wallet_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('easy_wallet_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{easy_wallet_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{easy_wallet_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"easy_wallet_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('easy_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('easy_wallet_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('easy_wallet_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('easy_wallet_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "02 — Mastercard",
      "description": "**Flow prefix:** `mastercard`. **Order currency:** `USD`. **Customer inputs:** None at initiation.\n\nHosted checkout: open `mastercard_checkout_url` in a browser, then refresh. Minimum USD 10; requires a published USD exchange rate. No API OTP confirmation.\n\nServer-only merchant configuration in admin: `merchant_id`, `password`, `merchant_name`, `merchant_url`. Seeded provider base URL: `https://test-gateway.mastercard.com/api/rest/version/78/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('mastercard_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{mastercard_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"USD\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mastercard_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('mastercard_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('mastercard_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{mastercard_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"USD\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{mastercard_checkout_key}}\",\n  \"exchange_rate_id\": {{mastercard_exchange_rate_id}},\n  \"expected_total_minor\": {{mastercard_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mastercard_payment_method_id\", \"mastercard_quote_total_minor\", \"mastercard_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('mastercard_checkout_key')) {",
                  "    pm.environment.set('mastercard_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mastercard_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('mastercard_quote_total_minor')));",
                  "});",
                  "pm.environment.set('mastercard_order_id', String(data.id));",
                  "pm.environment.set('mastercard_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('mastercard_order_currency', data.currency);",
                  "pm.environment.set('mastercard_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{mastercard_order_id}},\n  \"idempotency_key\": \"{{mastercard_idempotency_key}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mastercard_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('mastercard_idempotency_key')) {",
                  "    pm.environment.set('mastercard_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('mastercard_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mastercard_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mastercard_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mastercard_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mastercard_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mastercard_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mastercard_payment_id', data.id);",
                  "pm.environment.set('mastercard_status', data.status);",
                  "pm.environment.set('mastercard_next_action', data.next_action);",
                  "pm.environment.set('mastercard_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mastercard_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{mastercard_order_id}},\n  \"idempotency_key\": \"{{mastercard_idempotency_key}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"USD\",\n  \"status\": \"pending\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"redirect\",\n  \"next_action_data\": {\n    \"url\": \"https://sharqiah.test/payments/EXAMPLE/checkout?expires=EXAMPLE&signature=EXAMPLE\"\n  },\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mastercard_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('mastercard_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mastercard_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mastercard_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mastercard_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mastercard_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mastercard_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mastercard_payment_id', data.id);",
                  "pm.environment.set('mastercard_status', data.status);",
                  "pm.environment.set('mastercard_next_action', data.next_action);",
                  "pm.environment.set('mastercard_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mastercard_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"USD\",\n  \"status\": \"pending\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"redirect\",\n  \"next_action_data\": {\n    \"url\": \"https://sharqiah.test/payments/EXAMPLE/checkout?expires=EXAMPLE&signature=EXAMPLE\"\n  },\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{mastercard_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mastercard_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mastercard_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mastercard_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mastercard_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mastercard_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mastercard_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mastercard_payment_id', data.id);",
                  "pm.environment.set('mastercard_status', data.status);",
                  "pm.environment.set('mastercard_next_action', data.next_action);",
                  "pm.environment.set('mastercard_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mastercard_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{mastercard_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"USD\",\n  \"status\": \"pending\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"redirect\",\n  \"next_action_data\": {\n    \"url\": \"https://sharqiah.test/payments/EXAMPLE/checkout?expires=EXAMPLE&signature=EXAMPLE\"\n  },\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{mastercard_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mastercard_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('mastercard_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mastercard_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('mastercard_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('mastercard_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "03 — Jaib Wallet",
      "description": "**Flow prefix:** `jaib_wallet`. **Order currency:** `YER`. **Customer inputs:** `jaib_wallet_customer_identifier`, `jaib_wallet_voucher`.\n\nVoucher purchase completes during initiation on a successful provider result. No API OTP confirmation.\n\nServer-only merchant configuration in admin: `merchant_id`, `username`, `password`, `pin_api`, `currency_id`. Seeded provider base URL: `https://www.w-jaib.com:4075/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('jaib_wallet_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{jaib_wallet_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jaib_wallet_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('jaib_wallet_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('jaib_wallet_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{jaib_wallet_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{jaib_wallet_checkout_key}}\",\n  \"exchange_rate_id\": {{jaib_wallet_exchange_rate_id}},\n  \"expected_total_minor\": {{jaib_wallet_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jaib_wallet_payment_method_id\", \"jaib_wallet_quote_total_minor\", \"jaib_wallet_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('jaib_wallet_checkout_key')) {",
                  "    pm.environment.set('jaib_wallet_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jaib_wallet_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('jaib_wallet_quote_total_minor')));",
                  "});",
                  "pm.environment.set('jaib_wallet_order_id', String(data.id));",
                  "pm.environment.set('jaib_wallet_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('jaib_wallet_order_currency', data.currency);",
                  "pm.environment.set('jaib_wallet_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{jaib_wallet_order_id}},\n  \"idempotency_key\": \"{{jaib_wallet_idempotency_key}}\",\n  \"customer_identifier\": \"{{jaib_wallet_customer_identifier}}\",\n  \"details\": {\"voucher\": \"{{jaib_wallet_voucher}}\"}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jaib_wallet_order_id\", \"jaib_wallet_customer_identifier\", \"jaib_wallet_voucher\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('jaib_wallet_idempotency_key')) {",
                  "    pm.environment.set('jaib_wallet_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('jaib_wallet_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('jaib_wallet_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('jaib_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jaib_wallet_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('jaib_wallet_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('jaib_wallet_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('jaib_wallet_payment_id', data.id);",
                  "pm.environment.set('jaib_wallet_status', data.status);",
                  "pm.environment.set('jaib_wallet_next_action', data.next_action);",
                  "pm.environment.set('jaib_wallet_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('jaib_wallet_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{jaib_wallet_order_id}},\n  \"idempotency_key\": \"{{jaib_wallet_idempotency_key}}\",\n  \"customer_identifier\": \"{{jaib_wallet_customer_identifier}}\",\n  \"details\": {\"voucher\": \"{{jaib_wallet_voucher}}\"}\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jaib_wallet_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('jaib_wallet_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('jaib_wallet_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('jaib_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jaib_wallet_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('jaib_wallet_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('jaib_wallet_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('jaib_wallet_payment_id', data.id);",
                  "pm.environment.set('jaib_wallet_status', data.status);",
                  "pm.environment.set('jaib_wallet_next_action', data.next_action);",
                  "pm.environment.set('jaib_wallet_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('jaib_wallet_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{jaib_wallet_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jaib_wallet_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('jaib_wallet_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('jaib_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jaib_wallet_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('jaib_wallet_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('jaib_wallet_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('jaib_wallet_payment_id', data.id);",
                  "pm.environment.set('jaib_wallet_status', data.status);",
                  "pm.environment.set('jaib_wallet_next_action', data.next_action);",
                  "pm.environment.set('jaib_wallet_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('jaib_wallet_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{jaib_wallet_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{jaib_wallet_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jaib_wallet_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('jaib_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jaib_wallet_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('jaib_wallet_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('jaib_wallet_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "04 — Floosak",
      "description": "**Flow prefix:** `floosak`. **Order currency:** `YER`. **Customer inputs:** `floosak_customer_identifier`.\n\nConfirmation uses `floosak_verification_code` (OTP).\n\nServer-only merchant configuration in admin: `access_token`, `source_wallet_id`. Seeded provider base URL: `https://floosak.ye/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('floosak_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{floosak_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('floosak_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('floosak_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{floosak_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{floosak_checkout_key}}\",\n  \"exchange_rate_id\": {{floosak_exchange_rate_id}},\n  \"expected_total_minor\": {{floosak_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_payment_method_id\", \"floosak_quote_total_minor\", \"floosak_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('floosak_checkout_key')) {",
                  "    pm.environment.set('floosak_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('floosak_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('floosak_quote_total_minor')));",
                  "});",
                  "pm.environment.set('floosak_order_id', String(data.id));",
                  "pm.environment.set('floosak_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('floosak_order_currency', data.currency);",
                  "pm.environment.set('floosak_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{floosak_order_id}},\n  \"idempotency_key\": \"{{floosak_idempotency_key}}\",\n  \"customer_identifier\": \"{{floosak_customer_identifier}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_order_id\", \"floosak_customer_identifier\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('floosak_idempotency_key')) {",
                  "    pm.environment.set('floosak_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('floosak_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('floosak_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('floosak_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('floosak_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('floosak_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('floosak_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('floosak_payment_id', data.id);",
                  "pm.environment.set('floosak_status', data.status);",
                  "pm.environment.set('floosak_next_action', data.next_action);",
                  "pm.environment.set('floosak_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('floosak_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{floosak_order_id}},\n  \"idempotency_key\": \"{{floosak_idempotency_key}}\",\n  \"customer_identifier\": \"{{floosak_customer_identifier}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('floosak_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('floosak_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('floosak_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('floosak_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('floosak_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('floosak_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('floosak_payment_id', data.id);",
                  "pm.environment.set('floosak_status', data.status);",
                  "pm.environment.set('floosak_next_action', data.next_action);",
                  "pm.environment.set('floosak_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('floosak_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{floosak_payment_id}}/confirmation",
            "description": "Enter floosak_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{floosak_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('floosak_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('floosak_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('floosak_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('floosak_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('floosak_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('floosak_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('floosak_payment_id', data.id);",
                  "pm.environment.set('floosak_status', data.status);",
                  "pm.environment.set('floosak_next_action', data.next_action);",
                  "pm.environment.set('floosak_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('floosak_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{floosak_payment_id}}/confirmation",
                "description": "Enter floosak_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{floosak_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{floosak_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('floosak_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('floosak_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('floosak_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('floosak_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('floosak_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('floosak_payment_id', data.id);",
                  "pm.environment.set('floosak_status', data.status);",
                  "pm.environment.set('floosak_next_action', data.next_action);",
                  "pm.environment.set('floosak_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('floosak_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{floosak_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{floosak_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"floosak_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('floosak_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('floosak_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('floosak_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('floosak_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "05 — Jawali",
      "description": "**Flow prefix:** `jawali`. **Order currency:** `YER`. **Customer inputs:** `jawali_customer_identifier`.\n\nConfirmation uses `jawali_verification_code` (customer purchase/payment code).\n\nServer-only merchant configuration in admin: `merchant_id`, `username`, `password`, `client_id`, `client_secret`, `wallet_id`, `wallet_password`. Seeded provider base URL: `https://app.wecash.com.ye:8493/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('jawali_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{jawali_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('jawali_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('jawali_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{jawali_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{jawali_checkout_key}}\",\n  \"exchange_rate_id\": {{jawali_exchange_rate_id}},\n  \"expected_total_minor\": {{jawali_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_payment_method_id\", \"jawali_quote_total_minor\", \"jawali_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('jawali_checkout_key')) {",
                  "    pm.environment.set('jawali_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jawali_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('jawali_quote_total_minor')));",
                  "});",
                  "pm.environment.set('jawali_order_id', String(data.id));",
                  "pm.environment.set('jawali_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('jawali_order_currency', data.currency);",
                  "pm.environment.set('jawali_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{jawali_order_id}},\n  \"idempotency_key\": \"{{jawali_idempotency_key}}\",\n  \"customer_identifier\": \"{{jawali_customer_identifier}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_order_id\", \"jawali_customer_identifier\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('jawali_idempotency_key')) {",
                  "    pm.environment.set('jawali_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('jawali_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('jawali_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('jawali_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jawali_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('jawali_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('jawali_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('jawali_payment_id', data.id);",
                  "pm.environment.set('jawali_status', data.status);",
                  "pm.environment.set('jawali_next_action', data.next_action);",
                  "pm.environment.set('jawali_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('jawali_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{jawali_order_id}},\n  \"idempotency_key\": \"{{jawali_idempotency_key}}\",\n  \"customer_identifier\": \"{{jawali_customer_identifier}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"payment_code\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('jawali_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('jawali_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('jawali_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jawali_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('jawali_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('jawali_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('jawali_payment_id', data.id);",
                  "pm.environment.set('jawali_status', data.status);",
                  "pm.environment.set('jawali_next_action', data.next_action);",
                  "pm.environment.set('jawali_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('jawali_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"payment_code\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{jawali_payment_id}}/confirmation",
            "description": "Enter jawali_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked. Use the customer purchase/payment code in verification_code.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{jawali_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('jawali_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('jawali_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('jawali_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jawali_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('jawali_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('jawali_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('jawali_payment_id', data.id);",
                  "pm.environment.set('jawali_status', data.status);",
                  "pm.environment.set('jawali_next_action', data.next_action);",
                  "pm.environment.set('jawali_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('jawali_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{jawali_payment_id}}/confirmation",
                "description": "Enter jawali_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked. Use the customer purchase/payment code in verification_code.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{jawali_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{jawali_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('jawali_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('jawali_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jawali_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('jawali_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('jawali_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('jawali_payment_id', data.id);",
                  "pm.environment.set('jawali_status', data.status);",
                  "pm.environment.set('jawali_next_action', data.next_action);",
                  "pm.environment.set('jawali_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('jawali_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{jawali_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"payment_code\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{jawali_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"jawali_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('jawali_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('jawali_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('jawali_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('jawali_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "06 — Saba Cash",
      "description": "**Flow prefix:** `saba_cash`. **Order currency:** `YER`. **Customer inputs:** `saba_cash_customer_identifier`.\n\nConfirmation uses `saba_cash_verification_code` (OTP).\n\nServer-only merchant configuration in admin: `username`, `password`, `currency_id`, `terminal_id`. Seeded provider base URL: `https://api.sabacash.com:49901/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('saba_cash_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{saba_cash_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('saba_cash_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('saba_cash_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{saba_cash_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{saba_cash_checkout_key}}\",\n  \"exchange_rate_id\": {{saba_cash_exchange_rate_id}},\n  \"expected_total_minor\": {{saba_cash_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_payment_method_id\", \"saba_cash_quote_total_minor\", \"saba_cash_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('saba_cash_checkout_key')) {",
                  "    pm.environment.set('saba_cash_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('saba_cash_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('saba_cash_quote_total_minor')));",
                  "});",
                  "pm.environment.set('saba_cash_order_id', String(data.id));",
                  "pm.environment.set('saba_cash_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('saba_cash_order_currency', data.currency);",
                  "pm.environment.set('saba_cash_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{saba_cash_order_id}},\n  \"idempotency_key\": \"{{saba_cash_idempotency_key}}\",\n  \"customer_identifier\": \"{{saba_cash_customer_identifier}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_order_id\", \"saba_cash_customer_identifier\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('saba_cash_idempotency_key')) {",
                  "    pm.environment.set('saba_cash_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('saba_cash_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('saba_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('saba_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('saba_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('saba_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('saba_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('saba_cash_payment_id', data.id);",
                  "pm.environment.set('saba_cash_status', data.status);",
                  "pm.environment.set('saba_cash_next_action', data.next_action);",
                  "pm.environment.set('saba_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('saba_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{saba_cash_order_id}},\n  \"idempotency_key\": \"{{saba_cash_idempotency_key}}\",\n  \"customer_identifier\": \"{{saba_cash_customer_identifier}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('saba_cash_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('saba_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('saba_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('saba_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('saba_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('saba_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('saba_cash_payment_id', data.id);",
                  "pm.environment.set('saba_cash_status', data.status);",
                  "pm.environment.set('saba_cash_next_action', data.next_action);",
                  "pm.environment.set('saba_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('saba_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{saba_cash_payment_id}}/confirmation",
            "description": "Enter saba_cash_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{saba_cash_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('saba_cash_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('saba_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('saba_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('saba_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('saba_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('saba_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('saba_cash_payment_id', data.id);",
                  "pm.environment.set('saba_cash_status', data.status);",
                  "pm.environment.set('saba_cash_next_action', data.next_action);",
                  "pm.environment.set('saba_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('saba_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{saba_cash_payment_id}}/confirmation",
                "description": "Enter saba_cash_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{saba_cash_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{saba_cash_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('saba_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('saba_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('saba_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('saba_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('saba_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('saba_cash_payment_id', data.id);",
                  "pm.environment.set('saba_cash_status', data.status);",
                  "pm.environment.set('saba_cash_next_action', data.next_action);",
                  "pm.environment.set('saba_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('saba_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{saba_cash_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{saba_cash_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"saba_cash_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('saba_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('saba_cash_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('saba_cash_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('saba_cash_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "07 — Shamil Money",
      "description": "**Flow prefix:** `shamil_money`. **Order currency:** `YER`. **Customer inputs:** `shamil_money_customer_identifier`, `shamil_money_voucher`.\n\nConfirmation uses `shamil_money_verification_code` (OTP).\n\nServer-only merchant configuration in admin: `client_id`, `client_secret`, `username`, `password`, `device_name`, `device_type`, `client_ip`. Seeded provider base URL: `https://shamilmoney.com:7394/Interface/API/Ecommerce/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('shamil_money_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{shamil_money_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('shamil_money_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('shamil_money_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{shamil_money_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{shamil_money_checkout_key}}\",\n  \"exchange_rate_id\": {{shamil_money_exchange_rate_id}},\n  \"expected_total_minor\": {{shamil_money_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_payment_method_id\", \"shamil_money_quote_total_minor\", \"shamil_money_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('shamil_money_checkout_key')) {",
                  "    pm.environment.set('shamil_money_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('shamil_money_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('shamil_money_quote_total_minor')));",
                  "});",
                  "pm.environment.set('shamil_money_order_id', String(data.id));",
                  "pm.environment.set('shamil_money_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('shamil_money_order_currency', data.currency);",
                  "pm.environment.set('shamil_money_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{shamil_money_order_id}},\n  \"idempotency_key\": \"{{shamil_money_idempotency_key}}\",\n  \"customer_identifier\": \"{{shamil_money_customer_identifier}}\",\n  \"details\": {\"voucher\": \"{{shamil_money_voucher}}\"}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_order_id\", \"shamil_money_customer_identifier\", \"shamil_money_voucher\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('shamil_money_idempotency_key')) {",
                  "    pm.environment.set('shamil_money_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('shamil_money_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('shamil_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('shamil_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('shamil_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('shamil_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('shamil_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('shamil_money_payment_id', data.id);",
                  "pm.environment.set('shamil_money_status', data.status);",
                  "pm.environment.set('shamil_money_next_action', data.next_action);",
                  "pm.environment.set('shamil_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('shamil_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{shamil_money_order_id}},\n  \"idempotency_key\": \"{{shamil_money_idempotency_key}}\",\n  \"customer_identifier\": \"{{shamil_money_customer_identifier}}\",\n  \"details\": {\"voucher\": \"{{shamil_money_voucher}}\"}\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('shamil_money_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('shamil_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('shamil_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('shamil_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('shamil_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('shamil_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('shamil_money_payment_id', data.id);",
                  "pm.environment.set('shamil_money_status', data.status);",
                  "pm.environment.set('shamil_money_next_action', data.next_action);",
                  "pm.environment.set('shamil_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('shamil_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{shamil_money_payment_id}}/confirmation",
            "description": "Enter shamil_money_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{shamil_money_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('shamil_money_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('shamil_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('shamil_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('shamil_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('shamil_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('shamil_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('shamil_money_payment_id', data.id);",
                  "pm.environment.set('shamil_money_status', data.status);",
                  "pm.environment.set('shamil_money_next_action', data.next_action);",
                  "pm.environment.set('shamil_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('shamil_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{shamil_money_payment_id}}/confirmation",
                "description": "Enter shamil_money_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{shamil_money_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{shamil_money_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('shamil_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('shamil_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('shamil_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('shamil_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('shamil_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('shamil_money_payment_id', data.id);",
                  "pm.environment.set('shamil_money_status', data.status);",
                  "pm.environment.set('shamil_money_next_action', data.next_action);",
                  "pm.environment.set('shamil_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('shamil_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{shamil_money_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{shamil_money_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"shamil_money_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('shamil_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('shamil_money_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('shamil_money_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('shamil_money_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "08 — CashPay",
      "description": "**Flow prefix:** `cash_pay`. **Order currency:** `YER`. **Customer inputs:** `cash_pay_customer_identifier`, `cash_pay_voucher`.\n\nConfirmation uses `cash_pay_verification_code` (OTP).\n\nServer-only merchant configuration in admin: `merchant_id`, `username`, `password`, `secret_key`, `currency_id`, `certificate_path`, `certificate_password`. Seeded provider base URL: `https://www.tamkeen.com.ye:61890/CashPay/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('cash_pay_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{cash_pay_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('cash_pay_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('cash_pay_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{cash_pay_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{cash_pay_checkout_key}}\",\n  \"exchange_rate_id\": {{cash_pay_exchange_rate_id}},\n  \"expected_total_minor\": {{cash_pay_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_payment_method_id\", \"cash_pay_quote_total_minor\", \"cash_pay_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('cash_pay_checkout_key')) {",
                  "    pm.environment.set('cash_pay_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_pay_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('cash_pay_quote_total_minor')));",
                  "});",
                  "pm.environment.set('cash_pay_order_id', String(data.id));",
                  "pm.environment.set('cash_pay_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('cash_pay_order_currency', data.currency);",
                  "pm.environment.set('cash_pay_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{cash_pay_order_id}},\n  \"idempotency_key\": \"{{cash_pay_idempotency_key}}\",\n  \"customer_identifier\": \"{{cash_pay_customer_identifier}}\",\n  \"details\": {\"voucher\": \"{{cash_pay_voucher}}\"}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_order_id\", \"cash_pay_customer_identifier\", \"cash_pay_voucher\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('cash_pay_idempotency_key')) {",
                  "    pm.environment.set('cash_pay_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('cash_pay_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('cash_pay_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('cash_pay_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_pay_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('cash_pay_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('cash_pay_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('cash_pay_payment_id', data.id);",
                  "pm.environment.set('cash_pay_status', data.status);",
                  "pm.environment.set('cash_pay_next_action', data.next_action);",
                  "pm.environment.set('cash_pay_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('cash_pay_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{cash_pay_order_id}},\n  \"idempotency_key\": \"{{cash_pay_idempotency_key}}\",\n  \"customer_identifier\": \"{{cash_pay_customer_identifier}}\",\n  \"details\": {\"voucher\": \"{{cash_pay_voucher}}\"}\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('cash_pay_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('cash_pay_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('cash_pay_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_pay_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('cash_pay_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('cash_pay_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('cash_pay_payment_id', data.id);",
                  "pm.environment.set('cash_pay_status', data.status);",
                  "pm.environment.set('cash_pay_next_action', data.next_action);",
                  "pm.environment.set('cash_pay_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('cash_pay_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{cash_pay_payment_id}}/confirmation",
            "description": "Enter cash_pay_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{cash_pay_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('cash_pay_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('cash_pay_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('cash_pay_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_pay_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('cash_pay_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('cash_pay_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('cash_pay_payment_id', data.id);",
                  "pm.environment.set('cash_pay_status', data.status);",
                  "pm.environment.set('cash_pay_next_action', data.next_action);",
                  "pm.environment.set('cash_pay_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('cash_pay_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{cash_pay_payment_id}}/confirmation",
                "description": "Enter cash_pay_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{cash_pay_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{cash_pay_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('cash_pay_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('cash_pay_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_pay_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('cash_pay_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('cash_pay_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('cash_pay_payment_id', data.id);",
                  "pm.environment.set('cash_pay_status', data.status);",
                  "pm.environment.set('cash_pay_next_action', data.next_action);",
                  "pm.environment.set('cash_pay_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('cash_pay_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{cash_pay_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{cash_pay_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_pay_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('cash_pay_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_pay_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('cash_pay_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('cash_pay_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "09 — Kuraimi Haseb",
      "description": "**Flow prefix:** `kuraimi_haseb`. **Order currency:** `YER`. **Customer inputs:** `kuraimi_haseb_customer_identifier`, `kuraimi_haseb_pin`.\n\nCustomer ID and PIN are sent during initiation; a successful provider result completes the payment. No API OTP confirmation.\n\nServer-only merchant configuration in admin: `username`, `password`. Seeded provider base URL: `https://api.kuraimipay.com:4474/alk-payments-exp/v1/PHEPaymentAPI/EPayment/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('kuraimi_haseb_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{kuraimi_haseb_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"kuraimi_haseb_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('kuraimi_haseb_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('kuraimi_haseb_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{kuraimi_haseb_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{kuraimi_haseb_checkout_key}}\",\n  \"exchange_rate_id\": {{kuraimi_haseb_exchange_rate_id}},\n  \"expected_total_minor\": {{kuraimi_haseb_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"kuraimi_haseb_payment_method_id\", \"kuraimi_haseb_quote_total_minor\", \"kuraimi_haseb_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('kuraimi_haseb_checkout_key')) {",
                  "    pm.environment.set('kuraimi_haseb_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('kuraimi_haseb_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('kuraimi_haseb_quote_total_minor')));",
                  "});",
                  "pm.environment.set('kuraimi_haseb_order_id', String(data.id));",
                  "pm.environment.set('kuraimi_haseb_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('kuraimi_haseb_order_currency', data.currency);",
                  "pm.environment.set('kuraimi_haseb_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{kuraimi_haseb_order_id}},\n  \"idempotency_key\": \"{{kuraimi_haseb_idempotency_key}}\",\n  \"customer_identifier\": \"{{kuraimi_haseb_customer_identifier}}\",\n  \"details\": {\"pin\": \"{{kuraimi_haseb_pin}}\"}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"kuraimi_haseb_order_id\", \"kuraimi_haseb_customer_identifier\", \"kuraimi_haseb_pin\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('kuraimi_haseb_idempotency_key')) {",
                  "    pm.environment.set('kuraimi_haseb_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('kuraimi_haseb_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('kuraimi_haseb_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('kuraimi_haseb_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('kuraimi_haseb_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('kuraimi_haseb_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('kuraimi_haseb_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('kuraimi_haseb_payment_id', data.id);",
                  "pm.environment.set('kuraimi_haseb_status', data.status);",
                  "pm.environment.set('kuraimi_haseb_next_action', data.next_action);",
                  "pm.environment.set('kuraimi_haseb_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('kuraimi_haseb_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{kuraimi_haseb_order_id}},\n  \"idempotency_key\": \"{{kuraimi_haseb_idempotency_key}}\",\n  \"customer_identifier\": \"{{kuraimi_haseb_customer_identifier}}\",\n  \"details\": {\"pin\": \"{{kuraimi_haseb_pin}}\"}\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"kuraimi_haseb_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('kuraimi_haseb_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('kuraimi_haseb_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('kuraimi_haseb_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('kuraimi_haseb_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('kuraimi_haseb_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('kuraimi_haseb_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('kuraimi_haseb_payment_id', data.id);",
                  "pm.environment.set('kuraimi_haseb_status', data.status);",
                  "pm.environment.set('kuraimi_haseb_next_action', data.next_action);",
                  "pm.environment.set('kuraimi_haseb_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('kuraimi_haseb_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{kuraimi_haseb_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"kuraimi_haseb_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('kuraimi_haseb_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('kuraimi_haseb_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('kuraimi_haseb_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('kuraimi_haseb_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('kuraimi_haseb_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('kuraimi_haseb_payment_id', data.id);",
                  "pm.environment.set('kuraimi_haseb_status', data.status);",
                  "pm.environment.set('kuraimi_haseb_next_action', data.next_action);",
                  "pm.environment.set('kuraimi_haseb_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('kuraimi_haseb_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{kuraimi_haseb_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{kuraimi_haseb_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"kuraimi_haseb_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('kuraimi_haseb_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('kuraimi_haseb_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('kuraimi_haseb_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('kuraimi_haseb_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "10 — One Cash",
      "description": "**Flow prefix:** `one_cash`. **Order currency:** `YER`. **Customer inputs:** `one_cash_customer_identifier`.\n\nConfirmation uses `one_cash_verification_code` (OTP).\n\nServer-only merchant configuration in admin: `merchant_id`, `username`, `password`, `public_key`, `hmac_key`. Seeded provider base URL: `https://82.114.171.42:49049/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('one_cash_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{one_cash_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('one_cash_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('one_cash_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{one_cash_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{one_cash_checkout_key}}\",\n  \"exchange_rate_id\": {{one_cash_exchange_rate_id}},\n  \"expected_total_minor\": {{one_cash_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_payment_method_id\", \"one_cash_quote_total_minor\", \"one_cash_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('one_cash_checkout_key')) {",
                  "    pm.environment.set('one_cash_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('one_cash_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('one_cash_quote_total_minor')));",
                  "});",
                  "pm.environment.set('one_cash_order_id', String(data.id));",
                  "pm.environment.set('one_cash_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('one_cash_order_currency', data.currency);",
                  "pm.environment.set('one_cash_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{one_cash_order_id}},\n  \"idempotency_key\": \"{{one_cash_idempotency_key}}\",\n  \"customer_identifier\": \"{{one_cash_customer_identifier}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_order_id\", \"one_cash_customer_identifier\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('one_cash_idempotency_key')) {",
                  "    pm.environment.set('one_cash_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('one_cash_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('one_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('one_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('one_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('one_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('one_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('one_cash_payment_id', data.id);",
                  "pm.environment.set('one_cash_status', data.status);",
                  "pm.environment.set('one_cash_next_action', data.next_action);",
                  "pm.environment.set('one_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('one_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{one_cash_order_id}},\n  \"idempotency_key\": \"{{one_cash_idempotency_key}}\",\n  \"customer_identifier\": \"{{one_cash_customer_identifier}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('one_cash_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('one_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('one_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('one_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('one_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('one_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('one_cash_payment_id', data.id);",
                  "pm.environment.set('one_cash_status', data.status);",
                  "pm.environment.set('one_cash_next_action', data.next_action);",
                  "pm.environment.set('one_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('one_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{one_cash_payment_id}}/confirmation",
            "description": "Enter one_cash_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{one_cash_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('one_cash_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('one_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('one_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('one_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('one_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('one_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('one_cash_payment_id', data.id);",
                  "pm.environment.set('one_cash_status', data.status);",
                  "pm.environment.set('one_cash_next_action', data.next_action);",
                  "pm.environment.set('one_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('one_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{one_cash_payment_id}}/confirmation",
                "description": "Enter one_cash_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{one_cash_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{one_cash_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('one_cash_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('one_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('one_cash_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('one_cash_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('one_cash_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('one_cash_payment_id', data.id);",
                  "pm.environment.set('one_cash_status', data.status);",
                  "pm.environment.set('one_cash_next_action', data.next_action);",
                  "pm.environment.set('one_cash_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('one_cash_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{one_cash_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{one_cash_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"one_cash_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('one_cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('one_cash_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('one_cash_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('one_cash_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "11 — Mobile Money",
      "description": "**Flow prefix:** `mobile_money`. **Order currency:** `YER`. **Customer inputs:** None at initiation.\n\nConfirmation uses `mobile_money_verification_code` (customer purchase/payment code).\n\nServer-only merchant configuration in admin: `client_id`, `username`, `password`, `merchant_id`, `app_id`, `bank_id`, `branch_name`. Seeded provider base URL: `https://mobilemoney.com.ye:6446/mmPay/v2/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('mobile_money_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{mobile_money_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('mobile_money_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('mobile_money_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{mobile_money_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{mobile_money_checkout_key}}\",\n  \"exchange_rate_id\": {{mobile_money_exchange_rate_id}},\n  \"expected_total_minor\": {{mobile_money_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_payment_method_id\", \"mobile_money_quote_total_minor\", \"mobile_money_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('mobile_money_checkout_key')) {",
                  "    pm.environment.set('mobile_money_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mobile_money_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('mobile_money_quote_total_minor')));",
                  "});",
                  "pm.environment.set('mobile_money_order_id', String(data.id));",
                  "pm.environment.set('mobile_money_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('mobile_money_order_currency', data.currency);",
                  "pm.environment.set('mobile_money_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{mobile_money_order_id}},\n  \"idempotency_key\": \"{{mobile_money_idempotency_key}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('mobile_money_idempotency_key')) {",
                  "    pm.environment.set('mobile_money_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('mobile_money_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mobile_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mobile_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mobile_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mobile_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mobile_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mobile_money_payment_id', data.id);",
                  "pm.environment.set('mobile_money_status', data.status);",
                  "pm.environment.set('mobile_money_next_action', data.next_action);",
                  "pm.environment.set('mobile_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mobile_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{mobile_money_order_id}},\n  \"idempotency_key\": \"{{mobile_money_idempotency_key}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"payment_code\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('mobile_money_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mobile_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mobile_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mobile_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mobile_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mobile_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mobile_money_payment_id', data.id);",
                  "pm.environment.set('mobile_money_status', data.status);",
                  "pm.environment.set('mobile_money_next_action', data.next_action);",
                  "pm.environment.set('mobile_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mobile_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"payment_code\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{mobile_money_payment_id}}/confirmation",
            "description": "Enter mobile_money_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked. Use the customer purchase/payment code in verification_code.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{mobile_money_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('mobile_money_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mobile_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mobile_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mobile_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mobile_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mobile_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mobile_money_payment_id', data.id);",
                  "pm.environment.set('mobile_money_status', data.status);",
                  "pm.environment.set('mobile_money_next_action', data.next_action);",
                  "pm.environment.set('mobile_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mobile_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{mobile_money_payment_id}}/confirmation",
                "description": "Enter mobile_money_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked. Use the customer purchase/payment code in verification_code.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{mobile_money_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{mobile_money_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mobile_money_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mobile_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mobile_money_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mobile_money_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mobile_money_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mobile_money_payment_id', data.id);",
                  "pm.environment.set('mobile_money_status', data.status);",
                  "pm.environment.set('mobile_money_next_action', data.next_action);",
                  "pm.environment.set('mobile_money_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mobile_money_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{mobile_money_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"payment_code\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{mobile_money_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mobile_money_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('mobile_money_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mobile_money_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('mobile_money_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('mobile_money_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "12 — PYES",
      "description": "**Flow prefix:** `pyes`. **Order currency:** `YER`. **Customer inputs:** `pyes_customer_identifier`.\n\nConfirmation uses `pyes_verification_code` (OTP; PYES: 1–10 digits).\n\nServer-only merchant configuration in admin: `device_name`, `username`, `password`, `agent_username`, `pos_id`, `company_id`, `currency_id`. Seeded provider base URL: `https://banksys.alamalbank.com/ords/amb/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('pyes_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{pyes_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('pyes_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('pyes_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{pyes_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{pyes_checkout_key}}\",\n  \"exchange_rate_id\": {{pyes_exchange_rate_id}},\n  \"expected_total_minor\": {{pyes_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_payment_method_id\", \"pyes_quote_total_minor\", \"pyes_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('pyes_checkout_key')) {",
                  "    pm.environment.set('pyes_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('pyes_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('pyes_quote_total_minor')));",
                  "});",
                  "pm.environment.set('pyes_order_id', String(data.id));",
                  "pm.environment.set('pyes_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('pyes_order_currency', data.currency);",
                  "pm.environment.set('pyes_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{pyes_order_id}},\n  \"idempotency_key\": \"{{pyes_idempotency_key}}\",\n  \"customer_identifier\": \"{{pyes_customer_identifier}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_order_id\", \"pyes_customer_identifier\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('pyes_idempotency_key')) {",
                  "    pm.environment.set('pyes_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('pyes_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('pyes_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('pyes_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('pyes_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('pyes_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('pyes_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('pyes_payment_id', data.id);",
                  "pm.environment.set('pyes_status', data.status);",
                  "pm.environment.set('pyes_next_action', data.next_action);",
                  "pm.environment.set('pyes_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('pyes_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{pyes_order_id}},\n  \"idempotency_key\": \"{{pyes_idempotency_key}}\",\n  \"customer_identifier\": \"{{pyes_customer_identifier}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('pyes_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('pyes_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('pyes_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('pyes_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('pyes_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('pyes_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('pyes_payment_id', data.id);",
                  "pm.environment.set('pyes_status', data.status);",
                  "pm.environment.set('pyes_next_action', data.next_action);",
                  "pm.environment.set('pyes_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('pyes_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{pyes_payment_id}}/confirmation",
            "description": "Enter pyes_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked. PYES accepts only 1–10 digits.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{pyes_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('pyes_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('pyes_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('pyes_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('pyes_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('pyes_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('pyes_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('pyes_payment_id', data.id);",
                  "pm.environment.set('pyes_status', data.status);",
                  "pm.environment.set('pyes_next_action', data.next_action);",
                  "pm.environment.set('pyes_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('pyes_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{pyes_payment_id}}/confirmation",
                "description": "Enter pyes_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked. PYES accepts only 1–10 digits.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{pyes_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{pyes_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('pyes_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('pyes_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('pyes_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('pyes_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('pyes_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('pyes_payment_id', data.id);",
                  "pm.environment.set('pyes_status', data.status);",
                  "pm.environment.set('pyes_next_action', data.next_action);",
                  "pm.environment.set('pyes_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('pyes_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{pyes_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{pyes_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"pyes_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('pyes_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('pyes_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('pyes_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('pyes_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "13 — Mahfazati",
      "description": "**Flow prefix:** `mahfazati`. **Order currency:** `YER`. **Customer inputs:** `mahfazati_customer_identifier`.\n\nConfirmation uses `mahfazati_verification_code` (OTP).\n\nServer-only merchant configuration in admin: `merchant_id`, `username`, `password`. Seeded provider base URL: `https://agentapi.tadhamonbank.com/`. Postman calls Sharqiah; it never calls that provider URL directly or sends merchant credentials.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('mahfazati_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{mahfazati_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('mahfazati_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('mahfazati_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{mahfazati_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"YER\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{mahfazati_checkout_key}}\",\n  \"exchange_rate_id\": {{mahfazati_exchange_rate_id}},\n  \"expected_total_minor\": {{mahfazati_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_payment_method_id\", \"mahfazati_quote_total_minor\", \"mahfazati_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('mahfazati_checkout_key')) {",
                  "    pm.environment.set('mahfazati_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mahfazati_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('mahfazati_quote_total_minor')));",
                  "});",
                  "pm.environment.set('mahfazati_order_id', String(data.id));",
                  "pm.environment.set('mahfazati_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('mahfazati_order_currency', data.currency);",
                  "pm.environment.set('mahfazati_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Initiate payment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": {{mahfazati_order_id}},\n  \"idempotency_key\": \"{{mahfazati_idempotency_key}}\",\n  \"customer_identifier\": \"{{mahfazati_customer_identifier}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_order_id\", \"mahfazati_customer_identifier\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('mahfazati_idempotency_key')) {",
                  "    pm.environment.set('mahfazati_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}",
                  "pm.environment.set('mahfazati_last_initiate_body', pm.variables.replaceIn(pm.request.body.raw));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mahfazati_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mahfazati_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mahfazati_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mahfazati_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mahfazati_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mahfazati_payment_id', data.id);",
                  "pm.environment.set('mahfazati_status', data.status);",
                  "pm.environment.set('mahfazati_next_action', data.next_action);",
                  "pm.environment.set('mahfazati_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mahfazati_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. A 502 outcome_unknown can mean the provider accepted the payment: replay this exact body/key to recover its transaction, then check status; do not create a new key. A 2xx response is not proof of settlement: inspect status and next_action.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"order_id\": {{mahfazati_order_id}},\n  \"idempotency_key\": \"{{mahfazati_idempotency_key}}\",\n  \"customer_identifier\": \"{{mahfazati_customer_identifier}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "05 - Replay exact initiation / recover unknown outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
            "body": {
              "mode": "raw",
              "raw": "{{replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_last_initiate_body\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Send Initiate payment first. This also recovers an ambiguous 502 response using the same key.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "pm.variables.set('replay_body', pm.environment.get('mahfazati_last_initiate_body'));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mahfazati_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mahfazati_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mahfazati_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mahfazati_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mahfazati_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (true && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mahfazati_payment_id', data.id);",
                  "pm.environment.set('mahfazati_status', data.status);",
                  "pm.environment.set('mahfazati_next_action', data.next_action);",
                  "pm.environment.set('mahfazati_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mahfazati_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Reuses the fully resolved previous initiation payload, including its idempotency key. Expected 200 and the same transaction ID. Never rotates the payment key automatically.",
                "body": {
                  "mode": "raw",
                  "raw": "{{replay_body}}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "06 - Confirm OTP / payment code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{mahfazati_payment_id}}/confirmation",
            "description": "Enter mahfazati_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"verification_code\": \"{{mahfazati_verification_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (pm.environment.get('mahfazati_status') !== 'requires_confirmation') {",
                  "    console.warn('No confirmation is currently required. Check the payment status.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_verification_code\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Enter the customer OTP/payment code, then send this request manually.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mahfazati_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mahfazati_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mahfazati_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mahfazati_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mahfazati_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mahfazati_payment_id', data.id);",
                  "pm.environment.set('mahfazati_status', data.status);",
                  "pm.environment.set('mahfazati_next_action', data.next_action);",
                  "pm.environment.set('mahfazati_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mahfazati_checkout_url', data.next_action_data.url);",
                  "}",
                  "pm.test('Confirmation completes the payment', () => pm.expect(data.status).to.equal('completed'));",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments/{{mahfazati_payment_id}}/confirmation",
                "description": "Enter mahfazati_verification_code after initiation. This request is skipped while the code is blank, or when status is not requires_confirmation. A 200 response still needs its status checked.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"verification_code\": \"{{mahfazati_verification_code}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"completed\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": \"2026-10-24T10:00:00.000000Z\",\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{mahfazati_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('mahfazati_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('mahfazati_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mahfazati_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('mahfazati_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('mahfazati_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('mahfazati_payment_id', data.id);",
                  "pm.environment.set('mahfazati_status', data.status);",
                  "pm.environment.set('mahfazati_next_action', data.next_action);",
                  "pm.environment.set('mahfazati_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('mahfazati_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{mahfazati_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"requires_confirmation\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"otp\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{mahfazati_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"mahfazati_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('mahfazati_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('mahfazati_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('mahfazati_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('mahfazati_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "14 — Bank / company transfer",
      "description": "**Flow prefix:** `bank_account`. Set `bank_account_reference` before Create. No provider is selected. Evidence remains pending until admin review; there is no customer confirmation or approval endpoint.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('bank_account_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{bank_account_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"bank_account_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('bank_account_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('bank_account_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{bank_account_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{bank_account_checkout_key}}\",\n  \"exchange_rate_id\": {{bank_account_exchange_rate_id}},\n  \"expected_total_minor\": {{bank_account_quote_total_minor}},\n  \"payment_reference\": \"{{bank_account_reference}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"bank_account_payment_method_id\", \"bank_account_quote_total_minor\", \"bank_account_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\", \"bank_account_reference\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('bank_account_checkout_key')) {",
                  "    pm.environment.set('bank_account_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('bank_account_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('bank_account_quote_total_minor')));",
                  "});",
                  "pm.environment.set('bank_account_order_id', String(data.id));",
                  "pm.environment.set('bank_account_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('bank_account_order_currency', data.currency);",
                  "pm.environment.set('bank_account_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Submit transfer evidence (optional receipt)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. Reference and optional receipt stay pending until an authorized administrator reviews them in Filament. There is no customer API to approve transfers. The receipt field is disabled initially: enable it and choose a file in Postman before sending. Retrying must use exactly the same reference, company and receipt bytes.",
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "order_id",
                  "value": "{{bank_account_order_id}}",
                  "type": "text"
                },
                {
                  "key": "idempotency_key",
                  "value": "{{bank_account_idempotency_key}}",
                  "type": "text"
                },
                {
                  "key": "details[reference]",
                  "value": "{{bank_account_reference}}",
                  "type": "text"
                },
                {
                  "key": "receipt",
                  "type": "file",
                  "src": null,
                  "disabled": true,
                  "description": "Optional: enable and select a JPEG/PNG/WebP image up to 4096 KB. Repeat the exact same file on retries."
                }
              ]
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"bank_account_order_id\", \"bank_account_reference\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('bank_account_idempotency_key')) {",
                  "    pm.environment.set('bank_account_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('bank_account_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('bank_account_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('bank_account_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('bank_account_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('bank_account_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('bank_account_payment_id', data.id);",
                  "pm.environment.set('bank_account_status', data.status);",
                  "pm.environment.set('bank_account_next_action', data.next_action);",
                  "pm.environment.set('bank_account_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('bank_account_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. Reference and optional receipt stay pending until an authorized administrator reviews them in Filament. There is no customer API to approve transfers. The receipt field is disabled initially: enable it and choose a file in Postman before sending. Retrying must use exactly the same reference, company and receipt bytes.",
                "body": {
                  "mode": "formdata",
                  "formdata": [
                    {
                      "key": "order_id",
                      "value": "{{bank_account_order_id}}",
                      "type": "text"
                    },
                    {
                      "key": "idempotency_key",
                      "value": "{{bank_account_idempotency_key}}",
                      "type": "text"
                    },
                    {
                      "key": "details[reference]",
                      "value": "{{bank_account_reference}}",
                      "type": "text"
                    },
                    {
                      "key": "receipt",
                      "type": "file",
                      "src": null,
                      "disabled": true,
                      "description": "Optional: enable and select a JPEG/PNG/WebP image up to 4096 KB. Repeat the exact same file on retries."
                    }
                  ]
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"pending\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{bank_account_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"bank_account_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('bank_account_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('bank_account_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('bank_account_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('bank_account_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('bank_account_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('bank_account_payment_id', data.id);",
                  "pm.environment.set('bank_account_status', data.status);",
                  "pm.environment.set('bank_account_next_action', data.next_action);",
                  "pm.environment.set('bank_account_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('bank_account_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{bank_account_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"pending\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{bank_account_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"bank_account_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('bank_account_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('bank_account_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('bank_account_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('bank_account_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "15 — Remittance",
      "description": "**Flow prefix:** `remittance`. Set `remittance_reference` before Create. Set `remittance_company` before evidence submission. No provider is selected. Evidence remains pending until admin review; there is no customer confirmation or approval endpoint.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('remittance_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{remittance_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"remittance_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('remittance_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('remittance_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{remittance_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{remittance_checkout_key}}\",\n  \"exchange_rate_id\": {{remittance_exchange_rate_id}},\n  \"expected_total_minor\": {{remittance_quote_total_minor}},\n  \"payment_reference\": \"{{remittance_reference}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"remittance_payment_method_id\", \"remittance_quote_total_minor\", \"remittance_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\", \"remittance_reference\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('remittance_checkout_key')) {",
                  "    pm.environment.set('remittance_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('remittance_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('remittance_quote_total_minor')));",
                  "});",
                  "pm.environment.set('remittance_order_id', String(data.id));",
                  "pm.environment.set('remittance_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('remittance_order_currency', data.currency);",
                  "pm.environment.set('remittance_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "04 - Submit transfer evidence (optional receipt)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. Reference and optional receipt stay pending until an authorized administrator reviews them in Filament. There is no customer API to approve transfers. The receipt field is disabled initially: enable it and choose a file in Postman before sending. Retrying must use exactly the same reference, company and receipt bytes.",
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "order_id",
                  "value": "{{remittance_order_id}}",
                  "type": "text"
                },
                {
                  "key": "idempotency_key",
                  "value": "{{remittance_idempotency_key}}",
                  "type": "text"
                },
                {
                  "key": "details[reference]",
                  "value": "{{remittance_reference}}",
                  "type": "text"
                },
                {
                  "key": "details[company]",
                  "value": "{{remittance_company}}",
                  "type": "text"
                },
                {
                  "key": "receipt",
                  "type": "file",
                  "src": null,
                  "disabled": true,
                  "description": "Optional: enable and select a JPEG/PNG/WebP image up to 4096 KB. Repeat the exact same file on retries."
                }
              ]
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"remittance_order_id\", \"remittance_reference\", \"remittance_company\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "if (!pm.environment.get('remittance_idempotency_key')) {",
                  "    pm.environment.set('remittance_idempotency_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('remittance_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('remittance_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('remittance_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('remittance_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('remittance_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('remittance_payment_id', data.id);",
                  "pm.environment.set('remittance_status', data.status);",
                  "pm.environment.set('remittance_next_action', data.next_action);",
                  "pm.environment.set('remittance_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('remittance_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "Uses order_id and a stable idempotency_key. Do not send an amount, currency, provider ID or merchant reference. Reference and optional receipt stay pending until an authorized administrator reviews them in Filament. There is no customer API to approve transfers. The receipt field is disabled initially: enable it and choose a file in Postman before sending. Retrying must use exactly the same reference, company and receipt bytes.",
                "body": {
                  "mode": "formdata",
                  "formdata": [
                    {
                      "key": "order_id",
                      "value": "{{remittance_order_id}}",
                      "type": "text"
                    },
                    {
                      "key": "idempotency_key",
                      "value": "{{remittance_idempotency_key}}",
                      "type": "text"
                    },
                    {
                      "key": "details[reference]",
                      "value": "{{remittance_reference}}",
                      "type": "text"
                    },
                    {
                      "key": "details[company]",
                      "value": "{{remittance_company}}",
                      "type": "text"
                    },
                    {
                      "key": "receipt",
                      "type": "file",
                      "src": null,
                      "disabled": true,
                      "description": "Optional: enable and select a JPEG/PNG/WebP image up to 4096 KB. Repeat the exact same file on retries."
                    }
                  ]
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"pending\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "07 - Refresh payment status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{remittance_payment_id}}",
            "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"remittance_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const prior = pm.environment.get('remittance_payment_id');",
                  "pm.test('Payment belongs to this order and has the server-derived amount', () => {",
                  "    pm.expect(data.id).to.match(/^[0-9a-f-]{36}$/i);",
                  "    pm.expect(data.order_id).to.equal(Number(pm.environment.get('remittance_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('remittance_payment_method_id')));",
                  "    pm.expect(data.amount_minor).to.equal(Number(pm.environment.get('remittance_order_total_minor')));",
                  "    pm.expect(data.currency).to.equal(pm.environment.get('remittance_order_currency'));",
                  "    pm.expect(data.status).to.be.oneOf(['created', 'pending', 'requires_confirmation', 'completed', 'failed', 'expired']);",
                  "    pm.expect(data.next_action).to.be.oneOf(['none', 'otp', 'payment_code', 'redirect']);",
                  "    pm.expect(data.has_receipt).to.be.a('boolean');",
                  "    pm.expect(data).not.to.have.property('provider_configuration');",
                  "    pm.expect(data).not.to.have.property('receipt_path');",
                  "});",
                  "pm.test('Payment has not failed or expired', () => pm.expect(data.status).not.to.be.oneOf(['failed', 'expired']));",
                  "if (false && prior) {",
                  "    pm.test('Idempotent replay returns the same payment', () => pm.expect(data.id).to.equal(prior));",
                  "}",
                  "pm.environment.set('remittance_payment_id', data.id);",
                  "pm.environment.set('remittance_status', data.status);",
                  "pm.environment.set('remittance_next_action', data.next_action);",
                  "pm.environment.set('remittance_has_receipt', String(data.has_receipt));",
                  "if (!pm.environment.get('validation_payment_id')) pm.environment.set('validation_payment_id', data.id);",
                  "if (data.next_action === 'redirect') {",
                  "    pm.test('Hosted checkout link exists', () => pm.expect(data.next_action_data.url).to.be.a('string'));",
                  "    pm.environment.set('remittance_checkout_url', data.next_action_data.url);",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  }
                ],
                "url": "{{base_url}}/payments/{{remittance_payment_id}}",
                "description": "Refreshes the transaction. Some adapters cannot conclusively reconcile a remote outcome; pending remains pending until an authoritative result or admin reconciliation. Manual transfers reflect admin review. Mastercard is completed only after capture, not session creation or redirect alone."
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"id\": \"11111111-1111-4111-8111-111111111111\",\n  \"order_id\": 1001,\n  \"payment_method_id\": 101,\n  \"amount_minor\": 150000,\n  \"currency\": \"YER\",\n  \"status\": \"pending\",\n  \"provider_reference\": \"EXAMPLE-REFERENCE\",\n  \"next_action\": \"none\",\n  \"next_action_data\": [],\n  \"failure_code\": null,\n  \"failure_message\": null,\n  \"has_receipt\": false,\n  \"completed_at\": null,\n  \"failed_at\": null,\n  \"expired_at\": null,\n  \"created_at\": \"2026-10-24T10:00:00.000000Z\"\n}"
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{remittance_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"remittance_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('remittance_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('remittance_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('remittance_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('remittance_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "16 — Cash / pay on delivery",
      "description": "**Flow prefix:** `cash`. Uses the order APIs only. Order stays unpaid until cash collection; do not initiate an electronic transaction.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('cash_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{cash_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('cash_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('cash_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{cash_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{cash_checkout_key}}\",\n  \"exchange_rate_id\": {{cash_exchange_rate_id}},\n  \"expected_total_minor\": {{cash_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_payment_method_id\", \"cash_quote_total_minor\", \"cash_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('cash_checkout_key')) {",
                  "    pm.environment.set('cash_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('cash_quote_total_minor')));",
                  "});",
                  "pm.environment.set('cash_order_id', String(data.id));",
                  "pm.environment.set('cash_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('cash_order_currency', data.currency);",
                  "pm.environment.set('cash_order_payment_status', data.payment_status);",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{cash_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"cash_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('cash_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('cash_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('cash_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('cash_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "17 — Customer wallet",
      "description": "**Flow prefix:** `customer_wallet`. Uses the order APIs only. Wallet funds are debited at Create; positive balance is required, and partial payment can leave cash_due.",
      "item": [
        {
          "name": "01 - Discover published method ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "const methods = Array.isArray(data) ? data : data.data;",
                  "pm.test('Returns payment methods', () => pm.expect(methods).to.be.an('array'));",
                  "for (const selector of [{\"prefix\": \"easy_wallet\", \"provider\": \"easy_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mastercard\", \"provider\": \"mastercard\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jaib_wallet\", \"provider\": \"jaib_wallet\", \"type\": \"electronic_payment\"}, {\"prefix\": \"floosak\", \"provider\": \"floosak\", \"type\": \"electronic_payment\"}, {\"prefix\": \"jawali\", \"provider\": \"jawali\", \"type\": \"electronic_payment\"}, {\"prefix\": \"saba_cash\", \"provider\": \"saba_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"shamil_money\", \"provider\": \"shamil_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"cash_pay\", \"provider\": \"cash_pay\", \"type\": \"electronic_payment\"}, {\"prefix\": \"kuraimi_haseb\", \"provider\": \"kuraimi_haseb\", \"type\": \"electronic_payment\"}, {\"prefix\": \"one_cash\", \"provider\": \"one_cash\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mobile_money\", \"provider\": \"mobile_money\", \"type\": \"electronic_payment\"}, {\"prefix\": \"pyes\", \"provider\": \"pyes\", \"type\": \"electronic_payment\"}, {\"prefix\": \"mahfazati\", \"provider\": \"mahfazati\", \"type\": \"electronic_payment\"}, {\"prefix\": \"bank_account\", \"provider\": null, \"type\": \"bank_account\"}, {\"prefix\": \"remittance\", \"provider\": null, \"type\": \"remittance\"}, {\"prefix\": \"cash\", \"provider\": null, \"type\": \"no_details\"}, {\"prefix\": \"customer_wallet\", \"provider\": null, \"type\": \"customer_wallet\"}]) {",
                  "    const key = selector.prefix + '_payment_method_id';",
                  "    const matches = methods.filter(m => m.type === selector.type && (m.provider || null) === selector.provider);",
                  "    const previous = pm.environment.get(key);",
                  "    const selected = matches.find(m => String(m.id) === String(previous)) || matches[0];",
                  "    pm.environment.set(key, selected ? String(selected.id) : '');",
                  "}",
                  "pm.test('Provider configuration stays private', () => {",
                  "    methods.forEach(m => {",
                  "        pm.expect(m).not.to.have.property('configuration');",
                  "        pm.expect(m).to.have.property('payment_inputs');",
                  "    });",
                  "});",
                  "pm.test('Selected method is published and available', () => pm.expect(String(pm.environment.get('customer_wallet_payment_method_id') || '')).not.to.equal(''));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Quote order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/quote",
            "description": "Returns a fresh quote without creating an order. Choose a real published item and your own delivery address. Enter item_variant_id for a variant item. Mastercard requires a USD rate and a total of at least USD 10; One Cash requires minor units divisible by 10.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{customer_wallet_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"customer_wallet_payment_method_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Quote has integer minor units and a rate', () => {",
                  "    pm.expect(data.total_minor).to.be.a('number');",
                  "    pm.expect(Number.isSafeInteger(data.total_minor)).to.equal(true);",
                  "    pm.expect(data.total_minor).to.be.above(0);",
                  "    pm.expect(data).to.have.property('exchange_rate_id');",
                  "});",
                  "pm.environment.set('customer_wallet_quote_total_minor', String(data.total_minor));",
                  "pm.environment.set('customer_wallet_exchange_rate_id', String(data.exchange_rate_id));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Create order (stable checkout key)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders",
            "description": "Creates the order, or returns the same order for an unchanged checkout_key and body. Keep the key for retries. Clear this flow's runtime variables only when deliberately starting another order. The server derives all payment amounts from this order. Wallet orders debit the internal wallet here; no POST /payments is used for cash or wallet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"payment_method_id\": {{customer_wallet_payment_method_id}},\n  \"address_id\": {{address_id}},\n  \"currency\": \"{{base_currency}}\",\n  \"items\": [{\"item_id\": {{item_id}}, \"item_variant_id\": {{item_variant_id_or_null}}, \"quantity\": {{quantity}}}],\n  \"coupon_code\": \"{{coupon_code}}\",\n  \"checkout_key\": \"{{customer_wallet_checkout_key}}\",\n  \"exchange_rate_id\": {{customer_wallet_exchange_rate_id}},\n  \"expected_total_minor\": {{customer_wallet_quote_total_minor}}\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"customer_wallet_payment_method_id\", \"customer_wallet_quote_total_minor\", \"customer_wallet_exchange_rate_id\", \"address_id\", \"item_id\", \"quantity\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Run Quote first; manual orders also require a transfer reference.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const variant = String(pm.environment.get('item_variant_id') || '').trim();",
                  "pm.variables.set('item_variant_id_or_null', variant ? JSON.stringify(Number(variant)) : 'null');",
                  "",
                  "if (!pm.environment.get('customer_wallet_checkout_key')) {",
                  "    pm.environment.set('customer_wallet_checkout_key', pm.variables.replaceIn('{{$guid}}'));",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([201, 200]));",
                  "if ([201, 200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order uses the selected method and quoted total', () => {",
                  "    pm.expect(data.id).to.be.a('number');",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('customer_wallet_payment_method_id')));",
                  "    pm.expect(data.total_minor).to.equal(Number(pm.environment.get('customer_wallet_quote_total_minor')));",
                  "});",
                  "pm.environment.set('customer_wallet_order_id', String(data.id));",
                  "pm.environment.set('customer_wallet_order_total_minor', String(data.total_minor));",
                  "pm.environment.set('customer_wallet_order_currency', data.currency);",
                  "pm.environment.set('customer_wallet_order_payment_status', data.payment_status);",
                  "pm.test('Wallet contributes to the order', () => pm.expect(data.wallet_paid_base).to.be.above(0));",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "08 - Inspect order settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/orders/{{customer_wallet_order_id}}",
            "description": "Confirms the order's payment_status after the transaction. Cash stays unpaid until collection. The internal wallet may cover part of the order, leaving cash_due for the remainder."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"customer_wallet_order_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "const data = pm.response.json();",
                  "pm.test('Order and payment method are unchanged', () => {",
                  "    pm.expect(data.id).to.equal(Number(pm.environment.get('customer_wallet_order_id')));",
                  "    pm.expect(data.payment_method_id).to.equal(Number(pm.environment.get('customer_wallet_payment_method_id')));",
                  "});",
                  "pm.test('Payment state is valid', () => pm.expect(data.payment_status).to.be.oneOf(['unpaid', 'unconfirmed', 'confirmed', 'reversed']));",
                  "pm.environment.set('customer_wallet_order_payment_status', data.payment_status);",
                  "if (pm.environment.get('customer_wallet_status') === 'completed') {",
                  "    pm.test('Completed transaction confirms the order', () => pm.expect(data.payment_status).to.equal('confirmed'));",
                  "}",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "09 - Inspect wallet ledger after order",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/wallet",
            "description": "Verify the debit and any cash remainder against the order response."
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "90 — Contract and authorization failures",
      "description": "These requests should fail with the specified HTTP status. They do not submit an invalid OTP to a provider. Idempotency and ownership tests require an existing payment; another-customer check requires other_access_token.",
      "item": [
        {
          "name": "01 - Reject missing app key",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": ""
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([401]));",
                  "if ([401].includes(pm.response.code)) {",
                  "pm.test('Authentication error is JSON', () => pm.expect(pm.response.json()).to.have.property('message'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "02 - Reject missing customer token",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payment-methods",
            "description": "",
            "auth": {
              "type": "noauth"
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([401]));",
                  "if ([401].includes(pm.response.code)) {",
                  "",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "03 - Reject missing payment input",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([422]));",
                  "if ([422].includes(pm.response.code)) {",
                  "pm.test('Required payment fields are documented by errors', () => pm.expect(pm.response.json().errors).to.have.all.keys('order_id', 'idempotency_key'));",
                  "}"
                ]
              }
            }
          ],
          "response": [
            {
              "name": "Illustrative response (not a live provider result)",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Accept-Language",
                    "value": "{{language}}"
                  },
                  {
                    "key": "X-App-Key",
                    "value": "{{app_key}}"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": "{{base_url}}/payments",
                "description": "",
                "body": {
                  "mode": "raw",
                  "raw": "{}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Unprocessable Content",
              "code": 422,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json"
                }
              ],
              "cookie": [],
              "body": "{\n  \"message\": \"The order id field is required. (and 1 more error)\",\n  \"errors\": {\n    \"order_id\": [\n      \"The order id field is required.\"\n    ],\n    \"idempotency_key\": [\n      \"The idempotency key field is required.\"\n    ]\n  }\n}"
            }
          ]
        },
        {
          "name": "04 - Reject client-controlled amount / currency / method / reference",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order_id\": 0,\n  \"idempotency_key\": \"{{$guid}}\",\n  \"amount_minor\": 1,\n  \"currency\": \"USD\",\n  \"payment_method_id\": 1,\n  \"merchant_reference\": \"client-supplied\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([422]));",
                  "if ([422].includes(pm.response.code)) {",
                  "pm.test('Server owns payment pricing and identity', () => pm.expect(pm.response.json().errors).to.include.all.keys('amount_minor', 'currency', 'payment_method_id', 'merchant_reference'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "05 - Reject empty confirmation code",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments/{{validation_payment_id}}/confirmation",
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"validation_payment_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Initiate a payment first, or enter an owned payment UUID.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([422]));",
                  "if ([422].includes(pm.response.code)) {",
                  "pm.test('Code is required', () => pm.expect(pm.response.json().errors).to.have.property('verification_code'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "06 - Reject changed data with an existing payment key",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/payments",
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{{negative_replay_body}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "const flow = pm.environment.get('validation_flow') || 'floosak';",
                  "const raw = pm.environment.get(flow + '_last_initiate_body');",
                  "if (!raw || !pm.environment.get(flow + '_payment_id')) {",
                  "    console.warn('Complete initiation for validation_flow first.');",
                  "    pm.execution.skipRequest();",
                  "}",
                  "const changedPayload = JSON.parse(raw);",
                  "changedPayload.details = Object.assign({}, changedPayload.details, {reference: 'POSTMAN-CHANGED-IDEMPOTENCY-DATA'});",
                  "pm.variables.set('negative_replay_body', JSON.stringify(changedPayload));"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([422]));",
                  "if ([422].includes(pm.response.code)) {",
                  "pm.test('Changed idempotency payload is rejected before a new charge', () => pm.expect(pm.response.json().errors).to.have.property('idempotency_key'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "07 - Hide payment from another customer",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              }
            ],
            "url": "{{base_url}}/payments/{{validation_payment_id}}",
            "description": "",
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{other_access_token}}",
                  "type": "string"
                }
              ]
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"validation_payment_id\", \"other_access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Supply a DIFFERENT customer token and an existing payment UUID.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([404]));",
                  "if ([404].includes(pm.response.code)) {",
                  "",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "91 — Optional order payment-method change",
      "description": "Only send this for an explicitly chosen order. The server rejects switching an order with an unresolved transaction. Leave the change_* variables blank to skip this request during a run.",
      "item": [
        {
          "name": "Change selected order payment method",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Accept-Language",
                "value": "{{language}}"
              },
              {
                "key": "X-App-Key",
                "value": "{{app_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/{{change_order_id}}/payment-method",
            "description": "Optional manual action for a separate order. Supply change_payment_reference for bank/remittance. No unresolved electronic or manual transaction may be attached. Wallet switching can debit/reverse wallet funds.",
            "body": {
              "mode": "raw",
              "raw": "{\"payment_method_id\": {{change_payment_method_id}}, \"payment_reference\": \"{{change_payment_reference}}\"}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "{",
                  "const missing = [\"access_token\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Set access_token, or finish the customer OTP login in Setup.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}",
                  "",
                  "{",
                  "const missing = [\"change_order_id\", \"change_payment_method_id\"].filter(key => !String(pm.environment.get(key) || '').trim());",
                  "if (missing.length) {",
                  "    console.warn(\"Complete the required environment values first.\" + ' Missing: ' + missing.join(', '));",
                  "    pm.execution.skipRequest();",
                  "}",
                  "}"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Expected HTTP status', () => pm.expect(pm.response.code).to.be.oneOf([200]));",
                  "if ([200].includes(pm.response.code)) {",
                  "pm.test('Order uses the requested payment method', () => pm.expect(pm.response.json().payment_method_id).to.equal(Number(pm.environment.get('change_payment_method_id'))));",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
