openapi: "3.0.3"
info:
  title: "Payments API"
  version: "1.0.0"
  description: "A captured payment that was later refunded is still one row, and the refunded status is the current state. The amount constraint is strictly positive, so a zero-amount authorisation attempt is an invalid instance. The currency check constraint is the simplest three-letter check to assert against. The merchant reference means a payment fixture needs a merchant row first."
paths: {}
x-domain-id: "prob_payments"
x-dialect: "postgres"
components:
  schemas:
    merchants:
      type: "object"
      x-primary-key: "id"
      required: ["id", "name"]
      properties:
        id:
          type: "string"
          format: "uuid"
        name:
          type: "string"
          x-unique: true
    payments:
      type: "object"
      x-primary-key: "id"
      required: ["id", "merchant_id", "amount_cents", "currency", "status"]
      properties:
        id:
          type: "string"
          format: "uuid"
        merchant_id:
          $ref: "#/components/schemas/merchants"
        amount_cents:
          type: "integer"
          minimum: 1
        currency:
          type: "string"
          minLength: 3
          maxLength: 3
        status:
          type: "string"
          enum: ["pending", "captured", "refunded", "failed"]
