首页 > 解决方案 > 条纹:未知参数([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])。你的意思是传递一个选项对象吗?

标签: firebasegoogle-cloud-functionsstripe-payments

解决方案


鸭子是对的。default_payment_method 属性仅存在于客户对象中,而不存在于 paymentMethod 对象中。我在附加付款方式后通过单独更新条纹客户解决了这个问题。


推荐阅读