@mamindom/contracts 1.0.207 → 1.0.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events/orders/index.d.ts +1 -0
- package/dist/events/orders/index.js +1 -0
- package/dist/events/orders/order-money.interface.d.ts +25 -0
- package/dist/events/orders/order-money.interface.js +2 -0
- package/dist/events/payments/payment-cancelled.interface.d.ts +12 -0
- package/dist/events/payments/payment-captured.interface.d.ts +8 -0
- package/dist/events/payments/payment-failed.interface.d.ts +12 -0
- package/dist/events/payments/payment-held.interface.d.ts +12 -0
- package/dist/events/payments/payment-refunded.interface.d.ts +12 -0
- package/dist/events/stock/stock-restock-requested.interface.d.ts +11 -0
- package/dist/gen/order.d.ts +118 -0
- package/dist/gen/order.js +9 -0
- package/dist/gen/payment.d.ts +28 -0
- package/dist/gen/payment.js +2 -0
- package/dist/proto/order.proto +130 -0
- package/dist/proto/payment.proto +21 -0
- package/events/orders/index.ts +1 -0
- package/events/orders/order-money.interface.ts +30 -0
- package/events/payments/payment-cancelled.interface.ts +13 -0
- package/events/payments/payment-captured.interface.ts +10 -0
- package/events/payments/payment-failed.interface.ts +13 -0
- package/events/payments/payment-held.interface.ts +13 -0
- package/events/payments/payment-refunded.interface.ts +13 -0
- package/events/stock/stock-restock-requested.interface.ts +13 -0
- package/gen/order.ts +182 -0
- package/gen/payment.ts +43 -0
- package/package.json +1 -1
- package/proto/order.proto +130 -0
- package/proto/payment.proto +21 -0
|
@@ -19,4 +19,5 @@ __exportStar(require("./order-created.interface"), exports);
|
|
|
19
19
|
__exportStar(require("./order-side-effects.interface"), exports);
|
|
20
20
|
__exportStar(require("./order-status-changed.interface"), exports);
|
|
21
21
|
__exportStar(require("./order-crm.interface"), exports);
|
|
22
|
+
__exportStar(require("./order-money.interface"), exports);
|
|
22
23
|
__exportStar(require("./order-one-c.interface"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Менеджер виставив клієнту доплату за перерахунком замовлення в 1С.
|
|
3
|
+
*
|
|
4
|
+
* Подія йде в notification-service: покупець дізнається про доплату з
|
|
5
|
+
* повідомлення (SMS / e-mail) і бачить її в кабінеті. Публікується ЛИШЕ після
|
|
6
|
+
* того, як рахунок реально створено в payment-service — повідомлення
|
|
7
|
+
* «доплатіть» без робочого посилання гірше за мовчання.
|
|
8
|
+
*/
|
|
9
|
+
export interface OrderSurchargeRequestedEvent {
|
|
10
|
+
orderId: string;
|
|
11
|
+
orderNumber: string;
|
|
12
|
+
userId?: string;
|
|
13
|
+
adjustmentId: string;
|
|
14
|
+
/** Сума доплати у гривнях, рядком (`Money.toWire`). */
|
|
15
|
+
amount: string;
|
|
16
|
+
paymentUrl: string;
|
|
17
|
+
/** Доки посилання дійсне. */
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
customer: {
|
|
20
|
+
firstName: string;
|
|
21
|
+
lastName: string;
|
|
22
|
+
email: string;
|
|
23
|
+
phone: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -6,4 +6,16 @@ export interface PaymentCancelledEvent {
|
|
|
6
6
|
amount: string;
|
|
7
7
|
reason?: string;
|
|
8
8
|
cancelledAt: number;
|
|
9
|
+
/**
|
|
10
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
11
|
+
* у 1С (`order_money_adjustments`).
|
|
12
|
+
*
|
|
13
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
14
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
15
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
16
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
17
|
+
*/
|
|
18
|
+
kind?: string;
|
|
19
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
20
|
+
adjustmentId?: string;
|
|
9
21
|
}
|
|
@@ -7,4 +7,12 @@ export interface PaymentCapturedEvent {
|
|
|
7
7
|
capturedAmount: string;
|
|
8
8
|
currency: string;
|
|
9
9
|
capturedAt: number;
|
|
10
|
+
/**
|
|
11
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
12
|
+
* у 1С. Без цього поля споживач не міг відрізнити їх і переписував статус
|
|
13
|
+
* ОСНОВНОГО платежу на подію про доплату.
|
|
14
|
+
*/
|
|
15
|
+
kind?: string;
|
|
16
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
17
|
+
adjustmentId?: string;
|
|
10
18
|
}
|
|
@@ -6,4 +6,16 @@ export interface PaymentFailedEvent {
|
|
|
6
6
|
amount: string;
|
|
7
7
|
failureReason: string;
|
|
8
8
|
failedAt: number;
|
|
9
|
+
/**
|
|
10
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
11
|
+
* у 1С (`order_money_adjustments`).
|
|
12
|
+
*
|
|
13
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
14
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
15
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
16
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
17
|
+
*/
|
|
18
|
+
kind?: string;
|
|
19
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
20
|
+
adjustmentId?: string;
|
|
9
21
|
}
|
|
@@ -6,4 +6,16 @@ export interface PaymentHeldEvent {
|
|
|
6
6
|
amount: string;
|
|
7
7
|
currency: string;
|
|
8
8
|
heldAt: number;
|
|
9
|
+
/**
|
|
10
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
11
|
+
* у 1С (`order_money_adjustments`).
|
|
12
|
+
*
|
|
13
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
14
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
15
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
16
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
17
|
+
*/
|
|
18
|
+
kind?: string;
|
|
19
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
20
|
+
adjustmentId?: string;
|
|
9
21
|
}
|
|
@@ -9,4 +9,16 @@ export interface PaymentRefundedEvent {
|
|
|
9
9
|
isPartial: boolean;
|
|
10
10
|
reason?: string;
|
|
11
11
|
refundedAt: number;
|
|
12
|
+
/**
|
|
13
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
14
|
+
* у 1С (`order_money_adjustments`).
|
|
15
|
+
*
|
|
16
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
17
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
18
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
19
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
20
|
+
*/
|
|
21
|
+
kind?: string;
|
|
22
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
23
|
+
adjustmentId?: string;
|
|
12
24
|
}
|
|
@@ -2,6 +2,17 @@ export interface StockRestockRequestedEvent {
|
|
|
2
2
|
orderId: string;
|
|
3
3
|
orderNumber: string;
|
|
4
4
|
reason: string;
|
|
5
|
+
/**
|
|
6
|
+
* Ідентифікатор ОПЕРАЦІЇ повернення. Стабільний для однієї події: RMQ
|
|
7
|
+
* доставляє щонайменше один раз, і дубль несе те саме значення.
|
|
8
|
+
*
|
|
9
|
+
* Саме на ньому тримається ідемпотентність у catalog. Виводити ключ зі
|
|
10
|
+
* стану складу не можна в принципі: перше ж виконання цей стан міняє, тож
|
|
11
|
+
* повтор отримував би інший ключ і повертав товар удруге. А відрізнити
|
|
12
|
+
* дубль від ЗАКОННОГО другого часткового повернення тієї самої позиції
|
|
13
|
+
* (1С зняла ще одну штуку) можна тільки за ідентифікатором операції.
|
|
14
|
+
*/
|
|
15
|
+
operationId?: string;
|
|
5
16
|
items: Array<{
|
|
6
17
|
productId: string;
|
|
7
18
|
variantId?: string;
|
package/dist/gen/order.d.ts
CHANGED
|
@@ -223,6 +223,7 @@ export interface OrderItemInput {
|
|
|
223
223
|
variantId: string;
|
|
224
224
|
quantity: number;
|
|
225
225
|
priceOverride: number;
|
|
226
|
+
priceProvided: boolean;
|
|
226
227
|
}
|
|
227
228
|
export interface GetOrderRequest {
|
|
228
229
|
id: string;
|
|
@@ -281,6 +282,85 @@ export interface SetCrmOrderIdRequest {
|
|
|
281
282
|
id: string;
|
|
282
283
|
crmOrderId: string;
|
|
283
284
|
}
|
|
285
|
+
export interface MoneyAdjustment {
|
|
286
|
+
id: string;
|
|
287
|
+
orderId: string;
|
|
288
|
+
kind: string;
|
|
289
|
+
status: string;
|
|
290
|
+
amount: number;
|
|
291
|
+
totalBefore: number;
|
|
292
|
+
totalAfter: number;
|
|
293
|
+
source: string;
|
|
294
|
+
paymentId: string;
|
|
295
|
+
paymentUrl: string;
|
|
296
|
+
expiresAt: number;
|
|
297
|
+
resolvedBy: string;
|
|
298
|
+
resolvedAt: number;
|
|
299
|
+
resolution: string;
|
|
300
|
+
dismissReason: string;
|
|
301
|
+
createdAt: number;
|
|
302
|
+
updatedAt: number;
|
|
303
|
+
}
|
|
304
|
+
export interface MoneyAdjustmentResponse {
|
|
305
|
+
ok: boolean;
|
|
306
|
+
adjustment: MoneyAdjustment | undefined;
|
|
307
|
+
errorMessage: string;
|
|
308
|
+
}
|
|
309
|
+
export interface ListMoneyAdjustmentsRequest {
|
|
310
|
+
orderId: string;
|
|
311
|
+
onlyOpen: boolean;
|
|
312
|
+
limit: number;
|
|
313
|
+
}
|
|
314
|
+
export interface ListMoneyAdjustmentsResponse {
|
|
315
|
+
items: MoneyAdjustment[];
|
|
316
|
+
}
|
|
317
|
+
export interface GetMoneyAdjustmentRequest {
|
|
318
|
+
id: string;
|
|
319
|
+
}
|
|
320
|
+
export interface MarkSurchargeIssuedRequest {
|
|
321
|
+
id: string;
|
|
322
|
+
paymentId: string;
|
|
323
|
+
paymentUrl: string;
|
|
324
|
+
actorId: string;
|
|
325
|
+
actorName: string;
|
|
326
|
+
}
|
|
327
|
+
export interface SettleMoneyAdjustmentRequest {
|
|
328
|
+
id: string;
|
|
329
|
+
resolution: string;
|
|
330
|
+
actorId: string;
|
|
331
|
+
actorName: string;
|
|
332
|
+
paymentId: string;
|
|
333
|
+
amount: number;
|
|
334
|
+
amountProvided: boolean;
|
|
335
|
+
}
|
|
336
|
+
export interface DismissMoneyAdjustmentRequest {
|
|
337
|
+
id: string;
|
|
338
|
+
reason: string;
|
|
339
|
+
actorId: string;
|
|
340
|
+
actorName: string;
|
|
341
|
+
}
|
|
342
|
+
export interface ListStuckEventsRequest {
|
|
343
|
+
limit: number;
|
|
344
|
+
}
|
|
345
|
+
export interface StuckEvent {
|
|
346
|
+
id: string;
|
|
347
|
+
pattern: string;
|
|
348
|
+
orderKey: string;
|
|
349
|
+
attempts: number;
|
|
350
|
+
lastError: string;
|
|
351
|
+
createdAt: number;
|
|
352
|
+
acknowledged: boolean;
|
|
353
|
+
}
|
|
354
|
+
export interface ListStuckEventsResponse {
|
|
355
|
+
items: StuckEvent[];
|
|
356
|
+
}
|
|
357
|
+
export interface StuckEventsActionRequest {
|
|
358
|
+
ids: string[];
|
|
359
|
+
actorId: string;
|
|
360
|
+
}
|
|
361
|
+
export interface StuckEventsActionResponse {
|
|
362
|
+
affected: number;
|
|
363
|
+
}
|
|
284
364
|
export interface SetOneCOrderRefRequest {
|
|
285
365
|
id: string;
|
|
286
366
|
oneCOrderNumber: string;
|
|
@@ -423,6 +503,25 @@ export interface OrderServiceClient {
|
|
|
423
503
|
setCrmOrderId(request: SetCrmOrderIdRequest): Observable<OrderResponse>;
|
|
424
504
|
setOneCOrderRef(request: SetOneCOrderRefRequest): Observable<OrderResponse>;
|
|
425
505
|
applyOneCStatus(request: ApplyOneCStatusRequest): Observable<OrderResponse>;
|
|
506
|
+
/** Врегулювання грошей після перерахунку (доплата / повернення). */
|
|
507
|
+
listMoneyAdjustments(request: ListMoneyAdjustmentsRequest): Observable<ListMoneyAdjustmentsResponse>;
|
|
508
|
+
getMoneyAdjustment(request: GetMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
509
|
+
/**
|
|
510
|
+
* Перевірка ПЕРЕД створенням рахунку: чи можна взагалі виставляти доплату.
|
|
511
|
+
* Без неї платіжне посилання встигало зʼявитись раніше за відмову.
|
|
512
|
+
*/
|
|
513
|
+
assertCanIssueSurcharge(request: GetMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
514
|
+
markSurchargeIssued(request: MarkSurchargeIssuedRequest): Observable<MoneyAdjustmentResponse>;
|
|
515
|
+
settleMoneyAdjustment(request: SettleMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
516
|
+
dismissMoneyAdjustment(request: DismissMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
517
|
+
/**
|
|
518
|
+
* Розбір заторів у черзі подій: подія, яка вичерпала ретраї, навмисно
|
|
519
|
+
* блокує всі наступні події свого замовлення (інакше `stock.reserve` поїхав
|
|
520
|
+
* би без свого `stock.release`). Тому потрібен і вихід із цього стану.
|
|
521
|
+
*/
|
|
522
|
+
listStuckEvents(request: ListStuckEventsRequest): Observable<ListStuckEventsResponse>;
|
|
523
|
+
retryStuckEvents(request: StuckEventsActionRequest): Observable<StuckEventsActionResponse>;
|
|
524
|
+
dismissStuckEvents(request: StuckEventsActionRequest): Observable<StuckEventsActionResponse>;
|
|
426
525
|
confirmPickup(request: ConfirmPickupRequest): Observable<OrderResponse>;
|
|
427
526
|
reorderOrder(request: ReorderOrderRequest): Observable<ReorderResponse>;
|
|
428
527
|
listHistory(request: ListHistoryRequest): Observable<ListHistoryResponse>;
|
|
@@ -451,6 +550,25 @@ export interface OrderServiceController {
|
|
|
451
550
|
setCrmOrderId(request: SetCrmOrderIdRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
452
551
|
setOneCOrderRef(request: SetOneCOrderRefRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
453
552
|
applyOneCStatus(request: ApplyOneCStatusRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
553
|
+
/** Врегулювання грошей після перерахунку (доплата / повернення). */
|
|
554
|
+
listMoneyAdjustments(request: ListMoneyAdjustmentsRequest): Promise<ListMoneyAdjustmentsResponse> | Observable<ListMoneyAdjustmentsResponse> | ListMoneyAdjustmentsResponse;
|
|
555
|
+
getMoneyAdjustment(request: GetMoneyAdjustmentRequest): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
556
|
+
/**
|
|
557
|
+
* Перевірка ПЕРЕД створенням рахунку: чи можна взагалі виставляти доплату.
|
|
558
|
+
* Без неї платіжне посилання встигало зʼявитись раніше за відмову.
|
|
559
|
+
*/
|
|
560
|
+
assertCanIssueSurcharge(request: GetMoneyAdjustmentRequest): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
561
|
+
markSurchargeIssued(request: MarkSurchargeIssuedRequest): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
562
|
+
settleMoneyAdjustment(request: SettleMoneyAdjustmentRequest): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
563
|
+
dismissMoneyAdjustment(request: DismissMoneyAdjustmentRequest): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
564
|
+
/**
|
|
565
|
+
* Розбір заторів у черзі подій: подія, яка вичерпала ретраї, навмисно
|
|
566
|
+
* блокує всі наступні події свого замовлення (інакше `stock.reserve` поїхав
|
|
567
|
+
* би без свого `stock.release`). Тому потрібен і вихід із цього стану.
|
|
568
|
+
*/
|
|
569
|
+
listStuckEvents(request: ListStuckEventsRequest): Promise<ListStuckEventsResponse> | Observable<ListStuckEventsResponse> | ListStuckEventsResponse;
|
|
570
|
+
retryStuckEvents(request: StuckEventsActionRequest): Promise<StuckEventsActionResponse> | Observable<StuckEventsActionResponse> | StuckEventsActionResponse;
|
|
571
|
+
dismissStuckEvents(request: StuckEventsActionRequest): Promise<StuckEventsActionResponse> | Observable<StuckEventsActionResponse> | StuckEventsActionResponse;
|
|
454
572
|
confirmPickup(request: ConfirmPickupRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
455
573
|
reorderOrder(request: ReorderOrderRequest): Promise<ReorderResponse> | Observable<ReorderResponse> | ReorderResponse;
|
|
456
574
|
listHistory(request: ListHistoryRequest): Promise<ListHistoryResponse> | Observable<ListHistoryResponse> | ListHistoryResponse;
|
package/dist/gen/order.js
CHANGED
|
@@ -35,6 +35,15 @@ function OrderServiceControllerMethods() {
|
|
|
35
35
|
"setCrmOrderId",
|
|
36
36
|
"setOneCOrderRef",
|
|
37
37
|
"applyOneCStatus",
|
|
38
|
+
"listMoneyAdjustments",
|
|
39
|
+
"getMoneyAdjustment",
|
|
40
|
+
"assertCanIssueSurcharge",
|
|
41
|
+
"markSurchargeIssued",
|
|
42
|
+
"settleMoneyAdjustment",
|
|
43
|
+
"dismissMoneyAdjustment",
|
|
44
|
+
"listStuckEvents",
|
|
45
|
+
"retryStuckEvents",
|
|
46
|
+
"dismissStuckEvents",
|
|
38
47
|
"confirmPickup",
|
|
39
48
|
"reorderOrder",
|
|
40
49
|
"listHistory",
|
package/dist/gen/payment.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ export interface Payment {
|
|
|
21
21
|
refundedAt: number;
|
|
22
22
|
captureSource: string;
|
|
23
23
|
captureNote: string;
|
|
24
|
+
/** Тип платежу і врегулювання, яке його породило (див. CreateInvoiceRequest). */
|
|
25
|
+
kind: string;
|
|
26
|
+
adjustmentId: string;
|
|
24
27
|
}
|
|
25
28
|
export interface PaymentProviderInfo {
|
|
26
29
|
key: string;
|
|
@@ -44,6 +47,14 @@ export interface CreateInvoiceRequest {
|
|
|
44
47
|
customerEmail: string;
|
|
45
48
|
customerPhone: string;
|
|
46
49
|
items: InvoiceItem[];
|
|
50
|
+
/**
|
|
51
|
+
* `primary` (за замовчуванням) — оплата замовлення; `surcharge` — доплата
|
|
52
|
+
* за перерахунком у 1С. На замовлення може бути один основний платіж і
|
|
53
|
+
* скільки завгодно доплат.
|
|
54
|
+
*/
|
|
55
|
+
kind: string;
|
|
56
|
+
/** Врегулювання, яке породило доплату (`order_money_adjustments`). */
|
|
57
|
+
adjustmentId: string;
|
|
47
58
|
}
|
|
48
59
|
export interface InvoiceItem {
|
|
49
60
|
name: string;
|
|
@@ -57,6 +68,9 @@ export interface GetPaymentRequest {
|
|
|
57
68
|
export interface GetPaymentByOrderRequest {
|
|
58
69
|
orderId: string;
|
|
59
70
|
}
|
|
71
|
+
export interface GetPaymentByAdjustmentRequest {
|
|
72
|
+
adjustmentId: string;
|
|
73
|
+
}
|
|
60
74
|
export interface ListPaymentsRequest {
|
|
61
75
|
page: number;
|
|
62
76
|
limit: number;
|
|
@@ -167,6 +181,13 @@ export interface PaymentServiceClient {
|
|
|
167
181
|
createInvoice(request: CreateInvoiceRequest): Observable<PaymentResponse>;
|
|
168
182
|
getPayment(request: GetPaymentRequest): Observable<PaymentResponse>;
|
|
169
183
|
getPaymentByOrder(request: GetPaymentByOrderRequest): Observable<PaymentResponse>;
|
|
184
|
+
/**
|
|
185
|
+
* Платіж ДОПЛАТИ за врегулюванням. `GetPaymentByOrder` для цього не
|
|
186
|
+
* годиться: він завжди віддає основний платіж замовлення.
|
|
187
|
+
*/
|
|
188
|
+
getPaymentByAdjustment(request: GetPaymentByAdjustmentRequest): Observable<PaymentResponse>;
|
|
189
|
+
/** Усі платежі замовлення (основний + доплати) — для звірки сум. */
|
|
190
|
+
listOrderPayments(request: GetPaymentByOrderRequest): Observable<ListPaymentsResponse>;
|
|
170
191
|
listPayments(request: ListPaymentsRequest): Observable<ListPaymentsResponse>;
|
|
171
192
|
capture(request: CaptureRequest): Observable<PaymentResponse>;
|
|
172
193
|
markPaidOffline(request: MarkPaidOfflineRequest): Observable<PaymentResponse>;
|
|
@@ -185,6 +206,13 @@ export interface PaymentServiceController {
|
|
|
185
206
|
createInvoice(request: CreateInvoiceRequest): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
|
186
207
|
getPayment(request: GetPaymentRequest): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
|
187
208
|
getPaymentByOrder(request: GetPaymentByOrderRequest): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
|
209
|
+
/**
|
|
210
|
+
* Платіж ДОПЛАТИ за врегулюванням. `GetPaymentByOrder` для цього не
|
|
211
|
+
* годиться: він завжди віддає основний платіж замовлення.
|
|
212
|
+
*/
|
|
213
|
+
getPaymentByAdjustment(request: GetPaymentByAdjustmentRequest): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
|
214
|
+
/** Усі платежі замовлення (основний + доплати) — для звірки сум. */
|
|
215
|
+
listOrderPayments(request: GetPaymentByOrderRequest): Promise<ListPaymentsResponse> | Observable<ListPaymentsResponse> | ListPaymentsResponse;
|
|
188
216
|
listPayments(request: ListPaymentsRequest): Promise<ListPaymentsResponse> | Observable<ListPaymentsResponse> | ListPaymentsResponse;
|
|
189
217
|
capture(request: CaptureRequest): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
|
190
218
|
markPaidOffline(request: MarkPaidOfflineRequest): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
package/dist/gen/payment.js
CHANGED
package/dist/proto/order.proto
CHANGED
|
@@ -36,6 +36,24 @@ service OrderService {
|
|
|
36
36
|
|
|
37
37
|
rpc ApplyOneCStatus(ApplyOneCStatusRequest) returns (OrderResponse);
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
// Врегулювання грошей після перерахунку (доплата / повернення).
|
|
41
|
+
rpc ListMoneyAdjustments(ListMoneyAdjustmentsRequest) returns (ListMoneyAdjustmentsResponse);
|
|
42
|
+
rpc GetMoneyAdjustment(GetMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
43
|
+
// Перевірка ПЕРЕД створенням рахунку: чи можна взагалі виставляти доплату.
|
|
44
|
+
// Без неї платіжне посилання встигало зʼявитись раніше за відмову.
|
|
45
|
+
rpc AssertCanIssueSurcharge(GetMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
46
|
+
rpc MarkSurchargeIssued(MarkSurchargeIssuedRequest) returns (MoneyAdjustmentResponse);
|
|
47
|
+
rpc SettleMoneyAdjustment(SettleMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
48
|
+
rpc DismissMoneyAdjustment(DismissMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
49
|
+
|
|
50
|
+
// Розбір заторів у черзі подій: подія, яка вичерпала ретраї, навмисно
|
|
51
|
+
// блокує всі наступні події свого замовлення (інакше `stock.reserve` поїхав
|
|
52
|
+
// би без свого `stock.release`). Тому потрібен і вихід із цього стану.
|
|
53
|
+
rpc ListStuckEvents(ListStuckEventsRequest) returns (ListStuckEventsResponse);
|
|
54
|
+
rpc RetryStuckEvents(StuckEventsActionRequest) returns (StuckEventsActionResponse);
|
|
55
|
+
rpc DismissStuckEvents(StuckEventsActionRequest) returns (StuckEventsActionResponse);
|
|
56
|
+
|
|
39
57
|
rpc ConfirmPickup(ConfirmPickupRequest) returns (OrderResponse);
|
|
40
58
|
|
|
41
59
|
rpc ReorderOrder(ReorderOrderRequest) returns (ReorderResponse);
|
|
@@ -319,7 +337,11 @@ message OrderItemInput {
|
|
|
319
337
|
string product_id = 1;
|
|
320
338
|
string variant_id = 2;
|
|
321
339
|
int32 quantity = 3;
|
|
340
|
+
|
|
322
341
|
double price_override = 4;
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
bool price_provided = 5;
|
|
323
345
|
}
|
|
324
346
|
|
|
325
347
|
message GetOrderRequest {
|
|
@@ -393,6 +415,114 @@ message SetCrmOrderIdRequest {
|
|
|
393
415
|
}
|
|
394
416
|
|
|
395
417
|
|
|
418
|
+
|
|
419
|
+
message MoneyAdjustment {
|
|
420
|
+
string id = 1;
|
|
421
|
+
string order_id = 2;
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
string kind = 3;
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
string status = 4;
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
double amount = 5;
|
|
431
|
+
double total_before = 6;
|
|
432
|
+
double total_after = 7;
|
|
433
|
+
|
|
434
|
+
string source = 8;
|
|
435
|
+
|
|
436
|
+
string payment_id = 9;
|
|
437
|
+
string payment_url = 10;
|
|
438
|
+
int64 expires_at = 11;
|
|
439
|
+
|
|
440
|
+
string resolved_by = 12;
|
|
441
|
+
int64 resolved_at = 13;
|
|
442
|
+
string resolution = 14;
|
|
443
|
+
string dismiss_reason = 15;
|
|
444
|
+
|
|
445
|
+
int64 created_at = 16;
|
|
446
|
+
int64 updated_at = 17;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
message MoneyAdjustmentResponse {
|
|
450
|
+
bool ok = 1;
|
|
451
|
+
MoneyAdjustment adjustment = 2;
|
|
452
|
+
string error_message = 3;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
message ListMoneyAdjustmentsRequest {
|
|
456
|
+
|
|
457
|
+
string order_id = 1;
|
|
458
|
+
bool only_open = 2;
|
|
459
|
+
int32 limit = 3;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
message ListMoneyAdjustmentsResponse {
|
|
463
|
+
repeated MoneyAdjustment items = 1;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
message GetMoneyAdjustmentRequest {
|
|
467
|
+
string id = 1;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
message MarkSurchargeIssuedRequest {
|
|
471
|
+
string id = 1;
|
|
472
|
+
string payment_id = 2;
|
|
473
|
+
string payment_url = 3;
|
|
474
|
+
string actor_id = 4;
|
|
475
|
+
string actor_name = 5;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
message SettleMoneyAdjustmentRequest {
|
|
479
|
+
string id = 1;
|
|
480
|
+
string resolution = 2;
|
|
481
|
+
string actor_id = 3;
|
|
482
|
+
string actor_name = 4;
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
string payment_id = 5;
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
double amount = 6;
|
|
489
|
+
bool amount_provided = 7;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
message DismissMoneyAdjustmentRequest {
|
|
493
|
+
string id = 1;
|
|
494
|
+
string reason = 2;
|
|
495
|
+
string actor_id = 3;
|
|
496
|
+
string actor_name = 4;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
message ListStuckEventsRequest {
|
|
500
|
+
int32 limit = 1;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
message StuckEvent {
|
|
504
|
+
string id = 1;
|
|
505
|
+
string pattern = 2;
|
|
506
|
+
string order_key = 3;
|
|
507
|
+
int32 attempts = 4;
|
|
508
|
+
string last_error = 5;
|
|
509
|
+
int64 created_at = 6;
|
|
510
|
+
bool acknowledged = 7;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
message ListStuckEventsResponse {
|
|
514
|
+
repeated StuckEvent items = 1;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
message StuckEventsActionRequest {
|
|
518
|
+
repeated string ids = 1;
|
|
519
|
+
string actor_id = 2;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
message StuckEventsActionResponse {
|
|
523
|
+
int32 affected = 1;
|
|
524
|
+
}
|
|
525
|
+
|
|
396
526
|
message SetOneCOrderRefRequest {
|
|
397
527
|
string id = 1;
|
|
398
528
|
|
package/dist/proto/payment.proto
CHANGED
|
@@ -8,6 +8,11 @@ service PaymentService {
|
|
|
8
8
|
|
|
9
9
|
rpc GetPayment(GetPaymentRequest) returns (PaymentResponse);
|
|
10
10
|
rpc GetPaymentByOrder(GetPaymentByOrderRequest) returns (PaymentResponse);
|
|
11
|
+
// Платіж ДОПЛАТИ за врегулюванням. `GetPaymentByOrder` для цього не
|
|
12
|
+
// годиться: він завжди віддає основний платіж замовлення.
|
|
13
|
+
rpc GetPaymentByAdjustment(GetPaymentByAdjustmentRequest) returns (PaymentResponse);
|
|
14
|
+
// Усі платежі замовлення (основний + доплати) — для звірки сум.
|
|
15
|
+
rpc ListOrderPayments(GetPaymentByOrderRequest) returns (ListPaymentsResponse);
|
|
11
16
|
rpc ListPayments(ListPaymentsRequest) returns (ListPaymentsResponse);
|
|
12
17
|
|
|
13
18
|
|
|
@@ -63,6 +68,10 @@ message Payment {
|
|
|
63
68
|
|
|
64
69
|
string capture_source = 19;
|
|
65
70
|
string capture_note = 20;
|
|
71
|
+
|
|
72
|
+
// Тип платежу і врегулювання, яке його породило (див. CreateInvoiceRequest).
|
|
73
|
+
string kind = 21;
|
|
74
|
+
string adjustment_id = 22;
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
message PaymentProviderInfo {
|
|
@@ -95,6 +104,14 @@ message CreateInvoiceRequest {
|
|
|
95
104
|
string customer_email = 8;
|
|
96
105
|
string customer_phone = 9;
|
|
97
106
|
repeated InvoiceItem items = 10;
|
|
107
|
+
|
|
108
|
+
// `primary` (за замовчуванням) — оплата замовлення; `surcharge` — доплата
|
|
109
|
+
// за перерахунком у 1С. На замовлення може бути один основний платіж і
|
|
110
|
+
// скільки завгодно доплат.
|
|
111
|
+
string kind = 11;
|
|
112
|
+
|
|
113
|
+
// Врегулювання, яке породило доплату (`order_money_adjustments`).
|
|
114
|
+
string adjustment_id = 12;
|
|
98
115
|
}
|
|
99
116
|
|
|
100
117
|
message InvoiceItem {
|
|
@@ -112,6 +129,10 @@ message GetPaymentByOrderRequest {
|
|
|
112
129
|
string order_id = 1;
|
|
113
130
|
}
|
|
114
131
|
|
|
132
|
+
message GetPaymentByAdjustmentRequest {
|
|
133
|
+
string adjustment_id = 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
115
136
|
message ListPaymentsRequest {
|
|
116
137
|
int32 page = 1;
|
|
117
138
|
int32 limit = 2;
|
package/events/orders/index.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Менеджер виставив клієнту доплату за перерахунком замовлення в 1С.
|
|
3
|
+
*
|
|
4
|
+
* Подія йде в notification-service: покупець дізнається про доплату з
|
|
5
|
+
* повідомлення (SMS / e-mail) і бачить її в кабінеті. Публікується ЛИШЕ після
|
|
6
|
+
* того, як рахунок реально створено в payment-service — повідомлення
|
|
7
|
+
* «доплатіть» без робочого посилання гірше за мовчання.
|
|
8
|
+
*/
|
|
9
|
+
export interface OrderSurchargeRequestedEvent {
|
|
10
|
+
orderId: string
|
|
11
|
+
orderNumber: string
|
|
12
|
+
userId?: string
|
|
13
|
+
|
|
14
|
+
adjustmentId: string
|
|
15
|
+
|
|
16
|
+
/** Сума доплати у гривнях, рядком (`Money.toWire`). */
|
|
17
|
+
amount: string
|
|
18
|
+
|
|
19
|
+
paymentUrl: string
|
|
20
|
+
|
|
21
|
+
/** Доки посилання дійсне. */
|
|
22
|
+
expiresAt: number
|
|
23
|
+
|
|
24
|
+
customer: {
|
|
25
|
+
firstName: string
|
|
26
|
+
lastName: string
|
|
27
|
+
email: string
|
|
28
|
+
phone: string
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -6,4 +6,17 @@ export interface PaymentCancelledEvent {
|
|
|
6
6
|
amount: string
|
|
7
7
|
reason?: string
|
|
8
8
|
cancelledAt: number
|
|
9
|
+
/**
|
|
10
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
11
|
+
* у 1С (`order_money_adjustments`).
|
|
12
|
+
*
|
|
13
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
14
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
15
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
16
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
17
|
+
*/
|
|
18
|
+
kind?: string
|
|
19
|
+
|
|
20
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
21
|
+
adjustmentId?: string
|
|
9
22
|
}
|
|
@@ -7,4 +7,14 @@ export interface PaymentCapturedEvent {
|
|
|
7
7
|
capturedAmount: string
|
|
8
8
|
currency: string
|
|
9
9
|
capturedAt: number
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
13
|
+
* у 1С. Без цього поля споживач не міг відрізнити їх і переписував статус
|
|
14
|
+
* ОСНОВНОГО платежу на подію про доплату.
|
|
15
|
+
*/
|
|
16
|
+
kind?: string
|
|
17
|
+
|
|
18
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
19
|
+
adjustmentId?: string
|
|
10
20
|
}
|
|
@@ -6,4 +6,17 @@ export interface PaymentFailedEvent {
|
|
|
6
6
|
amount: string
|
|
7
7
|
failureReason: string
|
|
8
8
|
failedAt: number
|
|
9
|
+
/**
|
|
10
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
11
|
+
* у 1С (`order_money_adjustments`).
|
|
12
|
+
*
|
|
13
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
14
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
15
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
16
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
17
|
+
*/
|
|
18
|
+
kind?: string
|
|
19
|
+
|
|
20
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
21
|
+
adjustmentId?: string
|
|
9
22
|
}
|
|
@@ -6,4 +6,17 @@ export interface PaymentHeldEvent {
|
|
|
6
6
|
amount: string
|
|
7
7
|
currency: string
|
|
8
8
|
heldAt: number
|
|
9
|
+
/**
|
|
10
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
11
|
+
* у 1С (`order_money_adjustments`).
|
|
12
|
+
*
|
|
13
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
14
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
15
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
16
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
17
|
+
*/
|
|
18
|
+
kind?: string
|
|
19
|
+
|
|
20
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
21
|
+
adjustmentId?: string
|
|
9
22
|
}
|
|
@@ -9,4 +9,17 @@ export interface PaymentRefundedEvent {
|
|
|
9
9
|
isPartial: boolean
|
|
10
10
|
reason?: string
|
|
11
11
|
refundedAt: number
|
|
12
|
+
/**
|
|
13
|
+
* `primary` — оплата замовлення, `surcharge` — доплата за перерахунком
|
|
14
|
+
* у 1С (`order_money_adjustments`).
|
|
15
|
+
*
|
|
16
|
+
* Поле є в КОЖНІЙ платіжній події, а не лише в `captured`: споживачі
|
|
17
|
+
* шукають платіж замовлення за `orderId`, і без `kind` подія про доплату
|
|
18
|
+
* переписувала б стан ОСНОВНОГО платежу. Наприклад, повернення доплати
|
|
19
|
+
* 240 ₴ робило все замовлення на 1200 ₴ «поверненим».
|
|
20
|
+
*/
|
|
21
|
+
kind?: string
|
|
22
|
+
|
|
23
|
+
/** Врегулювання, яке породило доплату. Порожнє для основного платежу. */
|
|
24
|
+
adjustmentId?: string
|
|
12
25
|
}
|
|
@@ -2,6 +2,19 @@ export interface StockRestockRequestedEvent {
|
|
|
2
2
|
orderId: string
|
|
3
3
|
orderNumber: string
|
|
4
4
|
reason: string
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Ідентифікатор ОПЕРАЦІЇ повернення. Стабільний для однієї події: RMQ
|
|
8
|
+
* доставляє щонайменше один раз, і дубль несе те саме значення.
|
|
9
|
+
*
|
|
10
|
+
* Саме на ньому тримається ідемпотентність у catalog. Виводити ключ зі
|
|
11
|
+
* стану складу не можна в принципі: перше ж виконання цей стан міняє, тож
|
|
12
|
+
* повтор отримував би інший ключ і повертав товар удруге. А відрізнити
|
|
13
|
+
* дубль від ЗАКОННОГО другого часткового повернення тієї самої позиції
|
|
14
|
+
* (1С зняла ще одну штуку) можна тільки за ідентифікатором операції.
|
|
15
|
+
*/
|
|
16
|
+
operationId?: string
|
|
17
|
+
|
|
5
18
|
items: Array<{
|
|
6
19
|
productId: string
|
|
7
20
|
variantId?: string
|
package/gen/order.ts
CHANGED
|
@@ -259,6 +259,7 @@ export interface OrderItemInput {
|
|
|
259
259
|
variantId: string;
|
|
260
260
|
quantity: number;
|
|
261
261
|
priceOverride: number;
|
|
262
|
+
priceProvided: boolean;
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
export interface GetOrderRequest {
|
|
@@ -326,6 +327,98 @@ export interface SetCrmOrderIdRequest {
|
|
|
326
327
|
crmOrderId: string;
|
|
327
328
|
}
|
|
328
329
|
|
|
330
|
+
export interface MoneyAdjustment {
|
|
331
|
+
id: string;
|
|
332
|
+
orderId: string;
|
|
333
|
+
kind: string;
|
|
334
|
+
status: string;
|
|
335
|
+
amount: number;
|
|
336
|
+
totalBefore: number;
|
|
337
|
+
totalAfter: number;
|
|
338
|
+
source: string;
|
|
339
|
+
paymentId: string;
|
|
340
|
+
paymentUrl: string;
|
|
341
|
+
expiresAt: number;
|
|
342
|
+
resolvedBy: string;
|
|
343
|
+
resolvedAt: number;
|
|
344
|
+
resolution: string;
|
|
345
|
+
dismissReason: string;
|
|
346
|
+
createdAt: number;
|
|
347
|
+
updatedAt: number;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export interface MoneyAdjustmentResponse {
|
|
351
|
+
ok: boolean;
|
|
352
|
+
adjustment: MoneyAdjustment | undefined;
|
|
353
|
+
errorMessage: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface ListMoneyAdjustmentsRequest {
|
|
357
|
+
orderId: string;
|
|
358
|
+
onlyOpen: boolean;
|
|
359
|
+
limit: number;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export interface ListMoneyAdjustmentsResponse {
|
|
363
|
+
items: MoneyAdjustment[];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export interface GetMoneyAdjustmentRequest {
|
|
367
|
+
id: string;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface MarkSurchargeIssuedRequest {
|
|
371
|
+
id: string;
|
|
372
|
+
paymentId: string;
|
|
373
|
+
paymentUrl: string;
|
|
374
|
+
actorId: string;
|
|
375
|
+
actorName: string;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export interface SettleMoneyAdjustmentRequest {
|
|
379
|
+
id: string;
|
|
380
|
+
resolution: string;
|
|
381
|
+
actorId: string;
|
|
382
|
+
actorName: string;
|
|
383
|
+
paymentId: string;
|
|
384
|
+
amount: number;
|
|
385
|
+
amountProvided: boolean;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface DismissMoneyAdjustmentRequest {
|
|
389
|
+
id: string;
|
|
390
|
+
reason: string;
|
|
391
|
+
actorId: string;
|
|
392
|
+
actorName: string;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface ListStuckEventsRequest {
|
|
396
|
+
limit: number;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface StuckEvent {
|
|
400
|
+
id: string;
|
|
401
|
+
pattern: string;
|
|
402
|
+
orderKey: string;
|
|
403
|
+
attempts: number;
|
|
404
|
+
lastError: string;
|
|
405
|
+
createdAt: number;
|
|
406
|
+
acknowledged: boolean;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface ListStuckEventsResponse {
|
|
410
|
+
items: StuckEvent[];
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export interface StuckEventsActionRequest {
|
|
414
|
+
ids: string[];
|
|
415
|
+
actorId: string;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface StuckEventsActionResponse {
|
|
419
|
+
affected: number;
|
|
420
|
+
}
|
|
421
|
+
|
|
329
422
|
export interface SetOneCOrderRefRequest {
|
|
330
423
|
id: string;
|
|
331
424
|
oneCOrderNumber: string;
|
|
@@ -511,6 +604,37 @@ export interface OrderServiceClient {
|
|
|
511
604
|
|
|
512
605
|
applyOneCStatus(request: ApplyOneCStatusRequest): Observable<OrderResponse>;
|
|
513
606
|
|
|
607
|
+
/** Врегулювання грошей після перерахунку (доплата / повернення). */
|
|
608
|
+
|
|
609
|
+
listMoneyAdjustments(request: ListMoneyAdjustmentsRequest): Observable<ListMoneyAdjustmentsResponse>;
|
|
610
|
+
|
|
611
|
+
getMoneyAdjustment(request: GetMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Перевірка ПЕРЕД створенням рахунку: чи можна взагалі виставляти доплату.
|
|
615
|
+
* Без неї платіжне посилання встигало зʼявитись раніше за відмову.
|
|
616
|
+
*/
|
|
617
|
+
|
|
618
|
+
assertCanIssueSurcharge(request: GetMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
619
|
+
|
|
620
|
+
markSurchargeIssued(request: MarkSurchargeIssuedRequest): Observable<MoneyAdjustmentResponse>;
|
|
621
|
+
|
|
622
|
+
settleMoneyAdjustment(request: SettleMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
623
|
+
|
|
624
|
+
dismissMoneyAdjustment(request: DismissMoneyAdjustmentRequest): Observable<MoneyAdjustmentResponse>;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Розбір заторів у черзі подій: подія, яка вичерпала ретраї, навмисно
|
|
628
|
+
* блокує всі наступні події свого замовлення (інакше `stock.reserve` поїхав
|
|
629
|
+
* би без свого `stock.release`). Тому потрібен і вихід із цього стану.
|
|
630
|
+
*/
|
|
631
|
+
|
|
632
|
+
listStuckEvents(request: ListStuckEventsRequest): Observable<ListStuckEventsResponse>;
|
|
633
|
+
|
|
634
|
+
retryStuckEvents(request: StuckEventsActionRequest): Observable<StuckEventsActionResponse>;
|
|
635
|
+
|
|
636
|
+
dismissStuckEvents(request: StuckEventsActionRequest): Observable<StuckEventsActionResponse>;
|
|
637
|
+
|
|
514
638
|
confirmPickup(request: ConfirmPickupRequest): Observable<OrderResponse>;
|
|
515
639
|
|
|
516
640
|
reorderOrder(request: ReorderOrderRequest): Observable<ReorderResponse>;
|
|
@@ -579,6 +703,55 @@ export interface OrderServiceController {
|
|
|
579
703
|
|
|
580
704
|
applyOneCStatus(request: ApplyOneCStatusRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
581
705
|
|
|
706
|
+
/** Врегулювання грошей після перерахунку (доплата / повернення). */
|
|
707
|
+
|
|
708
|
+
listMoneyAdjustments(
|
|
709
|
+
request: ListMoneyAdjustmentsRequest,
|
|
710
|
+
): Promise<ListMoneyAdjustmentsResponse> | Observable<ListMoneyAdjustmentsResponse> | ListMoneyAdjustmentsResponse;
|
|
711
|
+
|
|
712
|
+
getMoneyAdjustment(
|
|
713
|
+
request: GetMoneyAdjustmentRequest,
|
|
714
|
+
): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Перевірка ПЕРЕД створенням рахунку: чи можна взагалі виставляти доплату.
|
|
718
|
+
* Без неї платіжне посилання встигало зʼявитись раніше за відмову.
|
|
719
|
+
*/
|
|
720
|
+
|
|
721
|
+
assertCanIssueSurcharge(
|
|
722
|
+
request: GetMoneyAdjustmentRequest,
|
|
723
|
+
): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
724
|
+
|
|
725
|
+
markSurchargeIssued(
|
|
726
|
+
request: MarkSurchargeIssuedRequest,
|
|
727
|
+
): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
728
|
+
|
|
729
|
+
settleMoneyAdjustment(
|
|
730
|
+
request: SettleMoneyAdjustmentRequest,
|
|
731
|
+
): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
732
|
+
|
|
733
|
+
dismissMoneyAdjustment(
|
|
734
|
+
request: DismissMoneyAdjustmentRequest,
|
|
735
|
+
): Promise<MoneyAdjustmentResponse> | Observable<MoneyAdjustmentResponse> | MoneyAdjustmentResponse;
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Розбір заторів у черзі подій: подія, яка вичерпала ретраї, навмисно
|
|
739
|
+
* блокує всі наступні події свого замовлення (інакше `stock.reserve` поїхав
|
|
740
|
+
* би без свого `stock.release`). Тому потрібен і вихід із цього стану.
|
|
741
|
+
*/
|
|
742
|
+
|
|
743
|
+
listStuckEvents(
|
|
744
|
+
request: ListStuckEventsRequest,
|
|
745
|
+
): Promise<ListStuckEventsResponse> | Observable<ListStuckEventsResponse> | ListStuckEventsResponse;
|
|
746
|
+
|
|
747
|
+
retryStuckEvents(
|
|
748
|
+
request: StuckEventsActionRequest,
|
|
749
|
+
): Promise<StuckEventsActionResponse> | Observable<StuckEventsActionResponse> | StuckEventsActionResponse;
|
|
750
|
+
|
|
751
|
+
dismissStuckEvents(
|
|
752
|
+
request: StuckEventsActionRequest,
|
|
753
|
+
): Promise<StuckEventsActionResponse> | Observable<StuckEventsActionResponse> | StuckEventsActionResponse;
|
|
754
|
+
|
|
582
755
|
confirmPickup(request: ConfirmPickupRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
583
756
|
|
|
584
757
|
reorderOrder(request: ReorderOrderRequest): Promise<ReorderResponse> | Observable<ReorderResponse> | ReorderResponse;
|
|
@@ -618,6 +791,15 @@ export function OrderServiceControllerMethods() {
|
|
|
618
791
|
"setCrmOrderId",
|
|
619
792
|
"setOneCOrderRef",
|
|
620
793
|
"applyOneCStatus",
|
|
794
|
+
"listMoneyAdjustments",
|
|
795
|
+
"getMoneyAdjustment",
|
|
796
|
+
"assertCanIssueSurcharge",
|
|
797
|
+
"markSurchargeIssued",
|
|
798
|
+
"settleMoneyAdjustment",
|
|
799
|
+
"dismissMoneyAdjustment",
|
|
800
|
+
"listStuckEvents",
|
|
801
|
+
"retryStuckEvents",
|
|
802
|
+
"dismissStuckEvents",
|
|
621
803
|
"confirmPickup",
|
|
622
804
|
"reorderOrder",
|
|
623
805
|
"listHistory",
|
package/gen/payment.ts
CHANGED
|
@@ -31,6 +31,9 @@ export interface Payment {
|
|
|
31
31
|
refundedAt: number;
|
|
32
32
|
captureSource: string;
|
|
33
33
|
captureNote: string;
|
|
34
|
+
/** Тип платежу і врегулювання, яке його породило (див. CreateInvoiceRequest). */
|
|
35
|
+
kind: string;
|
|
36
|
+
adjustmentId: string;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
export interface PaymentProviderInfo {
|
|
@@ -56,6 +59,14 @@ export interface CreateInvoiceRequest {
|
|
|
56
59
|
customerEmail: string;
|
|
57
60
|
customerPhone: string;
|
|
58
61
|
items: InvoiceItem[];
|
|
62
|
+
/**
|
|
63
|
+
* `primary` (за замовчуванням) — оплата замовлення; `surcharge` — доплата
|
|
64
|
+
* за перерахунком у 1С. На замовлення може бути один основний платіж і
|
|
65
|
+
* скільки завгодно доплат.
|
|
66
|
+
*/
|
|
67
|
+
kind: string;
|
|
68
|
+
/** Врегулювання, яке породило доплату (`order_money_adjustments`). */
|
|
69
|
+
adjustmentId: string;
|
|
59
70
|
}
|
|
60
71
|
|
|
61
72
|
export interface InvoiceItem {
|
|
@@ -73,6 +84,10 @@ export interface GetPaymentByOrderRequest {
|
|
|
73
84
|
orderId: string;
|
|
74
85
|
}
|
|
75
86
|
|
|
87
|
+
export interface GetPaymentByAdjustmentRequest {
|
|
88
|
+
adjustmentId: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
76
91
|
export interface ListPaymentsRequest {
|
|
77
92
|
page: number;
|
|
78
93
|
limit: number;
|
|
@@ -208,6 +223,17 @@ export interface PaymentServiceClient {
|
|
|
208
223
|
|
|
209
224
|
getPaymentByOrder(request: GetPaymentByOrderRequest): Observable<PaymentResponse>;
|
|
210
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Платіж ДОПЛАТИ за врегулюванням. `GetPaymentByOrder` для цього не
|
|
228
|
+
* годиться: він завжди віддає основний платіж замовлення.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
getPaymentByAdjustment(request: GetPaymentByAdjustmentRequest): Observable<PaymentResponse>;
|
|
232
|
+
|
|
233
|
+
/** Усі платежі замовлення (основний + доплати) — для звірки сум. */
|
|
234
|
+
|
|
235
|
+
listOrderPayments(request: GetPaymentByOrderRequest): Observable<ListPaymentsResponse>;
|
|
236
|
+
|
|
211
237
|
listPayments(request: ListPaymentsRequest): Observable<ListPaymentsResponse>;
|
|
212
238
|
|
|
213
239
|
capture(request: CaptureRequest): Observable<PaymentResponse>;
|
|
@@ -246,6 +272,21 @@ export interface PaymentServiceController {
|
|
|
246
272
|
request: GetPaymentByOrderRequest,
|
|
247
273
|
): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
|
248
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Платіж ДОПЛАТИ за врегулюванням. `GetPaymentByOrder` для цього не
|
|
277
|
+
* годиться: він завжди віддає основний платіж замовлення.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
getPaymentByAdjustment(
|
|
281
|
+
request: GetPaymentByAdjustmentRequest,
|
|
282
|
+
): Promise<PaymentResponse> | Observable<PaymentResponse> | PaymentResponse;
|
|
283
|
+
|
|
284
|
+
/** Усі платежі замовлення (основний + доплати) — для звірки сум. */
|
|
285
|
+
|
|
286
|
+
listOrderPayments(
|
|
287
|
+
request: GetPaymentByOrderRequest,
|
|
288
|
+
): Promise<ListPaymentsResponse> | Observable<ListPaymentsResponse> | ListPaymentsResponse;
|
|
289
|
+
|
|
249
290
|
listPayments(
|
|
250
291
|
request: ListPaymentsRequest,
|
|
251
292
|
): Promise<ListPaymentsResponse> | Observable<ListPaymentsResponse> | ListPaymentsResponse;
|
|
@@ -297,6 +338,8 @@ export function PaymentServiceControllerMethods() {
|
|
|
297
338
|
"createInvoice",
|
|
298
339
|
"getPayment",
|
|
299
340
|
"getPaymentByOrder",
|
|
341
|
+
"getPaymentByAdjustment",
|
|
342
|
+
"listOrderPayments",
|
|
300
343
|
"listPayments",
|
|
301
344
|
"capture",
|
|
302
345
|
"markPaidOffline",
|
package/package.json
CHANGED
package/proto/order.proto
CHANGED
|
@@ -36,6 +36,24 @@ service OrderService {
|
|
|
36
36
|
|
|
37
37
|
rpc ApplyOneCStatus(ApplyOneCStatusRequest) returns (OrderResponse);
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
// Врегулювання грошей після перерахунку (доплата / повернення).
|
|
41
|
+
rpc ListMoneyAdjustments(ListMoneyAdjustmentsRequest) returns (ListMoneyAdjustmentsResponse);
|
|
42
|
+
rpc GetMoneyAdjustment(GetMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
43
|
+
// Перевірка ПЕРЕД створенням рахунку: чи можна взагалі виставляти доплату.
|
|
44
|
+
// Без неї платіжне посилання встигало зʼявитись раніше за відмову.
|
|
45
|
+
rpc AssertCanIssueSurcharge(GetMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
46
|
+
rpc MarkSurchargeIssued(MarkSurchargeIssuedRequest) returns (MoneyAdjustmentResponse);
|
|
47
|
+
rpc SettleMoneyAdjustment(SettleMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
48
|
+
rpc DismissMoneyAdjustment(DismissMoneyAdjustmentRequest) returns (MoneyAdjustmentResponse);
|
|
49
|
+
|
|
50
|
+
// Розбір заторів у черзі подій: подія, яка вичерпала ретраї, навмисно
|
|
51
|
+
// блокує всі наступні події свого замовлення (інакше `stock.reserve` поїхав
|
|
52
|
+
// би без свого `stock.release`). Тому потрібен і вихід із цього стану.
|
|
53
|
+
rpc ListStuckEvents(ListStuckEventsRequest) returns (ListStuckEventsResponse);
|
|
54
|
+
rpc RetryStuckEvents(StuckEventsActionRequest) returns (StuckEventsActionResponse);
|
|
55
|
+
rpc DismissStuckEvents(StuckEventsActionRequest) returns (StuckEventsActionResponse);
|
|
56
|
+
|
|
39
57
|
rpc ConfirmPickup(ConfirmPickupRequest) returns (OrderResponse);
|
|
40
58
|
|
|
41
59
|
rpc ReorderOrder(ReorderOrderRequest) returns (ReorderResponse);
|
|
@@ -319,7 +337,11 @@ message OrderItemInput {
|
|
|
319
337
|
string product_id = 1;
|
|
320
338
|
string variant_id = 2;
|
|
321
339
|
int32 quantity = 3;
|
|
340
|
+
|
|
322
341
|
double price_override = 4;
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
bool price_provided = 5;
|
|
323
345
|
}
|
|
324
346
|
|
|
325
347
|
message GetOrderRequest {
|
|
@@ -393,6 +415,114 @@ message SetCrmOrderIdRequest {
|
|
|
393
415
|
}
|
|
394
416
|
|
|
395
417
|
|
|
418
|
+
|
|
419
|
+
message MoneyAdjustment {
|
|
420
|
+
string id = 1;
|
|
421
|
+
string order_id = 2;
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
string kind = 3;
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
string status = 4;
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
double amount = 5;
|
|
431
|
+
double total_before = 6;
|
|
432
|
+
double total_after = 7;
|
|
433
|
+
|
|
434
|
+
string source = 8;
|
|
435
|
+
|
|
436
|
+
string payment_id = 9;
|
|
437
|
+
string payment_url = 10;
|
|
438
|
+
int64 expires_at = 11;
|
|
439
|
+
|
|
440
|
+
string resolved_by = 12;
|
|
441
|
+
int64 resolved_at = 13;
|
|
442
|
+
string resolution = 14;
|
|
443
|
+
string dismiss_reason = 15;
|
|
444
|
+
|
|
445
|
+
int64 created_at = 16;
|
|
446
|
+
int64 updated_at = 17;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
message MoneyAdjustmentResponse {
|
|
450
|
+
bool ok = 1;
|
|
451
|
+
MoneyAdjustment adjustment = 2;
|
|
452
|
+
string error_message = 3;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
message ListMoneyAdjustmentsRequest {
|
|
456
|
+
|
|
457
|
+
string order_id = 1;
|
|
458
|
+
bool only_open = 2;
|
|
459
|
+
int32 limit = 3;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
message ListMoneyAdjustmentsResponse {
|
|
463
|
+
repeated MoneyAdjustment items = 1;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
message GetMoneyAdjustmentRequest {
|
|
467
|
+
string id = 1;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
message MarkSurchargeIssuedRequest {
|
|
471
|
+
string id = 1;
|
|
472
|
+
string payment_id = 2;
|
|
473
|
+
string payment_url = 3;
|
|
474
|
+
string actor_id = 4;
|
|
475
|
+
string actor_name = 5;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
message SettleMoneyAdjustmentRequest {
|
|
479
|
+
string id = 1;
|
|
480
|
+
string resolution = 2;
|
|
481
|
+
string actor_id = 3;
|
|
482
|
+
string actor_name = 4;
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
string payment_id = 5;
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
double amount = 6;
|
|
489
|
+
bool amount_provided = 7;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
message DismissMoneyAdjustmentRequest {
|
|
493
|
+
string id = 1;
|
|
494
|
+
string reason = 2;
|
|
495
|
+
string actor_id = 3;
|
|
496
|
+
string actor_name = 4;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
message ListStuckEventsRequest {
|
|
500
|
+
int32 limit = 1;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
message StuckEvent {
|
|
504
|
+
string id = 1;
|
|
505
|
+
string pattern = 2;
|
|
506
|
+
string order_key = 3;
|
|
507
|
+
int32 attempts = 4;
|
|
508
|
+
string last_error = 5;
|
|
509
|
+
int64 created_at = 6;
|
|
510
|
+
bool acknowledged = 7;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
message ListStuckEventsResponse {
|
|
514
|
+
repeated StuckEvent items = 1;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
message StuckEventsActionRequest {
|
|
518
|
+
repeated string ids = 1;
|
|
519
|
+
string actor_id = 2;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
message StuckEventsActionResponse {
|
|
523
|
+
int32 affected = 1;
|
|
524
|
+
}
|
|
525
|
+
|
|
396
526
|
message SetOneCOrderRefRequest {
|
|
397
527
|
string id = 1;
|
|
398
528
|
|
package/proto/payment.proto
CHANGED
|
@@ -8,6 +8,11 @@ service PaymentService {
|
|
|
8
8
|
|
|
9
9
|
rpc GetPayment(GetPaymentRequest) returns (PaymentResponse);
|
|
10
10
|
rpc GetPaymentByOrder(GetPaymentByOrderRequest) returns (PaymentResponse);
|
|
11
|
+
// Платіж ДОПЛАТИ за врегулюванням. `GetPaymentByOrder` для цього не
|
|
12
|
+
// годиться: він завжди віддає основний платіж замовлення.
|
|
13
|
+
rpc GetPaymentByAdjustment(GetPaymentByAdjustmentRequest) returns (PaymentResponse);
|
|
14
|
+
// Усі платежі замовлення (основний + доплати) — для звірки сум.
|
|
15
|
+
rpc ListOrderPayments(GetPaymentByOrderRequest) returns (ListPaymentsResponse);
|
|
11
16
|
rpc ListPayments(ListPaymentsRequest) returns (ListPaymentsResponse);
|
|
12
17
|
|
|
13
18
|
|
|
@@ -63,6 +68,10 @@ message Payment {
|
|
|
63
68
|
|
|
64
69
|
string capture_source = 19;
|
|
65
70
|
string capture_note = 20;
|
|
71
|
+
|
|
72
|
+
// Тип платежу і врегулювання, яке його породило (див. CreateInvoiceRequest).
|
|
73
|
+
string kind = 21;
|
|
74
|
+
string adjustment_id = 22;
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
message PaymentProviderInfo {
|
|
@@ -95,6 +104,14 @@ message CreateInvoiceRequest {
|
|
|
95
104
|
string customer_email = 8;
|
|
96
105
|
string customer_phone = 9;
|
|
97
106
|
repeated InvoiceItem items = 10;
|
|
107
|
+
|
|
108
|
+
// `primary` (за замовчуванням) — оплата замовлення; `surcharge` — доплата
|
|
109
|
+
// за перерахунком у 1С. На замовлення може бути один основний платіж і
|
|
110
|
+
// скільки завгодно доплат.
|
|
111
|
+
string kind = 11;
|
|
112
|
+
|
|
113
|
+
// Врегулювання, яке породило доплату (`order_money_adjustments`).
|
|
114
|
+
string adjustment_id = 12;
|
|
98
115
|
}
|
|
99
116
|
|
|
100
117
|
message InvoiceItem {
|
|
@@ -112,6 +129,10 @@ message GetPaymentByOrderRequest {
|
|
|
112
129
|
string order_id = 1;
|
|
113
130
|
}
|
|
114
131
|
|
|
132
|
+
message GetPaymentByAdjustmentRequest {
|
|
133
|
+
string adjustment_id = 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
115
136
|
message ListPaymentsRequest {
|
|
116
137
|
int32 page = 1;
|
|
117
138
|
int32 limit = 2;
|