Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

decimal points in the orders amount getting ignored

Experts,
I am having a situation on the payment section of the website, we use third party payment gateway for processing orders online, for some reason the total amount on the cart changing from 34,99 to 3499 on the payment confirmation page.
I mean, through out the shopping basket until the final page before it gets redirected to the payment site, the amount looks ok, soon it reaches to the payment site's confimration page its changing to 3499. Strangely, this is happening only for thosecustomers outside UK.
Please can someone advise?
Thanks
S
       
Avatar of abel
abel
Flag of Netherlands image

My guess would be, since I had something similar with the Dutch iDeal transaction system (which is a bank payment system for shopping websites), that the comma is not recognized as the decimal separator.

Since you are saying "outside of UK" their regional settings will be different. Either they have a comma where they should have a dot, or they have a dot where they should have a comma.

(with our service this was resolved by sending the data only in cents)

The resolution is usually to force the language and region settings of the affected pages, or to send the data without the normal converters, but to convert it by hand, inserting the comma (or dot) yourself.
Note: if you use ToString/Format on a currency object and you do not specify the region, the region settings of the client are used, which is not always what you might expect. The moral here is: take control yourself, otherwise you never know what you gonna get if you let MS/ASP/C#/VB do it for you.
Avatar of newbie27

ASKER

hello abel,

thanks for your input

i dont understand how would clients regional setting would any way to do with my server side script which gets the values from the shoping cart and that should be 49.99

although, all you have mentioned above makes sense to me but i am just confused with it..

do you mean, all the products on the website would show them as 49,99 instead of 49.99 ?

basically this is what the script does to send data for processing the payment

 If Not SendToEPDQ(OrderID, SB.GetTotal) Then
            Response.Redirect("~/CheckOutError.aspx")
        End If


in here, orderid and the total gets sent, where should i enforce that it should be only decimals not commas please?

please advise

thanks
 Private Function SendToEPDQ(ByVal OrderID As Integer, ByVal Total As Decimal) As Boolean
        Try
            'The Following Creates the WebClient Object
            Dim web As New System.Net.WebClient()
            'The Header Content Type is then set
            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
            'PostData is then declared as data type Byte and populated with the post data
            Dim PostData As Byte() = System.Text.Encoding.ASCII.GetBytes("clientid=121212&password=121212&oid=" & OrderID & "&chargetype=Auth&currencycode=826&total=" & Total)
            'The Web object is then used to upload the postdata to the Encryption URL and the response is stored in the Response variable
            Dim Response As Byte() = web.UploadData("https://secure2.12112.co.uk/cgi-bin/CcxBarclaysEpdqEncTool.e", "POST", PostData)
            'The response from the post is the converted from Type Byte to String and stored in the session variable
            Dim TextResponse As String = (System.Text.Encoding.ASCII.GetString(Response))
            Session("Response") = TextResponse
        Catch ex As Exception
            Test.eMail.SendErrorEmail("Error retrieving information from ePDQ (CheckOutDetails - SendToePDQ)", ex.ToString)
            Return False
        End Try
 
        Return True
    End Function
 
 
 
 
 Public Function GetTotal() As Decimal
        'returns the total of the shopping basket including the shipping cost
        Dim total As Decimal
        Dim subTotal As Decimal
 
        subTotal = Me.GetSubTotalIncVAT
 
        total = subTotal + Me._Shippping
        Return total
    End Function

Open in new window

This little piece of code will show you what happens if you would not do anything and let the system decide. It shows "normal" (if you do not do anything) and the US/EURO way. See screenshot. Note that, if the user sets the language of his/her computer, the page will react and show something different for "Normal".

All you need to do in your code is set the Culture of the current page.

Note: this particular part of MS / .NET is particularly unclearly documented and it is a nuisance to try to find this out. As a tip: set the culture of your web site in the web.config. That way you will not have this type of problems again.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        litNormal.Text = NormalDec(12.34)
        litUS.Text = USDec(12.34)
        litEuropean.Text = EuroDec(12.34)
    End Sub
 
    Private Function NormalDec(ByVal val As Decimal) As String
        Return val.ToString()
    End Function
 
    Private Function USDec(ByVal val As Decimal) As String
        Culture = "en-US"
        Return val.ToString()
    End Function
 
    Private Function EuroDec(ByVal val As Decimal) As String
        Culture = "de-DE"
        Return val.ToString()
    End Function
 
 
<p style="font-size:14pt">
    Normal: <asp:Literal runat="server" ID="litNormal"></asp:Literal>
</p>
<p style="font-size:14pt">
    US: <asp:Literal runat="server" ID="litUS"></asp:Literal>
</p>
<p style="font-size:14pt">
    European: <asp:Literal runat="server" ID="litEuropean"></asp:Literal>
</p>

Open in new window

ScreenShot065.png
In other words, what you need to do with your code is: add "Culture = "en-US" before the stringizing operation, for instance, as the first line in the try/catch.
thank you so much for your explanation abel

is this what you would recommend me to do?

please advise

