473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

passing variable from asp.net to asp

12
Desperately need help....

here's the snippet of my code that im trying to solve since last week...

icePayment.aspx
Expand|Select|Wrap|Line Numbers
  1. If (Left(Request.Form("return_url"), 7) <> "http://") Then 
  2.   errorInput = errorInput & "Invalid return URL path! <BR>" 
  3.   errorExist = True 
  4.   Response.Redirect("InvalidUrlError.aspx")
  5. Else 
  6.  Session( "res") = "1" 
  7.   TextBox2.Text = Session(Response.Redirect(Request.Form("res")"retu rn_url"))
payResult.asp
Expand|Select|Wrap|Line Numbers
  1. <% if ( Request.QueryString(Session("res") ) = "1") then %>
  2.   Thanks!
  3. <% else %>
  4.   sorry
  5. <% end if %> 
However,it could not be captured in payResult.asp

Ive tried using Request.form(Session("res"), Session("res") in payResult.asp but still it doesnt work...
Oct 13 '09 #1
23 3558
CroCrew
564 Expert 512MB
Hello Ryna,

If I understand your question/problem you have a scenario where your user is on a dotNet page and you want to redirect them to a Classic asp page and also pass in a variable to the Classic asp page too?

If that’s the case then pass the variable within the query string like this:

Expand|Select|Wrap|Line Numbers
  1. Response.Redirect("payResult.asp?res=" & Session("res"))
  2.  

Hope that helps,
CroCrew~
Oct 13 '09 #2
ryna
12
hi crowcrew...

its not working...it shows page error(The page cannot be displayed)

=(
Oct 14 '09 #3
CroCrew
564 Expert 512MB
Hello ryna,

So, I/we understand the situation better could you please post the code for both the pages? A 404 (page cannot be displayed) could be many things.

But, please before pasting your code for each page make sure you wrap the code of each page inside [code] tags.

Thanks,
CroCrew~
Oct 14 '09 #4
ryna
12
Here's the code..

icePayment.aspx

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports System.Data.SqlClient
  3.  
  4. Partial Class icePayment
  5.     Inherits System.Web.UI.Page
  6.  
  7.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  8.  
  9.         Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")
  10.         conn.Open()
  11.  
  12.         Dim response_text As String
  13.         'Dim redirectStr As String
  14.         Dim input(9) As Object
  15.         Dim errorInput As String
  16.         Dim errorExist As Boolean
  17.         Dim inputName As Object  ' Object
  18.         Dim i As Integer
  19.         Dim j As Integer
  20.         Dim k As Integer
  21.  
  22.         errorInput = ""
  23.         errorExist = False
  24.         inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"}
  25.  
  26.         'get input from Form
  27.         For i = 0 To 8
  28.             Input(i) = Request.Form(inputName(i))
  29.         Next
  30.         'Check the Input is Empty
  31.         For j = 0 To 8
  32.             If IsNothing(Input(j)) Then
  33.                 errorInput = errorInput & inputName(j) & " is blank.<BR>"
  34.                 errorExist = True
  35.             End If
  36.         Next
  37.         'Check the Input is Numeric
  38.         For k = 0 To 5
  39.             If Not (IsNumeric(Input(k))) Then
  40.                 errorInput = errorInput & inputName(k) & " is not numeric.<BR>"
  41.                 errorExist = True
  42.             End If
  43.         Next
  44.         If Not (errorExist) Then
  45.  
  46.         End If
  47.  
  48.         Dim response_code As Integer
  49.         'Dim Msg As String
  50.  
  51.         Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn)
  52.  
  53.         Dim merchant As String = Request.Form("merchant_id")
  54.         Dim merchantDr As SqlDataReader
  55.         merchantDr = merchantSql.ExecuteReader()
  56.  
  57.  
  58.         response_code = 0
  59.         If merchantDr.Read() Then
  60.             response_code = 0
  61.  
  62.             If merchant <> Trim(merchantDr("merchantID")) Then
  63.                 response_text = "Invalid Merchant ID"
  64.                 'Response.Redirect("MerchantError.aspx")
  65.             End If
  66.  
  67.         Else
  68.         End If
  69.         merchantDr.Close()
  70.         conn.Close()
  71.  
  72.         conn.Open()
  73.         Dim credit As String = Trim(Request.Form("card_num"))
  74.         Dim cardName As String = Trim(Request.Form("card_name"))
  75.         Dim cardType As String = (Request.Form("card_type"))
  76.         'Dim cardType As String = CDbl(Request.Form("card_type")) / 1
  77.         Dim amount As String = Trim(Request.Form("amount"))
  78.         Dim ref_code As String = Trim(Request.Form("ref_code"))
  79.         Dim desc As String
  80.         Dim time As Date
  81.         Dim randomNo As Single
  82.         Dim trans_date As String
  83.         Dim trans_code As String
  84.         Dim expireMonSql As Integer
  85.         Dim expireYrSql As Integer
  86.         Dim credit_limit As Object
  87.         Dim total_credit As Object
  88.         Dim credit_balance As Object
  89.         Dim merchant_balance As Object
  90.         Dim userID As Object
  91.         Dim mBalance As Object
  92.         Dim debit_account As Object
  93.         Dim credit_account As Object
  94.         Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon")))
  95.         Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr")))
  96.         'Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance  FROM iceUser INNER JOIN (  account_summary INNER JOIN iceCredit   ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Request.Form("card_num") & "' ", conn)
  97.         Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Trim(Request.Form("card_num")) & "' ", conn)
  98.         'Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID ", conn)
  99.  
  100.         Dim creditDr As SqlDataReader
  101.         creditDr = creditSql.ExecuteReader()
  102.  
  103.         If creditDr.Read() Then
  104.             response_code = 0
  105.  
  106.             If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then
  107.                 response_text = "Invalid Credit Card No"
  108.  
  109.             Else
  110.                 If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then
  111.                     response_text = "Invalid Card Holder's Name"
  112.  
  113.                     ' Label1.Text = cardName & Trim(UCase(creditDr("fullName")))
  114.                 Else
  115.                     'If cardType <> CDblcreditDr("cardType")) / 1 Then
  116.                     If cardType <> (creditDr("cardType")) Then
  117.                         response_text = "Invalid Card Type"
  118.  
  119.  
  120.                     Else
  121.                         expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate")))
  122.                         expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate")))
  123.                         credit_limit = Trim(creditDr("creditLimit"))
  124.                         total_credit = Trim(creditDr("totalCredit"))
  125.  
  126.                         If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then
  127.                             response_text = "Invalid Credit Card"
  128.  
  129.  
  130.                         ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then
  131.                             response_text = "Card limit is reached!"
  132.  
  133.                         Else
  134.                             response_code = 1
  135.                             credit_balance = Trim(creditDr("creditBalance"))
  136.                             debit_account = Trim(creditDr("creditCardNo"))
  137.                             credit_account = Trim(creditDr("merchantID"))
  138.                             merchant_balance = Trim(creditDr("merchantBalance"))
  139.                             userID = Trim(creditDr("userID"))
  140.  
  141.  
  142.                             If (response_code = 1) Then
  143.  
  144.                                 If (CInt(credit_balance) = 0) Then
  145.                                     credit_limit = CDbl(credit_limit) - CDbl(amount)
  146.                                     credit_balance = -CDbl(amount)
  147.  
  148.                                 Else
  149.                                     credit_balance = CDbl(credit_balance) - CDbl(amount)
  150.  
  151.  
  152.                                     If (credit_balance >= 0) Then
  153.                                         credit_limit = total_credit
  154.  
  155.                                     Else
  156.                                         credit_limit = total_credit + credit_balance
  157.  
  158.                                     End If
  159.                                 End If
  160.  
  161.                                 'mBalance = merchant_balance
  162.                                 'mBalance = mBalance + CDbl(amount)
  163.                                 'conn.Close()
  164.                                 'conn.Open()
  165.  
  166.                                 ''update merchant balance
  167.                                 'Dim updateMerchant As String
  168.                                 'updateMerchant = "update iceMerchant set merchantBalance = '" & mBalance & "' where merchantID = '" & merchant & "'"
  169.                                 'Dim cmdMerchant As New SqlCommand(updateMerchant, conn)
  170.                                 'cmdMerchant.ExecuteNonQuery()
  171.  
  172.                                 'conn.Close()
  173.                                 'conn.Open()
  174.  
  175.                                 ''edit iceCredit table
  176.                                 'Dim updateCredit As String
  177.                                 'updateCredit = "update iceCredit set creditBalance = '" & credit_balance & "',creditLimit = '" & credit_limit & "' where creditCardNo ='" & credit & "'  "
  178.  
  179.                                 'Dim cmdCredit As New SqlCommand(updateCredit, conn)
  180.                                 'cmdCredit.ExecuteNonQuery()
  181.  
  182.  
  183.                                 'Randomize(Timer())
  184.                                 'randomNo = 0
  185.                                 'Do While randomNo <= 1000
  186.                                 '    randomNo = Int((9999 * Rnd()) + 1)
  187.                                 'Loop
  188.                                 'time = TimeOfDay()
  189.                                 'trans_date = Today() & " " & TimeOfDay()
  190.                                 'trans_code = "ICE-"
  191.                                 'trans_code = trans_code & randomNo & Second(time) & "-" & Int(Timer())
  192.                                 'Dim c1 As String = "Credit Card Transaction @"
  193.                                 'Dim c2 As String = "</BR> Ref. Code: "
  194.                                 'desc = c1 & time & c2 & ref_code
  195.  
  196.                                 'conn.Close()
  197.                                 'conn.Open()
  198.  
  199.                                 ''insert(transaction)
  200.                                 'Dim updateTrans As String
  201.                                 'updateTrans = "insert into iceTransaction(trans_code, account_id, trans_amt, trans_date, trans_desc,tID) values ('" & trans_code & "','" & debit_account & "', '" & amount & "','" & trans_date & "','" & desc & "','" & userID & "')"
  202.  
  203.                                 'Dim cmdTrans As New SqlCommand(updateTrans, conn)
  204.                                 'cmdTrans.ExecuteNonQuery()
  205.                                 ''Request.Form("response_code") = 1
  206.                                 'response_text = "Transaction is success!!"
  207.                                 ''redirectStr = Request.Form("return_url")
  208.  
  209.                             End If
  210.  
  211.                         End If
  212.  
  213.                         If (Left(Request.Form("return_url"), 7) <> "http://") Then
  214.                             errorInput = errorInput & "Invalid return URL path! <BR>"
  215.                             errorExist = True
  216.                             Response.Redirect("inputerror.aspx")
  217.                             Response.Redirect("InvalidUrlError.aspx")
  218.                         Else
  219.  
  220.                             Session("res") = response_code
  221.                             Session("text") = response_text
  222.                           Response.Redirect((Request.Form("return_url")))
  223.                         End If
  224.  
  225.                         If (errorExist) Then
  226.                             response_code = 0
  227.                             response_text = errorInput
  228.                         End If
  229.                     End If
  230.  
  231.                 End If
  232.  
  233.             End If
  234.  
  235.         End If
  236.         'End If
  237.  
  238.  
  239.         creditDr.Close()
  240.         conn.Close()
  241.  
  242.     End Sub
  243.  
  244. End Class
  245.  
  246.  
