Stripe - 无权访问帐户“{{XX}}”(或该帐户不存在)

Jam*_*rey 2 node.js stripe-payments

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

“无权访问帐户 '{{acct_1FvpC4JkgwMoBOTZ}}'(或者该帐户不存在)。”但我正在使用的 SECRET api 密钥匹配且未更改。我的平台显然也有客户和商家加入:

商人:

在此输入图像描述 顾客:

在此输入图像描述

NODE.JS 初始化:

const stripe = require('stripe')(StripeKey);
Run Code Online (Sandbox Code Playgroud)

@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);

      });



  })();
});
Run Code Online (Sandbox Code Playgroud)

安卓代码:

  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);
Run Code Online (Sandbox Code Playgroud)

@Param connectAccount = 测试模式客户端 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);
           }); 

}
Run Code Online (Sandbox Code Playgroud)

我收到的令牌错误:提供的密钥'sk_test_hB****************************EYq3' does not have access to account '{{acct_1FvpC4JkgwMoBOTZ}}' (or that account does not exist). Application access may have been revoked.

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

flo*_*mas 5

您实际上是在发送{{${connectedAccount}}}which 变成{{acct_ABCXYZ123}},这是不正确的;试试这个:

stripe.tokens.create({
    customer: customerId,
  }, {
    stripe_account: `${connectedAccount}`,
  }).then(function(token) {
Run Code Online (Sandbox Code Playgroud)