Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Created February 9, 2023 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamoCA/6f3dcd5e2c573cd9e82e9dc55cc310b5 to your computer and use it in GitHub Desktop.
Save JamoCA/6f3dcd5e2c573cd9e82e9dc55cc310b5 to your computer and use it in GitHub Desktop.
Add Stripe Processing Fee to Charge using ColdFusion / CFML
<cfscript>
// 2023-02-09 Add Stripe Processing Fee to Charge (ColdFusion / CFML)
// https://support.stripe.com/questions/passing-the-stripe-fee-on-to-customers
// The amounts are calculated based on the US Stripe fee of 2.9% + $0.30 per transaction
numeric function addProcessingFeeToAmount(required numeric amount, numeric fixedFee=0.30, numeric percentageFee=0.029) hint="I add a processing fee to a charge amount" {
return javacast("double", numberformat((arguments. Amount + arguments.fixedFee)/(1 - arguments.percentageFee), '0.00'));
}
newCharge = addProcessingFeeToAmount(1000); // 1030.18
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment