【发布时间】:2020-01-01 13:54:48
【问题描述】:
我正在使用 Stripe Connect,并且我已成功加入 3 个商家。我正在尝试生成付款意图,并且我一直在获得
" 无权访问帐户 '{{acct_1FvpC4JkgwMoBOTZ}}'(或该帐户不存在)。" 然而我使用的 SECRET api 密钥匹配并且没有改变。我的平台显然也吸引了客户和商家:
商家:
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 connectedAccount = 测试模式客户端 ID
生成令牌:
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);
});
}
我收到的令牌错误:提供的密钥 'sk_test_hB****************************EYq3' does not have access to account '{{acct_1FvpC4JkgwMoBOTZ}}' (or that account does not exist). Application access may have been revoked.
有人知道我在哪里出错了吗?最终用例是:客户向商家付款,我的平台收取该金额的申请费。
【问题讨论】:
-
请控制台记录令牌值
-
已添加,我收到令牌错误
-
好的,我正在检查
-
请检查密钥设置
-
秘钥是来自accounts API的测试密钥...我觉得没问题