【发布时间】:2021-02-05 16:34:51
【问题描述】:
我正在运行以下节点应用程序(仅相关部分):
app.post("/create_customer_portal_session",async (req, res) => {
const {customerId} = req.body;
var session = await stripe.billingPortal.sessions.create({
customer: customerId,
return_url: 'https://****.com/account.php',
});
res.send(session);
});
如果我输入customer:'<customer id manually inserted>',它运行良好,但如果我尝试从请求中获取 customerId 的值,它就不行。
我错过了什么?
在客户端我有:
$('#portal').click(function(e){
var customerId='<?php echo $stripe_customer;?>';
e.preventDefault();
$.post('https://****.com/store/create_customer_portal_session', {customerId:customerId},function( data ) {
window.location.href = data.url;
});
});
【问题讨论】:
-
request.body 的值是多少?
-
也许这是一个愚蠢的问题,但我该如何检查呢?
-
你可以用
console.log打印出来 -
您的页面实际上是由 PHP 服务器托管的吗?您共享了用 Node 编写的后端代码(并将问题标记为
express),所以<?php echo的存在让我有点困惑。 -
我有一个 Lamp 堆栈,我在其中对节点服务器执行 Ajax 调用。 @karllekko
标签: node.js express stripe-payments