【发布时间】:2017-11-04 11:21:41
【问题描述】:
在 Meteor/React 应用程序中,我需要从 mrgalaxy:stripe 导入 Stripe。我试过了:
import { Stripe } from 'meteor/mrgalaxy:stripe';
但它会返回:
TypeError: Cannot read property 'setPublishableKey' of undefined
在服务器文件夹中,我创建了 stripe.js 文件,其中添加了以下内容:
import { Meteor } from 'meteor/meteor';
import { Stripe } from 'meteor/mrgalaxy:stripe';
Meteor.startup(function(){
Stripe.setPublishableKey(Meteor.settings.public.StripePub);
});
【问题讨论】:
-
这个包使用了过期版本的 api 和 npm 包。因为您现在可以直接使用 npm 包并将脚本声明添加到您的
<head>模板中。
标签: reactjs meteor stripe-payments