gpt4 book ai didi

node.js - Stripe - 无权访问帐户 '{{XX}}'(或该帐户不存在)

转载 作者:太空宇宙 更新时间:2023-11-03 23:12:41 24 4
gpt4 key购买 nike

我正在使用 Stripe Connect,并且已成功加入 3 个商家。我正在尝试生成付款意向,并且一直得到

“无权访问帐户“{{acct_1FvpC4JkgwMoBOTZ}}”(或该帐户不存在)。” 然而我正在使用的 SECRET api key 是匹配的并且没有改变。我的平台显然也有客户和商家加入:

商家:

enter image description here客户:

enter image description here

NODE.JS 初始化:

const stripe = require('stripe')(StripeKey);

@param CONNECTED_STRIPE_ACCOUNT_ID = acct_1FvpC4JkgwMoBOTZ

@param customerId = cus_GSe2V6snvtLlQs

代码:

exports.onDonationFinance = functions.database.ref("/Stripe/{donationId}").onCreate((snapshot,context)=>{
var amount = snapshot.child("amount").val();
var email = snapshot.child("email").val();
const CONNECTED_STRIPE_ACCOUNT_ID = snapshot.child("conn_id").val();
const customerId = snapshot.child("cus_id").val();
const id = context.params.donationId;
const token = generateToken(customerId,CONNECTED_STRIPE_ACCOUNT_ID);
if(amount===0){
amount =250;
}else if(amount ===1){
amount =500;
}else if(amount ===2){
amount =1000;
}else if(amount ===3){
amount =1500;
}
const applicationFee = Math.round((amount/100)*1.45);
stripe.customers.create({
source: token
}, {
stripe_account: CONNECTED_STRIPE_ACCOUNT_ID,
});
(async () => {

const paymentIntent = await stripe.paymentIntents.create({
payment_method_types: ['card'],
amount: 1000,
currency: 'gbp',
application_fee_amount: applicationFee,
customer: customerId,
}, {
stripe_account: CONNECTED_STRIPE_ACCOUNT_ID,
}).then(function(paymentIntent) {
// asynchronously called
const clientSecret = paymentIntent.client_secret
const donationStripeCleanup = admin.database().ref(`Stripe/${id}`)
return admin.database().ref(`Stripe/${id}/clientSecret`).set(clientSecret);

});



})();
});

Android 代码:

  extraParams.put("setup_future_usage", "off_session");
confirmparams = ConfirmPaymentIntentParams.createWithPaymentMethodCreateParams(params,dataSnapshot.getValue().toString(), null, false, extraParams);

stripe = new Stripe(MakeUserPayment.this, PaymentConfiguration.getInstance(getApplicationContext()).getPublishableKey());
stripe.confirmPayment(MakeUserPayment.this,confirmparams);
secretListener.removeEventListener(this);

@Param connectAccount = 测试模式客户端 ID

生成 token :

function generateToken(customerId, connectedAccount){
stripe.tokens.create({
customer: customerId,
}, {
stripe_account: `{{${connectedAccount}}}`,
}).then(function(token) {
// asynchronously called
console.log('Token :', token);
return token;
}).catch((error) => {
return console.log('Token Error:', error);
});

}

我收到的 token 错误:提供的 key 'sk_test_hB****************************EYq3' 不有权访问帐户“{{acct_1FvpC4JkgwMoBOTZ}}”(或者该帐户不存在)。应用程序访问权限可能已被撤销。

有人知道我哪里出错了吗?最终用例是:客户向商家付款,我的平台收取该金额的申请费。

最佳答案

您确实发送了 {{${connectedAccount}}} ,它变成了 {{acct_ABCXYZ123}},这是不正确的;试试这个:

stripe.tokens.create({
customer: customerId,
}, {
stripe_account: `${connectedAccount}`,
}).then(function(token) {

关于node.js - Stripe - 无权访问帐户 '{{XX}}'(或该帐户不存在),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59553115/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com