{
  "info": {
    "name": "Payment Flow - Complete Tests",
    "description": "Test the complete payment flow with Authorize.Net webhooks",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "1. Successful Payment",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"bookingId\": \"888\",\n  \"userId\": \"999\",\n  \"amount\": 299.99,\n  \"currency\": \"USD\",\n  \"card\": {\n    \"cardNumber\": \"4007000000027\",\n    \"expiry\": \"12/28\",\n    \"cvv\": \"999\"\n  }\n}"
        },
        "url": {
          "raw": "http://localhost:3004/payments/initiate",
          "protocol": "http",
          "host": ["localhost"],
          "port": "3004",
          "path": ["payments", "initiate"]
        },
        "description": "Initiate a successful payment. Card will be approved."
      }
    },
    {
      "name": "2. Declined Payment",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"bookingId\": \"888\",\n  \"userId\": \"999\",\n  \"amount\": 299.99,\n  \"currency\": \"USD\",\n  \"card\": {\n    \"cardNumber\": \"4000300011112220\",\n    \"expiry\": \"12/28\",\n    \"cvv\": \"999\"\n  }\n}"
        },
        "url": {
          "raw": "http://localhost:3004/payments/initiate",
          "protocol": "http",
          "host": ["localhost"],
          "port": "3004",
          "path": ["payments", "initiate"]
        },
        "description": "Initiate a payment that will be declined by Authorize.Net"
      }
    },
    {
      "name": "3. Fraud Hold Payment",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"bookingId\": \"888\",\n  \"userId\": \"999\",\n  \"amount\": 150.00,\n  \"currency\": \"USD\",\n  \"card\": {\n    \"cardNumber\": \"4007000000027\",\n    \"expiry\": \"12/28\",\n    \"cvv\": \"999\"\n  }\n}"
        },
        "url": {
          "raw": "http://localhost:3004/payments/initiate",
          "protocol": "http",
          "host": ["localhost"],
          "port": "3004",
          "path": ["payments", "initiate"]
        },
        "description": "Amount > $100 may trigger fraud hold in sandbox"
      }
    },
    {
      "name": "4. Simulate Webhook (Manual Confirmation)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"transactionId\": \"REPLACE_WITH_TRANSACTION_ID_FROM_WORKER_LOG\",\n  \"responseCode\": 1,\n  \"authAmount\": 299.99\n}"
        },
        "url": {
          "raw": "http://localhost:3004/webhooks/simulate",
          "protocol": "http",
          "host": ["localhost"],
          "port": "3004",
          "path": ["webhooks", "simulate"]
        },
        "description": "Manually trigger webhook to mark payment as SUCCESS and booking as CONFIRMED. Get transactionId from worker logs."
      }
    },
    {
      "name": "5. Get Payment Status",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "http://localhost:3004/payments/:paymentId",
          "protocol": "http",
          "host": ["localhost"],
          "port": "3004",
          "path": ["payments", ":paymentId"],
          "variable": [
            {
              "key": "paymentId",
              "value": "REPLACE_WITH_PAYMENT_ID"
            }
          ]
        },
        "description": "Check payment status - replace :paymentId with actual ID from step 1"
      }
    },
    {
      "name": "6. Get Booking Status",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "http://localhost:3002/bookings/:bookingId",
          "protocol": "http",
          "host": ["localhost"],
          "port": "3002",
          "path": ["bookings", ":bookingId"],
          "variable": [
            {
              "key": "bookingId",
              "value": "888"
            }
          ]
        },
        "description": "Check if booking is CONFIRMED after webhook (requires booking-service running)"
      }
    },
    {
      "name": "7. Health Check",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "http://localhost:3004/health",
          "protocol": "http",
          "host": ["localhost"],
          "port": "3004",
          "path": ["health"]
        },
        "description": "Verify payment service is running"
      }
    }
  ]
}
