marceloamadeu
marceloamadeu

Reputation: 39

How to work with stripe.js in an Ionic/Angular application

I am working on an app (ionic/angular) and now need to include payment via credit card using Stripe.

After much research on the internet I decided to use Stripe.js (https://stripe.com/docs/stripe-js).

In the index.html of the project, I made the inclusion of Stripe.js and it looks like this:

<body>
  <app-root></app-root>
  <script src="https://js.stripe.com/v3/"></script>
</body>
</html>

How do I now import Stripe into app/app.module.ts to use Stripe on another page (Example: in pages/payment/payment.page.ts)?

Upvotes: 2

Views: 1188

Answers (2)

joker
joker

Reputation: 51

no need to import in app/app.module.ts,

in pages/payment/payment.page.ts;u need declare let Stripe

Upvotes: 3

Dmitry Grinko
Dmitry Grinko

Reputation: 15232

You can use npm install ngx-stripe

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { NgxStripeModule } from 'ngx-stripe';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxStripeModule.forRoot('***your-stripe-publishable key***'),
    LibraryModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Read more

Upvotes: 4

Related Questions