HG-541: invoice status adjustments (#591)

* add invoice adjustment function

* add domain definitions for invoice adjustment

* fix copypaste

* add invoice adjustment id

* add invoice adjustment status

* add invoice already has status error

* add invoice adjustment reference

* add review fixes

* update exceptions

* fix missing exception

* fix exception

* fix duplicate

* update ordering

* rename exception

* rename exception in function

* post-review updates

* fix id, update exceptions

* fix ordering

* fix ordering
This commit is contained in:
Roman Pushkov 2020-07-07 11:15:38 +03:00 committed by GitHub
parent 1984435b31
commit a1072d0666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 154 additions and 0 deletions

View File

@ -109,6 +109,7 @@ enum ThreeDsVerification {
/* Invoices */
typedef base.ID InvoiceID
typedef base.ID InvoiceAdjustmentID
typedef base.ID InvoicePaymentID
typedef base.ID InvoicePaymentChargebackID
typedef base.ID InvoicePaymentRefundID
@ -333,6 +334,47 @@ struct RecurrentParentPayment {
/* Adjustments */
struct InvoiceAdjustment {
1: required InvoiceAdjustmentID id
2: required string reason
3: required base.Timestamp created_at
4: required InvoiceAdjustmentStatus status
5: required DataRevision domain_revision
6: optional PartyRevision party_revision
7: optional InvoiceAdjustmentState state
}
struct InvoiceAdjustmentPending {}
struct InvoiceAdjustmentProcessed {}
struct InvoiceAdjustmentCaptured { 1: required base.Timestamp at }
struct InvoiceAdjustmentCancelled { 1: required base.Timestamp at }
union InvoiceAdjustmentStatus {
1: InvoiceAdjustmentPending pending
2: InvoiceAdjustmentCaptured captured
3: InvoiceAdjustmentCancelled cancelled
4: InvoiceAdjustmentProcessed processed
}
/**
* Специфическое для выбранного сценария состояние поправки к инвойсу.
*/
union InvoiceAdjustmentState {
1: InvoiceAdjustmentStatusChangeState status_change
}
struct InvoiceAdjustmentStatusChangeState {
1: required InvoiceAdjustmentStatusChange scenario
}
/**
* Параметры поправки к инвойсу, используемые для смены его статуса.
*/
struct InvoiceAdjustmentStatusChange {
/** Статус, в который необходимо перевести инвойс. */
1: required InvoiceStatus target_status
}
struct InvoicePaymentAdjustment {
1: required InvoicePaymentAdjustmentID id
2: required InvoicePaymentAdjustmentStatus status

View File

@ -109,6 +109,7 @@ union InvoiceChange {
1: InvoiceCreated invoice_created
2: InvoiceStatusChanged invoice_status_changed
3: InvoicePaymentChange invoice_payment_change
4: InvoiceAdjustmentChange invoice_adjustment_change
}
union InvoiceTemplateChange {
@ -142,6 +143,36 @@ struct InvoicePaymentChange {
3: optional base.Timestamp occurred_at
}
/**
* Событие, касающееся корректировки по инвойсу.
*/
struct InvoiceAdjustmentChange {
1: required domain.InvoiceAdjustmentID id
2: required InvoiceAdjustmentChangePayload payload
}
/**
* Один из возможных вариантов события, порождённого корректировкой по инвойсу.
*/
union InvoiceAdjustmentChangePayload {
1: InvoiceAdjustmentCreated invoice_adjustment_created
2: InvoiceAdjustmentStatusChanged invoice_adjustment_status_changed
}
/**
* Событие о создании корректировки инвойса
*/
struct InvoiceAdjustmentCreated {
1: required domain.InvoiceAdjustment adjustment
}
/**
* Событие об изменении статуса корректировки платежа
*/
struct InvoiceAdjustmentStatusChanged {
1: required domain.InvoiceAdjustmentStatus status
}
/**
* Один из возможных вариантов события, порождённого платежом по инвойсу.
*/
@ -568,6 +599,7 @@ struct InvoicePaymentParamsFlowHold {
struct Invoice {
1: required domain.Invoice invoice
2: required list<InvoicePayment> payments
3: optional list<InvoiceAdjustment> adjustments
}
struct InvoicePayment {
@ -597,6 +629,7 @@ struct InvoiceRefundSession {
1: optional domain.TransactionInfo transaction_info
}
typedef domain.InvoiceAdjustment InvoiceAdjustment
typedef domain.InvoicePaymentAdjustment InvoicePaymentAdjustment
struct InvoicePaymentChargeback {
@ -748,6 +781,23 @@ struct InvoicePaymentCaptureParams {
3: optional domain.InvoiceCart cart
}
/**
* Параметры создаваемой поправки к инвойсу.
*/
struct InvoiceAdjustmentParams {
/** Причина, на основании которой создаётся поправка. */
1: required string reason
/** Сценарий создаваемой поправки. */
2: required InvoiceAdjustmentScenario scenario
}
/**
* Сценарий поправки к инвойсу.
*/
union InvoiceAdjustmentScenario {
1: domain.InvoiceAdjustmentStatusChange status_change
}
/**
* Параметры создаваемой поправки к платежу.
*/
@ -828,6 +878,14 @@ union InvalidStatus {
exception InvalidUser {}
exception InvoiceNotFound {}
exception InvoiceAdjustmentNotFound {}
exception InvoiceAdjustmentPending {}
exception InvoiceAdjustmentStatusUnacceptable {}
exception InvalidInvoiceAdjustmentStatus {
1: required domain.InvoiceAdjustmentStatus status
}
exception InvoicePaymentNotFound {}
exception InvoicePaymentRefundNotFound {}
@ -874,6 +932,10 @@ exception InvalidPaymentTargetStatus {
1: required domain.InvoicePaymentStatus status
}
exception InvoiceAlreadyHasStatus {
1: required domain.InvoiceStatus status
}
exception InvoicePaymentAlreadyHasStatus {
1: required domain.InvoicePaymentStatus status
}
@ -959,6 +1021,56 @@ service Invoicing {
4: base.InvalidRequest ex4
)
InvoiceAdjustment CreateInvoiceAdjustment (
1: UserInfo user,
2: domain.InvoiceID id,
3: InvoiceAdjustmentParams params
)
throws (
1: InvalidUser ex1,
2: InvoiceNotFound ex2,
3: InvalidInvoiceStatus ex3,
4: InvoiceAdjustmentPending ex4,
5: InvoiceAdjustmentStatusUnacceptable ex5,
6: InvoiceAlreadyHasStatus ex6
7: base.InvalidRequest ex7
)
InvoiceAdjustment GetAdjustment (
1: UserInfo user,
2: domain.InvoiceID id,
3: domain.InvoiceAdjustmentID adjustment_id
)
throws (
1: InvalidUser ex1,
2: InvoiceNotFound ex2,
3: InvoiceAdjustmentNotFound ex3
)
void CaptureAdjustment (
1: UserInfo user,
2: domain.InvoiceID id,
3: domain.InvoiceAdjustmentID adjustment_id
)
throws (
1: InvalidUser ex1,
2: InvoiceNotFound ex2,
3: InvoiceAdjustmentNotFound ex3,
4: InvalidInvoiceAdjustmentStatus ex4
)
void CancelAdjustment (
1: UserInfo user
2: domain.InvoiceID id,
3: domain.InvoiceAdjustmentID adjustment_id
)
throws (
1: InvalidUser ex1,
2: InvoiceNotFound ex2,
3: InvoiceAdjustmentNotFound ex3,
4: InvalidInvoiceAdjustmentStatus ex4
)
/* Terms */
domain.TermSet ComputeTerms (