#pozzworth_code

1 messages ¡ Page 1 of 1 (latest)

compact auroraBOT
weary hearthBOT
#

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.

compact auroraBOT
#

👋 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.

true crypt
#

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

compact auroraBOT
true crypt
#

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)

eager reef
#

Hi, let me help you with this.

#

I believe we chatted yesterday.
Why are you sending both parameters at the same time?

true crypt
#

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?

true crypt
eager reef
#

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.

true crypt
#

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 ?

eager reef
#

Yes

#

As long as price is also in cents.

true crypt
#

seems to be that way and i think that the issue is solved actually

#

thank you

eager reef
#

Happy to help.

compact auroraBOT