#pozzworth_code
1 messages ¡ Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- pozzworth_code, 19 hours ago, 17 messages
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1257605808804593736
đ Have more to share? Add details, code, screenshots, videos, etc. below.
const processPayment = async (req, res) => {
try {
const { customerId, price, currency, paymentMethodId, providerCustomerId, providerDefaultPaymentMethodId } = req.body;
if (!providerCustomerId) {
return res.status(400).json({ error: 'Provider customer ID is missing' });
}
// Calculate total deduction (Stripe fee + platform fee)
// const totalDeductionPercentage = 0.20; // 20%
// const totalDeductionAmount = price * totalDeductionPercentage;
// Calculate the amount to transfer to the Express account (80% of the total payment amount)
const stripeFeePercentage = 0.029; // 2.9%
const stripeFeeFixed = 0.30; // $0.30
const stripeFeeAmount = (price * stripeFeePercentage) + stripeFeeFixed;
const platformFeePercentage = 0.0499; // 4.99%
const platformFeeFixed = 0.99; // $0.99
const platformFeeAmount = (price * platformFeePercentage) + platformFeeFixed;
// Calculate amount for Express account
const expressAmount = price - platformFeeAmount - stripeFeeAmount;
const roundedExpressAmount = Math.round(expressAmount)
console.log('Amount for Express account:', roundedExpressAmount);
console.log('Platform fee amount:', platformFeeAmount);
console.log('Stripe fee amount:', stripeFeeAmount);
// Create a payment intent or perform payment directly
let paymentIntent;
if (providerDefaultPaymentMethodId) {
paymentIntent = await stripe.paymentIntents.create({
customer: customerId,
amount: price, // Replace with the actual amount in cents
currency: currency, // Replace with the desired currency
payment_method: paymentMethodId,
confirm: true,
transfer_data: {
amount: roundedExpressAmount,
destination: providerCustomerId
},
application_fee_amount: Math.round(platformFeeAmount), // Platform fee amount in cents
return_url: `https://samtroyer.com`
});
}
so say someone is booking a class at $5, and Stripe on any payments takes 2.9% + 30 cents, that's always happening
in my case i'm trying to hold a percentage of the earnings and then pass what remains on to the person receiving money for the class
and as a result of the code i get this response:
Payment error: StripeInvalidRequestError: You may not provide the application_fee_amount parameter
and the transfer_data[amount] parameter simultaneously. They are mutually exclusive.
at StripeError.generate (C:\Users\Sam Troyer\Desktop\ym-user\yogamatt\server\node_modules\stripe\cjs\Error.js:10:20)
Hi, let me help you with this.
I believe we chatted yesterday.
Why are you sending both parameters at the same time?
i'd read somewhere that i could but that seemed to be a mistake
how instead can i just have my platform account hold our percentage and the rest is transferred to the connect account?
we did talk but my chat got closed before i really understood how to solve the problem
These 2 parameters basically solve the same problem, so you never need to use both of them.
The difference is:
transfer_data.amount = total - application_fee
application_fee_amount = application_fee
And you can achieve the same result with either of them.
i see
const platformFeePercentage = 0.0499; // 4.99%
const platformFeeFixed = 0.99; // $0.99
const platformFeeAmount = (price * platformFeePercentage) + platformFeeFixed;
would it make sense that in my code the platformFee Fixed should be 99 instead of 0.99 because Stripe deals with $5 like 500 ?
Happy to help.