我的main.js中包含此代码:
DECLARE @BatchSize INT = 1000
DECLARE @Counter INT = 0
DECLARE @TableCount INT = 0
set @TableCount = (select count(*) from Table2)
while @Counter < (@TableCount/@BatchSize+1)
BEGIN
INSERT INTO Table1
SELECT * FROM Table2 MH
inner join Table3 M
on MH.Mid = M.Mid
WHERE NOT EXISTS (
SELECT * FROM Table1
where MH.otherid = M.otherid
)
order by id OFFSET (@BatchSize * @Counter)ROWS FETCH NEXT @Batchsize ROWS ONLY;
SET @Counter=@Counter+1
END
将此代码推送到我的Heroku服务器后,日志表明:var stripe = require("/cloud/stripe.js")("sk_test_*********");
//create customer
Parse.Cloud.define('createCustomer', function (req, res) {
stripe.customers.create({
description: req.params.fullName,
source: req.params.token
//email: req.params.email
}, function (err, customer) {
// asynchronously called
res.error("someting went wrong with creating a customer");
});
});
我也试过Error: Cannot find module '/cloud/stripe.js'
,但这会返回相同的错误。每当我尝试将这个新模块添加到我的服务器时,整个服务器就会失灵。这有什么变通方法?感谢
答案 0 :(得分:1)
您是否已将Stripe添加到节点项目的package.json
文件的要求中?如果是这样,您应该能够使用术语require('stripe')
来引用它,而不是您正在做的事情。
答案 1 :(得分:0)
I'll tell you what worked for me, I racked my brain on this for a day. Instead of using Cloud Code to make a charge, create a route on index.js. Something like this in index.js
var stripe = require('stripe')('sk_test_****');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: false
}));
app.post('/charge', function(req, res){
var token = req.body.token;
var amount = req.body.amount;
stripe.charges.create({
amount: amount,
currency: 'usd',
source: token,
}, function(err, charge){
if(err)
// Error check
else
res.send('Payment successful!');
}
});
I call this using jQuery post but you could also use a form.