I’m not sure about your specific problem, but most likely a server side import is happening at the client as vigorwebsolutions stated. It might be helpful if I share some resources to help you with your overall Stripe integration. I’ve also implemented Stripe integration and this approach has been working for me,
1- In a server folder under your import directory add a file called stripe.js
2- Within that file initiate Stripe and create low level methods, wrap them in a global server side object. Here is an example:
STRIPE = {
customers: {
create({ email, tokenId }) {
// validate the method arguments
check(email, String)
const createCustomerSync = Meteor.wrapAsync(stripe.customers.create, stripe.customers);
if (tokenId !== undefined) {
check(tokenId, String);
return createCustomerSync({ email,
source: tokenId,
});
}
// Use Meteor wrapAsync to convert async method to sync and bind the context,
return createCustomerSync({ email });
},
}
To initiate stripe, make sure you make use of the Meteor settings file
const stripe = connectToStripe(Meteor.settings.private.stripe);
You can have a file for development to hold your testing keys and another one for production.
3- Create a validated Meteor method and use that method to call the Server side Stripe object.
export const createCustomer = new ValidatedMethod({
name: 'createCustomer',
validate: new SimpleSchema({
email: {
type: String,
},
token: {
type: Object,
blackbox: true,
optional: true,
},
}).validator(),
run({ email, token }) {
// Some validation here
// then call server method
if (Meteor.isServer) {
// do some validation, check if there're duplicates etc..
let stripeCust = {};
const tokenId = (token !== undefined ? token.id : undefined);
try { stripeCust = STRIPE.customers.create({ email, tokenId }); } catch (e) {
throw RemoteErr('customers.createCustomer.stripe',
'stripe retrieveByEmail exception', e);
}
// update the DB and do more stuff
}
return customerDocId;
},
});
Not sure if that’s the best practice but I hope it helps. I’d also suggest taking a look at the Meteor Chef tutorials, they’re amazing: