我正在设置一个带条带的支付系统,我想向客户对象添加一些元数据。我想将我的工作区ID添加到客户的元数据属性中。我尝试了以下代码,但它返回以下错误:
âï¸ Error:
Error: Invalid val: {:_bsontype=>"ObjectID", :id=>"\\HÃ\u001E��\u000F�=��"} must be a string under 500 characters
我已经记录了添加到这个元数据属性中的工作区ID,但它似乎只是一个常规的MongoDB对象ID。有人知道我做错了什么吗?
应该向我创建的客户添加元数据的代码
// find the current User and use his workspace ID
const user = await User.findOne({ _id: req.userId });
const workspaceId = user._workspace;
// get the payment plan
const plan = await stripe.plans.retrieve('plan_EK1uRUJLJcDS6e');
// // then we create a new customer
const customer = await stripe.customers.create({
email,
source,
metadata: {
workspace_id: workspaceId
}
});
res.status(200).json({
message: 'payment complete',
subscription: adjustedSubscription
});