{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agentdrives-com/json-schema/agentdrives-com-payment-map-schema.json",
  "title": "PaymentMap",
  "description": "The Audit only: each way the product takes money against each step, a cell passed or partly only with evidence, and the money trail. Codes and card details never appear",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/agentdrives-com-openapi.json#/components/schemas/PaymentMap",
  "type": "object",
  "properties": {
    "version": {
      "const": 1
    },
    "run": {
      "type": "string"
    },
    "steps": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "enum": [
              "discover",
              "quote",
              "pay",
              "access",
              "receipt",
              "use",
              "topup",
              "change",
              "leave",
              "spend"
            ]
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "rails": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "enum": [
              "card",
              "spt",
              "x402",
              "mpp",
              "acp"
            ]
          },
          "name": {
            "type": "string"
          },
          "cells": {
            "type": "object",
            "description": "One per step id",
            "additionalProperties": {
              "$ref": "#/$defs/PaymentMapCell"
            }
          }
        }
      }
    },
    "trail": {
      "type": "object",
      "properties": {
        "payments": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "rail": {
                "enum": [
                  "card",
                  "spt",
                  "x402",
                  "mpp",
                  "acp"
                ]
              },
              "what": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              },
              "to": {
                "enum": [
                  "you",
                  "us"
                ]
              },
              "status": {
                "enum": [
                  "paid",
                  "refunded"
                ]
              },
              "tx": {
                "type": "string"
              },
              "url": {
                "type": "string"
              }
            }
          }
        },
        "cancelled": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "what": {
                "type": "string"
              },
              "at": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "how": {
                "type": "string"
              }
            }
          }
        },
        "paid": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              }
            }
          }
        },
        "refunded": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "net": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      }
    }
  },
  "$defs": {
    "PaymentMapCell": {
      "type": "object",
      "required": [
        "state",
        "text",
        "evidence"
      ],
      "properties": {
        "state": {
          "enum": [
            "passed",
            "partly",
            "blocked",
            "not_offered",
            "not_tried"
          ]
        },
        "text": {
          "type": "string"
        },
        "evidence": {
          "type": "array",
          "description": "Never empty when passed or partly",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "enum": [
                  "request",
                  "receipt",
                  "tx",
                  "seconds",
                  "shot",
                  "page"
                ]
              },
              "text": {
                "type": "string"
              },
              "url": {
                "type": "string"
              }
            }
          }
        },
        "blocks": {
          "type": "string",
          "description": "Blocked: what stops an agent"
        },
        "fix": {
          "type": "string",
          "description": "Blocked or partly: the fix, in your terms"
        }
      }
    }
  }
}