payResult.asp

Expand|Select|Wrap|Line Numbers
  1. <% if ( Request.Form(Session("res")) = 1) then %>
  2.              Thank You for buying GOODS from our online Store!
  3.  
  4.              <% else %>
  5.              I'm sorry,but there was a problem with this transaction.<br />
  6.              The server response was:<br />
  7.  
  8.              <% = Request.Form(Session("text")) %> <br />
  9.              Go back to check Out page to enter information again<br />
  10.  
  11. <% end if %> 
Oct 14 '09 #5
CroCrew
564 Expert 512MB
There is no code that is redirecting to PayResult.asp

is that comming in form the Request.Form("return_url")?

Before the "Dim conn" line in your Page_Load add the following code:

Expand|Select|Wrap|Line Numbers
  1. Response.Write("Here: " & Request.Form("return_url")) 
  2.  
Oct 14 '09 #6
CroCrew
564 Expert 512MB
What do you get before the post and then what do you get after the post.
Oct 14 '09 #7
CroCrew
564 Expert 512MB
Comment out the Response.Redirects on the page too so you don’t get the error
Oct 14 '09 #8
CroCrew
564 Expert 512MB
Hello ryna,

Try substituting your code in “icePayment.aspx” with this code and run your solution and tell us what you get.

icePayment.aspx
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data 
  2. Imports System.Data.SqlClient 
  3.  
  4. Partial Class icePayment 
  5.     Inherits System.Web.UI.Page 
  6.  
  7.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
  8.         Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true") 
  9.         conn.Open() 
  10.  
  11.         Dim response_text As String 
  12.         Dim input(9) As Object 
  13.         Dim errorInput As String 
  14.         Dim errorExist As Boolean 
  15.         Dim inputName As Object 
  16.         Dim i As Integer 
  17.         Dim j As Integer 
  18.         Dim k As Integer 
  19.  
  20.         errorInput = "" 
  21.         errorExist = False 
  22.         inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"} 
  23.  
  24.         For i = 0 To 8 
  25.             Input(i) = Request.Form(inputName(i)) 
  26.         Next 
  27.  
  28.         For j = 0 To 8 
  29.             If IsNothing(Input(j)) Then 
  30.                 errorInput = errorInput & inputName(j) & " is blank.<BR>" 
  31.                 errorExist = True 
  32.             End If 
  33.         Next 
  34.  
  35.         For k = 0 To 5 
  36.             If Not (IsNumeric(Input(k))) Then 
  37.                 errorInput = errorInput & inputName(k) & " is not numeric.<BR>" 
  38.                 errorExist = True 
  39.             End If 
  40.         Next 
  41.  
  42.         Dim response_code As Integer 
  43.         Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn) 
  44.  
  45.         Dim merchant As String = Request.Form("merchant_id") 
  46.         Dim merchantDr As SqlDataReader 
  47.         merchantDr = merchantSql.ExecuteReader() 
  48.  
  49.         response_code = 0 
  50.         If merchantDr.Read() Then 
  51.             response_code = 0 
  52.             If merchant <> Trim(merchantDr("merchantID")) Then 
  53.                 response_text = "Invalid Merchant ID" 
  54.             End If 
  55.         End If 
  56.         merchantDr.Close() 
  57.         conn.Close() 
  58.  
  59.         conn.Open() 
  60.         Dim credit As String = Trim(Request.Form("card_num")) 
  61.         Dim cardName As String = Trim(Request.Form("card_name")) 
  62.         Dim cardType As String = (Request.Form("card_type")) 
  63.         Dim amount As String = Trim(Request.Form("amount")) 
  64.         Dim ref_code As String = Trim(Request.Form("ref_code")) 
  65.         Dim desc As String 
  66.         Dim time As Date 
  67.         Dim randomNo As Single 
  68.         Dim trans_date As String 
  69.         Dim trans_code As String 
  70.         Dim expireMonSql As Integer 
  71.         Dim expireYrSql As Integer 
  72.         Dim credit_limit As Object 
  73.         Dim total_credit As Object 
  74.         Dim credit_balance As Object 
  75.         Dim merchant_balance As Object 
  76.         Dim userID As Object 
  77.         Dim mBalance As Object 
  78.         Dim debit_account As Object 
  79.         Dim credit_account As Object 
  80.         Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon"))) 
  81.         Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr"))) 
  82.         Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Trim(Request.Form("card_num")) & "' ", conn) 
  83.  
  84.         Dim creditDr As SqlDataReader 
  85.         creditDr = creditSql.ExecuteReader() 
  86.  
  87.         If creditDr.Read() Then 
  88.             response_code = 0 
  89.             If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then 
  90.                 response_text = "Invalid Credit Card No" 
  91.             Else 
  92.                 If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then 
  93.                     response_text = "Invalid Card Holder's Name" 
  94.                 Else 
  95.                     If cardType <> (creditDr("cardType")) Then 
  96.                         response_text = "Invalid Card Type" 
  97.                     Else 
  98.                         expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate"))) 
  99.                         expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate"))) 
  100.                         credit_limit = Trim(creditDr("creditLimit")) 
  101.                         total_credit = Trim(creditDr("totalCredit")) 
  102.  
  103.                         If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then 
  104.                             response_text = "Invalid Credit Card" 
  105.                         ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then 
  106.                             response_text = "Card limit is reached!" 
  107.                         Else 
  108.                             response_code = 1 
  109.                             credit_balance = Trim(creditDr("creditBalance")) 
  110.                             debit_account = Trim(creditDr("creditCardNo")) 
  111.                             credit_account = Trim(creditDr("merchantID")) 
  112.                             merchant_balance = Trim(creditDr("merchantBalance")) 
  113.                             userID = Trim(creditDr("userID")) 
  114.                             If (response_code = 1) Then 
  115.                                 If (CInt(credit_balance) = 0) Then 
  116.                                     credit_limit = CDbl(credit_limit) - CDbl(amount) 
  117.                                     credit_balance = -CDbl(amount) 
  118.                                 Else 
  119.                                     credit_balance = CDbl(credit_balance) - CDbl(amount) 
  120.                                     If (credit_balance >= 0) Then 
  121.                                         credit_limit = total_credit 
  122.                                     Else 
  123.                                         credit_limit = total_credit + credit_balance 
  124.                                     End If 
  125.                                 End If 
  126.                             End If 
  127.                         End If 
  128.  
  129.                         If (Left(Request.Form("return_url"), 7) <> "http://") Then 
  130.                             errorInput = errorInput & "Invalid return URL path! <BR>" 
  131.                             errorExist = True 
  132.                             Response.Write("Going to redirect to user to: inputerror.aspx") 
  133.                             Response.Write("Going to redirect to user to: InvalidUrlError.aspx") 
  134.                             Response.End
  135.                         Else 
  136.                             Session("res") = response_code 
  137.                             Session("text") = response_text 
  138.                             Response.Write("Going to redirect to user to: return_url" & Request.Form("return_url"))
  139.                             Response.End
  140.                         End If 
  141.  
  142.                         If (errorExist) Then 
  143.                             response_code = 0 
  144.                             response_text = errorInput 
  145.                         End If 
  146.                     End If 
  147.                 End If 
  148.             End If 
  149.         End If 
  150.  
  151.         creditDr.Close() 
  152.         conn.Close() 
  153.     End Sub 
  154. End Class 
  155.  
CroCrew~
Oct 14 '09 #9
ryna
12
this statement Request.Form("return_url")) is redirecting to payResult.asp

when I execute the code it did when to payResult.asp but it show:

<% else %>

I'm sorry,but there was a problem with this transaction.<br />
The server response was:<br />

eventhough its successfully update and insert to database...
Oct 15 '09 #10
CroCrew
564 Expert 512MB
Hello ryna,

Yes, that is because DotNet “Session” variables will not pass across to Classic ASP pages. So your If—Then statement will fall into the “else” because the condition is “False”.

Did you copy and paste my last post over your code? I need to know what the output is when you run and submit your form with it to help you.

CroCrew~
Oct 15 '09 #11
Frinavale
9,735 Expert Mod 8TB
Ryna, I gave you this same answer in your other thread on the topic. Please do not double post your question because it makes it very hard for us to answer your question and it makes it hard for you to get the answer to your problem too (for example right now you probably didn't see the answer in your other thread).

Please refrain from double posting your questions in the future.

-Frinny
Oct 15 '09 #12
ryna
12
Yes croCrew, I did copy and paste your code..
The output is: Going to redirect to user to: return_url payResult.asp
Oct 15 '09 #13
ryna
12
to Frinavale,Noted.

=)
Oct 15 '09 #14
CroCrew
564 Expert 512MB
Hello ryna,

