Я использую webtask.io для создания заряда Stripe на основе примера Thomasz здесь , но после того, как они обновились с Узла 4 до Узла 8, это больше не работает.Есть идеи, как заставить это работать снова?
var stripe = require('stripe');
module.exports = function (ctx, req, res) {
stripe(ctx.secrets.stripeSecretKey).charges.create({
amount: ctx.body.amount * 100,
currency: 'gbp',
source: ctx.body.stripeToken,
description: 'Test Payment',
}, function (error, charge) {
var status = error ? 400 : 200;
var message = error ? error.message : '<script>window.location.replace("' + ctx.body.redirectUrl + '");</script>';
res.writeHead(status, { 'Content-Type': 'text/html' });
return res.end('<h1>' + message + '</h1>');
});
};
Ошибка:
{
"code": 500,
"error": "Script generated an unhandled synchronous exception.",
"details": "TypeError: Cannot read property 'amount' of undefined",
"name": "TypeError",
"message": "Cannot read property 'amount' of undefined",
"stack": "TypeError: Cannot read property 'amount' of undefined\n at module.exports (/data/io/ea441d92-6f8c-46b0-a9a9-6c8098f03aac/webtask.js:5:26)\n at Async.waterfall (/data/sandbox/lib/sandbox.js:519:33)\n at nextTask (/data/sandbox/node_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node_modules/async/dist/async.js:969:16\n at Async.waterfall (/data/sandbox/lib/sandbox.js:408:24)\n at nextTask (/data/sandbox/node_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node_modules/async/dist/async.js:969:16\n at _combinedTickCallback (internal/process/next_tick.js:138:11)"
}