richnologies / ngx-stripe

Angular 6+ wrapper for StripeJS
MIT License
219 stars 77 forks source link

Cannot read property 'elements' of undefined #48

Closed ebgtestdotnet closed 4 years ago

ebgtestdotnet commented 5 years ago

Getting below error when write same code as example TypeError: Cannot read property 'elements' of undefined at StripeService.elements (http://localhost:8100/build/vendor.js:99663:28) at SwitchMapSubscriber.project (http://localhost:8100/build/vendor.js:99827:48) at SwitchMapSubscriber._next (http://localhost:8100/build/vendor.js:141243:27) at SwitchMapSubscriber.Subscriber.next (http://localhost:8100/build/vendor.js:38848:18) at CombineLatestSubscriber.notifyNext (http://localhost:8100/build/vendor.js:141035:34) at InnerSubscriber._next (http://localhost:8100/build/vendor.js:136619:21) at InnerSubscriber.Subscriber.next (http://localhost:8100/build/vendor.js:38848:18) at BehaviorSubject._subscribe (http://localhost:8100/build/vendor.js:140722:24) at BehaviorSubject.Observable._trySubscribe (http://localhost:8100/build/vendor.js:26619:25) at BehaviorSubject.Subject._trySubscribe (http://localhost:8100/build/vendor.js:41826:51) Ionic Framework: 3.9.2 Ionic App Scripts: 3.2.0 Angular Core: 5.2.9 Angular Compiler CLI: 5.2.9 Node: 6.10.3 OS Platform: Windows 7 Navigator Platform: Win32 User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36

360disrupt commented 5 years ago

This is probably the same issue as: https://github.com/richnologies/ngx-stripe/issues/40

alexisAvenel commented 5 years ago

Hello,

Same error ! Up plz

ProtocolNebula commented 5 years ago

I had the same issue and fixed adding the "forRoot()" to AppComponent->imports and exports: I still not tested with ng build.

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
  //   ....,
    NgxStripeModule.forRoot(environment.stripePublisableKey),
  ],
  exports: [
    NgxStripeModule,
  ],
})
export class AppModule { }

And the import into the module that manage stripe.

I hope for a better solution (I don't like to import into appModule). Maybe with StripeFactoryService works fine.

dlsemwal commented 5 years ago

This issue is coming due to wrong publishable key while you testing your code or you trying to use features of ngx-stripe in your application. create an account in ngx-stripe and get publishable key and put it onto module..

@NgModule({ declarations: [ AppComponent, ], imports: [ // ...., NgxStripeModule.forRoot(stripePublisableKey), ], exports: [ NgxStripeModule, ], }) export class AppModule { }

richnologies commented 4 years ago

I will close this now due to inactivity. Sorry for this library to be abandon for such a long time. A new version of the library has been published that should address this issue. Please give it a try. If the problem persists, please fell free to open it again. The new commitment of the team is to answer in less than a week.

saascharge commented 4 years ago

Hello, is there any workaround for legacy version (using Angular 7)?