Try substituting both pages now with the below two pages and run your solution and tell us what you get.

icePayment.aspx
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data  
  2. Imports System.Data.SqlClient  
  3.  
  4. Partial Class icePayment  
  5.     Inherits System.Web.UI.Page  
  6.  
  7.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
  8.         Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")  
  9.         conn.Open()  
  10.  
  11.         Dim response_text As String  
  12.         Dim input(9) As Object  
  13.         Dim errorInput As String  
  14.         Dim errorExist As Boolean  
  15.         Dim inputName As Object  
  16.         Dim i As Integer  
  17.         Dim j As Integer  
  18.         Dim k As Integer  
  19.  
  20.         errorInput = ""  
  21.         errorExist = False  
  22.         inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"}  
  23.  
  24.         For i = 0 To 8  
  25.             Input(i) = Request.Form(inputName(i))  
  26.         Next  
  27.  
  28.         For j = 0 To 8  
  29.             If IsNothing(Input(j)) Then  
  30.                 errorInput = errorInput & inputName(j) & " is blank.<BR>"  
  31.                 errorExist = True  
  32.             End If  
  33.         Next  
  34.  
  35.         For k = 0 To 5  
  36.             If Not (IsNumeric(Input(k))) Then  
  37.                 errorInput = errorInput & inputName(k) & " is not numeric.<BR>"  
  38.                 errorExist = True  
  39.             End If  
  40.         Next  
  41.  
  42.         Dim response_code As Integer  
  43.         Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn)  
  44.  
  45.         Dim merchant As String = Request.Form("merchant_id")  
  46.         Dim merchantDr As SqlDataReader  
  47.         merchantDr = merchantSql.ExecuteReader()  
  48.  
  49.         response_code = 0  
  50.         If merchantDr.Read() Then  
  51.             response_code = 0  
  52.             If merchant <> Trim(merchantDr("merchantID")) Then  
  53.                 response_text = "Invalid Merchant ID"  
  54.             End If  
  55.         End If  
  56.         merchantDr.Close()  
  57.         conn.Close()  
  58.  
  59.         conn.Open()  
  60.         Dim credit As String = Trim(Request.Form("card_num"))  
  61.         Dim cardName As String = Trim(Request.Form("card_name"))  
  62.         Dim cardType As String = (Request.Form("card_type"))  
  63.         Dim amount As String = Trim(Request.Form("amount"))  
  64.         Dim ref_code As String = Trim(Request.Form("ref_code"))  
  65.         Dim desc As String  
  66.         Dim time As Date  
  67.         Dim randomNo As Single  
  68.         Dim trans_date As String  
  69.         Dim trans_code As String  
  70.         Dim expireMonSql As Integer  
  71.         Dim expireYrSql As Integer  
  72.         Dim credit_limit As Object  
  73.         Dim total_credit As Object  
  74.         Dim credit_balance As Object  
  75.         Dim merchant_balance As Object  
  76.         Dim userID As Object  
  77.         Dim mBalance As Object  
  78.         Dim debit_account As Object  
  79.         Dim credit_account As Object  
  80.         Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon")))  
  81.         Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr")))  
  82.         Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Trim(Request.Form("card_num")) & "' ", conn)  
  83.  
  84.         Dim creditDr As SqlDataReader  
  85.         creditDr = creditSql.ExecuteReader()  
  86.  
  87.         If creditDr.Read() Then  
  88.             response_code = 0  
  89.             If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then  
  90.                 response_text = "Invalid Credit Card No"  
  91.             Else  
  92.                 If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then  
  93.                     response_text = "Invalid Card Holder's Name"  
  94.                 Else  
  95.                     If cardType <> (creditDr("cardType")) Then  
  96.                         response_text = "Invalid Card Type"  
  97.                     Else  
  98.                         expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate")))  
  99.                         expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate")))  
  100.                         credit_limit = Trim(creditDr("creditLimit"))  
  101.                         total_credit = Trim(creditDr("totalCredit"))  
  102.  
  103.                         If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then  
  104.                             response_text = "Invalid Credit Card"  
  105.                         ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then  
  106.                             response_text = "Card limit is reached!"  
  107.                         Else  
  108.                             response_code = 1  
  109.                             credit_balance = Trim(creditDr("creditBalance"))  
  110.                             debit_account = Trim(creditDr("creditCardNo"))  
  111.                             credit_account = Trim(creditDr("merchantID"))  
  112.                             merchant_balance = Trim(creditDr("merchantBalance"))  
  113.                             userID = Trim(creditDr("userID"))  
  114.                             If (response_code = 1) Then  
  115.                                 If (CInt(credit_balance) = 0) Then  
  116.                                     credit_limit = CDbl(credit_limit) - CDbl(amount)  
  117.                                     credit_balance = -CDbl(amount)  
  118.                                 Else  
  119.                                     credit_balance = CDbl(credit_balance) - CDbl(amount)  
  120.                                     If (credit_balance >= 0) Then  
  121.                                         credit_limit = total_credit  
  122.                                     Else  
  123.                                         credit_limit = total_credit + credit_balance  
  124.                                     End If  
  125.                                 End If  
  126.                             End If  
  127.                         End If  
  128.  
  129.                         If (Left(Request.Form("return_url"), 7) <> "http://") Then  
  130.                             errorInput = errorInput & "Invalid return URL path! <BR>"  
  131.                             errorExist = True  
  132.                             Response.Write("Going to redirect to user to: inputerror.aspx")  
  133.                             Response.Write("Going to redirect to user to: InvalidUrlError.aspx")  
  134.                             Response.End 
  135.                         Else  
  136.                             Response.Redirect(Request.Form("return_url") & "?res=" & response_code & "&text=" & response_text) 
  137.                         End If  
  138.  
  139.                         If (errorExist) Then  
  140.                             response_code = 0  
  141.                             response_text = errorInput  
  142.                         End If  
  143.                     End If  
  144.                 End If  
  145.             End If  
  146.         End If  
  147.  
  148.         creditDr.Close()  
  149.         conn.Close()  
  150.     End Sub  
  151. End Class  
  152.  
