Created
August 31, 2012 13:27
-
-
Save calvincorreli/3552662 to your computer and use it in GitHub Desktop.
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
def estimate_fee(cents, cardtype) | |
case cardtype.to_s.downcase | |
when /dankort/ | |
# Dankort: | |
# http://www.pbs.dk/da/produkter/dankort/Documents/DK_Prisliste_Dankort_eDankort_DK.pdf | |
# Transaction size Price | |
# 0 - 50.00 DKK 0.70 DKK | |
# 50.01 - 100.00 DKK 1.10 DKK | |
# > 100.01 1.45 DKK + 0.1% | |
# Using this: 1.45 DKK + 0.10% | |
if cents <= 5000 | |
70 | |
elsif cents <= 10000 | |
110 | |
else | |
(145 + 0.001 * cents).round | |
end | |
when /-dk$/ | |
# MasterCard-DK, Visa-Electron-DK | |
# http://www.pbs.dk/da/produkter/internationale-betalingskort/Documents/IK_Prisliste_MasterCard_Maestro_Visa_VisaElectron_VPAY_JCB_ChinaUnionPay_AmericanExpress_DK.pdf | |
# 1.25% (minimum 0.70 DKK) | |
[0.0125 * cents, 70].max | |
else | |
# http://www.pbs.dk/da/produkter/internationale-betalingskort/Documents/IK_Prisliste_MasterCard_Maestro_Visa_VisaElectron_VPAY_JCB_ChinaUnionPay_AmericanExpress_DK.pdf | |
# Up to 3.75 % (minimum 1.95 DKK) | |
[0.0375 * cents, 195].max | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment