tyler-johnson / stripe-meteor

A Meteor package containing Stripe.js, Node-Stripe, and Stripe Checkout.
https://atmospherejs.com/mrgalaxy/stripe
150 stars 44 forks source link

Stripe not an object #34

Open livvyjeffs opened 9 years ago

livvyjeffs commented 9 years ago

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');
        });

    }
});
livvyjeffs commented 9 years ago

Also, can you explain how to make the "payment" button? Traditionally it's with:

<form><script .... /script></form>

but I tried that with Meteor and your package installed and it didn't work (I wasn't quite expecting it to), help on how to hook up the button and payment forms?