passing variable from asp.net to asp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ryna
    New Member
    • Oct 2009
    • 12

    passing variable from asp.net to asp

    Desperately need help....

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

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

    Ive tried using Request.form(Se ssion("res"), Session("res") in payResult.asp but still it doesnt work...
    Last edited by Frinavale; Oct 15 '09, 03:07 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags & indentation.
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    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:

    Code:
    Response.Redirect("payResult.asp?res=" & Session("res"))

    Hope that helps,
    CroCrew~

    Comment

    • ryna
      New Member
      • Oct 2009
      • 12

      #3
      hi crowcrew...

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

      =(

      Comment

      • CroCrew
        Recognized Expert Contributor
        • Jan 2008
        • 564

        #4
        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~

        Comment

        • ryna
          New Member
          • Oct 2009
          • 12

          #5
          problem with passing variable

          Here's the code..

          icePayment.aspx

          Code:
          Imports System.Data
          Imports System.Data.SqlClient
          
          Partial Class icePayment
              Inherits System.Web.UI.Page
          
              Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          
                  Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")
                  conn.Open()
          
                  Dim response_text As String
                  'Dim redirectStr As String
                  Dim input(9) As Object
                  Dim errorInput As String
                  Dim errorExist As Boolean
                  Dim inputName As Object  ' Object
                  Dim i As Integer
                  Dim j As Integer
                  Dim k As Integer
          
                  errorInput = ""
                  errorExist = False
                  inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"}
          
                  'get input from Form
                  For i = 0 To 8
                      Input(i) = Request.Form(inputName(i))
                  Next
                  'Check the Input is Empty
                  For j = 0 To 8
                      If IsNothing(Input(j)) Then
                          errorInput = errorInput & inputName(j) & " is blank.<BR>"
                          errorExist = True
                      End If
                  Next
                  'Check the Input is Numeric
                  For k = 0 To 5
                      If Not (IsNumeric(Input(k))) Then
                          errorInput = errorInput & inputName(k) & " is not numeric.<BR>"
                          errorExist = True
                      End If
                  Next
                  If Not (errorExist) Then
          
                  End If
          
                  Dim response_code As Integer
                  'Dim Msg As String
          
                  Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn)
          
                  Dim merchant As String = Request.Form("merchant_id")
                  Dim merchantDr As SqlDataReader
                  merchantDr = merchantSql.ExecuteReader()
          
          
                  response_code = 0
                  If merchantDr.Read() Then
                      response_code = 0
          
                      If merchant <> Trim(merchantDr("merchantID")) Then
                          response_text = "Invalid Merchant ID"
                          'Response.Redirect("MerchantError.aspx")
                      End If
          
                  Else
                  End If
                  merchantDr.Close()
                  conn.Close()
          
                  conn.Open()
                  Dim credit As String = Trim(Request.Form("card_num"))
                  Dim cardName As String = Trim(Request.Form("card_name"))
                  Dim cardType As String = (Request.Form("card_type"))
                  'Dim cardType As String = CDbl(Request.Form("card_type")) / 1
                  Dim amount As String = Trim(Request.Form("amount"))
                  Dim ref_code As String = Trim(Request.Form("ref_code"))
                  Dim desc As String
                  Dim time As Date
                  Dim randomNo As Single
                  Dim trans_date As String
                  Dim trans_code As String
                  Dim expireMonSql As Integer
                  Dim expireYrSql As Integer
                  Dim credit_limit As Object
                  Dim total_credit As Object
                  Dim credit_balance As Object
                  Dim merchant_balance As Object
                  Dim userID As Object
                  Dim mBalance As Object
                  Dim debit_account As Object
                  Dim credit_account As Object
                  Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon")))
                  Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr")))
                  '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)
                  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)
                  '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)
          
                  Dim creditDr As SqlDataReader
                  creditDr = creditSql.ExecuteReader()
          
                  If creditDr.Read() Then
                      response_code = 0
                     
                      If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then
                          response_text = "Invalid Credit Card No"
                       
                      Else
                          If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then
                              response_text = "Invalid Card Holder's Name"
                             
                              ' Label1.Text = cardName & Trim(UCase(creditDr("fullName")))
                          Else
                              'If cardType <> CDblcreditDr("cardType")) / 1 Then
                              If cardType <> (creditDr("cardType")) Then
                                  response_text = "Invalid Card Type"
                               
          
                              Else
                                  expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate")))
                                  expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate")))
                                  credit_limit = Trim(creditDr("creditLimit"))
                                  total_credit = Trim(creditDr("totalCredit"))
          
                                  If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then
                                      response_text = "Invalid Credit Card"
                                    
          
                                  ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then
                                      response_text = "Card limit is reached!"
                                    
                                  Else
                                      response_code = 1
                                      credit_balance = Trim(creditDr("creditBalance"))
                                      debit_account = Trim(creditDr("creditCardNo"))
                                      credit_account = Trim(creditDr("merchantID"))
                                      merchant_balance = Trim(creditDr("merchantBalance"))
                                      userID = Trim(creditDr("userID"))
          
          
                                      If (response_code = 1) Then
                                         
                                          If (CInt(credit_balance) = 0) Then
                                              credit_limit = CDbl(credit_limit) - CDbl(amount)
                                              credit_balance = -CDbl(amount)
          
                                          Else
                                              credit_balance = CDbl(credit_balance) - CDbl(amount)
          
          
                                              If (credit_balance >= 0) Then
                                                  credit_limit = total_credit
          
                                              Else
                                                  credit_limit = total_credit + credit_balance
          
                                              End If
                                          End If
          
                                          'mBalance = merchant_balance
                                          'mBalance = mBalance + CDbl(amount)
                                          'conn.Close()
                                          'conn.Open()
          
                                          ''update merchant balance
                                          'Dim updateMerchant As String
                                          'updateMerchant = "update iceMerchant set merchantBalance = '" & mBalance & "' where merchantID = '" & merchant & "'"
                                          'Dim cmdMerchant As New SqlCommand(updateMerchant, conn)
                                          'cmdMerchant.ExecuteNonQuery()
          
                                          'conn.Close()
                                          'conn.Open()
          
                                          ''edit iceCredit table
                                          'Dim updateCredit As String
                                          'updateCredit = "update iceCredit set creditBalance = '" & credit_balance & "',creditLimit = '" & credit_limit & "' where creditCardNo ='" & credit & "'  "
          
                                          'Dim cmdCredit As New SqlCommand(updateCredit, conn)
                                          'cmdCredit.ExecuteNonQuery()
          
          
                                          'Randomize(Timer())
                                          'randomNo = 0
                                          'Do While randomNo <= 1000
                                          '    randomNo = Int((9999 * Rnd()) + 1)
                                          'Loop
                                          'time = TimeOfDay()
                                          'trans_date = Today() & " " & TimeOfDay()
                                          'trans_code = "ICE-"
                                          'trans_code = trans_code & randomNo & Second(time) & "-" & Int(Timer())
                                          'Dim c1 As String = "Credit Card Transaction @"
                                          'Dim c2 As String = "</BR> Ref. Code: "
                                          'desc = c1 & time & c2 & ref_code
          
                                          'conn.Close()
                                          'conn.Open()
          
                                          ''insert(transaction)
                                          'Dim updateTrans As String
                                          '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 & "')"
          
                                          'Dim cmdTrans As New SqlCommand(updateTrans, conn)
                                          'cmdTrans.ExecuteNonQuery()
                                          ''Request.Form("response_code") = 1
                                          'response_text = "Transaction is success!!"
                                          ''redirectStr = Request.Form("return_url")
          
                                      End If
          
                                  End If
          
                                  If (Left(Request.Form("return_url"), 7) <> "http://") Then
                                      errorInput = errorInput & "Invalid return URL path! <BR>"
                                      errorExist = True
                                      Response.Redirect("inputerror.aspx")
                                      Response.Redirect("InvalidUrlError.aspx")
                              [B]    Else
                                   
                                      Session("res") = response_code
                                      Session("text") = response_text
                                    Response.Redirect((Request.Form("return_url")))
                                  End If[/B]
          
                                  If (errorExist) Then
                                      response_code = 0
                                      response_text = errorInput
                                  End If
                              End If
          
                          End If
          
                      End If
          
                  End If
                  'End If
          
          
                  creditDr.Close()
                  conn.Close()
          
              End Sub
          
          End Class
          payResult.asp

          Code:
          [B]<% if ( Request.Form(Session("res")) = 1) then %>
                       Thank You for buying GOODS from our online Store!
                       
                       <% else %>
                       I'm sorry,but there was a problem with this transaction.<br />
                       The server response was:<br />
          
                       <% = Request.Form(Session("text")) %> <br />
                       Go back to check Out page to enter information again<br />
                     
          <% end if %>[/B]

          Comment

          • CroCrew
            Recognized Expert Contributor
            • Jan 2008
            • 564

            #6
            There is no code that is redirecting to PayResult.asp

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

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

            Code:
            Response.Write("Here: " & Request.Form("return_url"))

            Comment

            • CroCrew
              Recognized Expert Contributor
              • Jan 2008
              • 564

              #7
              What do you get before the post and then what do you get after the post.

              Comment

              • CroCrew
                Recognized Expert Contributor
                • Jan 2008
                • 564

                #8
                Comment out the Response.Redire cts on the page too so you don’t get the error

                Comment

                • CroCrew
                  Recognized Expert Contributor
                  • Jan 2008
                  • 564

                  #9
                  Hello ryna,

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

                  icePayment.aspx
                  Code:
                  Imports System.Data 
                  Imports System.Data.SqlClient 
                    
                  Partial Class icePayment 
                      Inherits System.Web.UI.Page 
                    
                      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
                          Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true") 
                          conn.Open() 
                    
                          Dim response_text As String 
                          Dim input(9) As Object 
                          Dim errorInput As String 
                          Dim errorExist As Boolean 
                          Dim inputName As Object 
                          Dim i As Integer 
                          Dim j As Integer 
                          Dim k As Integer 
                    
                          errorInput = "" 
                          errorExist = False 
                          inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"} 
                    
                          For i = 0 To 8 
                              Input(i) = Request.Form(inputName(i)) 
                          Next 
                  
                          For j = 0 To 8 
                              If IsNothing(Input(j)) Then 
                                  errorInput = errorInput & inputName(j) & " is blank.<BR>" 
                                  errorExist = True 
                              End If 
                          Next 
                  
                          For k = 0 To 5 
                              If Not (IsNumeric(Input(k))) Then 
                                  errorInput = errorInput & inputName(k) & " is not numeric.<BR>" 
                                  errorExist = True 
                              End If 
                          Next 
                  
                          Dim response_code As Integer 
                          Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn) 
                    
                          Dim merchant As String = Request.Form("merchant_id") 
                          Dim merchantDr As SqlDataReader 
                          merchantDr = merchantSql.ExecuteReader() 
                    
                          response_code = 0 
                          If merchantDr.Read() Then 
                              response_code = 0 
                              If merchant <> Trim(merchantDr("merchantID")) Then 
                                  response_text = "Invalid Merchant ID" 
                              End If 
                          End If 
                          merchantDr.Close() 
                          conn.Close() 
                    
                          conn.Open() 
                          Dim credit As String = Trim(Request.Form("card_num")) 
                          Dim cardName As String = Trim(Request.Form("card_name")) 
                          Dim cardType As String = (Request.Form("card_type")) 
                          Dim amount As String = Trim(Request.Form("amount")) 
                          Dim ref_code As String = Trim(Request.Form("ref_code")) 
                          Dim desc As String 
                          Dim time As Date 
                          Dim randomNo As Single 
                          Dim trans_date As String 
                          Dim trans_code As String 
                          Dim expireMonSql As Integer 
                          Dim expireYrSql As Integer 
                          Dim credit_limit As Object 
                          Dim total_credit As Object 
                          Dim credit_balance As Object 
                          Dim merchant_balance As Object 
                          Dim userID As Object 
                          Dim mBalance As Object 
                          Dim debit_account As Object 
                          Dim credit_account As Object 
                          Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon"))) 
                          Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr"))) 
                          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) 
                    
                          Dim creditDr As SqlDataReader 
                          creditDr = creditSql.ExecuteReader() 
                    
                          If creditDr.Read() Then 
                              response_code = 0 
                              If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then 
                                  response_text = "Invalid Credit Card No" 
                              Else 
                                  If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then 
                                      response_text = "Invalid Card Holder's Name" 
                                  Else 
                                      If cardType <> (creditDr("cardType")) Then 
                                          response_text = "Invalid Card Type" 
                                      Else 
                                          expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate"))) 
                                          expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate"))) 
                                          credit_limit = Trim(creditDr("creditLimit")) 
                                          total_credit = Trim(creditDr("totalCredit")) 
                    
                                          If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then 
                                              response_text = "Invalid Credit Card" 
                                          ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then 
                                              response_text = "Card limit is reached!" 
                                          Else 
                                              response_code = 1 
                                              credit_balance = Trim(creditDr("creditBalance")) 
                                              debit_account = Trim(creditDr("creditCardNo")) 
                                              credit_account = Trim(creditDr("merchantID")) 
                                              merchant_balance = Trim(creditDr("merchantBalance")) 
                                              userID = Trim(creditDr("userID")) 
                                              If (response_code = 1) Then 
                                                  If (CInt(credit_balance) = 0) Then 
                                                      credit_limit = CDbl(credit_limit) - CDbl(amount) 
                                                      credit_balance = -CDbl(amount) 
                                                  Else 
                                                      credit_balance = CDbl(credit_balance) - CDbl(amount) 
                                                      If (credit_balance >= 0) Then 
                                                          credit_limit = total_credit 
                                                      Else 
                                                          credit_limit = total_credit + credit_balance 
                                                      End If 
                                                  End If 
                                              End If 
                                          End If 
                    
                                          If (Left(Request.Form("return_url"), 7) <> "http://") Then 
                                              errorInput = errorInput & "Invalid return URL path! <BR>" 
                                              errorExist = True 
                                              Response.Write("Going to redirect to user to: inputerror.aspx") 
                                              Response.Write("Going to redirect to user to: InvalidUrlError.aspx") 
                  							Response.End
                                          Else 
                                              Session("res") = response_code 
                                              Session("text") = response_text 
                  							Response.Write("Going to redirect to user to: return_url" & Request.Form("return_url"))
                  							Response.End
                                          End If 
                    
                                          If (errorExist) Then 
                                              response_code = 0 
                                              response_text = errorInput 
                                          End If 
                                      End If 
                                  End If 
                              End If 
                          End If 
                    
                          creditDr.Close() 
                          conn.Close() 
                      End Sub 
                  End Class
                  CroCrew~

                  Comment

                  • ryna
                    New Member
                    • Oct 2009
                    • 12

                    #10
                    this statement Request.Form("r eturn_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...

                    Comment

                    • CroCrew
                      Recognized Expert Contributor
                      • Jan 2008
                      • 564

                      #11
                      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~

                      Comment

                      • Frinavale
                        Recognized Expert Expert
                        • Oct 2006
                        • 9749

                        #12
                        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

                        Comment

                        • ryna
                          New Member
                          • Oct 2009
                          • 12

                          #13
                          Yes croCrew, I did copy and paste your code..
                          The output is: Going to redirect to user to: return_url payResult.asp

                          Comment

                          • ryna
                            New Member
                            • Oct 2009
                            • 12

                            #14
                            to Frinavale,Noted .

                            =)

                            Comment

                            • CroCrew
                              Recognized Expert Contributor
                              • Jan 2008
                              • 564

                              #15
                              Hello ryna,

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

                              icePayment.aspx
                              Code:
                              Imports System.Data  
                              Imports System.Data.SqlClient  
                                
                              Partial Class icePayment  
                                  Inherits System.Web.UI.Page  
                                
                                  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
                                      Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")  
                                      conn.Open()  
                                
                                      Dim response_text As String  
                                      Dim input(9) As Object  
                                      Dim errorInput As String  
                                      Dim errorExist As Boolean  
                                      Dim inputName As Object  
                                      Dim i As Integer  
                                      Dim j As Integer  
                                      Dim k As Integer  
                                
                                      errorInput = ""  
                                      errorExist = False  
                                      inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"}  
                                
                                      For i = 0 To 8  
                                          Input(i) = Request.Form(inputName(i))  
                                      Next  
                                
                                      For j = 0 To 8  
                                          If IsNothing(Input(j)) Then  
                                              errorInput = errorInput & inputName(j) & " is blank.<BR>"  
                                              errorExist = True  
                                          End If  
                                      Next  
                                
                                      For k = 0 To 5  
                                          If Not (IsNumeric(Input(k))) Then  
                                              errorInput = errorInput & inputName(k) & " is not numeric.<BR>"  
                                              errorExist = True  
                                          End If  
                                      Next  
                                
                                      Dim response_code As Integer  
                                      Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn)  
                                
                                      Dim merchant As String = Request.Form("merchant_id")  
                                      Dim merchantDr As SqlDataReader  
                                      merchantDr = merchantSql.ExecuteReader()  
                                
                                      response_code = 0  
                                      If merchantDr.Read() Then  
                                          response_code = 0  
                                          If merchant <> Trim(merchantDr("merchantID")) Then  
                                              response_text = "Invalid Merchant ID"  
                                          End If  
                                      End If  
                                      merchantDr.Close()  
                                      conn.Close()  
                                
                                      conn.Open()  
                                      Dim credit As String = Trim(Request.Form("card_num"))  
                                      Dim cardName As String = Trim(Request.Form("card_name"))  
                                      Dim cardType As String = (Request.Form("card_type"))  
                                      Dim amount As String = Trim(Request.Form("amount"))  
                                      Dim ref_code As String = Trim(Request.Form("ref_code"))  
                                      Dim desc As String  
                                      Dim time As Date  
                                      Dim randomNo As Single  
                                      Dim trans_date As String  
                                      Dim trans_code As String  
                                      Dim expireMonSql As Integer  
                                      Dim expireYrSql As Integer  
                                      Dim credit_limit As Object  
                                      Dim total_credit As Object  
                                      Dim credit_balance As Object  
                                      Dim merchant_balance As Object  
                                      Dim userID As Object  
                                      Dim mBalance As Object  
                                      Dim debit_account As Object  
                                      Dim credit_account As Object  
                                      Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon")))  
                                      Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr")))  
                                      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)  
                                
                                      Dim creditDr As SqlDataReader  
                                      creditDr = creditSql.ExecuteReader()  
                                
                                      If creditDr.Read() Then  
                                          response_code = 0  
                                          If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then  
                                              response_text = "Invalid Credit Card No"  
                                          Else  
                                              If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then  
                                                  response_text = "Invalid Card Holder's Name"  
                                              Else  
                                                  If cardType <> (creditDr("cardType")) Then  
                                                      response_text = "Invalid Card Type"  
                                                  Else  
                                                      expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate")))  
                                                      expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate")))  
                                                      credit_limit = Trim(creditDr("creditLimit"))  
                                                      total_credit = Trim(creditDr("totalCredit"))  
                                
                                                      If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then  
                                                          response_text = "Invalid Credit Card"  
                                                      ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then  
                                                          response_text = "Card limit is reached!"  
                                                      Else  
                                                          response_code = 1  
                                                          credit_balance = Trim(creditDr("creditBalance"))  
                                                          debit_account = Trim(creditDr("creditCardNo"))  
                                                          credit_account = Trim(creditDr("merchantID"))  
                                                          merchant_balance = Trim(creditDr("merchantBalance"))  
                                                          userID = Trim(creditDr("userID"))  
                                                          If (response_code = 1) Then  
                                                              If (CInt(credit_balance) = 0) Then  
                                                                  credit_limit = CDbl(credit_limit) - CDbl(amount)  
                                                                  credit_balance = -CDbl(amount)  
                                                              Else  
                                                                  credit_balance = CDbl(credit_balance) - CDbl(amount)  
                                                                  If (credit_balance >= 0) Then  
                                                                      credit_limit = total_credit  
                                                                  Else  
                                                                      credit_limit = total_credit + credit_balance  
                                                                  End If  
                                                              End If  
                                                          End If  
                                                      End If  
                                
                                                      If (Left(Request.Form("return_url"), 7) <> "http://") Then  
                                                          errorInput = errorInput & "Invalid return URL path! <BR>"  
                                                          errorExist = True  
                                                          Response.Write("Going to redirect to user to: inputerror.aspx")  
                                                          Response.Write("Going to redirect to user to: InvalidUrlError.aspx")  
                                                          Response.End 
                                                      Else  
                                                          Response.Redirect(Request.Form("return_url") & "?res=" & response_code & "&text=" & response_text) 
                                                      End If  
                                
                                                      If (errorExist) Then  
                                                          response_code = 0  
                                                          response_text = errorInput  
                                                      End If  
                                                  End If  
                                              End If  
                                          End If  
                                      End If  
                                
                                      creditDr.Close()  
                                      conn.Close()  
                                  End Sub  
                              End Class
                              payResult.asp
                              Code:
                              <%
                              	If (Request.QueryString("res") = 1) Then
                              		Response.Write("Thank You for buying GOODS from our online Store!")
                              	Else
                                      Response.Write("I'm sorry,but there was a problem with this transaction.<br />")
                              		Response.Write("The server response was:<br />")
                              		Response.Write(Request.QueryString("text") & "<br />")
                              		Response.Write("Go back to check Out page to enter information again<br />")  
                              	End If
                              %>

                              Comment

                              Working...