I'm currently facing an issue while trying to integrate the GoLevelUp stripe package into my NestJs project. Although I can successfully import the package into my global app module, I'm struggling to inject a functional client into the designated controller.
(https://github.com/golevelup/nestjs/tree/master/packages/stripe) (https://www.npmjs.com/package/@golevelup/nestjs-stripe) (https://www.npmjs.com/package/@nestjs/core)
redacted.controller.ts:
import { InjectStripeClient } from '@golevelup/nestjs-stripe';
import Stripe from 'stripe';
@Controller('[REDACTED]')
export class MyAwesomeController {
constructor(
@InjectStripeClient() stripeClient: Stripe, //this line crashes
private readonly myService: MyCoolService
) { }
}
app.module.ts:
import { StripeModule } from '@golevelup/nestjs-stripe';
import { OtherModules } from 'where/ever';
@Module({
imports: [
ModuleA,
ModuleB,
...,
StripeModule.forRoot(StripeModule,
{
apiKey: 'PC_LOAD_KEY',
webhookConfig: {
// stripeWebhookSecret: 'PC_LOAD_SECRET'
//TODO -- same deal w/ config
stripeWebhookSecret: 'SHHHH',
},
}),
MoreModulues,
...,
],
controllers: [AppController, ControllerB, ControllerC, ...],
providers: [AppService, ServiceB, ServiceC, ...]
}
The given code snippet is unable to build, showing the following error message:
Nest can't resolve dependencies of the [REDACTED]Controller (?, [REDACTED]Service). Please make sure that the argument Symbol(STRIPE_CLIENT_TOKEN) at index [0] is available in the [REDACTED]Module context.
Potential solutions:
- If Symbol(STRIPE_CLIENT_TOKEN) is a provider, is it part of the current [REDACTED]Module?
- If Symbol(STRIPE_CLIENT_TOKEN) is exported from a separate @Module, is that module imported within [REDACTED]Module?
@Module({
imports: [ /* the Module containing Symbol(STRIPE_CLIENT_TOKEN) */ ]
It is essential for me to instantiate a working stripe client to interact with the stripe API. Without this functionality, the package is essentially unusable. I lack the expertise to properly configure this setup and prevent it from crashing.
I have delved into the golevelup package to pinpoint the "STRIPE_CLIENT_TOKEN" causing the issue.
Here are the relevant files within the package: https://github.com/golevelup/nestjs/tree/master/packages/stripe/src/stripe.constants.ts https://github.com/golevelup/nestjs/tree/master/packages/stripe/src/stripe.decorators.ts https://github.com/golevelup/nestjs/tree/master/packages/stripe/src/stripe.module.ts
I have also examined the official stripe package for insights on configuring the missing tokens. Currently, I find myself stuck and in need of guidance or a functional example. Otherwise, I may resort to implementing it myself using Stripe™ primitives.