How to calculate international credit card IOF?

Asked

Viewed 369 times

-3

Has anyone ever needed to implement international credit card IOF calculation function on systems that could give me this help? I need to know the rules of how to calculate. Thank you!

  • 2

    It’s not just multiplying by 1,0638?

  • Math, my calculations worked out as per your help. How do I know this rule and always keep up to date when there is change in this rate?

1 answer

-1


public static bool Mod10Check(string creditCardNumber)
{
     //// check whether input string is null or empty
     if (string.IsNullOrEmpty(creditCardNumber))
     {
         return false;
     }

      //// 1.   Starting with the check digit double the value of every other digit 
      //// 2.   If doubling of a number results in a two digits number, add up
      ///   the digits to get a single digit number. This will results in eight single digit numbers                    
      //// 3. Get the sum of the digits
      int sumOfDigits = creditCardNumber.Where((e) => e >= '0' && e <= '9')
                .Reverse()
                .Select((e, i) => ((int)e - 48) * (i % 2 == 0 ? 1 : 2))
                .Sum((e) => e / 10 + e % 10);


       //// If the final sum is divisible by 10, then the credit card number
       //   is valid. If it is not divisible by 10, the number is invalid.            
       return sumOfDigits % 10 == 0;            
}

From what I understand my answer is no longer correct so here is a correction I keep the other for future reference.

From what I understand (and I’m from Portugal, we don’t have IOF), the tax currently is 1.10% on the total value.

Has two ways to calculate with aggravation or included in the total purchase amount.

1) Aggravated

 var valor = 100;
 var total = valor + (valor * 0.0638);

That is 106.38.

2) Without Aggravation

 var valor = 100;
 var total = valor - (valor * 0.0638);

That is 100 being that the amount to pay without IOF is 93.62

Reference page https://www.jafezasmalas.com/como-fugir-do-iof-nas-compras-e-saques-no-exterior/

  • If the final sum is divisible by 10, then the credit card number is valid < This is an algorithm to check whether the card number is valid or not, the question asks for something completely different.

  • What you’re asking for is the Digit check and that’s exactly what I sent you

  • But IOF is the name of a tax

  • But what the tax has to do with the credit card?

  • 1

    When you shop abroad you pay IOF, by the way what the author of the question wants I could not understand either. Probably why the question is negative D:

  • Pho3nix, thank you for the explanation and the example in the code. I just needed the IOF calculation rule to apply on the system already ready and include more of that fee. You even helped more than that. Know if there is any form or organ where I can always keep up to date when this rate of 6.38% is updated?

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.