• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GEWIS / sudosos-backend / 26087122199

19 May 2026 08:59AM UTC coverage: 87.545% (-0.2%) from 87.783%
26087122199

Pull #896

github

web-flow
Merge e22f245d2 into 9dd74ee61
Pull Request #896: Add PaymentRequest service layer

4007 of 4670 branches covered (85.8%)

Branch coverage included in aggregate %.

260 of 384 new or added lines in 4 files covered. (67.71%)

2 existing lines in 1 file now uncovered.

20579 of 23414 relevant lines covered (87.89%)

835.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/controller/response/payment-request-response.ts
NEW
1
/**
×
2
 *  SudoSOS back-end API service.
3
 *  Copyright (C) 2026 Study association GEWIS
4
 *
5
 *  This program is free software: you can redistribute it and/or modify
6
 *  it under the terms of the GNU Affero General Public License as published
7
 *  by the Free Software Foundation, either version 3 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU Affero General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU Affero General Public License
16
 *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 *
18
 *  @license
NEW
19
 */
×
20

NEW
21
/**
×
22
 * This is the module page of the payment-request-response.
23
 *
24
 * @module stripe/payment-request
NEW
25
 */
×
26

27
import BaseResponseWithoutId from './base-response-without-id';
28
import { BaseUserResponse } from './user-response';
29
import { DineroObjectResponse } from './dinero-response';
30
import { PaginationResult } from '../../helpers/pagination';
31
import { PaymentRequestStatus } from '../../entity/payment-request/payment-request-status';
32

33
/**
34
 * PaymentRequest is UUID-keyed. To avoid overloading the `id` slot (which on
35
 * other responses is the numeric DB id), the UUID is exposed under a
36
 * semantically named field, mirroring how `QRAuthenticator` exposes its UUID
37
 * as `sessionId`. The response therefore extends `BaseResponseWithoutId`
38
 * (timestamps + version, no `id`) and declares a `uuid` of its own.
39
 *
40
 * @typedef {object} BasePaymentRequestResponse
41
 * @property {string} uuid.required - UUID v4 identifier (also the public share-link id).
42
 * @property {string} createdAt - ISO-8601 creation timestamp.
43
 * @property {string} updatedAt - ISO-8601 last update timestamp.
44
 * @property {integer} version - Optimistic-locking version.
45
 * @property {BaseUserResponse} for.required - The user whose balance will be credited on payment.
46
 * @property {BaseUserResponse} createdBy.required - The user that issued this request.
47
 * @property {DineroObjectResponse} amount.required - Fixed, immutable amount.
48
 * @property {string} expiresAt.required - ISO-8601 timestamp after which payments stop being accepted.
49
 * @property {string} paidAt - ISO-8601 timestamp the request was marked paid (null if not paid).
50
 * @property {string} cancelledAt - ISO-8601 timestamp the request was cancelled (null if not cancelled).
51
 * @property {BaseUserResponse} cancelledBy - The user that cancelled the request (null if not cancelled).
52
 * @property {BaseUserResponse} fulfilledBy - The admin that marked the request paid out-of-band (null for Stripe-settled or unpaid requests).
53
 * @property {string} description - Optional human-readable description.
54
 * @property {string} status.required - enum:PENDING,PAID,EXPIRED,CANCELLED - Derived lifecycle status.
55
 */
56
export interface BasePaymentRequestResponse extends BaseResponseWithoutId {
57
  uuid: string;
58
  for: BaseUserResponse;
59
  createdBy: BaseUserResponse;
60
  amount: DineroObjectResponse;
61
  expiresAt: string;
62
  paidAt: string | null;
63
  cancelledAt: string | null;
64
  cancelledBy: BaseUserResponse | null;
65
  fulfilledBy: BaseUserResponse | null;
66
  description: string | null;
67
  status: PaymentRequestStatus;
68
}
69

70
/**
71
 * Minimal response returned to unauthenticated callers of the public share
72
 * link endpoint. It deliberately omits `createdBy`, `cancelledBy`, and other
73
 * internal audit fields — anyone with the link can see it, so we leak as
74
 * little user info as possible.
75
 *
76
 * @typedef {object} PublicPaymentRequestResponse
77
 * @property {string} uuid.required - UUID v4 identifier.
78
 * @property {string} forDisplayName.required - Recipient display name (e.g. "John D.").
79
 * @property {DineroObjectResponse} amount.required - Fixed amount to be paid.
80
 * @property {string} expiresAt.required - ISO-8601 timestamp after which payments stop being accepted.
81
 * @property {string} description - Optional human-readable description.
82
 * @property {string} status.required - enum:PENDING,PAID,EXPIRED,CANCELLED - Derived lifecycle status.
83
 */
84
export interface PublicPaymentRequestResponse {
85
  uuid: string;
86
  forDisplayName: string;
87
  amount: DineroObjectResponse;
88
  expiresAt: string;
89
  description: string | null;
90
  status: PaymentRequestStatus;
91
}
92

93
/**
94
 * Response returned from the "start payment" endpoint. Contains just enough
95
 * to let the browser redirect into the Stripe Payment Element.
96
 *
97
 * @typedef {object} PaymentRequestStartResponse
98
 * @property {string} paymentRequestId.required - The PaymentRequest id the intent is linked to.
99
 * @property {string} stripeId.required - Stripe payment intent id.
100
 * @property {string} clientSecret.required - Stripe client secret for the intent.
101
 */
102
export interface PaymentRequestStartResponse {
103
  paymentRequestId: string;
104
  stripeId: string;
105
  clientSecret: string;
106
}
107

NEW
108
/**
×
109
 * @typedef {object} PaginatedBasePaymentRequestResponse
110
 * @property {PaginationResult} _pagination.required - Pagination metadata
111
 * @property {Array<BasePaymentRequestResponse>} records.required - Returned payment requests
NEW
112
 */
×
113
export interface PaginatedBasePaymentRequestResponse {
114
  _pagination: PaginationResult;
115
  records: BasePaymentRequestResponse[];
NEW
116
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc