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/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 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 tags: - Events /v1/event/{eventId}: get: operationId: getEvent parameters: - in: path name: eventId required: true schema: type: integer format: int64 responses: "200": content: application/json: schema: $ref: '#/components/schemas/Event' description: OK "404": description: Not found summary: Find event by ID (id of event table) tags: - Events /v1/payout: get: operationId: search 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 - CREATED - STARTED - SUBMITTED - CAPTURABLE - SUCCESS - FAILED_REJECTED - FAILED_EXPIRED - FAILED_CANCELLED - CANCELLED - ERROR - ERROR_GATEWAY 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 - CREATED - STARTED - SUBMITTED - CAPTURABLE - SUCCESS - FAILED_REJECTED - FAILED_EXPIRED - FAILED_CANCELLED - CANCELLED - ERROR - ERROR_GATEWAY 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/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: test@example.org 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 - 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: 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: 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/{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 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 - 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 required: true schema: type: string - example: 1 in: query name: gateway_account_id required: true schema: type: string - description: Set to 'true' to return all events. By default events that do not map to an external state are removed and duplicate events mapping to same external state are reduced to one event. in: query name: include_all_events schema: type: boolean default: false - description: Set to '2' to return failed transaction states FAILED_REJECTED/FAILED_EXPIRED/FAILED_CANCELLED mapped to declined/timedout/cancelled 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 responses: "200": content: application/json; qs=1: schema: $ref: '#/components/schemas/TransactionEventResponse' description: OK "404": description: Not found "422": content: application/json; qs=1: schema: $ref: '#/components/schemas/ErrorResponse' description: Missing required query parameters summary: Get events for transaction external ID tags: - Transactions components: schemas: Address: type: object properties: city: type: string example: London country: type: string example: GB county: type: string example: county line1: type: string example: address line 1 line2: type: string example: address line 2 postcode: type: string example: Ex 8RR AuthorisationSummary: type: object properties: three_d_secure: $ref: '#/components/schemas/ThreeDSecure' CardDetails: type: object properties: billing_address: $ref: '#/components/schemas/Address' card_brand: type: string example: Visa card_type: type: string enum: - CREDIT - DEBIT example: credit cardholder_name: type: string example: J Doe expiry_date: type: string example: 11/43 first_digits_card_number: type: string example: "424242" last_digits_card_number: type: string example: "4242" CommaDelimitedSetParameter: type: object properties: notEmpty: type: boolean parameters: type: array items: type: string rawString: type: string ErrorResponse: type: object properties: error_identifier: type: string enum: - GENERIC - REFUND_NOT_AVAILABLE - REFUND_AMOUNT_AVAILABLE_MISMATCH - ZERO_AMOUNT_NOT_ALLOWED - MOTO_NOT_ALLOWED - CANCEL_CHARGE_FAILURE_DUE_TO_CONFLICTING_TERMINAL_STATE_AT_GATEWAY_CHARGE_STATE_FORCIBLY_TRANSITIONED - CANCEL_CHARGE_FAILURE_DUE_TO_CONFLICTING_TERMINAL_STATE_AT_GATEWAY_INVALID_STATE_TRANSITION - AUTH_TOKEN_INVALID - AUTH_TOKEN_REVOKED - ACCOUNT_NOT_LINKED_WITH_PSP - TELEPHONE_PAYMENT_NOTIFICATIONS_NOT_ALLOWED - AGREEMENT_NOT_FOUND example: GENERIC message: type: array items: type: string example: example error message Event: type: object properties: event_data: type: string example: "{\"live\": false, \"moto\": false, \"amount\": 1000, \"source\"\ : \"CARD_API\", \"language\": \"en\", \"reference\": \"my payment reference\"\ , \"return_url\": \"https://www.payments.service.gov.uk\", \"description\"\ : \"my payment\", \"delayed_capture\": false, \"payment_provider\": \"\ sandbox\", \"gateway_account_id\": \"3\", \"credential_external_id\":\ \ \"ddb294481de146c09598c8cce0461af9\", \"save_payment_instrument_to_agreement\"\ : false}\"" event_date: type: string format: date-time event_type: type: string example: PAYMENT_CREATED live: type: boolean example: true parent_resource_external_id: type: string default: "null" example: l40ajdf0923uojlkfjsldkjfl2 reproject_domain_object: type: boolean default: false example: true resource_external_id: type: string example: 58na2dr7rv7h6h53bef1l0soep resource_type: type: string enum: - agreement - payment - refund - service - card_payment - payout - dispute example: payment service_id: type: string example: ea2d6673b23d4ff7ad88a1fd3c7ab0f6 sqs_message_id: type: string example: fe689579-63af-40bf-a783-23de97134b5f EventTicker: type: object properties: amount: type: integer format: int64 example: 100 card_brand: type: string example: visa event_date: type: string format: date-time event_type: type: string example: PAYMENT_CREATED gateway_account_id: type: string example: "1" payment_provider: type: string example: sandbox resource_external_id: type: string example: 9np5pocnotgkpp029d5kdfau5f resource_type: type: string enum: - agreement - payment - refund - service - card_payment - payout - dispute example: payment transaction_type: type: string example: PAYMENT ExternalTransactionState: type: object properties: code: type: string example: P0030 finished: type: boolean example: true message: type: string example: Payment was cancelled by the user status: type: string example: cancelled GatewayAccountMonthlyPerformanceReportEntity: type: object properties: average_amount: type: number example: 1000.0 gateway_account_id: type: integer format: int64 example: 1 month: type: integer format: int64 example: 3 total_amount: type: number example: 1000 total_volume: type: integer format: int64 example: 1 year: type: integer format: int64 example: 2022 PaginationBuilder: type: object properties: first_page: $ref: '#/components/schemas/PaginationLink' last_page: $ref: '#/components/schemas/PaginationLink' next_page: $ref: '#/components/schemas/PaginationLink' prev_page: $ref: '#/components/schemas/PaginationLink' self: $ref: '#/components/schemas/PaginationLink' PaginationLink: type: object properties: href: type: string example: https://an.example.link PayoutSearchResponse: type: object properties: _links: $ref: '#/components/schemas/PaginationBuilder' count: type: integer format: int64 example: 100 page: type: integer format: int64 example: 1 results: type: array items: $ref: '#/components/schemas/PayoutView' total: type: integer format: int64 example: 1000 PayoutView: type: object properties: amount: type: integer format: int64 description: amount in pence example: 1000 created_date: type: string format: date-time gateway_account_id: type: string example: "1" gateway_payout_id: type: string example: po_sd0fkpam0dlwe10dmlsl3mf live: type: boolean example: true paid_out_date: type: string format: date-time service_id: type: string example: dlsd0dkad20sk0adne9fjd state: type: string enum: - UNDEFINED - IN_TRANSIT - PAID_OUT - FAILED example: "{\"status\":\"paidout\",\"finished\":true}" PerformanceReportEntity: type: object properties: average_amount: type: number example: 1000.0 total_amount: type: number example: 1000 total_volume: type: integer format: int64 example: 1 RefundSummary: type: object properties: amount_available: type: integer format: int64 amount_refunded: type: integer format: int64 amount_submitted: type: integer format: int64 status: type: string example: unavailable user_external_id: type: string SettlementSummary: type: object properties: settled_date: type: string example: 2022-01-26 ThreeDSecure: type: object properties: required: type: boolean description: '`true` if payment requires 3D Secure authentication. ' example: true version: type: string example: 2.1.0 TimeseriesReportSlice: type: object properties: all_payments: type: integer format: int32 example: 10 amount: type: integer format: int32 example: 70 completed_payments: type: integer format: int32 example: 7 errored_payments: type: integer format: int32 example: 3 fee: type: integer format: int32 net_amount: type: integer format: int32 timestamp: type: string format: date-time total_amount: type: integer format: int32 TransactionEvent: type: object properties: amount: type: integer format: int64 example: 1000 data: type: object additionalProperties: type: object event_type: type: string example: CANCELLED_BY_USER resource_type: type: string example: PAYMENT state: $ref: '#/components/schemas/ExternalTransactionState' timestamp: type: string format: date-time TransactionEventResponse: type: object properties: events: type: array items: $ref: '#/components/schemas/TransactionEvent' transaction_id: type: string example: 9np5pocnotgkpp029d5kdfau5f TransactionSearchResponse: type: object properties: _links: $ref: '#/components/schemas/PaginationBuilder' count: type: integer format: int64 page: type: integer format: int64 results: type: array items: $ref: '#/components/schemas/TransactionView' total: type: integer format: int64 TransactionSummaryResult: type: object properties: moto_payments: $ref: '#/components/schemas/TransactionsStatisticsResult' net_income: type: integer format: int64 example: 6000 payments: $ref: '#/components/schemas/TransactionsStatisticsResult' refunds: $ref: '#/components/schemas/TransactionsStatisticsResult' TransactionView: type: object properties: amount: type: integer format: int64 example: 1000 authorisation_summary: $ref: '#/components/schemas/AuthorisationSummary' card_details: $ref: '#/components/schemas/CardDetails' corporate_card_surcharge: type: integer format: int64 example: 0 created_date: type: string format: date-time credential_external_id: type: string example: 7a7a718cb8b0401f8b8f4cdda9804073 delayed_capture: type: boolean description: type: string example: New passport application email: type: string example: citizen@example.org fee: type: integer format: int64 example: 2 gateway_account_id: type: string example: "1" gateway_payout_id: type: string example: po_mdoiu23jkdj1kj23sd gateway_transaction_id: type: string example: fd21-1mdknkls1-2121-csdf language: type: string example: en live: type: boolean metadata: type: object additionalProperties: type: object moto: type: boolean net_amount: type: integer format: int64 example: -2 parent_transaction_id: type: string description: Parent transaction external ID. Available for refunds example: 4dfdhapsdgftgkpp029d5kdfau5f payment_details: $ref: '#/components/schemas/TransactionView' payment_provider: type: string example: sandbox reference: type: string example: payment reference refund_summary: $ref: '#/components/schemas/RefundSummary' refunded_by: type: string description: External ID of the service user that refunded payment. Only available for refunds example: dj8923eihsdih23hkjfe8d refunded_by_user_email: type: string description: Service user email that refunded the payment. Only available for refunds example: test@example.org return_url: type: string example: https://service-name.gov.uk/transactions/12345 service_id: type: string example: baea0585e30d4acbb438524fca82b51e settlement_summary: $ref: '#/components/schemas/SettlementSummary' source: type: string enum: - CARD_API - CARD_PAYMENT_LINK - CARD_AGENT_INITIATED_MOTO - CARD_EXTERNAL_TELEPHONE example: CARD_API state: $ref: '#/components/schemas/ExternalTransactionState' total_amount: type: integer format: int64 example: 1000 transaction_id: type: string example: 9np5pocnotgkpp029d5kdfau5f transaction_type: type: string enum: - PAYMENT - REFUND example: PAYMENT wallet_type: type: string example: APPLE_PAY TransactionsForTransactionResponse: type: object properties: parent_transaction_id: type: string example: 9np5pocnotgkpp029d5kdfau5f transactions: type: array items: $ref: '#/components/schemas/TransactionView' TransactionsStatisticsResult: type: object properties: count: type: integer format: int64 example: 1 gross_amount: type: integer format: int64 example: 2000