2017-09-25 2 views
1

私はアプリケーション用にStripeを設定する方法を理解しようとしていましたが、モジュールの実装に問題があります。通常、モジュールを使用しているときは、ファイルの先頭にそれを使用できるようにする必要がありますが、私がpaymentCtrlファイルでそれを行うと、うまく動作せず、次の2つのエラーが発生します:どこで宣言する必要がありますか私はそれを使用できるようにするために?まあ、あなたは私がこれについては非常に新しいので、支払いが働くようにこれを構造化する方法を理解したいと思います。コントローラでモジュールエラーが発生する

エラー:

require is not defined at paymentCtrl.js:1

Failed to instantiate module paymentController due to: Error: [$injector:nomod] Module 'paymentController' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

paymentCtrl:

var stripe = require('stripe')('sk_test_....'); 

angular.module('paymentController', []) 


.controller('paymentCtrl', function($scope) { 


}); 

app.js:

+0

角度アプリケーションで 'require'を使用しようとしていますか?私はあなたがサーバー側でそれを行う必要があると思います – rkm

答えて

0
angular.module('userApp', ['appRoutes', 'userControllers', 'userServices', 'ngAnimate', 'mainController', 'authServices', 'managementController', 'paymentController']) 

.config(function($httpProvider) { 
    $httpProvider.interceptors.push('AuthInterceptors'); 
}); 

StripeのNode.js libraryは、サーバー側のコードで使用するためのものです。あなたはあなたの秘密のAPIキーを明らかにするので、クライアント側のコードに埋め込むべきではありません。

クライアント側のコードでは、CheckoutまたはElementsを使用して支払い情報を収集してトークン化できます。

関連する問題