{
  "openapi": "3.0.3",
  "info": {
    "title": "Платёжка API",
    "version": "1",
    "description": "Приём платежей картой и по СБП. Суммы — целые числа в копейках, даты — ISO 8601. Результат платежа приходит вебхуком или запросом GET /payments/{id}."
  },
  "servers": [
    {
      "url": "https://platezhka.online/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/payments": {
      "post": {
        "summary": "Создать платёж",
        "operationId": "create_payments",
        "responses": {
          "201": {
            "description": "Создать платёж",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Повтор с тем же ключом и телом возвращает сохранённый ответ",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "integer",
                    "description": "Сумма в копейках"
                  },
                  "order_id": {
                    "type": "string",
                    "description": "Номер заказа в вашей системе, до 128 символов. Возвращается в платеже и вебхуках, по нему ищут в кабинете и в GET /payments"
                  },
                  "description": {
                    "type": "string",
                    "description": "Назначение, до 1000 символов; показывается плательщику и в ПЦ"
                  },
                  "capture": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "manual"
                    ],
                    "description": "auto — автосписание (по умолчанию из настроек магазина), manual — холд с последующим capture"
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "card",
                      "sbp"
                    ],
                    "description": "Что виджет показывает первым: sbp — QR (по умолчанию), card — форму карты"
                  },
                  "confirmation": {
                    "type": "object",
                    "description": "{type: hosted} — виджет (по умолчанию); {type: redirect} с method card — payment_url ведёт прямо на форму ПЦ"
                  },
                  "return_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Куда вернуть плательщика. После оплаты возвращаем автоматически через 5 секунд и добавляем payment_id=<id>"
                  },
                  "customer": {
                    "type": "object",
                    "description": "Покупатель: id — идентификатор в вашей системе (до 128 символов), email и phone — контакт для чека"
                  },
                  "items": {
                    "type": "array",
                    "items": {},
                    "description": "Позиции чека (text, price, quantity, tax, paymentSubjectType, paymentMethodType). Сумма позиций должна равняться amount. Без позиций чек формируется одной строкой из description"
                  },
                  "metadata": {
                    "type": "object",
                    "description": "Произвольные данные, возвращаются как есть"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Срок оплаты (по умолчанию — из настроек магазина)"
                  },
                  "save_payment_method": {
                    "type": "boolean",
                    "description": "Автосписания: сохранить способ оплаты покупателя (только СБП). Требует включённых автосписаний"
                  },
                  "payment_method_id": {
                    "type": "string",
                    "description": "Автосписания: списать по сохранённому способу без участия покупателя; ответ сразу содержит результат"
                  }
                },
                "required": [
                  "amount"
                ]
              }
            }
          }
        }
      },
      "get": {
        "summary": "Список платежей",
        "operationId": "list_payments",
        "responses": {
          "200": {
            "description": "Список платежей",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/payment"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Статус платежа",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "authorized",
                "succeeded",
                "canceled",
                "expired",
                "refunded",
                "partially_refunded",
                "on_hold"
              ]
            }
          },
          {
            "name": "order_id",
            "in": "query",
            "required": false,
            "description": "Номер заказа магазина, точное совпадение",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "description": "Идентификатор покупателя магазина",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "method",
            "in": "query",
            "required": false,
            "description": "Способ оплаты",
            "schema": {
              "type": "string",
              "enum": [
                "card",
                "sbp"
              ]
            }
          },
          {
            "name": "created_from",
            "in": "query",
            "required": false,
            "description": "Созданы не раньше, ISO 8601",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "created_to",
            "in": "query",
            "required": false,
            "description": "Созданы не позже, ISO 8601",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, до 100 (по умолчанию 20)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "description": "id последнего полученного объекта",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/payments/{id}": {
      "get": {
        "summary": "Получить платёж",
        "operationId": "get_payments",
        "responses": {
          "200": {
            "description": "Получить платёж",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/payments/{id}/capture": {
      "post": {
        "summary": "Списать холд",
        "operationId": "capture_payments",
        "responses": {
          "200": {
            "description": "Списать холд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "integer",
                    "description": "Сумма частичного списания, не больше холда"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/payments/{id}/cancel": {
      "post": {
        "summary": "Отменить неоплаченный платёж или холд",
        "operationId": "cancel_payments",
        "responses": {
          "200": {
            "description": "Отменить неоплаченный платёж или холд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/refunds": {
      "post": {
        "summary": "Создать возврат",
        "operationId": "create_refunds",
        "responses": {
          "201": {
            "description": "Создать возврат",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/refund"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Повтор с тем же ключом и телом возвращает сохранённый ответ",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payment_id": {
                    "type": "string",
                    "description": "Платёж"
                  },
                  "amount": {
                    "type": "integer",
                    "description": "Сумма возврата в копейках; без неё — весь остаток"
                  },
                  "items": {
                    "type": "array",
                    "items": {},
                    "description": "Возвращаемые позиции чека при частичном возврате"
                  },
                  "reason": {
                    "type": "string",
                    "description": "Причина возврата"
                  }
                },
                "required": [
                  "payment_id"
                ]
              }
            }
          }
        }
      },
      "get": {
        "summary": "Список возвратов",
        "operationId": "list_refunds",
        "responses": {
          "200": {
            "description": "Список возвратов",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/refund"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "payment_id",
            "in": "query",
            "required": false,
            "description": "Только по этому платежу",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, до 100 (по умолчанию 20)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "description": "id последнего полученного объекта",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/refunds/{id}": {
      "get": {
        "summary": "Получить возврат",
        "operationId": "get_refunds",
        "responses": {
          "200": {
            "description": "Получить возврат",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/refund"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/receipts/{id}": {
      "get": {
        "summary": "Получить чек",
        "operationId": "get_receipts",
        "responses": {
          "200": {
            "description": "Получить чек",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/receipt"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/invoices": {
      "post": {
        "summary": "Выставить счёт",
        "operationId": "create_invoices",
        "responses": {
          "201": {
            "description": "Выставить счёт",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/invoice"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Повтор с тем же ключом и телом возвращает сохранённый ответ",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "integer",
                    "description": "Сумма в копейках"
                  },
                  "description": {
                    "type": "string",
                    "description": "Назначение счёта"
                  },
                  "comment": {
                    "type": "string",
                    "description": "Комментарий для покупателя"
                  },
                  "capture": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "manual"
                    ],
                    "description": "Режим списания"
                  },
                  "customer": {
                    "type": "object",
                    "description": "Получатель: email, phone"
                  },
                  "items": {
                    "type": "array",
                    "items": {},
                    "description": "Позиции чека"
                  },
                  "return_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Куда вернуть плательщика после оплаты"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Срок оплаты"
                  },
                  "send_email": {
                    "type": "boolean",
                    "description": "Отправить счёт письмом на customer.email"
                  }
                },
                "required": [
                  "amount"
                ]
              }
            }
          }
        }
      },
      "get": {
        "summary": "Список счетов",
        "operationId": "list_invoices",
        "responses": {
          "200": {
            "description": "Список счетов",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, до 100 (по умолчанию 20)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "description": "id последнего полученного объекта",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/invoices/{id}": {
      "get": {
        "summary": "Получить счёт",
        "operationId": "get_invoices",
        "responses": {
          "200": {
            "description": "Получить счёт",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/invoice"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/invoices/{id}/cancel": {
      "post": {
        "summary": "Отменить счёт",
        "operationId": "cancel_invoices",
        "responses": {
          "200": {
            "description": "Отменить счёт",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/invoice"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/payment_links": {
      "post": {
        "summary": "Создать ссылку на оплату",
        "operationId": "create_payment_links",
        "responses": {
          "201": {
            "description": "Создать ссылку на оплату",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment_link"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Повтор с тем же ключом и телом возвращает сохранённый ответ",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Название"
                  },
                  "amount": {
                    "type": "integer",
                    "description": "Сумма в копейках; без неё сумму вводит плательщик"
                  },
                  "description": {
                    "type": "string",
                    "description": "Описание"
                  },
                  "items": {
                    "type": "array",
                    "items": {},
                    "description": "Позиции чека (для фиксированной суммы)"
                  },
                  "success_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Куда вернуть плательщика после оплаты"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Срок действия"
                  }
                },
                "required": [
                  "title"
                ]
              }
            }
          }
        }
      }
    },
    "/payment_links/{id}": {
      "get": {
        "summary": "Получить ссылку на оплату",
        "operationId": "get_payment_links",
        "responses": {
          "200": {
            "description": "Получить ссылку на оплату",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment_link"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/balance": {
      "get": {
        "summary": "Баланс магазина",
        "operationId": "get_balance",
        "responses": {
          "200": {
            "description": "Баланс магазина",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/balance"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        }
      }
    },
    "/payouts": {
      "post": {
        "summary": "Создать выплату",
        "operationId": "create_payouts",
        "responses": {
          "201": {
            "description": "Создать выплату",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payout"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Повтор с тем же ключом и телом возвращает сохранённый ответ",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "integer",
                    "description": "Сумма в копейках"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "debit",
                      "net"
                    ],
                    "description": "debit — amount списывается с баланса, net — amount приходит получателю"
                  },
                  "all_available": {
                    "type": "boolean",
                    "description": "Вывести весь доступный остаток"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "Список выплат",
        "operationId": "list_payouts",
        "responses": {
          "200": {
            "description": "Список выплат",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/payout"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, до 100 (по умолчанию 20)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "description": "id последнего полученного объекта",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/payouts/{id}": {
      "get": {
        "summary": "Получить выплату",
        "operationId": "get_payouts",
        "responses": {
          "200": {
            "description": "Получить выплату",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payout"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/webhook_endpoints": {
      "post": {
        "summary": "Добавить адрес вебхука",
        "operationId": "create_webhook_endpoints",
        "responses": {
          "201": {
            "description": "Добавить адрес вебхука",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/webhook_endpoint"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Адрес (только https)"
                  },
                  "events": {
                    "type": "array",
                    "items": {},
                    "description": "События; если параметр не передан — все, кроме payment.pending"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        }
      },
      "get": {
        "summary": "Список адресов вебхуков",
        "operationId": "list_webhook_endpoints",
        "responses": {
          "200": {
            "description": "Список адресов вебхуков",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/webhook_endpoint"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook_endpoints/{id}": {
      "delete": {
        "summary": "Удалить адрес вебхука",
        "operationId": "delete_webhook_endpoints",
        "responses": {
          "204": {
            "description": "Удалено"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/payment_methods": {
      "get": {
        "summary": "Список сохранённых способов оплаты",
        "operationId": "list_payment_methods",
        "responses": {
          "200": {
            "description": "Список сохранённых способов оплаты",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/payment_method"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "description": "Покупатель в вашей системе",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Статус",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, до 100 (по умолчанию 20)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "description": "id последнего полученного объекта",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/payment_methods/{id}": {
      "get": {
        "summary": "Получить способ оплаты",
        "operationId": "get_payment_methods",
        "responses": {
          "200": {
            "description": "Получить способ оплаты",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment_method"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Отключить способ оплаты",
        "operationId": "delete_payment_methods",
        "responses": {
          "200": {
            "description": "Отключить способ оплаты",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/payment_method"
                }
              }
            }
          },
          "default": {
            "description": "Ошибка",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Секретный ключ магазина: sk_test_… или sk_live_…"
      }
    },
    "schemas": {
      "payment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Идентификатор платежа, pay_…"
          },
          "object": {
            "type": "string",
            "description": "Всегда payment"
          },
          "shop_id": {
            "type": "string",
            "description": "Номер магазина"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ],
            "description": "Контур магазина"
          },
          "test": {
            "type": "boolean",
            "description": "true для платежа тестового магазина"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "authorized",
              "succeeded",
              "canceled",
              "expired",
              "refunded",
              "partially_refunded",
              "on_hold"
            ],
            "description": "Статус платежа"
          },
          "amount": {
            "type": "integer",
            "description": "Сумма в копейках"
          },
          "currency": {
            "type": "string",
            "description": "Всегда RUB"
          },
          "captured_amount": {
            "type": "integer",
            "description": "Списано, копейки"
          },
          "refunded_amount": {
            "type": "integer",
            "description": "Возвращено, копейки"
          },
          "order_id": {
            "type": "string",
            "description": "Номер заказа в вашей системе"
          },
          "description": {
            "type": "string",
            "description": "Назначение платежа"
          },
          "capture_mode": {
            "type": "string",
            "enum": [
              "auto",
              "manual"
            ],
            "description": "auto — автосписание, manual — холд"
          },
          "method": {
            "type": "string",
            "enum": [
              "card",
              "sbp"
            ],
            "description": "Способ оплаты; пусто, пока плательщик не выбрал"
          },
          "confirmation": {
            "type": "object",
            "description": "Сценарий подтверждения: {type: hosted | redirect}"
          },
          "payment_url": {
            "type": "string",
            "format": "uri",
            "description": "Виджет на нашей странице — для ссылок и писем; на сайте используйте виджет с id платежа"
          },
          "return_url": {
            "type": "string",
            "format": "uri",
            "description": "Куда вернуть плательщика после оплаты"
          },
          "customer": {
            "type": "object",
            "description": "Покупатель: id (в вашей системе), email, phone"
          },
          "items": {
            "type": "array",
            "items": {},
            "description": "Позиции чека"
          },
          "metadata": {
            "type": "object",
            "description": "Произвольные данные магазина, возвращаются как есть"
          },
          "source": {
            "type": "string",
            "enum": [
              "cabinet",
              "api",
              "link"
            ],
            "description": "Канал создания"
          },
          "save_payment_method": {
            "type": "boolean",
            "description": "Платёж с сохранением способа оплаты для автосписаний"
          },
          "payment_method": {
            "type": "object",
            "description": "Сохранённый способ оплаты: id, type, title. Появляется после привязки или при автосписании"
          },
          "decline": {
            "type": "object",
            "description": "Отказ банка: reason_code, message. Только при status = canceled"
          },
          "cancel_reason": {
            "type": "string",
            "description": "merchant_canceled — отменён магазином до оплаты; charge_failed — автосписание не прошло; register_failed — ПЦ не зарегистрировал заказ"
          },
          "receipt_url": {
            "type": "string",
            "format": "uri",
            "description": "Ссылка на чек в ОФД"
          },
          "receipt_status": {
            "type": "string",
            "description": "Состояние чека"
          },
          "paygine_order_id": {
            "type": "integer",
            "description": "Номер заказа в процессинговом центре"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Срок оплаты"
          },
          "paid_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время оплаты"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время создания"
          }
        },
        "description": "Платёж"
      },
      "refund": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Идентификатор возврата, rf_…"
          },
          "object": {
            "type": "string",
            "description": "Всегда refund"
          },
          "payment_id": {
            "type": "string",
            "description": "Платёж, по которому сделан возврат"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "failed"
            ],
            "description": "Статус возврата"
          },
          "amount": {
            "type": "integer",
            "description": "Сумма возврата, копейки"
          },
          "currency": {
            "type": "string",
            "description": "Всегда RUB"
          },
          "reason": {
            "type": "string",
            "description": "Причина возврата"
          },
          "items": {
            "type": "array",
            "items": {},
            "description": "Возвращаемые позиции чека"
          },
          "error": {
            "type": "string",
            "description": "Причина ошибки при status = failed"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время создания"
          }
        },
        "description": "Возврат"
      },
      "receipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Идентификатор чека"
          },
          "object": {
            "type": "string",
            "description": "Всегда receipt"
          },
          "payment_id": {
            "type": "string",
            "description": "Платёж"
          },
          "kind": {
            "type": "string",
            "enum": [
              "sale",
              "refund"
            ],
            "description": "Чек прихода или возврата"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "ready",
              "failed"
            ],
            "description": "Состояние чека"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Ссылка на чек в ОФД"
          },
          "refund_id": {
            "type": "string",
            "description": "Возврат, для чека возврата"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время создания"
          }
        },
        "description": "Чек"
      },
      "payout": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Идентификатор выплаты, po_…"
          },
          "object": {
            "type": "string",
            "description": "Всегда payout"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "awaiting_confirmation",
              "processing",
              "succeeded",
              "failed",
              "canceled"
            ],
            "description": "Статус выплаты"
          },
          "channel": {
            "type": "string",
            "enum": [
              "bank_account",
              "sbp",
              "card"
            ],
            "description": "Канал выплаты"
          },
          "amount": {
            "type": "integer",
            "description": "Сумма списания с баланса, копейки"
          },
          "fee": {
            "type": "integer",
            "description": "Комиссия платформы, копейки"
          },
          "net_amount": {
            "type": "integer",
            "description": "Сумма к получению, копейки"
          },
          "currency": {
            "type": "string",
            "description": "Всегда RUB"
          },
          "recipient_mask": {
            "type": "string",
            "description": "Маска реквизита получателя"
          },
          "error": {
            "type": "string",
            "description": "Причина ошибки при status = failed"
          },
          "automatic": {
            "type": "boolean",
            "description": "Выплата создана расписанием"
          },
          "executed_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время исполнения"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время создания"
          }
        },
        "description": "Выплата"
      },
      "invoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Идентификатор счёта, pl_…"
          },
          "object": {
            "type": "string",
            "description": "Всегда invoice"
          },
          "shop_id": {
            "type": "string",
            "description": "Номер магазина"
          },
          "status": {
            "type": "string",
            "enum": [
              "issued",
              "sent",
              "paid",
              "canceled",
              "expired"
            ],
            "description": "Статус счёта"
          },
          "amount": {
            "type": "integer",
            "description": "Сумма, копейки"
          },
          "currency": {
            "type": "string",
            "description": "Всегда RUB"
          },
          "description": {
            "type": "string",
            "description": "Назначение"
          },
          "comment": {
            "type": "string",
            "description": "Комментарий для покупателя"
          },
          "capture": {
            "type": "string",
            "enum": [
              "auto",
              "manual"
            ],
            "description": "Режим списания"
          },
          "customer": {
            "type": "object",
            "description": "Получатель счёта: email, phone"
          },
          "items": {
            "type": "array",
            "items": {},
            "description": "Позиции чека"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Ссылка на оплату счёта"
          },
          "payment_id": {
            "type": "string",
            "description": "Платёж, которым счёт оплачен"
          },
          "return_url": {
            "type": "string",
            "format": "uri",
            "description": "Куда вернуть плательщика после оплаты"
          },
          "sent_at": {
            "type": "string",
            "format": "date-time",
            "description": "Когда отправлено письмо"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Срок оплаты"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время создания"
          }
        },
        "description": "Счёт"
      },
      "payment_link": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Идентификатор ссылки, pl_…"
          },
          "object": {
            "type": "string",
            "description": "Всегда payment_link"
          },
          "shop_id": {
            "type": "string",
            "description": "Номер магазина"
          },
          "title": {
            "type": "string",
            "description": "Название"
          },
          "amount": {
            "type": "integer",
            "description": "Сумма, копейки; пусто — сумму вводит плательщик"
          },
          "currency": {
            "type": "string",
            "description": "Всегда RUB"
          },
          "description": {
            "type": "string",
            "description": "Описание"
          },
          "active": {
            "type": "boolean",
            "description": "Ссылка включена"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Публичный адрес ссылки"
          },
          "payments_count": {
            "type": "integer",
            "description": "Сколько платежей создано по ссылке"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Срок действия"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время создания"
          }
        },
        "description": "Ссылка на оплату"
      },
      "payment_method": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Идентификатор способа оплаты, pm_…"
          },
          "object": {
            "type": "string",
            "description": "Всегда payment_method"
          },
          "type": {
            "type": "string",
            "enum": [
              "sbp"
            ],
            "description": "Тип способа оплаты"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ],
            "description": "active — можно списывать, inactive — отключён"
          },
          "title": {
            "type": "string",
            "description": "Название для показа покупателю"
          },
          "test": {
            "type": "boolean",
            "description": "true для способа оплаты тестового магазина"
          },
          "customer_id": {
            "type": "string",
            "description": "Покупатель в вашей системе (customer.id первого платежа)"
          },
          "first_payment_id": {
            "type": "string",
            "description": "Платёж, при котором способ сохранён"
          },
          "last_used_at": {
            "type": "string",
            "format": "date-time",
            "description": "Последнее списание"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время сохранения"
          }
        },
        "description": "Сохранённый способ оплаты"
      },
      "webhook_endpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Идентификатор адреса"
          },
          "object": {
            "type": "string",
            "description": "Всегда webhook_endpoint"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Адрес (только https)"
          },
          "events": {
            "type": "array",
            "items": {},
            "description": "Подписка на события; пустой список — все события"
          },
          "active": {
            "type": "boolean",
            "description": "Доставка включена"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время создания"
          }
        },
        "description": "Адрес вебхука"
      },
      "balance": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "description": "Всегда balance"
          },
          "sd_ref": {
            "type": "string",
            "description": "Идентификатор счёта магазина в ПЦ"
          },
          "currency": {
            "type": "string",
            "description": "Всегда RUB"
          },
          "balance": {
            "type": "integer",
            "description": "Баланс, копейки"
          },
          "available_balance": {
            "type": "integer",
            "description": "Доступно к выводу, копейки"
          },
          "state": {
            "type": "string",
            "description": "Состояние счёта в ПЦ"
          },
          "ledger_balance": {
            "type": "integer",
            "description": "Баланс по нашему учёту, копейки"
          }
        }
      },
      "error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "paygine_code": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  }
}