payResult.asp
Expand|Select|Wrap|Line Numbers
  1. <%
  2.     If (Request.QueryString("res") = 1) Then
  3.         Response.Write("Thank You for buying GOODS from our online Store!")
  4.     Else
  5.         Response.Write("I'm sorry,but there was a problem with this transaction.<br />")
  6.         Response.Write("The server response was:<br />")
  7.         Response.Write(Request.QueryString("text") & "<br />")
  8.         Response.Write("Go back to check Out page to enter information again<br />")  
  9.     End If
  10. %>
  11.  
Oct 15 '09 #15
CroCrew
564 Expert 512MB
Sorry just made a change to "payResult.asp" Check that page again if you seen it before I made the edits.
Oct 15 '09 #16
ryna
12
hi CroCrew,

it show page not found (404)...
Oct 19 '09 #17
CroCrew
564 Expert 512MB
Is "payResult.asp" in the same folder that "icePayment.aspx" is in? Are you getting a 404 when going to "payResult.asp"? Post the error that your getting.
Oct 19 '09 #18
Frinavale
9,735 Expert Mod 8TB
Ryna, a 404 error means that it can't find the page that you're redirecting to.

You should check to make sure that the URLs are correct.

Try using the .NET debugger (that comes with VisualStudio) to step through your code and make sure that the URLs are pointing to the right place. If you don't want to use the debugger for some reason you could try hard coding the URL of the payResult.asp page:


