SagePay Direct and HttpWebRequest

Discussion in 'Third-party applications' started by oxbofficeco, Jan 8, 2010.

  1. Hi there,

    I'm wanting to use SagePay's direct integration, but I'm a bit concerned that the use of the HttpWebRequest class could be a problem on the DiscountASP.net.

    Below is a sample of some code from the integration kit provided by SagePay. Does anyone know if the use of the HttpWebRequest/Response classes will work as shown below.

    Thanks

    Mark

    Dim objUTFEncode As New UTF8Encoding
    Dim arrRequest As Byte()
    Dim objStreamReq As Stream
    Dim objStreamRes As StreamReader
    Dim objHttpRequest As HttpWebRequest
    Dim objHttpResponse As HttpWebResponse
    Dim objUri As New Uri(SystemURL(strConnectTo, "purchase"))

    objHttpRequest = HttpWebRequest.Create(objUri)
    objHttpRequest.KeepAlive = False
    objHttpRequest.Method = "POST"

    objHttpRequest.ContentType = "application/x-www-form-urlencoded"
    arrRequest = objUTFEncode.GetBytes(strPost)
    objHttpRequest.ContentLength = arrRequest.Length

    objStreamReq = objHttpRequest.GetRequestStream()
    objStreamReq.Write(arrRequest, 0, arrRequest.Length)
    objStreamReq.Close()

    'Get response
    objHttpResponse = objHttpRequest.GetResponse()
    objStreamRes = New StreamReader(objHttpResponse.GetResponseStream(), Encoding.ASCII)

    strResponse = objStreamRes.ReadToEnd()
    objStreamRes.Close()
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    You should be able to make outbound http connections from your web app.
     

Share This Page