HG-58: Allow to refund payments (#105)

This commit is contained in:
Andrew Mayorov 2017-09-18 19:20:46 +03:00 committed by GitHub
parent 0dcdfc204d
commit d3cf4735ba
15 changed files with 147 additions and 4 deletions

View File

@ -1,6 +1,5 @@
type: object type: object
allOf: allOf:
- $ref: '#/definitions/InvoiceStatus'
- type: object - type: object
required: required:
- id - id
@ -55,3 +54,4 @@ allOf:
metadata: metadata:
description: Связанные с инвойсом метаданные description: Связанные с инвойсом метаданные
type: object type: object
- $ref: '#/definitions/InvoiceStatus'

View File

@ -11,3 +11,5 @@ properties:
- PaymentStarted - PaymentStarted
- PaymentStatusChanged - PaymentStatusChanged
- PaymentInteractionRequested - PaymentInteractionRequested
- RefundStarted
- RefundStatusChanged

View File

@ -9,7 +9,6 @@ properties:
- unpaid - unpaid
- cancelled - cancelled
- paid - paid
- refunded
- fulfilled - fulfilled
reason: reason:
description: Причина отмены или погашения инвойса description: Причина отмены или погашения инвойса

View File

@ -26,4 +26,5 @@ allOf:
- PaymentProcessed - PaymentProcessed
- PaymentCaptured - PaymentCaptured
- PaymentCancelled - PaymentCancelled
- PaymentRefunded
- PaymentFailed - PaymentFailed

View File

@ -1,6 +1,5 @@
type: object type: object
allOf: allOf:
- $ref: '#/definitions/PaymentStatus'
- type: object - type: object
required: required:
- id - id
@ -65,3 +64,4 @@ allOf:
description: Уникальный отпечаток user agent'а плательщика description: Уникальный отпечаток user agent'а плательщика
type: string type: string
maxLength: 1000 maxLength: 1000
- $ref: '#/definitions/PaymentStatus'

View File

@ -10,6 +10,7 @@ properties:
- processed - processed
- captured - captured
- cancelled - cancelled
- refunded
- failed - failed
error: error:
$ref: '#/definitions/LogicError' $ref: '#/definitions/LogicError'

View File

@ -0,0 +1,18 @@
type: object
allOf:
- type: object
required:
- id
- createdAt
properties:
id:
description: Идентификатор возврата
type: string
createdAt:
description: Дата и время осуществления
type: string
format: date-time
reason:
description: Причина осуществления возврата
type: string
- $ref: '#/definitions/RefundStatus'

View File

@ -0,0 +1,12 @@
type: object
allOf:
- $ref: '#/definitions/InvoiceChange'
- type: object
required:
- paymentID
- refund
properties:
paymentID:
type: string
refund:
$ref: '#/definitions/Refund'

View File

@ -0,0 +1,26 @@
type: object
required:
- status
properties:
status:
description: Статус возврата
type: string
enum:
- pending
- succeeded
- failed
error:
description: |
Данные ошибки, возникшей в процессе проведения возврата, в случае если
возврат был неуспешен
type: object
required:
- code
- message
properties:
code:
description: Код ошибки, пригодный для обработки автоматическими системами
type: string
message:
description: Описание ошибки, пригодное для восприятия человеком
type: string

View File

@ -0,0 +1,13 @@
type: object
allOf:
- $ref: '#/definitions/InvoiceChange'
- type: object
required:
- paymentID
- refundID
properties:
paymentID:
type: string
refundID:
type: string
- $ref: '#/definitions/RefundStatus'

View File

@ -19,7 +19,6 @@ get:
- unpaid - unpaid
- cancelled - cancelled
- paid - paid
- refunded
- fulfilled - fulfilled
- name: paymentStatus - name: paymentStatus
in: query in: query
@ -31,6 +30,7 @@ get:
- processed - processed
- captured - captured
- cancelled - cancelled
- refunded
- failed - failed
- name: paymentFlow - name: paymentFlow
in: query in: query

View File

@ -20,6 +20,7 @@ get:
- processed - processed
- captured - captured
- cancelled - cancelled
- refunded
- failed - failed
- name: paymentFlow - name: paymentFlow
in: query in: query

View File

@ -0,0 +1,44 @@
get:
description: Получить все возвраты указанного платежа.
tags:
- Payments
operationId: getRefunds
parameters:
- $ref: '#/parameters/requestID'
- $ref: '#/parameters/invoiceID'
- $ref: '#/parameters/paymentID'
responses:
'200':
description: Данные возвратов по платежу
schema:
type: array
items:
$ref: '#/definitions/Refund'
'400':
$ref: '#/responses/BadRequest'
'404':
$ref: '#/responses/NotFound'
post:
description: Создать возврат указанного платежа
tags:
- Payments
operationId: createRefund
parameters:
- $ref: '#/parameters/requestID'
- $ref: '#/parameters/invoiceID'
- $ref: '#/parameters/paymentID'
- name: reason
in: body
description: Причина совершения возврата
required: false
schema:
$ref: '#/definitions/Reason'
responses:
'201':
description: Возврат создан
schema:
$ref: '#/definitions/Refund'
'400':
$ref: '#/responses/BadRequest'
'404':
$ref: '#/responses/NotFound'

View File

@ -0,0 +1,19 @@
get:
description: Получить данные определённого возврата указанного платежа.
tags:
- Payments
operationId: getRefundByID
parameters:
- $ref: '#/parameters/requestID'
- $ref: '#/parameters/invoiceID'
- $ref: '#/parameters/paymentID'
- $ref: '#/parameters/refundID'
responses:
'200':
description: Данные возврата
schema:
$ref: '#/definitions/Refund'
'400':
$ref: '#/responses/BadRequest'
'404':
$ref: '#/responses/NotFound'

View File

@ -145,6 +145,13 @@ parameters:
required: true required: true
type: string type: string
maxLength: 40 maxLength: 40
refundID:
name: refundID
in: path
description: Идентификатор возврата в рамках платежа
required: true
type: string
maxLength: 40
contractID: contractID:
name: contractID name: contractID
in: path in: path