Converting dollars to long values for processing

I would like to mask user inputs when they enter the dollar value for payment, which will result in the following format: $ 5,009.75.
Then, I can use JQuery to remove the $ and the space, resulting with 5009.75.
Finally, I need to know how do I convert that value to a (long), i.e., convert that amount to pennies to process the payment.
When I tried to multiply 5009.75, such as 5009.75*100 in C#, I am getting 500900 back. The cents are missing. Any ideas on converting 5009.75 to cents for processing in c#?

I do not often use C#, so take this answer with a big grain of salt.

Since your value is starting as a string (and assuming the cents are required and present) you should be able to use JQuery to remove the period (decimal point) as well.

If this does not work for you, post a code example.

Multiplying the value should be just fine. Whats the snippet of code your running and getting the wrong value. :slightly_smiling_face:

So, if I am sending $20523.95 to Square for processing, is the value 2052395 the expected correct value?
I discovered that I am doing the following:

            var InvoiceAmount = (double)request["InvoiceAmount"];
            var InvoiceTotal = (long)((double)(InvoiceAmount * 100));

The return value is what I posted above. Am I now doing it correctly for Square to properly process the amount intended by the sender?

Yes, 2052395 is the expected value when passing the amount to Square. :slightly_smiling_face: