Created
February 9, 2023 17:49
-
-
Save JamoCA/6f3dcd5e2c573cd9e82e9dc55cc310b5 to your computer and use it in GitHub Desktop.
Add Stripe Processing Fee to Charge using ColdFusion / CFML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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