Skip to content

Latest commit

 

History

History
326 lines (191 loc) · 9.96 KB

README.md

File metadata and controls

326 lines (191 loc) · 9.96 KB

@letsgo/stripe

@letsgo/stripe

This package consolidates all interactions between LetsGo and Stripe APIs. It provides facility functions specific to the LetsGo use cases which wrap relevant Stripe API calls.

Table of contents

Interfaces

Type Aliases

Functions

Type Aliases

StripeMode

Ƭ StripeMode: "LIVE" | "TEST"

Stripe mode for the API client.

Defined in

index.ts:20

Functions

cancelSubscription

cancelSubscription(options): Promise<SubscriptionResponse>

Cancels an existing Stipe subscription. The subscription will be canceled at the end of the current billing period, and no refunds will be issued.

Parameters

Name Type Description
options CancelSubscriptionOptions Options for canceling an existing Stripe subscription.

Returns

Promise<SubscriptionResponse>

Updated Stripe subscription.

Defined in

index.ts:497


completePaymentSetup

completePaymentSetup(options): Promise<CompletePaymentSetupResponse>

Completes an update of a payment method for a Stripe subscription. If the update was successful, the new payment method is stored as the default payment method for the customer and the subscription.

Parameters

Name Type Description
options CompletePaymentSetupOptions Options for completing a new Stripe payment setup.

Returns

Promise<CompletePaymentSetupResponse>

Parameters describing the result of a completed Stripe payment setup.

Defined in

index.ts:405


createCustomer

createCustomer(options): Promise<Stripe.Customer>

Creates a new Stripe customer.

Parameters

Name Type Description
options CreateCustomerOptions Options for creating a new customer.

Returns

Promise<Stripe.Customer>

New Stripe customer.

Defined in

index.ts:157


createNewPaymentSetup

createNewPaymentSetup(options): Promise<CreateNewPaymentSetupResponse>

Creates a new Stripe payment setup to update a customer's payment method and returns a a client secret representing the Stripe payment intent. This allows the caller to continue the processing the payment method update for in the front-end.

Parameters

Name Type Description
options CreateNewPaymentSetupOptions Options for creating a new Stripe payment setup.

Returns

Promise<CreateNewPaymentSetupResponse>

Parameters describing the newly created Stripe payment setup including the payment intent.

Defined in

index.ts:338


createNewSubscription

createNewSubscription(options): Promise<CreateNewSubscriptionResponse>

Creates a new Stripe subscription and returns a a client secret representing the Stripe payment intent. This allows the caller to continue the processing the payment for the subscription in the front-end.

Parameters

Name Type Description
options CreateNewSubscriptionOptions Options for creating a new Stripe subscription.

Returns

Promise<CreateNewSubscriptionResponse>

Parameters describing the newly created Stripe subscription including the payment intent.

Defined in

index.ts:276


getPrice

getPrice(lookupKey): Promise<Stripe.Price>

Returns a Stripe price associated with the provided lookup key or throws an exception if none can be found. The lookup key is the LetsGo plan ID.

Parameters

Name Type Description
lookupKey string Lookup key expected to be associated with a Stripe price. This is the LetsGo plan ID.

Returns

Promise<Stripe.Price>

The Stripe price with the specified lookup key.

Defined in

index.ts:195


getStripeConfiguration

getStripeConfiguration(mode?): StripeConfiguration

Determine the Stripe configuration based on the environment variables. If the mode parameter is not specified, the mode is selected using the value of the LETSGO_STRIPE_LIVE_MODE environment variable. Based on the mode, the configuration will use environment variables specific to the live or test mode to determine the public, secret, and webhook keys for Stripe.

Parameters

Name Type
mode? StripeMode

Returns

StripeConfiguration

Defined in

index.ts:46


getSubscription

getSubscription(subscriptionId): Promise<GetSubscriptionResponse | undefined>

Returns a Stripe subscription with the specified ID or undefined if it cannot be found.

Parameters

Name Type Description
subscriptionId string Stripe subscription Id.

Returns

Promise<GetSubscriptionResponse | undefined>

Select parameters of a Stripe subscription with the specified ID or undefined if it cannot be found.

Defined in

index.ts:532


tryGetPrice

tryGetPrice(lookupKey): Promise<Stripe.Price | undefined>

Tries to locate a Stripe price using the provided lookup key. The lookup key is the LetsGo plan ID.

Parameters

Name Type Description
lookupKey string Lookup key expected to be associated with a Stripe price. This is the LetsGo plan ID.

Returns

Promise<Stripe.Price | undefined>

The Stripe price with the specified lookup key or undefined if not found.

Defined in

index.ts:178


updateSubscription

updateSubscription(options): Promise<SubscriptionResponse>

Changes the Stripe price associated with an existing Stripe subscription.

Parameters

Name Type Description
options UpdateSubscriptionOptions Options for updating an existing Stripe subscription.

Returns

Promise<SubscriptionResponse>

Updated Stripe subscription.

Defined in

index.ts:456


validateWebhookEvent

validateWebhookEvent(options): Promise<Stripe.Event>

Validates signature of the incoming webhook event. Returns the event if the signature is valid or throws an error.

Parameters

Name Type Description
options ValidateWebhookEventOptions Options for validating the webhook event.

Returns

Promise<Stripe.Event>

Validated Stripe event.

Defined in

index.ts:116