【发布时间】:2019-11-02 19:05:45
【问题描述】:
我一直在尝试将bank_name 添加到我的 Stripe Connect 用户的外部帐户,但我不断收到错误消息,就好像我误读了有关该功能的文档一样。
Error: Received unknown parameter: bank_account[bank_name]
文档显示我应该能够从bank_account 对象访问bank_name,但我的错误被缩小到它为空。我的console.log(newValue.externalAccount.bankName) 按预期返回输入的银行名称,因此输入的不是空值。知道为什么会出现此错误吗?
Firebase 功能:
exports.createStripeAccount = functions.firestore
.document("users/{userId}")
.onUpdate(async (change, context) => {
const newValue = change.after.data();
const previousValue = change.before.data();
if (newValue.state === "technician" && previousValue.state === "client") {
try {
const account_add_response = await stripe.accounts.create(
{
type: "custom",
country: "US",
requested_capabilities: ["platform_payments"],
email: newValue.email,
tos_acceptance: newValue.stripeTosAcceptance,
business_type: "individual",
business_profile: {
url: newValue.socialLinks.linkedin
},
individual: {
first_name: newValue.firstName,
last_name: newValue.lastName,
gender: newValue.gender,
email: newValue.email,
phone: newValue.phone,
address: {
line1: newValue.address.line1,
line2: newValue.address.line2,
city: newValue.address.city,
state: newValue.address.state,
postal_code: newValue.address.zip,
country: newValue.address.country
},
ssn_last_4: newValue.technician.ssnLast4,
dob: {
day: newValue.dob.day,
month: newValue.dob.month,
year: newValue.dob.year
}
}
},
async function(error, account) {
if (error) {
return console.error(error);
} else {
console.log(
"Writing account.id " + account.id + " to user DB..."
);
console.log("newValue.externalAccount.bankName: " + newValue.externalAccount.bankName)
const bank_add_response = await stripe.accounts.createExternalAccount(
account.id,
{
external_account: {
object: "bank_account",
country: "US",
currency: "USD",
account_holder_name:
newValue.externalAccount.accountHolderName, // Have user input manually, might be different than user's name
account_holder_type: "individual",
bank_name: newValue.externalAccount.bankName,
routing_number: newValue.externalAccount.routingNumber,
account_number: newValue.externalAccount.accountNumber
}
},
function(error, bank_account) {
if (error) {
return console.error(error);
} else {
console.log(
"Writing bank_account.id " +
bank_account.id +
" to user DB..."
);
return admin
.firestore()
.collection("users")
.doc(context.params.userId)
.set(
{
connectId: account.id,
externalAccount: {
bankAccountId: bank_account.id,
bankName: bank_account.bank_name,
last4: bank_account.last4,
}
},
{ merge: true }
);
}
}
);
}
}
);
} catch (error) {
console.log(error);
await change.ref.set(
{ error: userFacingMessage(error) },
{ merge: true }
);
return reportError(error, { user: context.params.userId });
}
}
});
【问题讨论】:
-
我对 Stripe 还很陌生,但有两件事对我来说似乎是错误的:1) 添加银行账户时,我认为
bank_name是只读的;您只想指定一个路由号码和帐号,并且条带会为您计算出银行名称 (stripe.com/docs/ach#verifying) 2) 当您发布新帐户详细信息时,您应该使用条带标记您的输入,然后通过令牌添加帐户(参见代码块下方的段落:stripe.com/docs/connect/payouts#bank-accounts,另请参见:stripe.com/docs/…) -
如果你看一下 Stripe 的外部帐户创建 API stripe.com/docs/api/external_account_bank_accounts/create 没有称为
bank_name的参数,它只支持在哈希 stripe.com/docs/api/external_account_bank_accounts/… 中指定的那些参数 -
谢谢大家,这就是为什么我使用的测试帐户被标记为 STRIPE TEST BANK 的原因
标签: javascript firebase google-cloud-functions stripe-payments