SudoSOS Back-end API / stripe/payment-request / PaymentRequestController
Class: PaymentRequestController ​
The BaseController class is responsible for:
- Storing route definitions.
- Generating router objects based on the policy.
Extends ​
Constructors ​
Constructor ​
new PaymentRequestController(options): PaymentRequestController;Parameters ​
| Parameter | Type |
|---|---|
options | BaseControllerOptions |
Returns ​
PaymentRequestController
Overrides ​
Properties ​
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
roleManager | protected | RoleManager | A reference to the role manager passed in the base controller options. | BaseController.roleManager |
specification | public | SwaggerSpecification | A reference to the swagger specification passed in the base controller options. | BaseController.specification |
Methods ​
cancelPaymentRequest() ​
cancelPaymentRequest(req, res): Promise<void>;POST /payment-requests/{id}/cancel
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The cancelled payment request
Operation Id ​
cancelPaymentRequest
Tags ​
paymentRequests - Operations of the payment-request controller
Security ​
JWT
configureLogger() ​
protected configureLogger(logger): void;Parameters ​
| Parameter | Type |
|---|---|
logger | Logger |
Returns ​
void
Inherited from ​
BaseController.configureLogger
createPaymentRequest() ​
createPaymentRequest(req, res): Promise<void>;POST /payment-requests
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The created payment request
Operation Id ​
createPaymentRequest
Tags ​
paymentRequests - Operations of the payment-request controller
Security ​
JWT
getPolicy() ​
getPolicy(): Policy;Gets the policy defined by child classes. This policy includes all routes that the controller accepts, the authorization middleware, and the final handler function for every route.
Returns ​
The policy of this controller.
Overrides ​
getRouter() ​
getRouter(): Router;Returns ​
Router
the router used by this controller.
Inherited from ​
markFulfilledExternally() ​
markFulfilledExternally(req, res): Promise<void>;POST /payment-requests/{id}/mark-fulfilled
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The marked-paid payment request
Operation Id ​
markPaymentRequestFulfilledExternally
Tags ​
paymentRequests - Operations of the payment-request controller
Security ​
JWT
returnAllPaymentRequests() ​
returnAllPaymentRequests(req, res): Promise<void>;GET /payment-requests
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - All existing payment requests
Operation Id ​
getAllPaymentRequests
Tags ​
paymentRequests - Operations of the payment-request controller
Security ​
JWT
returnSinglePaymentRequest() ​
returnSinglePaymentRequest(req, res): Promise<void>;GET /payment-requests/
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - Single payment request
Operation Id ​
getSinglePaymentRequest
Tags ​
paymentRequests - Operations of the payment-request controller
Security ​
JWT
startPaymentAuthenticated() ​
startPaymentAuthenticated(req, res): Promise<void>;POST /payment-requests/{id}/start
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - Stripe client secret
Operation Id ​
startPaymentRequestAuthenticated
Tags ​
paymentRequests - Operations of the payment-request controller
Security ​
JWT
getRelation() ​
static getRelation(req): Promise<string>;Determine "own" vs "all" for RBAC. Creation takes the forId from the body; state transitions look up the request by id and compare against the caller. The lookup is cached on req via loadPaymentRequest so the subsequent handler does not re-query.
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
Returns ​
Promise<string>
loadPaymentRequest() ​
static loadPaymentRequest(req): Promise<PaymentRequest>;Load the PaymentRequest for the current /:id request, caching on req so the policy + handler together only hit the DB once.
The full relation set (for, createdBy, cancelledBy, fulfilledBy) is loaded so that handlers can serialize the response directly from the cached entity without re-querying.
Returns null when there is no :id param or the request doesn't exist.
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken & object |
Returns ​
Promise<PaymentRequest>