【发布时间】:2020-01-16 16:18:57
【问题描述】:
我正在尝试编写一个 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});
});
当函数被触发时,我收到以下错误:
Stripe:未知参数([object Object])。你的意思是通过一个 选项对象?
【问题讨论】:
-
我相信你的问题是
stripe.paymentMethods.attach唯一可用的参数是客户 stripe.com/docs/api/payment_methods/attach?lang=node
标签: firebase google-cloud-functions stripe-payments