Firebase 条带:未知参数([对象])
我正在尝试编写一个firebase云函数,该函数将支付方法附加到条带客户,将他们订阅到计划,并将订阅对象写入firestore 实际上我刚刚写了一个函数,但不确定我改变了什么Firebase 条带:未知参数([对象]),firebase,google-cloud-functions,stripe-payments,Firebase,Google Cloud Functions,Stripe Payments,我正在尝试编写一个firebase云函数,该函数将支付方法附加到条带客户,将他们订阅到计划,并将订阅对象写入firestore 实际上我刚刚写了一个函数,但不确定我改变了什么 exports.attachAndSubscribe = functions.firestore .document('stripe_customers/{userId}') .onUpdate(async (change, context) => { const source =
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])。你是想通过考试吗
选项对象
鸭子是对的。默认的支付方法属性仅存在于客户对象中,而不存在于paymentMethod对象中。我通过在附加付款方式后单独更新stripe customer解决了问题。我相信您的问题在于
stripe.paymentMethods.attach
唯一可用的参数是customer,