Shopping cart bug.
Hi
I have a little problem with shopping cart which are written in classic asp.
I cannot seem to fix the bug where worldpay cannot accept the amount when it will submit the process. obivously there is something wrong with it.
In my knowledge in classic asp, for example like this,
file1.asp
<form>
if sCost = 0 then
<input type="hidden" name="amount" value="<%=netamount%>"/>
else
<input type="hidden" name="amount" value="<%=nett%>"/>
<form/>
file2.asp
<script>
dcost = request("deliverycost")
if dcost = 0 then
test = request.form("amount")
amount = test2
else
test1 = request.form("nett")
amount = test1
end if
<script>
The problem is that worldpay cannot accept the amount when dcost is more than 0. it show some error, saying currency or amount is not correct.
but it show correct amount when dcos is equal to 0, worldpay accept and process.
I had tried using different combination but none worked.
I am totally stuck there.
Here the partial code.
checkoutconfirm.asp
<script type="text/javascript">
function check(browser)
{
document.getElementById("nett").value=browser;
a = document.getElementById("nett").value=browser;
}
function invalid() {
if (document.BuyForm.nett.value =="") {
alert("Delivery option is blank. Please select option1 or option2");
document.BuyForm.nett.focus();
return false;
}
}
</script>
"code here go on until body tag"
<form action="checkoutprocess.asp" method="post" name="BuyForm" onSubmit='return invalid();'>
<%if check=2 or check=4 then %>
S<%= cursymbol & formatnumber(netamount) %><br />
<%else %>
S$<input type="text"name="nett" id="nett" size="8"readonly="true" />
<%end if%>
</span>
</td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
<input type="hidden" name="deliverycost" value="<%=sCost%>" />
<input type="hidden" name="subtotal" value="<%=subtotal%>" />
<%if sCost = 0 then %>
<input type="hidden" name="amount" value="<%=netamount%>" />
<%else%>
<input type="hidden" name="amount" value="<%=nett%>" />
<%end if%>
After that, i will submit information to checkoutprocess.asp to proceed the worldpay.
"checkoutprocess.asp"
<%@LANGUAGE="VBSCRIPT"%>
<%
If IsArray(Session("cart")) = false Then
response.redirect("ViewCart.asp")
End If
acart = Session("cart")
cempty = true
For i=lbound(acart) to ubound(acart)
If acart(i,0)<>"" and acart(i,1)<>"" Then
cempty=false
End If
Next
If cempty Then
response.redirect("ViewCart.asp")
End If
strstatus = "a"
dcost = request("deliverycost")
if dcost = 0 then
test=request.Form("amount")
subt = request("subtotal")
amount = test
dcost = test - subt
else
test2=request.Form("nett")
subt = request("subtotal")
amount = test2
dcost = test2 - subt
end if
'code go on here until u see body tag.
<body onLoad="redirectsumit();">
<FORM action="https://select.worldpay.com/wcc/purchase" method="post" name="BuyForm">
<INPUT name=instId type=hidden value="139979"> <%
desc = "Order No : " & orderid
cartID = desc & " " & now()
%>
<INPUT name="cartId" type=hidden value="<%=cartID%>">
<INPUT name="desc" type=hidden value="<%=desc%>">
<INPUT name="testMode" type=hidden value="100">
<% fullname = Request("userFname") & " " & Request("userLname")
%>
<INPUT name="name" type=hidden value="<%= fullname %>">
<INPUT name="address" type=hidden value="<%= Request("userAddress") %>">
<INPUT name="country" type=hidden value="<%= sCountry %>">
<INPUT name="postcode" type=hidden value="<%= Request("userZip") %>">
<INPUT name="email" type=hidden value="<%= Request("useremail") %>">
<INPUT TYPE=HIDDEN NAME=currency VALUE="SGD">
<INPUT TYPE=HIDDEN NAME=amount VALUE="<%= amount%>">
</form>
|