#LoveK

1 messages · Page 1 of 1 (latest)

pastel fulcrumBOT
wary mantle
#

const stripe = require('stripe')('stripe secret key');

// Calculate the subtotal, tax, and total amount
const price = 1000;
const taxPercent = 18;
const subtotal = price + Math.round((price * taxPercent) / 100);
const applicationFeePercent = 0.25;
const applicationFee = Math.round((subtotal * applicationFeePercent) / 100);
const total = subtotal + applicationFee;

// Create a Checkout Session
const createCheckoutSession = async () => {
const session = await stripe.checkout.sessions.create({
line_items: [
{
price_data: {
currency: 'usd',
unit_amount: subtotal,
product_data: {
name: 'Test',
},
},
quantity: 1,
},
],
mode: 'payment',
success_url: http://localhost:3000/payment/success,
cancel_url: http://localhost:3000/payment/cancel,
payment_intent_data: {
application_fee_amount: applicationFee,
transfer_data: {
destination: 'account id of connected account',
},
},
});
return session;
};
createCheckoutSession().then((session) => console.log(session));

pastel fulcrumBOT
deep relic
#

👋 happy to help

wary mantle
#

connected account has this amount

#

this is from the main account

#

not sure what am I doing wrong here

deep relic
#

const applicationFeePercent = 0.25;
const applicationFee = Math.round((subtotal * applicationFeePercent) / 100);
you're taking 0.25 % as an application fee?

wary mantle
#

yes

deep relic
#

so basically you're charging 11.8$ and taking a ~0.03 cents?

wary mantle
#

correct

deep relic
wary mantle
#

req_NRHUWaGX8LyBsJ

#

req_W9Tu0Wh6CtJXL6

deep relic
#

you're not doing anything wrong

#

what you're seeing is normal

#

this is how Destination Charges work

wary mantle
#

in that case total balance is showing in negative so is that correct too?

#

As per the amount I feel live we are sending more amount than what we are collecting

deep relic
#

yes because you are paying the Stripe fees

#

please look at the flow of funds diagram here

wary mantle
#

is there a direct way to pass that fees to connected account?

deep relic
#

in that way you can get the Stripe Fee from the balance transaction

#

and subtract it from the transfer amount

wary mantle
#

does this support checkout session?

#

there is another use case where if there is international card used the stripe fees calculation changes and it will affect this total

#

in checkout session we may not directly know if they will use such cards

deep relic
wary mantle
#

okay, is there a demo app for this which I can take reference and implement in our system?

deep relic
#

I'm not sure but you don't have a lot to change honestly from what you're doing

#

basically what you need to do is just to create the Checkout Session

#

you could also leverage the tax_rates, so you don't have to calculate it yourself

#

in Checkout Session you can use automatic_tax which will do the calculation for you

wary mantle
#

so as far as I understand, I can create normal checkout session and after that I create a transfer to collect stripe fees from connected account

deep relic
#

yes

#

let's say you charge 11.8 and the Stripe Fees are 0.64 and your application fee is 0.03

#

you would create a transfer to the Connected account with a 11.8-0.64-0.03 amount