openapi: "3.0.3"
info:
  title: "Payment gateway fixture for a stubbing walkthrough"
  version: "1.0.0"
  description: "The gateway enum has three members and the manual member is what an in-house test gateway reports. The requires_action state is the interesting branch, because it is the one that produces a client-side challenge. The gateway reference is nullable, because a failed charge never receives one from the provider. The merchant reference means the stub needs the merchant row to exist before it can answer a charge request."
paths: {}
x-domain-id: "tut_gateway"
x-dialect: "postgres"
components:
  schemas:
    merchants:
      type: "object"
      x-primary-key: "id"
      required: ["id", "name", "gateway"]
      properties:
        id:
          type: "string"
          format: "uuid"
        name:
          type: "string"
          x-unique: true
        gateway:
          type: "string"
          enum: ["stripe", "adyen", "manual"]
    charges:
      type: "object"
      x-primary-key: "id"
      required: ["id", "merchant_id", "amount_cents", "state"]
      properties:
        id:
          type: "string"
          format: "uuid"
        merchant_id:
          $ref: "#/components/schemas/merchants"
        amount_cents:
          type: "integer"
          minimum: 1
        state:
          type: "string"
          enum: ["requires_action", "settled", "failed"]
        gateway_ref:
          type: "string"
          nullable: true
