@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.
- CancelSubscriptionOptions
- CardInfo
- CompletePaymentSetupOptions
- CompletePaymentSetupResponse
- CreateCustomerOptions
- CreateNewPaymentSetupOptions
- CreateNewPaymentSetupResponse
- CreateNewSubscriptionOptions
- CreateNewSubscriptionResponse
- GetSubscriptionResponse
- StripeConfiguration
- SubscriptionResponse
- UpdateSubscriptionOptions
- ValidateWebhookEventOptions
- cancelSubscription
- completePaymentSetup
- createCustomer
- createNewPaymentSetup
- createNewSubscription
- getPrice
- getStripeConfiguration
- getSubscription
- tryGetPrice
- updateSubscription
- validateWebhookEvent
Ƭ StripeMode: "LIVE" | "TEST"
Stripe mode for the API client.
▸ 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.
| Name | Type | Description |
|---|---|---|
options |
CancelSubscriptionOptions |
Options for canceling an existing Stripe subscription. |
Promise<SubscriptionResponse>
Updated Stripe subscription.
▸ 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.
| Name | Type | Description |
|---|---|---|
options |
CompletePaymentSetupOptions |
Options for completing a new Stripe payment setup. |
Promise<CompletePaymentSetupResponse>
Parameters describing the result of a completed Stripe payment setup.
▸ createCustomer(options): Promise<Stripe.Customer>
Creates a new Stripe customer.
| Name | Type | Description |
|---|---|---|
options |
CreateCustomerOptions |
Options for creating a new customer. |
Promise<Stripe.Customer>
New Stripe customer.
▸ 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.
| Name | Type | Description |
|---|---|---|
options |
CreateNewPaymentSetupOptions |
Options for creating a new Stripe payment setup. |
Promise<CreateNewPaymentSetupResponse>
Parameters describing the newly created Stripe payment setup including the payment intent.
▸ 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.
| Name | Type | Description |
|---|---|---|
options |
CreateNewSubscriptionOptions |
Options for creating a new Stripe subscription. |
Promise<CreateNewSubscriptionResponse>
Parameters describing the newly created Stripe subscription including the payment intent.
▸ 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.
| Name | Type | Description |
|---|---|---|
lookupKey |
string |
Lookup key expected to be associated with a Stripe price. This is the LetsGo plan ID. |
Promise<Stripe.Price>
The Stripe price with the specified lookup key.
▸ 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.
| Name | Type |
|---|---|
mode? |
StripeMode |
▸ getSubscription(subscriptionId): Promise<GetSubscriptionResponse | undefined>
Returns a Stripe subscription with the specified ID or undefined if it cannot be found.
| Name | Type | Description |
|---|---|---|
subscriptionId |
string |
Stripe subscription Id. |
Promise<GetSubscriptionResponse | undefined>
Select parameters of a Stripe subscription with the specified ID or undefined if it cannot be found.
▸ 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.
| Name | Type | Description |
|---|---|---|
lookupKey |
string |
Lookup key expected to be associated with a Stripe price. This is the LetsGo plan ID. |
Promise<Stripe.Price | undefined>
The Stripe price with the specified lookup key or undefined if not found.
▸ updateSubscription(options): Promise<SubscriptionResponse>
Changes the Stripe price associated with an existing Stripe subscription.
| Name | Type | Description |
|---|---|---|
options |
UpdateSubscriptionOptions |
Options for updating an existing Stripe subscription. |
Promise<SubscriptionResponse>
Updated Stripe subscription.
▸ validateWebhookEvent(options): Promise<Stripe.Event>
Validates signature of the incoming webhook event. Returns the event if the signature is valid or throws an error.
| Name | Type | Description |
|---|---|---|
options |
ValidateWebhookEventOptions |
Options for validating the webhook event. |
Promise<Stripe.Event>
Validated Stripe event.