Integrating stripe

Hi, i’m trying to build a monthly subscription app and i found that i can use Stripe. I’m trying to use this tutorials
(https://angularfirebase.com/lessons/collect-payments-with-angular-stripe-checkout-and-firebase/
https://angularfirebase.com/lessons/angular-stripe-payments-part-2-firebase-cloud-functions-backend/)
and at some point i need to declare var StripeCheckout:any; in typings.d.ts. Can some explain what is typings.d.ts and how i can solve this issue?
(if i try to do it without it’s just going to say Cannot find name ‘StripeCheckout’.)

this.handler = StripeCheckout.configure({
      key: environment.stripeKey,
      locale: 'auto',
      token: token => {
        this.paymentSvc.processPayment(token, this.amount)
      }
    })

Thanks!

My guess is that u actually need to declare that var in the file of component where it is used (outside class definition)

Essentially Typescript needs to know what type of variable it is loading. For packages that don’t have explicit typing, adding StripeCheckout: any will type it as any and will let you use any method/variable with it. Just be careful with typos on those methods and variables.

More here: https://angular.io/guide/typescript-configuration

1 Like