#LoveK
1 messages · Page 1 of 1 (latest)
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));
👋 happy to help
connected account has this amount
this is from the main account
not sure what am I doing wrong here
const applicationFeePercent = 0.25;
const applicationFee = Math.round((subtotal * applicationFeePercent) / 100);
you're taking 0.25 % as an application fee?
yes
so basically you're charging 11.8$ and taking a ~0.03 cents?
correct
would you mind sharing the request ID? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
you're not doing anything wrong
what you're seeing is normal
this is how Destination Charges work
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
yes because you are paying the Stripe fees
please look at the flow of funds diagram here
is there a direct way to pass that fees to connected account?
in that way you can get the Stripe Fee from the balance transaction
and subtract it from the transfer amount
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
yes, you would do the Checkout Session normally as if you were creating it on your own Platform
and then use the charge from that Checkout Session (session.payment_intent.latest_charge) to pass in the source_transaction as explained here https://stripe.com/docs/connect/charges-transfers#transfer-availability
okay, is there a demo app for this which I can take reference and implement in our system?
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
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