StripeService injection error
gregoiregentil opened this issue · 3 comments
With both version 14 and 16, I get the same bug as #99
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(HomePageModule)[StripeService -> StripeService -> StripeService]:
NullInjectorError: No provider for StripeService!
NullInjectorError: R3InjectorError(HomePageModule)[StripeService -> StripeService -> StripeService]:
NullInjectorError: No provider for StripeService!
at NullInjector.get (core.mjs:8853:27)
at R3Injector.get (core.mjs:9292:33)
at R3Injector.get (core.mjs:9292:33)
at R3Injector.get (core.mjs:9292:33)
at ChainedInjector.get (core.mjs:13981:36)
at lookupTokenUsingModuleInjector (core.mjs:4484:39)
at getOrCreateInjectable (core.mjs:4532:12)
at Module.ɵɵdirectiveInject (core.mjs:11764:19)
at NodeInjectorFactory.IdentityComponent_Factory [as factory] (identity.component.ts:10:31)
at getNodeInjectable (core.mjs:4738:44)
at resolvePromise (zone.js:1193:31)
at resolvePromise (zone.js:1147:17)
at zone.js:1260:17
at _ZoneDelegate.invokeTask (zone.js:402:31)
at core.mjs:10715:55
at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:10715:36)
at _ZoneDelegate.invokeTask (zone.js:401:60)
at Object.onInvokeTask (core.mjs:11028:33)
at _ZoneDelegate.invokeTask (zone.js:401:60)
at Zone.runTask (zone.js:173:47)
My code is:
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { StripeService } from 'ngx-stripe';@component({
selector: 'ngstr-identity',
templateUrl: './identity.component.html'
})export class IdentityComponent {
constructor(private httpClient: HttpClient, private stripeService: StripeService) {}
verify() {
this.httpClient.post("identity.json", "", {
headers:{"content-type": "application/x-www-form-urlencoded"}
}).subscribe((response) => {
return this.stripeService.verifyIdentity(response["ephemeral_key_secret"]);
}, (error) => {
alert(error);
});
}}
Am I doing something wrong or is there still a problem in ngx-stripe?
Hi @gregoiregentil, are importing NgxStripeModule
in your application?
I apologize, I gave up on that road. I used directly the stripe.js in my page.
I realized that standalone components works passing the custom [stripe]
reference input from injectStripe()
because that wasn't clear in the documentation tho.
I had to add NgxStripeModule.forRoot()
to my lazy loaded module because I got No provider for _StripeFactoryService!
without it 🤔