Expand|Select|Wrap|Line Numbers
  1. 'What are you doing here?????
  2. If (Left(Request.Form("return_url"), 7) <> "http://") Then
  3.   errorInput = errorInput & "Invalid return URL path! <BR>"
  4.   errorExist = True
  5.   Response.Redirect("inputerror.aspx")
  6. 'The following line will not be executed..................
  7. 'Anything that comes after a Response.Redirect is not executed
  8.   Response.Redirect("InvalidUrlError.aspx")
  9. Else  
  10.   Session("res") = response_code
  11.   Session("text") = response_text
  12. 'Instead of this please try hard coding the return url 
  13. '  Response.Redirect((Request.Form("return_url")))
  14. 'Try this instead 
  15. '(Make sure that the URL is correctly pointing to the payResult.asp page):
  16.   Response.Redirect("http://localhost/websiteDirectory/payResult.asp?res=" & response_code,True)
  17. End If
Oct 19 '09 #19
ryna
12
hi croCrew...
my fault.The codes that you want me to test it works but

Response.Redirect(Request.Form("return_url") & "?res=" & response_code & "&text=" & response_text)
the one in bold there's curly line below...
it says variable"response_text" is used before it has been assigned a value.A null reference exception could result in at runtime.

it almost working..
Oct 20 '09 #20
ryna
12
when I enter the wrong credit card it did not show the error message
which is : response_text = "Invalid Credit Card No"

however when it is successful(enter correct information) it print out this line:
Response.Write("Thank You for buying GOODS from our online Store!")
Oct 20 '09 #21
CroCrew
564 Expert 512MB
Hello ryna,

So, is this resolved? You have your answer?

CroCrew~
Oct 20 '09 #22
ryna
12
im afraid not yet croCrew..
still stuck oon receiving the response_text...
Oct 21 '09 #23
Sir I need help in understanding this code..Any help will be appreciated :

Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")
Oct 23 '09 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
6
by: MSDNAndi | last post by:
Hi, I get the following warning: "Possibly incorrect assignment to local 'oLockObject' which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
3
by: James Robertson | last post by:
I am new to the ASP and VB thing so be kind. Question I have is that I have created an ASPX web site to use as an E-Mail page. But I want to use this for a lot of users. Can I create the link on...
3
by: DaTurk | last post by:
If I call this method, and pass it a byte by ref, and initialize another byte array, set the original equal to it, and then null the reference, why is the original byte array not null as well? I...
11
by: =?Utf-8?B?U3VqZWV0?= | last post by:
If there are long strings (like 1MB or 2MB) is it more performant to pass those by ref to methods or by value?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.