Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mean-Sean Stack. #7

Closed
countrdd opened this issue Feb 18, 2015 · 18 comments
Closed

Mean-Sean Stack. #7

countrdd opened this issue Feb 18, 2015 · 18 comments

Comments

@countrdd
Copy link

I am using the sean-generator, I keep getting:

Error: [$injector:modulerr] Failed to instantiate module angular-stripe due to:
TypeError: Cannot read property 'setPublishableKey' of undefined
at new module.exports (http://localhost/lib/angular-stripe/release/angular-stripe.js:18:34)

I am not just learning angular can someone explain how I can fix this.. with that platform. Would be greatley appreciated.

@bendrucker
Copy link
Owner

I really need to see code here since that error doesn't tell me anything. Happy to help here but I'm going to go ahead and close this since it's not an angular-stripe issue.

@countrdd
Copy link
Author

Thanks - I am muddling thru it it, kinda of...

I am just not sure how to set the published key,

@countrdd
Copy link
Author

I can give you access to my repo.

From: Ben Drucker <notifications@github.commailto:notifications@github.com>
Reply-To: bendrucker/angular-stripe <reply@reply.github.commailto:reply@reply.github.com>
Date: Wednesday, February 18, 2015 at 7:18 AM
To: bendrucker/angular-stripe <angular-stripe@noreply.github.commailto:angular-stripe@noreply.github.com>
Cc: Dusty Countryman <countrdd@leillc.netmailto:countrdd@leillc.net>
Subject: Re: [angular-stripe] Mean-Sean Stack. (#7)

Closed #7#7.

Reply to this email directly or view it on GitHubhttps://github.com//issues/7#event-237613309.

@bendrucker
Copy link
Owner

If it's on GH I'm willing to spend a few minutes helping you diagnose this. Do whatever you need to do and let's keep the discussion in this thread.

@countrdd
Copy link
Author

It is on BitBucket...is that still ok?

From: Ben Drucker <notifications@github.commailto:notifications@github.com>
Reply-To: bendrucker/angular-stripe <reply@reply.github.commailto:reply@reply.github.com>
Date: Wednesday, February 18, 2015 at 7:39 AM
To: bendrucker/angular-stripe <angular-stripe@noreply.github.commailto:angular-stripe@noreply.github.com>
Cc: Dusty Countryman <countrdd@leillc.netmailto:countrdd@leillc.net>
Subject: Re: [angular-stripe] Mean-Sean Stack. (#7)

If it's on GH I'm willing to spend a few minutes helping you diagnose this. Do whatever you need to do and let's keep the discussion in this thread.

Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-74857444.

@bendrucker
Copy link
Owner

I don't maintain an account there. If you can post code here I can help.

@countrdd
Copy link
Author

This is probably the easiest explanation - this is the boilerplate I used....https://github.com/meanjs/mean

I was adding angular-stripe into the applicationModuleVendorDependencies of the config.js
I think that is the problem, because I did not know where or how to set the key.

From: Ben Drucker <notifications@github.commailto:notifications@github.com>
Reply-To: bendrucker/angular-stripe <reply@reply.github.commailto:reply@reply.github.com>
Date: Wednesday, February 18, 2015 at 7:43 AM
To: bendrucker/angular-stripe <angular-stripe@noreply.github.commailto:angular-stripe@noreply.github.com>
Cc: Dusty Countryman <countrdd@leillc.netmailto:countrdd@leillc.net>
Subject: Re: [angular-stripe] Mean-Sean Stack. (#7)

I don't maintain an account there. If you can post code here I can help.

Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-74857814.

@bendrucker
Copy link
Owner

Sorry but I don't have time to dissect someone's enormous boilerplate project. You inject stripeProvider and call stripeProvider.setPublishableKey. Not sure what else to tell you.

@countrdd
Copy link
Author

Thanks ben!

From: Ben Drucker <notifications@github.commailto:notifications@github.com>
Reply-To: bendrucker/angular-stripe <reply@reply.github.commailto:reply@reply.github.com>
Date: Wednesday, February 18, 2015 at 9:09 AM
To: bendrucker/angular-stripe <angular-stripe@noreply.github.commailto:angular-stripe@noreply.github.com>
Cc: Dusty Countryman <countrdd@leillc.netmailto:countrdd@leillc.net>
Subject: Re: [angular-stripe] Mean-Sean Stack. (#7)

Sorry but I don't have time to dissect someone's enormous boilerplate project. You inject stripeProvider and call stripeProvider.setPublishableKey. Not sure what else to tell you.

Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-74868873.

@countrdd
Copy link
Author

Ben. Sorry to keep bugging you, guesing I am misunderstanding the module.

is it possible to do this from this module or is it limted to the helper functions at the end of the readme.

stripe.customers.list({ limit: 3 }, function(err, customers) {
// asynchronously called
});

@bendrucker
Copy link
Owner

This is a wrapper against Stripe.js which is strictly intended for tokenizing cards and bank accounts so they don't touch your server.

You're trying to call Stripe's API for application data. While you could theoretically use stripe-node via Browserify, this isn't something you should be trying to do. In order to do what you want, you'd have let the browser have access to your Stripe secret key which opens up a number of easy attack vectors for someone to get full access to your account.

@countrdd
Copy link
Author

OK. Gotcha. Thanks for the explanation.

I was getting confused...

So this I just want to submit the information to stripe, grab the token returned and then send it to my restfull api server to store the token for future billing, and then on the rest side is where I Would want to implement the stripe.js to actually talk to stripe...
Correct?

Thanks for the education.....I sometimes have a hard time wrapping my head around this stuff!

@bendrucker
Copy link
Owner

on the rest side is where I Would want to implement the stripe.js to actually talk to stripe

Exactly. Your client's job is to use angular-stripe to turn cards / bank accounts into tokens. Then you make charges, add customers, list customers, etc. on your server.

@benjamincharity
Copy link

Hey @bendrucker, I'm getting the same error mentioned at the beginning of this thread.

Uncaught Error: [$injector:modulerr] Failed to instantiate module clientApp due to:
Error: [$injector:modulerr] Failed to instantiate module angular-stripe due to:
TypeError: Cannot read property 'setPublishableKey' of undefined at new module.exports (http://localhost:9000/bower_components/angular-stripe/release/angular-stripe.js:18:34)

My app.js looks like this (edited for space):

angular.module('clientApp', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ui.router',
  'ngStorage',
  'angular-stripe'
])

.config(function($urlRouterProvider, $locationProvider, stripeProvider) {

  //
  // UI Router
  $urlRouterProvider.otherwise('/');
  $locationProvider.html5Mode(true);

  //
  // Stripe
  stripeProvider.setPublishableKey('my_key_was_here');
})

// etc...

I also tried setting the key in a controller when that didn't work:

angular.module('clientApp')
.controller('RegisterCtrl', function($scope, stripe) {
  'use strict';

  //
  // Stripe
  //stripe.setPublishableKey('pk_test_4KOAFDT9AawsCcEBxS2GdLYJ');

// etc...

I know your original response indicated that this is not an issue with the library, but I was hoping you could point me in the correct direction since the OP didn't post how he solved it. Thanks

@bendrucker
Copy link
Owner

@benjamincharity Sounds a lot like Stripe is not defined — you need to make sure to include Stripe.js before loading angular-stripe. I can put a more descriptive warning in if we can confirm that's your issue.

@benjamincharity
Copy link

Spot on @bendrucker. Grunt was apparently choking during the concat/compile phase because of the non-local resource and was just blowing away the Stripe library.

Thanks for pointing my ship in the correct direction!

@maxmalynowsky
Copy link

@bendrucker It's not explicitly obvious to include Stripe.js before loading angular-stripe. Can you update the readme to make this very obvious?

Example:

<script src="https://js.stripe.com/v2/"></script>
<script src="libs/angular/angular.js"></script>
<script src="libs/angular-stripe/release/angular-stripe.js"></script>

@bendrucker
Copy link
Owner

angular-stripe expects Stripe.js to be available as window.Stripe

I think that's adequate. If you can think of a clearer way to phrase that I'd welcome a PR. I won't use an example that makes use of code since it assumes you're loading your scripts via tags and I don't want to encourage that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants