• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

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
       
0
newbie27
Asked:
newbie27
  • 13
  • 13
1 Solution
 
abelCommented:
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.
0
 
abelCommented:
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.
0
 
newbie27Author Commented:
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

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
abelCommented:
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
0
 
abelCommented:
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.
0
 
newbie27Author Commented:
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

0
 
newbie27Author Commented:
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

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

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

please advise
0
 
abelCommented:
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
0
 
abelCommented:
> 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???).
0
 
newbie27Author Commented:
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

0
 
newbie27Author Commented:
is this correct?

Page.Culture = "en-UK"
0
 
abelCommented:
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.
0
 
newbie27Author Commented:
it says

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

please advise
0
 
abelCommented:
The caps is important. And you are right (well, the compiler is right). In you first post, you used "en-US". For United Kingdom, you should use "en-GB".

A list of codes is here, in case you ever need that again: http://msdn.microsoft.com/en-us/library/ms866170.aspx
0
 
newbie27Author Commented:
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

0
 
abelCommented:
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
0
 
abelCommented:
(I chose Albania as target, which is why the shipping is so high I think)
0
 
newbie27Author Commented:
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
0
 
abelCommented:
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.
0
 
newbie27Author Commented:
hey abel

yes, that has worked from him too.

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

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Q_24167963.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
0
 
abelCommented:
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....
0
 
newbie27Author Commented:
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
0
 
abelCommented:
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 :)
0
 
newbie27Author Commented:
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...

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 13
  • 13
Tackle projects and never again get stuck behind a technical roadblock.
Join Now