{
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "approve",
        "review"
      ],
      "description": "Approve a substantiated duplicate charge when permitted; otherwise choose review.",
      "x-runtime": {
        "choices": {
          "approve": {
            "eligibleWhen": {
              "all": [
                {
                  "eq": [
                    {
                      "ref": "state/order/paid"
                    },
                    true
                  ]
                },
                {
                  "lte": [
                    {
                      "ref": "state/order/amount"
                    },
                    {
                      "ref": "state/refund_limit"
                    }
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "reason": {
      "type": "string",
      "enum": [
        "duplicate_charge",
        "manual_review"
      ],
      "description": "The reason for the decision."
    }
  },
  "required": [
    "action",
    "reason"
  ],
  "additionalProperties": false,
  "if": {
    "properties": {
      "action": {
        "const": "approve"
      }
    },
    "required": [
      "action"
    ]
  },
  "then": {
    "properties": {
      "reason": {
        "const": "duplicate_charge"
      }
    }
  },
  "else": {
    "properties": {
      "reason": {
        "const": "manual_review"
      }
    }
  }
}
