[英](Stripe API) Able to obtain bank_account token, but not card token
[英]Stripe : Error: Received unknown parameter: bank_account[bank_name]
我一直在嘗試將bank_name
添加到我的Stripe Connect用戶的外部帳戶,但我一直收到錯誤,好像我誤讀了該函數的文檔。
Error: Received unknown parameter: bank_account[bank_name]
文檔顯示,我應該能夠訪問bank_name
從bank_account
對象,但我的誤差縮小到它為空。 我的console.log(newValue.externalAccount.bankName)
按預期輸入了bankName,因此它不會為null。我知道為什么會收到此錯誤?
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 });
}
}
});
看起來我誤解了bank_name
字段的用途。 我認為這是用戶定義的自定義名稱,例如“Doug's Chase Checkings”,但它似乎是由Stripe自動生成並且只讀。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.