Git Product home page Git Product logo

stripe-meteor's Introduction

A Meteor package containing Stripe scripts:

Install

Using Meteor's Package System:

$ meteor add mrgalaxy:stripe

Usage

Client

In order for Stripe.js to be loaded directly on iOS and Android a new rule needs to be created in your mobile-config.js located in the root of your project. Create the new file if it doesn't already exist and insert the line below.

App.accessRule('https://*.stripe.com/*');

In order to allow the Stripe variable to be accessible it must be loaded in the Meteor.startup. This will ensure that calls are deferred until after your Meteor app has started.

Meteor.startup(function() {
    Stripe.setPublishableKey('YOUR_PUBLISHABLE_KEY');
});

The same goes for Stripe Checkout, too:

Meteor.startup(function() {
    var handler = StripeCheckout.configure({
		key: 'YOUR_PUBLISHABLE_KEY',
		token: function(token) {}
	});
});

In order to remain PCI compliant under the new DSS 3.0 rules, never send credit card details to the server. Use client-side credit card details to create a secure token, per this example:

ccNum = $('#ccnum').val();
cvc = $('#cvc').val();
expMo = $('#exp-month').val();
expYr = $('#exp-year').val();

Stripe.card.createToken({
	number: ccNum,
	cvc: cvc,
	exp_month: expMo,
	exp_year: expYr,
}, function(status, response) {
	stripeToken = response.id;
	Meteor.call('chargeCard', stripeToken);
});

