firebase - 条纹:未知参数([object Object])
问题描述
我正在尝试编写一个firebase云功能,将付款方式附加到条纹客户,为他们订阅计划,并将订阅对象写入firestore。
我实际上只是写了一个有效的函数,但不确定我改变了什么。
exports.attachAndSubscribe = functions.firestore
.document('stripe_customers/{userId}')
.onUpdate(async (change, context) => {
const source = change.after.data();
const paymentMethod = source.paymentMethod;
await stripe.paymentMethods.attach(paymentMethod.id,
{customer: source.customer_id},
{invoice_settings: {default_payment_method: paymentMethod.id}
});
const subscription = await stripe.subscriptions.create(
{customer: source.customer_id,items: [{plan: 'plan_FnA3IsFL5Xc6Ct'}]
});
return admin.firestore()
.collection('stripe_customers')
.doc(userId)
.set(
{subscription: subscription});
});
当函数被触发时,我收到以下错误:
条纹:未知参数([object Object])。你的意思是传递一个选项对象吗?
解决方案
鸭子是对的。default_payment_method 属性仅存在于客户对象中,而不存在于 paymentMethod 对象中。我在附加付款方式后通过单独更新条纹客户解决了这个问题。
推荐阅读
- python - 在 tkinter 中填充正确的网格单元的问题
- javascript - HTML, Javascript 独立工作的多个按钮
- java - 为什么非零返回int充当0?
- google-sheets - 如何在 ARRAYFORMULA 中使用 AVERAGEIFS
- javascript - 尝试在 Jasmine 规范文件中导入类时出现“语法错误:无法在模块外使用导入语句”
- api - 带有 Swift Mailer 的 API 平台
- object - 在if语句中使用对象名称是真还是假?
- java - org.hibernate.LazyInitializationException:无法初始化代理 - 尝试初始化时没有会话
- javascript - 如何使用 window.open() 限制在 Javascript 中打开的选项卡数量
- css - 通过首选项或应用设置属性启用暗模式