SudoSOS Back-end API / stripe / StripeService
Class: StripeService ​
Extends ​
Constructors ​
Constructor ​
ts
new StripeService(manager?): StripeService;Parameters ​
| Parameter | Type |
|---|---|
manager? | EntityManager |
Returns ​
StripeService
Overrides ​
Properties ​
| Property | Modifier | Type | Inherited from |
|---|---|---|---|
manager | protected | EntityManager | WithManager.manager |
Methods ​
constructWebhookEvent() ​
ts
constructWebhookEvent(body, signature): Promise<Event>;Validate a Stripe webhook event
Parameters ​
| Parameter | Type | Description |
|---|---|---|
body | any | - |
signature | string | string[] | - |
Returns ​
Promise<Event>
createNewPaymentIntentStatus() ​
ts
createNewPaymentIntentStatus(paymentIntentId, state): Promise<StripePaymentIntentStatus>;Create a new deposit status
Parameters ​
| Parameter | Type | Description |
|---|---|---|
paymentIntentId | number | - |
state | StripePaymentIntentState | - |
Returns ​
Promise<StripePaymentIntentStatus>
createStripePaymentIntent() ​
ts
createStripePaymentIntent(user, amount): Promise<{
clientSecret: string;
deposit: StripeDeposit;
}>;Create a payment intent and save it to the database
Parameters ​
| Parameter | Type | Description |
|---|---|---|
user | User | User that wants to deposit some money into their account |
amount | Dinero | The amount to be deposited |
Returns ​
Promise<{ clientSecret: string; deposit: StripeDeposit; }>
The created deposit entity and the Stripe client secret
getPaymentIntent() ​
ts
getPaymentIntent(stripeId): Promise<StripePaymentIntent>;Get a payment intent with the given ID, if it exists
Parameters ​
| Parameter | Type | Description |
|---|---|---|
stripeId | string | - |
Returns ​
Promise<StripePaymentIntent>
handleWebhookEvent() ​
ts
handleWebhookEvent(event): Promise<void>;Handle the event by making the appropriate database additions
Parameters ​
| Parameter | Type | Description |
|---|---|---|
event | Event | {Stripe.Event} Event received from Stripe webhook |
Returns ​
Promise<void>
asStripeDepositResponse() ​
ts
static asStripeDepositResponse(deposit): StripeDepositResponse;Parameters ​
| Parameter | Type |
|---|---|
deposit | StripeDeposit |
Returns ​
getProcessingStripeDepositsFromUser() ​
ts
static getProcessingStripeDepositsFromUser(userId): Promise<StripeDeposit[]>;Parameters ​
| Parameter | Type |
|---|---|
userId | number |
Returns ​
Promise<StripeDeposit[]>
getStripeDeposit() ​
ts
static getStripeDeposit(id, relations?): Promise<StripeDeposit>;Parameters ​
| Parameter | Type | Default value |
|---|---|---|
id | number | undefined |
relations | string[] | [] |
Returns ​
Promise<StripeDeposit>
validateStripeRequestMaximumAmount() ​
ts
static validateStripeRequestMaximumAmount(balance, request): boolean;Topup should be at most 150 euros minus user's positive balance or user's negative balance.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
balance | BalanceResponse | - |
request | StripeRequest | - |
Returns ​
boolean
validateStripeRequestMinimumAmount() ​
ts
static validateStripeRequestMinimumAmount(balance, request): boolean;Topup should be at least 10 euros or the user's negative balance.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
balance | BalanceResponse | - |
request | StripeRequest | - |
Returns ​
boolean