Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 条带:未知参数([对象])_Firebase_Google Cloud Functions_Stripe Payments - Fatal编程技术网

Firebase 条带:未知参数([对象])

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 =

我正在尝试编写一个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])。你是想通过考试吗 选项对象


鸭子是对的。默认的支付方法属性仅存在于客户对象中,而不存在于paymentMethod对象中。我通过在附加付款方式后单独更新stripe customer解决了问题。

我相信您的问题在于
stripe.paymentMethods.attach
唯一可用的参数是customer,