【发布时间】:2021-08-16 00:27:23
【问题描述】:
我有以下 Firebase 功能:
exports.updateStripeCustomer = functions.region('europe-west3')
.firestore
.document('users/{userId}')
.onUpdate( async (change, context) => {
const oldValue = change.before.data();
const newValue = change.after.data();
if( JSON.stringify(newValue.adresse) != JSON.stringify(oldValue.adresse) ) {
const user = await admin.auth().getUser(change.after.id)
.then((user) => {
return user.displayName
})
const stripe = Stripe(<api-key>)
const customer = await stripe.customers.update(oldValue.stripe_id,
{
shipping: {
address: {
city: newValue.ort,
postal_code: newValue.plz,
line1: newValue.strasse,
line2: newValue.hausnum
},
name: user
},
}
);
return customer
}
return 'no Data changed'
})
该功能本身有效 - 只是传递运输信息的格式对我来说不是很清楚,而且似乎是错误的。 Stripe Api 文档中的示例对我来说不是很清楚。
Stripe 返回以下错误:
parameter_unknown - shipping[0]
Received unknown parameter: shipping[0]
完整的日志错误:
{
"shipping": {
"0": {
"name": "Testi Tester"
}
}
}
-------------
Response-Text
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: shipping[0]",
"param": "shipping[0]",
"type": "invalid_request_error"
}
}
非常感谢您的帮助!
【问题讨论】:
标签: node.js firebase stripe-payments