See the Stripe docs (https://stripe.com/docs/stripe.js, https://stripe.com/docs/checkout) for all the API specifics.

Server

Meteor.methods({
  'chargeCard': function(stripeToken) {
    var Stripe = StripeAPI('SECRET_KEY');

    Stripe.charges.create({
      amount: 1000,
      currency: 'usd',
      source: stripeToken
    }, function(err, charge) {
      console.log(err, charge);
    });
  }
});

For a complete reference, please see the original: https://github.com/stripe/stripe-node

stripe-meteor's People

Contributors

adambrodzinski avatar dandv avatar dangilkerson avatar lirbank avatar mjhea0 avatar rbwsam avatar slavik0329 avatar tejas-manohar avatar tyler-johnson avatar wesleyfsmith avatar wiserweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stripe-meteor's Issues

Not working with meteor 0.6.1

Hello,

Recently tried running this with meteor 0.6.1 but I keep getting this error:

TypeError: Object # has no method 'require'
at app/packages/stripe/stripe_server.js:3:34
at /Users/joe/kingpin/.meteor/local/build/server/server.js:286:12
at Array.forEach (native)
at Function..each..forEach (/Users/joe/.meteorite/meteors/meteor/meteor/1dfc7171f237a029cca74cbf25024acbf6ed5b75/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
at run (/Users/joe/kingpin/.meteor/local/build/server/server.js:227:7)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

Is anyone else getting this or is this user error?

cordova problem with external stripe js

For this to work in recent cordova versions you need to add to mobile-config.js

App.accessRule("https://*.stripe.com/*")

readme should be extended I guess.

it's saying StripeAPI isn't defined

W202302-11:56:28.593(-7)? (STDERR) /Users/jamesgillmore/.meteorite/meteors/meteor/meteor/bb6c88ca9e3409ce4d50b796123c62cfb8fc71fd/dev_bundle/lib/node_modules/fibers/future.js:173
W202302-11:56:28.755(-7)? (STDERR) throw(ex);
W202302-11:56:28.755(-7)? (STDERR) ^
W202302-11:56:28.756(-7)? (STDERR) ReferenceError: StripeAPI is not defined
W202302-11:56:28.756(-7)? (STDERR) at app/server/main.js:1:49

do I need to do something with futures or something?

Cannot read property key of undefined

I'm using the latest Stripe meteorite package and trying to do a simple Stripe Checkout implementation. However, I keep getting "Uncaught TypeError: Cannot read property 'key' of undefined". It seems like StripeCheckout isn't defined even though I can inspect it in Chrome Dev Tools. Here's the gist.

Stripe not an object

When I try to subscribe user with payments, it says Stripe is not an object. I'm guessing it's because it's before Meteor.startup is ready - how do I do this correctly?

Template.subscribe.events({
    "click button.purchase": function(event, template){

        $(template).find('status').text("You've purchased the dataset, thank you!");

        ccNum = $('#ccnum').val();
        cvc = $('#cvc').val();
        expMo = $('#exp-month').val();
        expYr = $('#exp-year').val();

        Stripe.card.createToken({
            number: ccNum,
            cvc: cvc,
            exp_month: expMo,
            exp_year: expYr,
        }, function(status, response) {
            stripeToken = response.id;
            Meteor.call('chargeCard', stripeToken);
        });

        Meteor.call('addSubscription', Meteor.userId(), ['subscribed'], function() {
            console.log(Meteor.user().username + ' is now subscribed');
        });

    }
});

Meteor code can't exist in callbacks provided to Stripe, and Fiber doesn't exist?

The callbacks I'm providing can't use Meteor code. Other people on stackoverflow are wrapping such code in Fibers, but Fiber isn't defined for me and I can't seem to be able to get it defined, i.e. with npm install fibers or require statements and whatnot.

What's the typical solution here. Basically stripe is useless if you can't take the data passed to the callback and do things like store it back in your Mongo customer objects for example.

stripe.subscriptions undefined?

Hi there,

I'm trying to create a new subscription, but stripe.subscriptions.create() results in this error:

TypeError: Cannot read property 'create' of undefined

What's that? Everything else what I did with stripe worked so far.

Greetings
Mat

Issue calling StripeAPI

Hello -

Thanks for putting this package together. I've been trying to use this within meteorite on the server side but continue to get this error when I call StripeAPI:

Exception while invoking method 'processStripePayment' ReferenceError: StripeAPI is not defined

I can clearly see the stripe_server.js file in the build directory.

I have a suspicion that meteorite is not installing the npm package correctly because if I call Npm.require('stripe') in my app code it says it cannot find that package. Have you run across this problem before? Any advice?

meteor add stripe not working anymore

I think you should update information about how to add the package in meteor now its meteor add mrgalaxy:stripe and no meteor add stripe since that package do not exist

Support for Managed Accounts

I am working on integrating stripe using Stripe Connect and Managed Accounts but your package does not seem to support this functionality. Is there any chance you can update this package to the newest version of the node-stripe package to gain access to this functionality?

I am currently attempting to call:

Stripe.accounts.create(payload, cb);

But I am getting:

Cannot call method 'create' of undefined

pointing to that line in the code.
I am using https://stripe.com/docs/api#account_object as a reference for integration.

Thanks

Updates -

The node-stripe has recently added some new functionality. Is there any way you could update this package. Thanks

WrapAsync exported functions

It would be nice if we could directly use the functions from this lib in a meteoric way, i.e. var charge = Stripe.charges.create()

0.8.1.3 Compatibility

I'm on an older project with meteor 0.8.1.3. Does this Stripe package have compatibility with this older meteor version. If not natively, can I use mrt add ...@... syntax to install this in a compatible state?

Uncaught TypeError: Cannot read property 'setPublishableKey' of undefined

Trying to figure out exactly why I'm getting this error. Here's what I have at the moment.

  1. Repo cloned into packages/stripe
  2. meteor list returns -- mrgalaxy:stripe 1.5.6 Stripe.js and Node-Stripe brought to Meteor.

When I tried to run 'meteor add stripe', I received 'stripe: no such package', so I added it the way it said on Atmosphere. (meteor add mrgalaxy:stripe). It looks like the JS file is loaded in the browser (<script type="text/javascript" src="/packages/mrgalaxy_stripe.js?e39957bab19924c96cdceccf75e296366a134590"></script>) when I inspect it, but I'm still getting this error, which leads me to believe I'm not including the package correctly. Any thoughts? If you need any additional debugging information from me, I'd be happy to provide it. Thanks for all your work.

ReferenceError: Stripe is not defined

Hi,

I'm getting this error in the server console on startup.
ReferenceError: Stripe is not defined
at both/startup.js:2:3

Code snippet
Meteor.startup(function() { Stripe.setPublishableKey('pk_test_etc'); // stripe test account });

Any ideas why this isn't working please? I've tried that code in both 'server' and 'both' folders in my Meteor project.

Many thanks,
Richard.

createRefund with meteor.wrapAsync issue?

I've tried to do the usual pattern for meteor.wrapAsync with charges.createRefund and its giving me issues.

var createRefund = Meteor.wrapAsync(StripeAPI.charges.createRefund.bind(StripeAPI.charges);

var result = createRefund(chargeId);

Spits out a very weird error message: "Cannot use 'in' operator to search for 'message' in illegal access" whenever I try to invoke createRefund.

When I do....

StripeAPI.charges.createRefund(chargeId, function(err, results) {
        if(err) {
            throw new Meteor.Error('stripe-error', err);
        } else {
            fut.return(results);
        }
    });

It works, but without the advantages of wrapAsync.

Any Ideas?

Uncaught ReferenceError: Stripe is not defined

This error is getting thrown in my client code according to Kadira. I can't reproduce it from a desktop browser and it only seems to happen on Android. The culprit is my Stripe.publishableKey = function... inside of Meteor.startup. Are you aware of any issues with Meteor not properly waiting for the package to be loaded before running the startup function?

resource: net::ERR_BLOCKED_BY_CLIENT on payment clicked

I don't know why I'm getting these errors. The payment works though (I'm in test mode). I'm only asking because this is payment related, else I would not bothered as long as it worked.

This is what I see in console

Payment button clicked
https://q.stripe.com/?event=checkout.outer.open&rf=http%3A%2F%2Flocalhost%3…tinct_id=54c691b1-1760-7355-d2f4-7c92acc53ceb&h=720&w=1280&i=1435143509158 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
https://api.mixpanel.com/track/?ip=1&img=1&data=eyJldmVudCI6ImNoZWNrb3V0Lm9…wib3B0aW9uLXN1cHBvcnRzVG9rZW5DYWxsYmFjayI6ZmFsc2UsImgiOjcyMCwidyI6MTI4MH19 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
https://q.stripe.com/?event=checkout.open&rf=http%3A%2F%2Flocalhost%3A3000%…-supportsTokenCallback=false&h=720&w=1280&lsid=DNT&cid=DNT&i=1435143510164 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
https://api.mixpanel.com/track/?ip=1&img=1&data=eyJldmVudCI6ImNoZWNrb3V0LmN…9wdGlvbi1zdXBwb3J0c1Rva2VuQ2FsbGJhY2siOmZhbHNlLCJoIjo3MjAsInciOjEyODB9fQ== Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
https://q.stripe.com/?event=checkout.close&rf=http%3A%2F%2Flocalhost%3A3000…-supportsTokenCallback=false&h=720&w=1280&lsid=DNT&cid=DNT&i=1435143513716 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT

This is my eventmap

event.preventDefault();

console.log('Payment button clicked');

var self = this; //get the data context/ template
var currency = 'inr';

// * 100 because this is in cents/paise; * 0.1 because only 10% advance needs to be taken
var advance = self.priceEstimate * 100 * 0.1;

StripeCheckout.open({
  key: 'pk_test_nc8D3LA65cujo3z00LaBgr9x',

  token      : function (token) {
    stripeToken = token.id;
    console.info(token);
    Meteor.call('chargeCard', stripeToken, advance, currency);
  },
  //amount: 5000, // this is equivalent to $50
  amount     : advance, // this is equivalent to $50
  name       : 'Appskart',
  description: event.currentTarget //button
    .parentElement //div text-right
    .parentElement //li element
    .childNodes[1] //h4 element (has app name)
    .innerText // the app name
  ,
  panelLabel : 'Pay Advance',
  currency   : currency
});

This is the relevant part of my template:

  <a class="payment-button">Pay Advance</a>

TypeError when used with another package

In the Package.onUse function, I specified both

api.use('mrgalaxy:stripe');
api.imply('mrgalaxy:stripe');

And both have the following error printed to the terminal:

TypeError: Object #<Object> has no method 'require' 
at Package (packages/mrgalaxy:stripe/stripe_server.js:3)

I am not sure what this is stemming from as I am testing in a freshly created app and package.

To reproduce, create a new package and a new app... link the package to the app, and then specify the api.use or imply call with this package name in the newly created package.

I notice this is not an issue when added directly to the app via the standard meteor add mrgalaxy:stripe

Stripe Running on All Pages

Currently when stripe is installed as a package it is loaded on all pages for the site.

Is there a way to manually set which pages stripe is loaded on?

It is causing 400 ms of extra latency per page load.

Stripe is not defined

I am still getting error like following in the client side.

even in the developer console, when typing Stripe is not working after the page wholely loaded.

undefined charge result on client

Hi there,
I have tried your example of charging but getting no results on the client:
Meteor.call('chargeCard', stripeToken);
I'm only getting undefined returns no matter what I do: returning directly from the chargeCard method, using a function(err, res) on calling chargeCard or wrapping the stripe.charge function call into Meteor.wrapAsync()
So I haven't find any way to find out what happens on the server when calling chargeCard.
Where are my mistakes and what to do?

Documentation Change: Using the Stripe API on a Meteor Server

I'd like to suggest updating the readme. It currently states that an asynchronous function can be run on the server. This isn't the case and requires Meteor.wrapAsync. See my SO question:
http://stackoverflow.com/questions/26226583/meteor-proper-use-of-meteor-wrapasync-on-server

I suggest changing the usage documentation to:
//client
Stripe.setPublishableKey('YOUR_PUBLISHABLE_KEY');

Meteor.call('stripeCreateUser', options, function(err, result) {
//do something
console.log(err, result);
});

//server
var Stripe = StripeAPI('your_secret_key');

Meteor.methods({
stripeCreateUser: function(options) {
// get a sync version of our API async func
var stripeCustomersCreateSync=Meteor.wrapAsync(Stripe.customers.create,Stripe.customers);
// call the sync version of our API func with the parameters from the method call
var result=stripeCustomersCreateSync({
description: 'Woot! A new customer!',
card: options.card,
plan: options.plan
});
// do whatever you want with the result
return result;
}
});

EDIT - just realized that all the formatting was omitted after submitting.... gross

Sample Project?

Hi. Wondering if you could publish a simple sample project, distinguishing the html, Client and Server code?

Would be much appreciated.

Stripe Transfers

Hey!

This is a great package but I don't believe you support stripe transfers. I have tried to implement them but they do not work. Any thoughts or advice is appreciated.

-Kris

not compatible with react-stripe-elements

Just creating an issue so maybe it may help people not wasting time like I did.

This package is not compatible with react-stripe-elements despite correct configuration, the stripe.js served is different from the one retrieved via <script src="https://js.stripe.com/v3/"></script>.

Error thrown is : Cannot read property 'elements' of undefined

Configuration is correctly made in Meteor.startup for client side:

Meteor.startup(() =>
{
	Stripe.setPublishableKey(Meteor.settings.public.stripe);
	render(<App />, document.getElementById('app'));
});

Stripe object is available and functions are working, but cannot add Element*s from react-stripe-elements.

I checked Redux related issue but even with redux-less app same error is thrown so Troubleshooting described here is not relevant. Plus it is working fine inside Redux connect()ed component when loading Stripe via script tag.

Note : same problem encountered with npm install stripe but npm's stripe is clearly indicated for server side use whereas this package claims to be compatible with cliend side use.

Slow load times

I am experiencing nearly a second load times waiting for the checkout.js.map to load from Stripe. This is fine on the page where I do my purchase, but I would prefer to not have the script loaded on all other pages to improve their load times.

Is there anyway to have the package insert the script into the html head only on pages of your choosing?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.