简体   繁体   English

如何安装Stripe for Meteor 1.3?

[英]How do I install Stripe for Meteor 1.3?

I'm creating a meteor web app that will sell one of our customer's products. 我正在创建一个流星网络应用程序,它将销售我们客户的一个产品。 I've decided to try and use Stripe to handle the payments (in particular Stripe Connect), and to charge an 'application fee' for each sale. 我决定尝试使用Stripe来处理付款(特别是Stripe Connect),并为每次销售收取“申请费”。

My questions: 我的问题:

  1. Do I still need to use mrgalaxy:stripe or kadira:stripe-connect in order to use the Node API for Stripe? 我是否还需要使用mrgalaxy:stripekadira:stripe-connect才能使用Stripe的Node API? I am getting incredibly confused with the documentation of these packages, which I now believe are outdated. 我对这些软件包的文档感到非常困惑,我现在认为这些文档已经过时了。

  2. If not, exactly how should I install and import Stripe for my app? 如果没有, 我应该如何为我的应用程序安装和导入Stripe

  3. What do I need to do differently on client and on server to import Stripe? 在客户端和服务器上我需要做些什么来导入Stripe?

What I have tried: 我尝试过的:

In my app directory: meteor npm install --save stripe . 在我的app目录中: meteor npm install --save stripe

In my client side javascript code: 在我的客户端javascript代码:

import stripe from "stripe"

var stripe = require("stripe"("sk_******************")

Meteor.startup(function() {
    stripe.setPublishableKey("sk_******************");
});

I believe the first are meant to do the same thing, but neither works! 我相信第一个意味着做同样的事情,但都不起作用! Chrome debugger gives me : Chrome调试器给了我:

Uncaught TypeError: require("http").createServer is not a function

which is running in node_modules/stripe/lib/stripe.js 它在node_modules/stripe/lib/stripe.js

I am epically confused right now and would give my right index finger for clear instruction on what exactly to write in my javascript file, so I can go from where I am now to creating my first charge object. 我现在非常困惑,并且会给我正确的食指,以清楚地说明我的javascript文件中究竟要写什么,所以我可以从现在的位置去创建我的第一个charge对象。

Thanks in advance! 提前致谢!

The Stripe npm package needs to be run on the server side, not client side. Stripe npm包需要在服务器端运行,而不是在客户端运行。 Stripe.js if for client side. Stripe.js如果是客户端。 You create a token with Stripe.js and then send that token to your server and use the NPM package to create a charge. 您使用Stripe.js创建令牌,然后将该令牌发送到您的服务器并使用NPM包创建费用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM