473,699 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculation Problem

I'm using the following code to calculate order amount in a payment form
for Authorize.net:

(Assume book_copies = 1 and ship_country = United States)

book_copies = request ("book_copie s")
product_price = 16.95

If ship_country = "United States" then
ship_amount = 3.99
Elseif ship_country = "Canada" then
ship_amount = 3.99
Else
ship_amount = 7.99
End if

order_amount = product_price * book_copies
total_amount = (product_price * book_copies) + ship_amount

I then set the values for authorize.net as follows:

<%

Dim sequence
Dim amount
Dim ret

amount = (product_price * book_copies) + ship_amount

....... unrelated code ......

%>

NOW, my question is:

What could be the difference between the following:

amount = (product_price * book_copies) + ship_amount

(this generates an error)

and

amount = 20.94

(this works if I set the value directly)

Thanks.

Brett
ba****@sprynet. com
Oct 4 '05 #1
9 1455

"BaWork" <ba****@sprynet .com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I'm using the following code to calculate order amount in a payment form
for Authorize.net:

(Assume book_copies = 1 and ship_country = United States)

book_copies = request ("book_copie s")
product_price = 16.95

If ship_country = "United States" then
ship_amount = 3.99
Elseif ship_country = "Canada" then
ship_amount = 3.99
Else
ship_amount = 7.99
End if

order_amount = product_price * book_copies
total_amount = (product_price * book_copies) + ship_amount

I then set the values for authorize.net as follows:

<%

Dim sequence
Dim amount
Dim ret

amount = (product_price * book_copies) + ship_amount

...... unrelated code ......

%>

NOW, my question is:

What could be the difference between the following:

amount = (product_price * book_copies) + ship_amount

(this generates an error)

and

amount = 20.94

(this works if I set the value directly)


book_copies is a string

use clng() to convert to a numeric
--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
http://www.outlook-find-replace.com - Find & Replace in Emails, Contacts,
Appointments, Tasks and Notes
Oct 4 '05 #2
Thanks for the response. That didn't fix it though. As far as the
generated code is concerned, this calculates the correct value:

amount = (product_price * book_copies) + ship_amount

but here is where it gets stupid. If the quantity is 2 or 5, it works,
if it 1,3 or 4, it doesn't.

Here is the page example:

http://www.vantagepoints.net/buy1.asp

Keeping all other values the same, changing only the number of books
determines if it works or not

If you chose 2 or 5, fill in dummy text and click "Continue", confirm
your order on the next page and click "Submit Order", it works. If you
use any the other possible values for book quantity, it doesn't.

Any ideas? Authorize.net won't help.

Thanks

Brett
ba****@sprynet. com

John Blessing wrote:
"BaWork" <ba****@sprynet .com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I'm using the following code to calculate order amount in a payment form
for Authorize.net:

(Assume book_copies = 1 and ship_country = United States)

book_copies = request ("book_copie s")
product_pri ce = 16.95

If ship_country = "United States" then
ship_amount = 3.99
Elseif ship_country = "Canada" then
ship_amount = 3.99
Else
ship_amount = 7.99
End if

order_amoun t = product_price * book_copies
total_amoun t = (product_price * book_copies) + ship_amount

I then set the values for authorize.net as follows:

<%

Dim sequence
Dim amount
Dim ret

amount = (product_price * book_copies) + ship_amount

...... unrelated code ......

%>

NOW, my question is:

What could be the difference between the following:

amount = (product_price * book_copies) + ship_amount

(this generates an error)

and

amount = 20.94

(this works if I set the value directly)

book_copies is a string

use clng() to convert to a numeric

Oct 4 '05 #3
BaWork wrote:
amount = (product_price * book_copies) + ship_amount

(this generates an error)

What error?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 4 '05 #4
Bob,

I'm sorry for not being more clear, Authorize.net generates an error
when calculating the hash value where the amount is one of the values
used in the hash calculation. But it isn't consistent, it works for
some values and not for others.

See my response to John's, I think I was better at explaining the issue.

I don't know how a value of 1 causes an error where a value of 2 does not...

Thanks for the response.

Brett
ba****@sprynet. com

Bob Barrows [MVP] wrote:
BaWork wrote:

amount = (product_price * book_copies) + ship_amount

(this generates an error)


What error?

Oct 4 '05 #5
What error? There must be some error message ...

BaWork wrote:
Bob,

I'm sorry for not being more clear, Authorize.net generates an error
when calculating the hash value where the amount is one of the values
used in the hash calculation. But it isn't consistent, it works for
some values and not for others.

See my response to John's, I think I was better at explaining the
issue.

I don't know how a value of 1 causes an error where a value of 2 does
not...

Thanks for the response.

Brett
ba****@sprynet. com

Bob Barrows [MVP] wrote:
BaWork wrote:

amount = (product_price * book_copies) + ship_amount

(this generates an error)


What error?


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 4 '05 #6
Bob,

It is an Authorize.net generated error that relates to the calculated
hash value not matching the server generated hash value. If you visit
http://vantagepoints.net/buy1.asp and run through the process using all
5 available quantities, you see the error for some and not for others.

In a nutshell, this code works as long as the quantity is 2 or 5.

amount = (product_price * book_copies) + ship_amount

If it is 1,3 or 4, it doesn't. For these values, if I hard-code the
total order amount, it works though.

So that is why I'm left thinking there is something wrong with my code
(even though I can't understand how it works for some values and not for
others...)

Thanks for your continued help. Authorize.net has offered zero
assistance on this.

Brett
ba****@sprynet. com
Bob Barrows [MVP] wrote:
What error? There must be some error message ...

BaWork wrote:
Bob,

I'm sorry for not being more clear, Authorize.net generates an error
when calculating the hash value where the amount is one of the values
used in the hash calculation. But it isn't consistent, it works for
some values and not for others.

See my response to John's, I think I was better at explaining the
issue.

I don't know how a value of 1 causes an error where a value of 2 does
not...

Thanks for the response.

Brett
ba****@spryne t.com

Bob Barrows [MVP] wrote:
BaWork wrote:

amount = (product_price * book_copies) + ship_amount

(this generates an error)
What error?


Oct 4 '05 #7
BaWork wrote:
Bob,

It is an Authorize.net generated error that relates to the calculated
hash value not matching the server generated hash value.
So the error says that the "calculated hash value does not match the
server-generated hash value"? OK, now we know it's not a vbscript error.
If you visit
http://vantagepoints.net/buy1.asp and run through the process using
all 5 available quantities, you see the error for some and not for
others.
Sorry, but I'm not going to do that: I'm at work.

In a nutshell, this code works as long as the quantity is 2 or 5.
Whose code is breaking? Yours or theirs? It sounds as if their code is
breaking...

amount = (product_price * book_copies) + ship_amount


Have you done:
Response.Write amount

and

Response.Write typename(amount )

? If not, do so. Perhaps you need to be more explicit, as John suggested.
Maybe:

amount=CDbl((pr oduct_price * CLng(book_copie s)) + ship_amount)

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 4 '05 #8
Bob,

I don't believe my code is breaking since it works for some values and
not for others. I use Authorize.net for payment processing on 3 other
sites, but this is first time doing something like this. Your
suggestion did not work, it still fails for values of 1,3 and 4 and
works for values of 2 and 5.

This code "amount = (product_price * book_copies) + ship_amount" returns
"Double" for Response.Write typename(amount )

This code "CDbl((product_ price * CLng(book_copie s)) + ship_amount)"
returns "Double for for Response.Write typename(amount )

"Response.W rite amount" returns a value like "54.84"

I just don't know.

Thanks....

Brett
ba****@sprynet. com

Bob Barrows [MVP] wrote:
BaWork wrote:
Bob,

It is an Authorize.net generated error that relates to the calculated
hash value not matching the server generated hash value.

So the error says that the "calculated hash value does not match the
server-generated hash value"? OK, now we know it's not a vbscript error.

If you visit
http://vantagepoints.net/buy1.asp and run through the process using
all 5 available quantities, you see the error for some and not for
others.

Sorry, but I'm not going to do that: I'm at work.

In a nutshell, this code works as long as the quantity is 2 or 5.

Whose code is breaking? Yours or theirs? It sounds as if their code is
breaking...

amount = (product_price * book_copies) + ship_amount

Have you done:
Response.Write amount

and

Response.Write typename(amount )

? If not, do so. Perhaps you need to be more explicit, as John suggested.
Maybe:

amount=CDbl((pr oduct_price * CLng(book_copie s)) + ship_amount)

Bob Barrows

Oct 4 '05 #9
BaWork wrote:
Bob,

I don't believe my code is breaking since it works for some values and
not for others. I use Authorize.net for payment processing on 3 other
sites, but this is first time doing something like this. Your
suggestion did not work, it still fails for values of 1,3 and 4 and
works for values of 2 and 5.

This code "amount = (product_price * book_copies) + ship_amount"
returns "Double" for Response.Write typename(amount )

For all values? If so, your code is doing nothing wrong.
This code "CDbl((product_ price * CLng(book_copie s)) + ship_amount)"
returns "Double for for Response.Write typename(amount )

"Response.W rite amount" returns a value like "54.84"

I just don't know.

Sorry, neither do I. It's probably got something to do with their hash
algorithm

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 4 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3152
by: chris vettese | last post by:
On my subform I have a field in the footer that totals the value of a field. On the main form I have referenced this field. I'm using this field in a calculation on my main form. The problem occurs when there are no records in the subform. The field on the main form that references the subform total field returns #Error. How can I make this field show the total when there are records and 0 when there are no records??? Thank you,...
5
2147
by: Aravind | last post by:
Hi folks. I have a form, frmHistory, that has the following code for its On Open event. =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-= Private Sub Form_Open(Cancel As Integer) Dim NumDays As Integer
1
1183
by: Maor Mishkin | last post by:
Hello All, I have a calculation problem, the system changes it's accuracy during the program, attached is a sample with the bug, you can compile it and run it in debug mode, then look at the changed result of ans1 & ans2. So the question now is how do I change the accuracy? Thanks Maor.
1
1392
by: Gas | last post by:
I am new to C#, I want to perfoem a calculation and I have a weird out come from the app. Here is the code double percentage = 0; percentage = ctrl1.Height / (ctrl1.Height+ ctrl2.Height) when I try to output the percentage, it is always 0.
6
1679
by: gsb58 | last post by:
Hi! Recently we, in Norway changed to three different VAT levels. All three needs to be on the invoice program. This is easy obtained via a new field and set the rowsource to valuelist and make the three values : 0;0,00;0,06;0,12;0,25. However my problem is calculating the orderlines and make them be summed in a textbox in the footer of the frmOrderlines.
3
3554
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really know nothing about advanced math, so I wrote a C program to help me: (BTW, I guess the result would be ln2.) #include <stdio.h>
1
1273
by: croxi | last post by:
Hello, I'm currently running Access 2007 in Spanish and VB8 in English. I need help regarding a problem I have with one of my Databases. What I have used is a MSoft Access 2007 template called "Inventory" which I have had to translate into Spanish. The problem I have had is to try and get the commands to translate as well between the English and Spanish versions of Access because the two are not exactly the same. What I'd like is to be able...
4
1913
rajiv07
by: rajiv07 | last post by:
I have a script to calculate the warranty the period of one year.I add 365 days of current date.I got the correct output for the year 2007 but the 2008 year calculation getting incorrect value.please anybody explain me what is happening here. #!/usr/bin/perl use Time::Local; my $time=timelocal(0,0,0,21,4,2007); my $warrenty=""; $warrenty=localtime($time+60*60*24*365);
6
1678
by: jenniferhelen | last post by:
I am having a problem with a calculation in Microsoft Access. I am trying to add two numeric columns, however the result I am receiving is the data is being concatenated. I am using the following formula: newField:(+). If field1 contains 567 and field2 contains -98, my result is 567-98 instead of 469. I have performed simular calcualtions many times and I am going nuts trying to figure out why this won't work. I appreciate any help you...
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.