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

Cannot use my app offline if using this package #12

Open
sferoze opened this issue May 4, 2017 · 1 comment
Open

Cannot use my app offline if using this package #12

sferoze opened this issue May 4, 2017 · 1 comment

Comments

@sferoze
Copy link

sferoze commented May 4, 2017

I have an app that uses this package but my app is also supposed to work offline.

With this package added, if you try to load your app offline, this package will prevent your app from loading.

Can we please fix this so if Meteor.status().connected is true then only will the package try and communicate with stripe servers?

@sferoze
Copy link
Author

sferoze commented May 4, 2017

Something like this fixes the issue. This code is from plans-stripe-client.js

Meteor.startup(function () {
  let initStripeService = () => {
    // If Stripe public key is configured in the Meteor settings JSON file
    if (Meteor.settings && Meteor.settings.public.Stripe && Meteor.settings.public.Stripe.publicKey) {

      // Configure Stripe Checkout
      // StripeCheckout is an object that is defined in the mrgalaxy:stripe package.
      // It simply exposes Stripe's checkout API documented here:
      // https://stripe.com/docs/checkout
      stripeCheckout = StripeCheckout.configure({
        key: Meteor.settings.public.Stripe.publicKey,
        // whether to put the 'remember me' checkbox on stripe form
        allowRememberMe: Meteor.settings.public.Stripe.rememberMe || false,
        token: function(token) {
          // Call the server-side function 'AppPlans/add' to create
          // a customer through the Stripe API, based on the token that resulted from
          // the payment form success.
          var options = _.extend(checkoutAddOptions || {}, {service: 'stripe', token: token.id, email: token.email});
          AppPlans.add(checkoutPlanName, options, function (error, result) {
            result = result && {added: result, email: token.email};
            addPlanCallback(error, result);
          });
        }
      });

    } // END if
  } // END initStripeService function
  hasRan = false
  Tracker.autorun((c) => {
    if (Meteor.status().connected) {
      if (!hasRan) {
        hasRan = true;
        c.stop();
        initStripeService()
      }
    }

    return Meteor.status().connected;
  });

}); // END Meteor.startup

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

1 participant