openapi: 3.1.0
info:
  title: BloomCore Payment Methods API
  version: 1.0.0
  description: |
    Read-only API эффективных способов оплаты конкретного магазина. Ответ объединяет
    общие настройки компании и настройки точки: запись магазина с тем же code
    перекрывает общую запись. Возвращаются только активные способы оплаты.
    Все CRM-идентификаторы во внешнем контракте являются UUID.
servers:
  - url: https://{tenant_subdomain}.crm.flowers/api/v1
    variables:
      tenant_subdomain:
        default: florio
security:
  - bearerAuth: []
tags:
  - name: Payment methods
    description: Безопасный справочник способов оплаты текущего магазина.
paths:
  /payment-methods:
    get:
      tags: [Payment methods]
      operationId: listPaymentMethods
      summary: Получить способы оплаты текущего магазина
      description: |
        Требует token scope payments.view, CRM-право payments.view и активный доступ
        владельца токена к магазину поддомена. Query-параметры не принимаются.
        Ответ не содержит provider, settings, metadata, внутренних bigint ID,
        кассовых реквизитов или учетных данных провайдера.
      responses:
        '200':
          description: Упорядоченный список активных способов оплаты.
          headers:
            Cache-Control:
              schema:
                type: string
                const: max-age=0, no-store, private
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethodListResponse'
              example:
                success: true
                data:
                  items:
                    - id: 019f7c83-a91d-7238-9c0b-28b10ad9ef51
                      code: cash
                      name: Наличные
                      type: cash
                      currency_code: RUB
                      is_cash: true
                      requires_fiscalization: false
                      supports_refund: true
                      sort_order: 10
                      revision: 8c573d62f67bf73f95dcf3426e6790ebdb1a98d9d3386051407e27ef4c80f9b2
                  count: 1
                request_id: 019f7c83-a91d-7238-9c0b-28b10ad9ef52
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationFailed'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Sanctum
  schemas:
    PaymentMethod:
      type: object
      additionalProperties: false
      required:
        - id
        - code
        - name
        - type
        - currency_code
        - is_cash
        - requires_fiscalization
        - supports_refund
        - sort_order
        - revision
      properties:
        id:
          type: string
          format: uuid
        code:
          type: string
          maxLength: 64
        name:
          type: string
          maxLength: 255
        type:
          type: string
          enum: [cash, card, bank_transfer, online_card, bonus, certificate, other]
        currency_code:
          type: string
          pattern: '^[A-Z]{3}$'
        is_cash:
          type: boolean
        requires_fiscalization:
          type: boolean
        supports_refund:
          type: boolean
        sort_order:
          type: integer
          minimum: 0
        revision:
          type: string
          pattern: '^[a-f0-9]{64}$'
          description: |
            Непрозрачная версия публичной проекции способа оплаты. Не вычисляйте ее
            самостоятельно; при будущей финансовой mutation передавайте значение,
            полученное из актуального ответа.
    PaymentMethodList:
      type: object
      additionalProperties: false
      required: [items, count]
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/PaymentMethod'
        count:
          type: integer
          minimum: 0
    PaymentMethodListResponse:
      type: object
      additionalProperties: false
      required: [success, data, request_id]
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/PaymentMethodList'
        request_id:
          type: string
          format: uuid
    Error:
      type: object
      additionalProperties: false
      required: [code, message, details]
      properties:
        code:
          type: string
        message:
          type: string
        details:
          type: object
    ErrorResponse:
      type: object
      additionalProperties: false
      required: [success, error, request_id]
      properties:
        success:
          type: boolean
          const: false
        error:
          $ref: '#/components/schemas/Error'
        request_id:
          type: string
          format: uuid
  responses:
    Unauthenticated:
      description: Bearer token отсутствует, истек или отозван.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Tenant/store, token scope, SaaS entitlement или CRM RBAC не разрешает запрос.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationFailed:
      description: Передан неподдерживаемый query-параметр.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
