-
Notifications
You must be signed in to change notification settings - Fork 8
/
ledger_spec.yaml
1802 lines (1802 loc) · 50.4 KB
/
ledger_spec.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.1
info:
description: Ledger API
title: Ledger API
version: v1.0.0
servers:
- url: http://ledger_url
paths:
/healthcheck:
get:
operationId: healthCheck
responses:
"200":
content:
application/json:
schema:
type: string
example:
postgresql:
healthy: true
message: Healthy
sqsQueue:
healthy: true
message: Healthy
deadlocks:
healthy: true
message: Healthy
description: OK
"503":
description: Service Unavailable
summary: "Healthcheck endpoint the ledger (checks postgresql, sqs queue)"
tags:
- Other
/v1/agreement:
get:
operationId: search
parameters:
- description: Service id(s)
example: 1
in: query
name: service_id
schema:
type: array
items:
type: string
- description: Limit the results to agreement(s) relating to live (not test)
accounts
example: true
in: query
name: live
schema:
type: boolean
- description: Gateway account id(s)
example: 1
in: query
name: account_id
schema:
type: array
items:
type: string
- description: "Unless set to true, either service_id or account_id field must\
\ be completed"
example: true
in: query
name: override_account_or_service_id_restriction
schema:
type: boolean
- description: Status of agreement
example: CREATED
in: query
name: status
schema:
type: string
enum:
- CREATED
- ACTIVE
- INACTIVE
- CANCELLED
- description: Limit the results to exact matches for the given reference
example: true
in: query
name: exact_reference_match
schema:
type: boolean
- description: The reference provided by the service when creating the agreement(s)
example: 12345
in: query
name: reference
schema:
type: string
- description: Page number of results
example: 1
in: query
name: page
schema:
type: integer
format: int64
- description: Number of results to be displayed
example: 10
in: query
name: display_size
schema:
type: integer
format: int64
default: 20
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/AgreementSearchResponse'
description: OK
"404":
description: Not found
summary: Search agreements by query params
tags:
- Agreements
/v1/agreement/{agreementExternalId}:
get:
operationId: get
parameters:
- description: The unique external id for the agreement
example: cgc1ocvh0pt9fqs0ma67r42l58
in: path
name: agreementExternalId
required: true
schema:
type: string
- description: "If true, an additional check will be carried out to ensure that\
\ ledger database is up-to-date with latest events before responding"
example: true
in: header
name: X-Consistent
schema:
type: boolean
- description: The gateway account id linked to the agreement
example: 1
in: query
name: account_id
schema:
type: string
- description: The service id linked to the agreement
example: 1
in: query
name: service_id
schema:
type: string
- description: "If false, the account_id or service_id must be specified"
example: false
in: query
name: override_account_or_service_id_restriction
schema:
type: boolean
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/Agreement'
description: OK
"404":
description: Not found
"422":
description: Invalid parameters. One of service_id or account_id fields
is required unless override_account_or_service_id_restriction=true
summary: Find agreement by ID
tags:
- Agreements
/v1/agreement/{agreementExternalId}/event:
get:
operationId: getEvents
parameters:
- description: The unique external id for the agreement
example: cgc1ocvh0pt9fqs0ma67r42l58
in: path
name: agreementExternalId
required: true
schema:
type: string
- description: The service id linked to the agreement
example: 1
in: query
name: service_id
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/AgreementEventsResponse'
description: OK
"404":
description: Not found
summary: Find agreement events by agreement ID
tags:
- Agreements
/v1/event:
post:
operationId: writeEvent
requestBody:
content:
'*/*':
schema:
type: array
items:
$ref: '#/components/schemas/EventMessageDto'
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/EventTicker'
description: OK
"422":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing query parameters
"500":
description: Invalid parameters or Downstream system error
summary: Write a list of events to the ledger database
tags:
- Events
/v1/event/ticker:
get:
operationId: listEvents
parameters:
- description: from date of events to be searched (this date is inclusive).
example: 2015-08-14T12:35:00Z
in: query
name: from_date
required: true
schema:
type: string
- description: to date of events to be searched (this date is exclusive)
example: 2015-08-14T12:35:00Z
in: query
name: to_date
required: true
schema:
type: string
- description: event types to find
example: PAYMENT_CREATED
in: query
name: event_types
schema:
type: array
items:
type: string
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/EventTicker'
description: OK
"422":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing query parameters
"500":
description: Invalid parameters or Downstream system error
summary: Get list of events between a date/time range and event type
tags:
- Events
/v1/payout:
get:
operationId: search_1
parameters:
- description: "State of payout. allowed values are intransit, paidout, failed"
in: query
name: state
schema:
type: string
- description: "Page number requested for the search, should be a positive integer\
\ (optional, defaults to 1)"
in: query
name: page
schema:
type: integer
format: int64
- description: "Number of results to be shown per page, should be a positive\
\ integer (optional, defaults to 500, max 500)"
in: query
name: display_size
schema:
type: integer
format: int64
- description: Set to true to list all payouts.
in: query
name: override_account_id_restriction
schema:
type: boolean
- description: Comma delimited gateway account IDs. Required except when override_account_id_restriction=true
example: "1,2"
in: query
name: gateway_account_id
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/PayoutSearchResponse'
description: OK
"404":
description: Not found
summary: Search payouts by gateway_account_id and state
tags:
- Payouts
/v1/report/gateway-performance-report:
get:
operationId: getGatewayMonthlyPerformanceReport
parameters:
- description: From date of transaction summary to be searched (this date is
inclusive).
example: 2022-03-29
in: query
name: from_date
required: true
schema:
type: string
- description: To date of transaction summary to be searched (this date is inclusive).
example: 2022-03-29
in: query
name: to_date
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/GatewayAccountMonthlyPerformanceReportEntity'
description: OK
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required query parameters (from_date or to_date)
"500":
description: Internal Server Error for invalid query parameter values
summary: Get monthly performance report by gateway account. Queries transaction_summary
table
tags:
- Reports
/v1/report/payments_by_state:
get:
operationId: getPaymentCountsByState
parameters:
- description: Gateway account ID. Required when override_account_id_restriction
is 'false'
example: 1
in: query
name: account_id
schema:
type: string
- description: Set to true to return statistics for moto transactions
example: false
in: query
name: include_moto_statistics
schema:
type: boolean
- description: From date of transactions to be searched (this date is exclusive).
example: 2022-03-29T00:00:00Z
in: query
name: from_date
schema:
type: string
- description: To date of transactions to be searched (this date is exclusive).
example: 2022-03-29T00:00:00Z
in: query
name: to_date
schema:
type: string
- description: Set to true to get counts for all gateway accounts.
in: query
name: override_account_id_restriction
schema:
type: boolean
responses:
"200":
content:
application/json:
schema:
type: object
example:
timedout: 0
submitted: 0
declined: 0
created: 0
success: 1
cancelled: 0
started: 0
error: 0
undefined: 0
capturable: 0
description: OK
"422":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required or invalid query parameters (from_date or
to_date)
summary: Get number of payments by transaction (payment) state
tags:
- Reports
/v1/report/performance-report:
get:
operationId: getPerformanceReport
parameters:
- description: From date of the transaction summary to be searched (this date
is inclusive). Required when to_date is provided
example: 2022-03-29
in: query
name: from_date
schema:
type: string
- description: To date of the transaction summary to be searched (this date
is inclusive). Required when from_date is provided
example: 2022-03-29
in: query
name: to_date
schema:
type: string
- description: Transaction state
in: query
name: state
schema:
type: string
enum:
- UNDEFINED
- STARTED
- CAPTURABLE
- FAILED_REJECTED
- FAILED_EXPIRED
- FAILED_CANCELLED
- CANCELLED
- CREATED
- SUBMITTED
- SUCCESS
- ERROR
- ERROR_GATEWAY
- NEEDS_RESPONSE
- UNDER_REVIEW
- LOST
- WON
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/PerformanceReportEntity'
description: OK
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: For missing query params or invalid state).
"500":
description: Internal Server Error for invalid query params (from_date/to_date)
values
summary: Get platform performance report (total volume and total_amount) for
the date range and transaction state. Queries transaction_summary table for
stats
tags:
- Reports
/v1/report/performance-report-legacy:
get:
operationId: getLegacyPerformanceReport
parameters:
- description: From date of transactions to be searched (this date is inclusive).
example: 2022-03-29T01:00:00Z
in: query
name: from_date
schema:
type: string
- description: To date of transactions to be searched (this date is exclusive).
example: 2022-03-29T01:00:00Z
in: query
name: to_date
schema:
type: string
- description: Transaction state
in: query
name: state
schema:
type: string
enum:
- UNDEFINED
- STARTED
- CAPTURABLE
- FAILED_REJECTED
- FAILED_EXPIRED
- FAILED_CANCELLED
- CANCELLED
- CREATED
- SUBMITTED
- SUCCESS
- ERROR
- ERROR_GATEWAY
- NEEDS_RESPONSE
- UNDER_REVIEW
- LOST
- WON
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/PerformanceReportEntity'
description: OK
"500":
description: Internal Server Error for invalid query parameter values
summary: "Get platform performance report (total volume and total_amount) for\
\ the date range and transaction state. Queries transaction table for stats,\
\ so could be slow for large date ranges"
tags:
- Reports
/v1/report/transactions-by-hour:
get:
operationId: getTransactionsByHour
parameters:
- description: From date of transaction summary to be searched (this date is
inclusive).
example: 2022-03-29T00:00:00Z
in: query
name: from_date
required: true
schema:
type: string
- description: To date of transaction summary to be searched (this date is inclusive).
example: 2022-03-29T00:00:00Z
in: query
name: to_date
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/TimeseriesReportSlice'
description: OK
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required query parameters
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Invalid query parameters (from_date or to_date)
summary: Get transaction summary by hour
tags:
- Reports
/v1/report/transactions-summary:
get:
operationId: getTransactionSummaryResult
parameters:
- description: Gateway account ID. Required when override_account_id_restriction
is 'false'
example: 1
in: query
name: account_id
schema:
type: string
- description: Set to true to return statistics for moto transactions
example: false
in: query
name: include_moto_statistics
schema:
type: boolean
- description: From date of transactions to be searched (this date is exclusive).
example: 2022-03-29T00:00:00Z
in: query
name: from_date
schema:
type: string
- description: To date of transactions to be searched (this date is exclusive).
example: 2022-03-29T00:00:00Z
in: query
name: to_date
schema:
type: string
- description: Set to true to return summary for all accounts.
in: query
name: override_account_id_restriction
schema:
type: boolean
- description: Set to true to make from_date non-mandatory.
in: query
name: override_from_date_validation
schema:
type: boolean
default: false
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionSummaryResult'
description: OK
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required query parameter (from_date)
"422":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required or invalid query parameters (from_date or
to_date)
summary: Get transaction summary for query params
tags:
- Reports
/v1/tasks/expunge-or-redact-historical-data:
post:
operationId: expungeOrRedactData
responses:
"200":
description: OK
summary: Redacts/Removes historical data based on `expungeOrRedactHistoricalDataConfig`.
Currently redacts PII from transactions and deletes related transaction events
tags:
- Tasks
/v1/transaction:
get:
operationId: search transactions
parameters:
- description: Set to '2' to return failed transaction states FAILED_REJECTED/FAILED_EXPIRED/FAILED_CANCELLED
mapped to declined/timedout/cancelled external status respectively.Otherwise
these transaction states will all be mapped to `failed` status
in: query
name: status_version
schema:
type: integer
format: int32
default: 2
- description: Set to 'true' to search for transactions by exact reference.
Otherwise reference is partially matched
in: query
name: exact_reference_match
schema:
type: boolean
default: false
- example: [email protected]
in: query
name: email
schema:
type: string
- example: my-payment-reference
in: query
name: reference
schema:
type: string
- example: J Doe
in: query
name: cardholder_name
schema:
type: string
- example: 7890
in: query
name: last_digits_card_number
schema:
type: string
- example: 123456
in: query
name: first_digits_card_number
schema:
type: string
- description: Comma delimited payment states.
example: "success,error"
in: query
name: payment_states
schema:
$ref: '#/components/schemas/CommaDelimitedSetParameter'
- example: success
in: query
name: state
schema:
type: string
- description: Comma delimited refund states.
example: "success,error"
in: query
name: refund_states
schema:
$ref: '#/components/schemas/CommaDelimitedSetParameter'
- description: Comma delimited card brands.
example: "visa,mastercard"
in: query
name: card_brands
schema:
$ref: '#/components/schemas/CommaDelimitedSetParameter'
- description: From date of transactions to be searched (this date is inclusive).
example: 2015-08-14T12:35:00Z
in: query
name: from_date
schema:
type: string
- description: To date of transactions to be searched (this date is inclusive).
example: 2015-08-14T12:35:00Z
in: query
name: to_date
schema:
type: string
- example: PAYMENT
in: query
name: transaction_type
schema:
type: string
enum:
- PAYMENT
- REFUND
- DISPUTE
- example: po_fj893joishj12lndk
in: query
name: gateway_payout_id
schema:
type: string
- description: From date of transactions settled date to be searched (this date
is inclusive).
example: 2015-08-14
in: query
name: from_settled_date
schema:
type: string
- description: To date of transactions settled date to be searched (this date
is inclusive).
example: 2015-08-14
in: query
name: to_settled_date
schema:
type: string
- example: metadata-value-1
in: query
name: metadata_value
schema:
type: string
- example: 17ii98mg7f6si930tcjt48ldlc
in: query
name: agreement_id
schema:
type: string
- example: 1
in: query
name: page
schema:
type: integer
format: int64
- example: 100
in: query
name: display_size
schema:
type: integer
format: int64
default: 500
- description: Set to 'true' to limit the search counting the total number of
transactions to 'limit_total_size' param
example: true
in: query
name: limit_total
schema:
type: boolean
default: false
- example: 1000
in: query
name: limit_total_size
schema:
type: integer
format: int64
default: 10000
- example: a14f0926-b44d-4160-8184-1b1f66e576ab
in: query
name: gateway_transaction_id
schema:
type: string
- description: Comma delimited dispute states.
example: "won,needs_response"
in: query
name: dispute_states
schema:
$ref: '#/components/schemas/CommaDelimitedSetParameter'
- description: Set to true to list transactions for all accounts.
in: query
name: override_account_id_restriction
schema:
type: boolean
- description: Comma delimited gateway account IDs. Required except when override_account_id_restriction=true
example: "1,2"
in: query
name: account_id
schema:
type: string
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/TransactionSearchResponse'
description: OK
"400":
content:
application/json; qs=1:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required query parameters
"504":
description: Search query cancelled due to query timeout
summary: Search transactions by query params. Same endpoint can be used to download
CSV (with Accept header="text/csv"). Refer to code for details
tags:
- Transactions
/v1/transaction/gateway-transaction/{gatewayTransactionId}:
get:
operationId: findByGatewayTransactionId
parameters:
- description: Transaction ID from payment provider
example: a14f0926-b44d-4160-8184-1b1f66e576ab
in: path
name: gatewayTransactionId
required: true
schema:
type: string
- example: sandbox
in: query
name: payment_provider
required: true
schema:
type: string
responses:
"200":
content:
application/json; qs=1:
schema:
$ref: '#/components/schemas/TransactionView'
description: OK
"404":
description: Not found
"422":
content:
application/json; qs=1:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: If payment_provider query parameter is missing
summary: Get transaction for a gateway transaction ID
tags:
- Transactions
/v1/transaction/redact-reference/{transactionExternalId}:
post:
operationId: redactReference
parameters:
- in: path
name: transactionExternalId
required: true
schema:
type: string
responses:
default:
content:
application/json; qs=1: {}
description: default response
tags:
- Transactions
/v1/transaction/{parentTransactionExternalId}/transaction:
get:
operationId: getTransactionsForParentTransaction
parameters:
- description: Parent transaction external ID
example: d0sk01d9amdk3ks0dk2dj03kd
in: path
name: parentTransactionExternalId
required: true
schema:
type: string
- description: Gateway account ID
example: 1
in: query
name: gateway_account_id
required: true
schema:
type: string
- description: The type of transactions to return
example: REFUND
in: query
name: transaction_type
schema:
type: string
enum:
- PAYMENT
- REFUND
- DISPUTE
responses:
"200":
content:
application/json; qs=1:
schema:
$ref: '#/components/schemas/TransactionsForTransactionResponse'
description: OK
"404":
description: Not found
"422":
content:
application/json; qs=1:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required query parameter (gateway_account_id)
summary: "Get transactions (ex: refunds) related to parent transaction (payment)"
tags:
- Transactions
/v1/transaction/{transactionExternalId}:
get:
operationId: getById
parameters:
- in: path
name: transactionExternalId
required: true
schema:
type: string
- in: query
name: account_id
schema:
type: string
- in: query
name: override_account_id_restriction
schema:
type: boolean
- in: query
name: transaction_type
schema:
type: string
enum:
- PAYMENT
- REFUND
- DISPUTE
- in: query
name: parent_external_id
schema:
type: string
- in: query
name: status_version
schema:
type: integer
format: int32
default: 2
responses:
"200":
content:
application/json; qs=1:
schema:
type: array
items:
$ref: '#/components/schemas/TransactionView'
description: OK
"400":
content:
application/json; qs=1:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Missing required query parameters
"500":
description: Internal Server Error for invalid query parameter values
summary: Get transaction by external ID
tags:
- Transactions
/v1/transaction/{transactionExternalId}/event:
get:
operationId: events
parameters:
- description: Transaction external ID
example: 9np5pocnotgkpp029d5kdfau5f
in: path
name: transactionExternalId