Reputation: 803
I'm using Stripe Connect and i've successfully onboarded 3 merchants. I'm trying to generate a payment intent and i'm consistantly getting
" does not have access to account '{{acct_1FvpC4JkgwMoBOTZ}}' (or that account does not exist). " and yet the SECRET api key i'm using matches and hasn't changed. My platform clearly has the customer and merchant onboarded as well:
Merchant:
NODE.JS Initilisation:
const stripe = require('stripe')(StripeKey);
@param CONNECTED_STRIPE_ACCOUNT_ID = acct_1FvpC4JkgwMoBOTZ
@param customerId = cus_GSe2V6snvtLlQs
Code:
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 Code:
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 = test mode client ID
To generate the 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 error i'm recieving: The provided key 'sk_test_hB****************************EYq3' does not have access to account '{{acct_1FvpC4JkgwMoBOTZ}}' (or that account does not exist). Application access may have been revoked.
Does anyone have any idea where i'm going wrong here? The end use case is: customer makes payment to merchant, my platform takes an application fee of that amount.
Upvotes: 2
Views: 7396
Reputation: 52907
I got the same error in ruby because of the same (silly) mistake.
I had
Stripe::Account.create_login_link('account.id')
but should have had
Stripe::Account.create_login_link(account.id)
Upvotes: 0
Reputation: 8747
You're literally sending {{${connectedAccount}}}
which turns into {{acct_ABCXYZ123}}
, which is not correct; try this instead:
stripe.tokens.create({
customer: customerId,
}, {
stripe_account: `${connectedAccount}`,
}).then(function(token) {
Upvotes: 5