0

I have a website that's using Stripe Connect and Express to act as a platform for sellers. In all of the Stripe documentation that I've seen, the application fee amount is expressed as a whole number. In the example below, "500" translating into "$5.00". If I didn't want to charge a fixed dollar amount, how can I go about expressing this as a percentage of the sale price?

payment_intent_data: {
      application_fee_amount: 500,
      transfer_data: {
        destination: tour.createdBy
      }
    }
Chris Clark
  • 488
  • 2
  • 19
  • 2
    "If I didn't want to charge a fixed dollar amount, how can I go about expressing this as a percentage of the sale price?" - by doing the *percentage-of* calculation in your own code where you generate the `payment_intent_data` object given that `application_fee_amount` needs to be a numeric value in the first place. – Dai Dec 26 '20 at 13:36

1 Answers1

1

have a website that's using Stripe Connect and Express to act as a platform for sellers

kk

In all of the Stripe documentation that I've seen, the application fee amount is expressed as a whole number.

Indeed. This is because Stripe uses JSON, and JSON does not guarantee that numeric values with decimal (radix) digits are preserved - this is because JSON uses JavaScript/ECMAScript's number type which is based on IEEE-754 which cannot be used to reliably store non-integer amounts, hence why Stripe uses "integer cents" instead of "floating dollars" to store currency values.

If I didn't want to charge a fixed dollar amount, how can I go about expressing this as a percentage of the sale price?

You can't - and you don't need to.

Stripe's entire business-model is based around having a developer-friendly web-service API (unlike say, PayPal or Authorize.net, which are both actively hostile to developers, for reasons I won't get into, but if anyone from PayPal is listening, please fix your broken non-immutable transaction history feature, that's just being irresponsible!) - ergo the implication is you are a developer who knows how to define a percentage in your own application code:

const AMOUNT = 500;
const PERCENTAGE_WHATEVER = 0.1; // 0.1 == 10%

const myStripeRequestDto = {
    application_fee_amount: AMOUNT,
    transfer_data: {
        destination: Math.floor( AMOUNT * PERCENTAGE_WHATEVER);
    }
}

const resp = await sendRequestToStripe( myStripeRequestDto );
Dai
  • 141,631
  • 28
  • 261
  • 374
  • Yeah, in hindsight, this was a stupid question. I ended up defining the percentage of price in my code... I did it a little different than what you have above. Mine is just "product.price * .01 * 100". Thank you for the detailed answer! – Chris Clark Dec 26 '20 at 15:29
  • 1
    account_id goes in the destination parameter, the Math.floor should be in the application_fee_amount parameter – BritishSam Jan 03 '23 at 10:40