MSXML.ServerXMLHTTP.3.0. returns error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • microcrafters
    New Member
    • Nov 2006
    • 1

    #1

    MSXML.ServerXMLHTTP.3.0. returns error

    Hello I am trying to set up a postback page for paypal. I got the code from paypal but it keeps returning the following error:

    Server Error in '/' Application.

    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security .SecurityExcept ion: Request for the permission of type 'System.Securit y.Permissions.S ecurityPermissi on, mscorlib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' failed.

    Source Error:


    Line 25:
    Line 26: 'objHttp = Server.CreateOb ject("Microsoft .XMLHTTP")
    Line 27: objHttp = Server.CreateOb ject("MSXML.Ser verXMLHTTP.3.0. ")
    Line 28: objHttp.open("P OST", "https://www.sandbox.pay pal.com/cgi-bin/webscr", False)
    Line 29: objHttp.setRequ estHeader("Cont ent-type", "applicatio n/x-www-form-urlencoded")

    this is the code I am trying to run from paypal.

    (sorry the code is so long I wanted to make sure you could see everything)
    Code:
               Try
                Dim authToken, txToken As String
                Dim query As String
                Dim objHttp As Object
                Dim sQuerystring As String
                Dim sParts() As String
                Dim iParts As Integer
                Dim aParts() As String
                Dim sResults(0, 0), sKey, sValue As String
                Dim i As Integer
                Dim txstatus, firstName, lastName, businessname, email, itemnumber, itemName, mcGross, mcCurrency, custom, test_pdt As String
                
                authToken = "myPayPalToken"
                
                txToken = Request.QueryString("tx").ToString()
                
                query = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken & "&test_pdt=" & test_pdt
                
                'objHttp = Server.CreateObject("Microsoft.XMLHTTP")
                objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
                tbNotes.Text = "server.createObject completed"
                objHttp.open("POST", "https://www.paypal.com/cgi-bin/webscr", False)
                objHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
                objHttp.Send(query)
        
                sQuerystring = objHttp.responseText
    
        
                If Mid(sQuerystring, 1, 7) = "SUCCESS" Then
                    txstatus = "SUCCESS"
    
                    sQuerystring = Mid(sQuerystring, 9)
                    sParts = Split(sQuerystring, vbLf)
                    iParts = UBound(sParts) - 1
                    ReDim sResults(iParts, 1)
                    For i = 0 To iParts
                        aParts = Split(sParts(i), "=")
                        sKey = aParts(0)
                        sValue = aParts(1)
                        sResults(i, 0) = sKey
                        sResults(i, 1) = sValue
    
                        Select Case sKey
                            Case "first_name"
                                firstName = sValue
                            Case "last_name"
                                lastName = sValue
                            Case "payer_business_name"
                                businessname = sValue
                            Case "payer_email"
                                email = sValue.Replace("%40", "@")
                            Case "item_number"
                                itemnumber = sValue
                            Case "item_name"
                                itemName = sValue
                            Case "mc_gross"
                                mcGross = sValue
                            Case "mc_currency"
                                mcCurrency = sValue
                            Case "custom"
                                custom = sValue
                        End Select
                    Next
                    tbEmail.Text = email
    
                    ' Response.Write("<p><h3>Your order has been received.</h3></p>")
                    ' Response.Write("<b>Details</b><br>")
                    ' Response.Write("<li>Name: " & firstName & " " & lastName & "</li>")
                    ' Response.Write("<li>Business: " & businessname & "</li>")
                    ' Response.Write("<li>Email: " & email & "</li>")
                    ' Response.Write("<li>Item: " & itemnumber & "</li>")
                    ' Response.Write("<li>Description: " & itemName & "</li>")
                    ' Response.Write("<li>Amount: " & mcCurrency & " " & mcGross & "</li>")
                    ' Response.Write("<li>Custom: " & custom & "</li>")
                    ' Response.Write("<hr>")
    
                Else
                    'if payment failed redirect to home page  
                    Response.Redirect("~/default.aspx")
                End If
    
            Catch ex As Exception
    
                'Response.Write(ex.Message)
            End Try
    Thanks Gary
Working...