golevelup / nestjs

A collection of badass modules and utilities to help you level up your NestJS applications 🚀
MIT License
2.16k stars 244 forks source link

golevelup/nestjs-stripe: project can not compile #730

Open TropicalPunch opened 3 months ago

TropicalPunch commented 3 months ago

Hi, i've been triyng to use this tutorial to connect my project to stripe. for some reason i keep gettig this error when running the server in local host: **" Nest can't resolve dependencies of the DiscoveryService (?, MetadataScanner). Please make sure that the argument ModulesContainer at index [0] is available in the DiscoveryModule context. Potential solutions:

     import { DynamicModule, Module, Provider } from '@nestjs/common';
import { ConfigModule,ConfigService } from '@nestjs/config';
import {
  StripeModule
} from '@golevelup/nestjs-stripe';
import { PaymentService } from './payment.service';
import { PaymentController } from './payment.controller';
import { Stripe } from 'stripe';

@Module({
  imports:[StripeModule.forRootAsync(StripeModule, {
    imports: [ConfigModule],
    useFactory: (configService: ConfigService) =>
      configService.get('stripe'),
    inject: [ConfigService],
  }),],
  controllers: [PaymentController],
  providers: [PaymentService]
})
export class PaymentModule {}

**app module**
@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      load: [config] 
    }),
     ...
     ....
    PaymentModule
  ],
  controllers: [AppController],
  providers: [
    AppService...
    ],
})

config structure:

export const config =  () => ({
...
    stripe: {
        apiKey: process.env.STRIPE_API_KEY,
        webhookConfig: {
          requestBodyProperty: 'rawBody',
          stripeSecrets: {
                account: process.env.STRIPE_WEBHOOK_SECRET
            }
        }
    }
});