Skip to content

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 ​

ts
new PaymentRequestController(options): PaymentRequestController;

Parameters ​

ParameterType
optionsBaseControllerOptions

Returns ​

PaymentRequestController

Overrides ​

BaseController.constructor

Properties ​

PropertyModifierTypeDescriptionInherited from
roleManagerprotectedRoleManagerA reference to the role manager passed in the base controller options.BaseController.roleManager
specificationpublicSwaggerSpecificationA reference to the swagger specification passed in the base controller options.BaseController.specification

Methods ​

cancelPaymentRequest() ​

ts
cancelPaymentRequest(req, res): Promise<void>;

POST /payment-requests/{id}/cancel

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The cancelled payment request

Operation Id ​

cancelPaymentRequest

Tags ​

paymentRequests - Operations of the payment-request controller

Security ​

JWT


configureLogger() ​

ts
protected configureLogger(logger): void;

Parameters ​

ParameterType
loggerLogger

Returns ​

void

Inherited from ​

BaseController.configureLogger


createPaymentRequest() ​

ts
createPaymentRequest(req, res): Promise<void>;

POST /payment-requests

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The created payment request

Operation Id ​

createPaymentRequest

Tags ​

paymentRequests - Operations of the payment-request controller

Security ​

JWT


getPolicy() ​

ts
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 ​

Policy

The policy of this controller.

Overrides ​

BaseController.getPolicy


getRouter() ​

ts
getRouter(): Router;

Returns ​

Router

the router used by this controller.

Inherited from ​

BaseController.getRouter


markFulfilledExternally() ​

ts
markFulfilledExternally(req, res): Promise<void>;

POST /payment-requests/{id}/mark-fulfilled

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The marked-paid payment request

Operation Id ​

markPaymentRequestFulfilledExternally

Tags ​

paymentRequests - Operations of the payment-request controller

Security ​

JWT


returnAllPaymentRequests() ​

ts
returnAllPaymentRequests(req, res): Promise<void>;

GET /payment-requests

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - All existing payment requests

Operation Id ​

getAllPaymentRequests

Tags ​

paymentRequests - Operations of the payment-request controller

Security ​

JWT


returnSinglePaymentRequest() ​

ts
returnSinglePaymentRequest(req, res): Promise<void>;

GET /payment-requests/

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - Single payment request

Operation Id ​

getSinglePaymentRequest

Tags ​

paymentRequests - Operations of the payment-request controller

Security ​

JWT


startPaymentAuthenticated() ​

ts
startPaymentAuthenticated(req, res): Promise<void>;

POST /payment-requests/{id}/start

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - Stripe client secret

Operation Id ​

startPaymentRequestAuthenticated

Tags ​

paymentRequests - Operations of the payment-request controller

Security ​

JWT


getRelation() ​

ts
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 ​

ParameterType
reqRequestWithToken

Returns ​

Promise<string>


loadPaymentRequest() ​

ts
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 ​

ParameterType
reqRequestWithToken & object

Returns ​

Promise<PaymentRequest>