{"openapi":"3.1.0","info":{"title":"EGN Pay API","version":"1.0.0","description":"Единый платёжный сервис экосистемы EGN (СБП и карты через эквайринг Т-Банка). Суммы — целые числа в копейках. Документация: https://pay.egnetwork.ru/docs, для LLM: https://pay.egnetwork.ru/llms-full.txt."},"servers":[{"url":"https://pay.egnetwork.ru/api/v1"}],"security":[{"bearer":[]}],"paths":{"/payments":{"post":{"operationId":"createPayment","summary":"Создать платёж","description":"Идемпотентно по order_id: повтор с той же суммой возвращает существующий платёж (200).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePayment"}}}},"responses":{"200":{"description":"Платёж","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"201":{"description":"Платёж","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"4XX":{"$ref":"#/components/responses/Error"},"5XX":{"$ref":"#/components/responses/Error"}}},"get":{"operationId":"listPayments","summary":"Список платежей (новые сначала)","parameters":[{"name":"order_id","in":"query","schema":{"type":"string"}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","succeeded","failed","expired","canceled","refunded","partially_refunded"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"starting_after","in":"query","schema":{"type":"string"},"description":"ID последнего платежа предыдущей страницы"}],"responses":{"200":{"description":"Список","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Payment"}},"has_more":{"type":"boolean"}}}}}},"4XX":{"$ref":"#/components/responses/Error"}}}},"/payments/{id}":{"get":{"operationId":"getPayment","summary":"Получить платёж","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^pay_[A-Za-z0-9]{20}$"}}],"responses":{"200":{"description":"Платёж","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"4XX":{"$ref":"#/components/responses/Error"}}}},"/payments/{id}/cancel":{"post":{"operationId":"cancelPayment","summary":"Отменить неоплаченный платёж","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^pay_[A-Za-z0-9]{20}$"}}],"responses":{"200":{"description":"Платёж","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"4XX":{"$ref":"#/components/responses/Error"},"5XX":{"$ref":"#/components/responses/Error"}}}},"/payments/{id}/refund":{"post":{"operationId":"refundPayment","summary":"Полный или частичный возврат","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^pay_[A-Za-z0-9]{20}$"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"integer","minimum":1,"description":"Копейки. Без поля — весь остаток"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Платёж","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"4XX":{"$ref":"#/components/responses/Error"},"5XX":{"$ref":"#/components/responses/Error"}}}},"/me":{"get":{"operationId":"getMerchant","summary":"Проверить ключ: сервис и режим","responses":{"200":{"description":"Сервис","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"merchant"},"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"livemode":{"type":"boolean"},"provider":{"type":"string","enum":["tbank","emulator"]},"webhook_url":{"type":["string","null"]},"allowed_return_hosts":{"type":"array","items":{"type":"string"}}}}}}},"4XX":{"$ref":"#/components/responses/Error"}}}}},"webhooks":{"paymentEvent":{"post":{"summary":"Событие платежа","description":"POST на webhook_url. Заголовок X-EGN-Signature: t=<unix>,v1=<hex HMAC-SHA256(webhook_secret, t + '.' + raw_body)>. Ответьте 2xx за 10 секунд. Повторы: 1м, 5м, 30м, 2ч, 6ч, 24ч, 24ч.","parameters":[{"name":"X-EGN-Signature","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-EGN-Event","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-EGN-Delivery","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"200":{"description":"Принято"}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"egn_live_… или egn_test_…"}},"responses":{"Error":{"description":"Ошибка","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","examples":["validation_error","unauthorized","order_id_conflict","provider_error"]},"message":{"type":"string"},"details":{"type":"object"}}}}}}}}},"schemas":{"CreatePayment":{"type":"object","required":["amount","order_id","description","customer"],"additionalProperties":false,"properties":{"amount":{"type":"integer","minimum":100,"maximum":1000000000,"description":"Копейки"},"order_id":{"type":"string","maxLength":64,"pattern":"^[\\w.:\\-]+$"},"description":{"type":"string","maxLength":140},"return_url":{"type":"string","format":"uri"},"webhook_url":{"type":"string","format":"uri"},"methods":{"type":"array","items":{"type":"string","enum":["sbp","card"]},"default":["sbp","card"]},"expires_in":{"type":"integer","minimum":300,"maximum":604800,"default":3600},"customer":{"type":"object","description":"Контакт покупателя для чека 54-ФЗ. Обязательно хотя бы одно поле","properties":{"email":{"type":"string","format":"email"},"phone":{"type":"string","pattern":"^\\+?\\d{10,15}$"}},"anyOf":[{"required":["email"]},{"required":["phone"]}]},"receipt":{"$ref":"#/components/schemas/Receipt"},"metadata":{"type":"object","additionalProperties":{"type":"string","maxLength":500},"maxProperties":20}}},"Receipt":{"type":"object","required":["taxation","items"],"properties":{"email":{"type":"string"},"phone":{"type":"string"},"taxation":{"type":"string","enum":["osn","usn_income","usn_income_outcome","envd","esn","patent"]},"items":{"type":"array","minItems":1,"items":{"type":"object","required":["name","price","quantity","tax"],"properties":{"name":{"type":"string","maxLength":128},"price":{"type":"integer"},"quantity":{"type":"number"},"amount":{"type":"integer"},"tax":{"type":"string","enum":["none","vat0","vat5","vat7","vat10","vat20","vat22","vat105","vat107","vat110","vat120","vat122"]},"payment_method":{"type":"string","default":"full_payment"},"payment_object":{"type":"string","default":"service"}}}}}},"Payment":{"type":"object","required":["id","object","livemode","status","amount","refunded_amount","currency","order_id","payment_url"],"properties":{"id":{"type":"string"},"object":{"const":"payment"},"livemode":{"type":"boolean"},"status":{"type":"string","enum":["pending","succeeded","failed","expired","canceled","refunded","partially_refunded"]},"amount":{"type":"integer"},"refunded_amount":{"type":"integer"},"currency":{"const":"RUB"},"description":{"type":"string"},"order_id":{"type":"string"},"methods":{"type":"array","items":{"type":"string","enum":["sbp","card"]}},"customer":{"type":"object","properties":{"email":{"type":["string","null"]},"phone":{"type":["string","null"]}}},"metadata":{"type":"object","additionalProperties":{"type":"string"}},"payment_url":{"type":"string","format":"uri"},"return_url":{"type":["string","null"]},"expires_at":{"type":"string","format":"date-time"},"paid_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"WebhookEvent":{"type":"object","required":["id","type","created_at","livemode","data"],"properties":{"id":{"type":"string"},"type":{"type":"string","enum":["payment.succeeded","payment.failed","payment.expired","payment.canceled","payment.partially_refunded","payment.refunded"]},"created_at":{"type":"string","format":"date-time"},"livemode":{"type":"boolean"},"data":{"type":"object","properties":{"payment":{"$ref":"#/components/schemas/Payment"}}}}}}}}