我正在开发一个应用程序(ionic/angular
),现在需要包括通过信用卡使用Stripe
付款。
在对互联网进行了大量研究之后,我决定使用Stripe.js
(https://stripe.com/docs/stripe-js)。
在该项目的index.html
中,我添加了Stripe.js
,看起来如下所示:
<body>
<app-root></app-root>
<script src="https://js.stripe.com/v3/"></script>
</body>
</html>
现在如何将Stripe导入app/app.module.ts
以在另一个页面上使用Stripe
(例如:在pages/payment/payment.page.ts
中)?
发布于 2019-04-26 20:22:03
您可以使用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 { }
发布于 2019-04-26 20:25:06
不需要导入app/app.module.ts
,
在pages/payment/payment.page.ts
中;您需要declare let Stripe
https://stackoverflow.com/questions/55877152
复制相似问题