thanks
Private Function SendToEPDQ(ByVal OrderID As Integer, ByVal Total As Decimal) As Boolean
        Try
            Culture = "en-US
            'The Following Creates the WebClient Object
            Dim web As New System.Net.WebClient()
            'The Header Content Type is then set
            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
            'PostData is then declared as data type Byte and populated with the post data
            Dim PostData As Byte() = System.Text.Encoding.ASCII.GetBytes("clientid=121212&password=121212&oid=" & OrderID & "&chargetype=Auth&currencycode=826&total=" & Total)
            'The Web object is then used to upload the postdata to the Encryption URL and the response is stored in the Response variable
            Dim Response As Byte() = web.UploadData("https://secure2.12112.co.uk/cgi-bin/CcxBarclaysEpdqEncTool.e", "POST", PostData)
            'The response from the post is the converted from Type Byte to String and stored in the session variable
            Dim TextResponse As String = (System.Text.Encoding.ASCII.GetString(Response))
            Session("Response") = TextResponse
        Catch ex As Exception
            Test.eMail.SendErrorEmail("Error retrieving information from ePDQ (CheckOutDetails - SendToePDQ)", ex.ToString)
            Return False
        End Try
 
        Return True
    End Function

Open in new window

Hi again,

I have set the regional settings to germany on my computer, have tested with your script and it seems its still appearing normal as "normal"

Ä

please can zou advise Ü

thanks

please see the screenshot attached
screenshot.JPG
I live in UK and the regional settings are set to the UK

should the culture be Culture = "en-UK" ?

please advise
You are in the wrong screen, that's for the keyboard... Try "Regional and Language Options" (see screenshot). I changed mine from Dutch to English/US, restarted the web app and it showed the differences (from comma to dot, in my case).

ScreenShot066.png
> should the culture be Culture = "en-UK" ?

if you want to prevent the users from inadvertently changing this per request, yes. For your requirement, it might be better to use UK if you show the amounts in pounds on the website. If you use dollars, you might use en-US (the currency type is automatically converted to the currency sign of the user, which, imho, is one of the weirdest decision MS ever made. Suppose you come from Japan and you use normal formatting and all prices are suddenly in Yen???).
abel,

is the currect syntax to change the culture in the funciton please?

i am getting an error ...

please advise

thanks for your help
Private Function SendToEPDQ(ByVal OrderID As Integer, ByVal Total As Decimal) As Boolean
        Try
            Culture = "en-US
            'The Following Creates the WebClient Object
            Dim web As New System.Net.WebClient()
            'The Header Content Type is then set
            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
            'PostData is then declared as data type Byte and populated with the post data
            Dim PostData As Byte() = System.Text.Encoding.ASCII.GetBytes("clientid=121212&password=121212&oid=" & OrderID & "&chargetype=Auth&currencycode=826&total=" & Total)
            'The Web object is then used to upload the postdata to the Encryption URL and the response is stored in the Response variable
            Dim Response As Byte() = web.UploadData("https://secure2.12112.co.uk/cgi-bin/CcxBarclaysEpdqEncTool.e", "POST", PostData)
            'The response from the post is the converted from Type Byte to String and stored in the session variable
            Dim TextResponse As String = (System.Text.Encoding.ASCII.GetString(Response))
            Session("Response") = TextResponse
        Catch ex As Exception
            Test.eMail.SendErrorEmail("Error retrieving information from ePDQ (CheckOutDetails - SendToePDQ)", ex.ToString)
            Return False
        End Try
 
        Return True
    End Function

Open in new window

is this correct?

Page.Culture = "en-UK"
Can you post the error you get? The syntax you show is correct (the first one). I assume you are on a "code behind" in an aspx.vb page.
it says

Culture name 'en-uk' is not supported.
Parameter name: name

please advise
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks
ok i have changed it, seems to be ok now... but i dont know whether this going to fix the problem
 
if you are in the place where you have regional settings set to , instead of . as a decimal point
 
http://www.giftrepublic.com/ProductRange.aspx?RangeID=3
 
please can you do me a favor of testing by adding an item in the shopping cart and please go to the checkout details page and from
there you would go to epdq page where you can see the total amount and when you click on purchase it will take you to the bank 
page where you will be shown the total price
 
please can you confirm that both the prices are in decimal points and corret?
 
thank you so much for your help

Open in new window

This is how it shows, all three steps. Seems to go well, but I haven't seen the situation before. My settings are on Dutch, and the testpage I created earlier for you show the comma, not the dot as decimal separator.

Imo, this looks good now :)

ScreenShot067.png
ScreenShot068.png
ScreenShot069.png
(I chose Albania as target, which is why the shipping is so high I think)
Excellent, thank you so much for the TEST.

Yes, all international shipping cost 19.99

I would have to get back to the customer who raised this issue this morning to see If this has been finally resolved.

Thank you so much for your help.

Will get back to you soon.

thanks
s
Hope it works just as well for your customer, too. Otherwise, ask him for his language settings (screenshot would be ideal) and the version of his/her browser and we can put that to test ourselves.
hey abel

yes, that has worked from him too.

i am so glad really... thank you so much for your help

https://www.experts-exchange.com/questions/24167963/any-one-from-germany-can-help-me-please.html

please go the above link and add your comments this one was open and i want to close that as well

thanks again
sam
I'm glad I could help you out. These little things are really tear-your-hear-out questions if you don't see what's going on....
abel:

i have one more bigger task which i am trying to do now, you probably have noticed after submitting all your details it will go to the bank payment page where customer still have to enter the details again ...

i want to somehow pass the info across so that users can only enter card details and thats it

please can you see what i am trying to explain you here?

i will open a new question for this though

thanks
Depending on the CC-interface that's offered to you, that may or may not be feasible. If they do not provide an interface for it, my advise is: do not try it. You may be violating user agreements. CC companies and people using credit cards are very protective to their data and they don't like it when they find out that it has been tampered with. That said, this kind of interfaces usually provide a way to pass on the address details and everything.

If I see that new question passing by I'll have a look :)
cool thank you for your input, i will better have a check with EPDQ guys whether it is allowed to do so in the first place...

thank you for your valuable advise again...

will post you soon, please see this section again...