简体   繁体   中英

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.

My questions:

  1. Do I still need to use mrgalaxy:stripe or kadira:stripe-connect in order to use the Node API for Stripe? 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?

  3. What do I need to do differently on client and on server to import Stripe?

What I have tried:

In my app directory: meteor npm install --save stripe .

In my client side javascript code:

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 :

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

which is running in 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.

Thanks in advance!

The Stripe npm package needs to be run on the server side, not client side. Stripe.js if for client side. You create a token with Stripe.js and then send that token to your server and use the NPM package to create a charge.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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