带角度2的条纹结帐

时间:2017-03-15 12:04:28

标签: angular typescript stripe-payments

我试图在我的Angular 2网络应用程序中使用Stripe Checkout。一切正常,直到我在收到卡片令牌后尝试调用createOrder函数。

错误是:EXCEPTION:this.createOrder不是函数

我收到令牌后如何调用createOrder函数?

openCheckout() {
let handler = (<any>window).StripeCheckout.configure({
  key: 'pk_test_OtZkFKLIU1WBuonz6xbk6UQB',
  locale: 'no',
  token: function (token: any) {
    this.createOrder(token, this.cart); //THIS IS WHERE THE ERROR OCCURS
  }
});

handler.open({
  name: 'Test Store',
  description: 'Test Description',
  amount: this.cart.totalAmount,
  currency: 'nok',
  email: 'test@test.no',
  image: '../../assets/images/test.png',
  ['allow-remember-me']: false
});

this.globalListener = this.renderer.listenGlobal('window', 'popstate', () => {
  handler.close();
});
}

createOrder(token, cart) {
this.ordersService.createOrder(token, this.cart).subscribe(
  res => {
    console.log(res);
  }, err => {
    console.log(err);
  });
}

0 个答案:

没有答案