2016-10-25 12 views
0

Stripe.card.createToken()私はバックエンドに使用するトークンを生成しようとしています。しかし、私はAngularとTypeScriptを使用しているので、すべて一緒にうまく一緒に再生する必要があります。私は現在angular-stripestripe.d.tsを使用していますので、TypeScriptとAngularが動作します。これは私が何をしようとしていますどのような現在ですが、それは動作しません:ストライプ、角度、およびタイプスクリプトが一緒に動作しない

namespace app.Areas.Subscription { 
    export class StripePaymentController { 
     CreditCard: string; 
     Expiry: Array<string>; 
     CVC: string; 

     stripe: StripeStatic; 
     card: StripeTokenData; 

     Subscribe() { 
      this.card = { 
       number: this.CreditCard, 
       exp_month: Number(this.Expiry["month"]), 
       exp_year: Number(this.Expiry["year"]), 
       cvc: this.CVC 
      }; 

      this.stripe.createToken(this.card, this.stripeResponseHandler); 
     } 

     stripeResponseHandler() { 
      console.log("Handled"); 
     } 

    } 
    app.controller("StripePaymentController", StripePaymentController); 
} 

私はこれをしようとすると、それは私に語った:

TypeError: Cannot read property 'createToken' of undefined

私はthis.stripeを検査するとき、それはundefined言います。私はStripeStaticインターフェースを初期化していないので、これは可能でしょうか?もしそうなら、どうすればいいですか?なぜ私はこれが動作していないのか分かりません。ありがとう。

答えて

0

ああ、私は完全に異なったものを試したかったので(TypeScriptはいつもうまく働いていないので)this.stripe.createToken()Stripe.createToken()に変更しました。明らかにStripeのタイプはStripeStaticで、今は正常に動作しています。男、ここに投稿して2分後:(

関連する問題