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

GEWIS / sudosos-backend / 26086501742

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

Pull #896

github

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

4008 of 4671 branches covered (85.81%)

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.73 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 keyed by UUID, not integer id, so it extends
35
 * `BaseResponseWithoutId` (no id field) and declares its own `id: string`.
36
 *
37
 * @typedef {object} BasePaymentRequestResponse
38
 * @property {string} id.required - UUID v4 identifier (also the public share-link id).
39
 * @property {string} createdAt - ISO-8601 creation timestamp.
40
 * @property {string} updatedAt - ISO-8601 last update timestamp.
41
 * @property {integer} version - Optimistic-locking version.
42
 * @property {BaseUserResponse} for.required - The user whose balance will be credited on payment.
43
 * @property {BaseUserResponse} createdBy.required - The user that issued this request.
44
 * @property {DineroObjectResponse} amount.required - Fixed, immutable amount.
45
 * @property {string} expiresAt.required - ISO-8601 timestamp after which payments stop being accepted.
46
 * @property {string} paidAt - ISO-8601 timestamp the request was marked paid (null if not paid).
47
 * @property {string} cancelledAt - ISO-8601 timestamp the request was cancelled (null if not cancelled).
48
 * @property {BaseUserResponse} cancelledBy - The user that cancelled the request (null if not cancelled).
49
 * @property {BaseUserResponse} fulfilledBy - The admin that marked the request paid out-of-band (null for Stripe-settled or unpaid requests).
50
 * @property {string} description - Optional human-readable description.
51
 * @property {string} status.required - enum:PENDING,PAID,EXPIRED,CANCELLED - Derived lifecycle status.
52
 */
53
export interface BasePaymentRequestResponse extends BaseResponseWithoutId {
54
  id: string;
55
  for: BaseUserResponse;
56
  createdBy: BaseUserResponse;
57
  amount: DineroObjectResponse;
58
  expiresAt: string;
59
  paidAt: string | null;
60
  cancelledAt: string | null;
61
  cancelledBy: BaseUserResponse | null;
62
  fulfilledBy: BaseUserResponse | null;
63
  description: string | null;
64
  status: PaymentRequestStatus;
65
}
66

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

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

NEW
105
/**
×
106
 * @typedef {object} PaginatedBasePaymentRequestResponse
107
 * @property {PaginationResult} _pagination.required - Pagination metadata
108
 * @property {Array<BasePaymentRequestResponse>} records.required - Returned payment requests
NEW
109
 */
×
110
export interface PaginatedBasePaymentRequestResponse {
111
  _pagination: PaginationResult;
112
  records: BasePaymentRequestResponse[];
NEW
113
}
×
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