Skip to content

SudoSOS Back-end API / stripe / StripeWebhookService

Class: StripeWebhookService ​

Extends ​

Constructors ​

Constructor ​

ts
new StripeWebhookService(manager?): StripeWebhookService;

Parameters ​

ParameterType
manager?EntityManager

Returns ​

StripeWebhookService

Overrides ​

WithManager.constructor

Properties ​

PropertyModifierTypeInherited from
managerprotectedEntityManagerWithManager.manager

Methods ​

configureLogger() ​

ts
protected configureLogger(logger): void;

Parameters ​

ParameterType
loggerLogger

Returns ​

void

Inherited from ​

WithManager.configureLogger


constructWebhookEvent() ​

ts
constructWebhookEvent(body, signature): Promise<Event>;

Validate a Stripe webhook event

Parameters ​

ParameterTypeDescription
bodyany-
signaturestring | string[]-

Returns ​

Promise<Event>


createNewPaymentIntentStatus() ​

ts
createNewPaymentIntentStatus(paymentIntentId, state): Promise<StripePaymentIntentStatus>;

Append a new status to a StripePaymentIntent and, when the new state is terminal, run the side effects for whatever the intent is linked to. On SUCCEEDED this settles the deposit (and marks any linked PaymentRequest as paid) or finalises the terminal payment; on CANCELLED it propagates a Stripe-initiated cancellation to a linked terminal payment.

Rejects when the intent does not exist, when the status already exists, or when it would conflict with a mutually exclusive terminal state already present (SUCCEEDED/FAILED/CANCELLED).

Parameters ​

ParameterTypeDescription
paymentIntentIdnumberThe local (database) ID of the payment intent.
stateStripePaymentIntentStateThe new state to record.

Returns ​

Promise<StripePaymentIntentStatus>

The persisted StripePaymentIntentStatus.


handleWebhookEvent() ​

ts
handleWebhookEvent(event): Promise<void>;

Handle the event by making the appropriate database additions

Parameters ​

ParameterTypeDescription
eventEvent{Stripe.Event} Event received from Stripe webhook

Returns ​

Promise<void>