Hi,
I’m using meteor, ionic and angular.
I add: meteor add mrgalaxy:stripe
And also: meteor npm install stripe --save
And some code.
import { Stripe } from 'stripe';
Meteor.startup(function() {
const stripeKey = require('stripe')(Meteor.settings.public.stripe.testPublishableKey);
Stripe.setPublishableKey(stripeKey);
});
But i have a message: “Promise returned from setPublishableKey is ignored.” for Stripe.setPublishableKey()
Help, please.
Two possible solutions:
import { Stripe } from 'stripe';
import { Promise } from 'meteor/promise';
Meteor.startup(function() {
const stripeKey = require('stripe')(Meteor.settings.public.stripe.testPublishableKey);
Promise.await(Stripe.setPublishableKey(stripeKey));
});
or
import { Stripe } from 'stripe';
Meteor.startup(async function() {
const stripeKey = require('stripe')(Meteor.settings.public.stripe.testPublishableKey);
await Stripe.setPublishableKey(stripeKey);
});
1 Like
Hi Robfallows,
Thanks for your reply.
The first example seems not to work for me because i have a message “Cannot find module meteor/promise”
I tried “meteor add promise” but that does not solve the issue.
Also I have another error message "Cannot find name ‘require’ "
And i tried to start the app with the second version of code but there are a lot of issues:
W20180327-11:15:58.290(4)? (STDERR) Note: you are using a pure-JavaScript implementation of bcrypt.
W20180327-11:15:58.342(4)? (STDERR) While this implementation will work correctly, it is known to be
W20180327-11:15:58.343(4)? (STDERR) approximately three times slower than the native implementation.
W20180327-11:15:58.343(4)? (STDERR) In order to use the native implementation instead, run
W20180327-11:15:58.343(4)? (STDERR)
W20180327-11:15:58.344(4)? (STDERR) meteor npm install --save bcrypt
W20180327-11:15:58.344(4)? (STDERR)
W20180327-11:15:58.344(4)? (STDERR) in the root directory of your application.
W20180327-11:15:58.344(4)? (STDERR) (node:12525) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: stripe_1.Stripe.setPublishableKey is not a function
W20180327-11:15:58.344(4)? (STDERR) (node:12525) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
What version of Meteor are you using?
Incidentally, I think you should be using one of these, but not both. Your current code seems to be using the npm package.
I use Meteor 1.6.0.1
You are right, I tried both because there was an issue with the import of Stripe.
At last i tried: npm install --save stripe (without the ‘meteor’)
So, below the last modification
I only added: npm install --save stripe
In server/main.ts
import {Stripe} from "stripe";
Meteor.startup(async function() {
const stripeKey = require('stripe')(Meteor.settings.public.stripe.testPublishableKey);
await Stripe.setPublishableKey(stripeKey);
});
In the console
=> Started proxy.
=> Meteor 1.6.1 is available. Update this project with 'meteor update'.
=> Started MongoDB.
server/main.ts (7, 23): Cannot find name 'require'.
=> Started your app.
=> App running at: http://localhost:3000/
W20180327-21:38:29.425(4)? (STDERR) Note: you are using a pure-JavaScript implementation of bcrypt.
W20180327-21:38:29.451(4)? (STDERR) While this implementation will work correctly, it is known to be
W20180327-21:38:29.452(4)? (STDERR) approximately three times slower than the native implementation.
W20180327-21:38:29.452(4)? (STDERR) In order to use the native implementation instead, run
W20180327-21:38:29.452(4)? (STDERR)
W20180327-21:38:29.453(4)? (STDERR) meteor npm install --save bcrypt
W20180327-21:38:29.453(4)? (STDERR)
W20180327-21:38:29.454(4)? (STDERR) in the root directory of your application.
W20180327-21:38:29.454(4)? (STDERR) (node:6905) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: stripe_1.Stripe.setPublishableKey is not a function
W20180327-21:38:29.454(4)? (STDERR) (node:6905) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
If i add: meteor npm install --save bcrypt
I need to redo: npm install --save stripe