Braintree 和 Node.js 创建子商户错误未授权
Braintree and Node.js Creating Sub Merchant Error Not Authorized
我正在使用 node.js braintree sdk 尝试创建子商家帐户。但是,到目前为止一直没有成功,我一直收到未授权错误,但我不知道如何在此调用中传递令牌。
这是我使用的网关:
// gateway
const braintree = require("braintree");
const gateway = new braintree.BraintreeGateway({
environment: braintree.Environment.Sandbox,
merchantId: process.env.BRAINTREE_MERCHANT_ID,
publicKey: process.env.BRAINTREE_PUBLIC_KEY,
privateKey: process.env.BRAINTREE_PRIVATE_KEY
});
这是我正在拨打的电话:
// sub merchant call
exports.createSubMerchant = async (req, res) => {
let {
firstName,
lastName,
email,
phone,
dateOfBirth,
ssn,
address1,
address2,
locality,
region,
postalCode,
businessLegalName,
businessDbaName,
taxId,
businessAddress1,
businessAddress2,
businessLocality,
businessRegion,
businessPostalCode,
fundingDescriptor,
fundingDestination,
fundingEmail,
fundingMobilePhone,
fundingAccountNumber,
fundingRoutingNumber,
tosAccepted,
id
} = req.body;
const merchantAccountParams = {
individual: {
firstName: firstName,
lastName: lastName,
email: email,
phone: phone,
dateOfBirth: dateOfBirth,
ssn: ssn,
address: {
streetAddress: `${address1}${address2 ? `, ${address2}` : null}`,
locality: locality,
region: region,
postalCode: postalCode
}
},
business: {
legalName: businessLegalName,
dbaName: businessDbaName,
taxId: taxId,
address: {
streetAddress: `${businessAddress1}${businessAddress2 ? `, ${businessAddress2}` : null}`,
locality: businessLocality,
region: businessRegion,
postalCode: businessPostalCode
}
},
funding: {
descriptor: fundingDescriptor,
destination: fundingDestination, // braintree.MerchantAccount.FundingDestination.Bank,
email: fundingEmail,
mobilePhone: fundingMobilePhone,
accountNumber: fundingAccountNumber,
routingNumber: fundingRoutingNumber
},
tosAccepted: tosAccepted,
masterMerchantAccountId: process.env.BRAINTREE_MERCHANT_ID,
id: id
};
try {
let result = await gateway.merchantAccount.create(merchantAccountParams)
console.log(`result: `, result)
res.json(result)
} catch (e) { console.log(e); res.json({error: e}) }
};
结果是这个错误:
UnauthorizedError: No authorization token was found
但是我在查看 Merchant Account: Create docs of braintree 时看不到在哪里添加令牌。
如果您有关于如何拨打此电话以添加子商户的解决方案,请分享。
收到 Braintree 的回复后,他们确认不再提供此计划。
我正在使用 node.js braintree sdk 尝试创建子商家帐户。但是,到目前为止一直没有成功,我一直收到未授权错误,但我不知道如何在此调用中传递令牌。
这是我使用的网关:
// gateway
const braintree = require("braintree");
const gateway = new braintree.BraintreeGateway({
environment: braintree.Environment.Sandbox,
merchantId: process.env.BRAINTREE_MERCHANT_ID,
publicKey: process.env.BRAINTREE_PUBLIC_KEY,
privateKey: process.env.BRAINTREE_PRIVATE_KEY
});
这是我正在拨打的电话:
// sub merchant call
exports.createSubMerchant = async (req, res) => {
let {
firstName,
lastName,
email,
phone,
dateOfBirth,
ssn,
address1,
address2,
locality,
region,
postalCode,
businessLegalName,
businessDbaName,
taxId,
businessAddress1,
businessAddress2,
businessLocality,
businessRegion,
businessPostalCode,
fundingDescriptor,
fundingDestination,
fundingEmail,
fundingMobilePhone,
fundingAccountNumber,
fundingRoutingNumber,
tosAccepted,
id
} = req.body;
const merchantAccountParams = {
individual: {
firstName: firstName,
lastName: lastName,
email: email,
phone: phone,
dateOfBirth: dateOfBirth,
ssn: ssn,
address: {
streetAddress: `${address1}${address2 ? `, ${address2}` : null}`,
locality: locality,
region: region,
postalCode: postalCode
}
},
business: {
legalName: businessLegalName,
dbaName: businessDbaName,
taxId: taxId,
address: {
streetAddress: `${businessAddress1}${businessAddress2 ? `, ${businessAddress2}` : null}`,
locality: businessLocality,
region: businessRegion,
postalCode: businessPostalCode
}
},
funding: {
descriptor: fundingDescriptor,
destination: fundingDestination, // braintree.MerchantAccount.FundingDestination.Bank,
email: fundingEmail,
mobilePhone: fundingMobilePhone,
accountNumber: fundingAccountNumber,
routingNumber: fundingRoutingNumber
},
tosAccepted: tosAccepted,
masterMerchantAccountId: process.env.BRAINTREE_MERCHANT_ID,
id: id
};
try {
let result = await gateway.merchantAccount.create(merchantAccountParams)
console.log(`result: `, result)
res.json(result)
} catch (e) { console.log(e); res.json({error: e}) }
};
结果是这个错误:
UnauthorizedError: No authorization token was found
但是我在查看 Merchant Account: Create docs of braintree 时看不到在哪里添加令牌。
如果您有关于如何拨打此电话以添加子商户的解决方案,请分享。
收到 Braintree 的回复后,他们确认不再提供此计划。