【问题标题】:Stripe: Unknown arguments ([object Object])条纹:未知参数([object Object])
【发布时间】: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])。你的意思是通过一个 选项对象?

【问题讨论】:

标签: firebase google-cloud-functions stripe-payments


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2020-06-12
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-13
    • 1970-01-01
    相关资源
    最近更新 更多