Click here to Skip to main content
16,006,442 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How can I disable back and forward button in browser? Pin
Ashish Kumar Vyas10-Sep-07 20:48
Ashish Kumar Vyas10-Sep-07 20:48 
GeneralRe: How can I disable back and forward button in browser? Pin
Chetan Patel11-Sep-07 22:59
Chetan Patel11-Sep-07 22:59 
QuestionHow to get the list of all the PCs connected in a network Pin
tonymathewt10-Sep-07 18:49
professionaltonymathewt10-Sep-07 18:49 
Questionauto update database Pin
MidoYC10-Sep-07 18:48
MidoYC10-Sep-07 18:48 
AnswerRe: auto update database Pin
Paul Conrad30-Sep-07 13:43
professionalPaul Conrad30-Sep-07 13:43 
QuestionHow do i place my ocx in vb.net form Pin
Kolachana10-Sep-07 17:32
Kolachana10-Sep-07 17:32 
AnswerRe: How do i place my ocx in vb.net form Pin
Chetan Patel10-Sep-07 20:33
Chetan Patel10-Sep-07 20:33 
QuestionVB.NET Codefiles Pin
newbie1234567891010-Sep-07 15:53
newbie1234567891010-Sep-07 15:53 
Hello
I have been using VB for an @ page directive extender. I now need to add code for Paypal PDT (Payment Data Transfer). This code is currently commented out in my project as you can see.

The first chunk of code is for extending the @ page directive.
'Imports System '1
'Imports System.Web.UI '1
'Imports System.Web.UI.HtmlControls '1
'Imports System.Web.UI.HtmlControls.HtmlGenericControl '1

'Partial Class Store_thankyou '1

' Inherits BasePage '1

' Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load'1
' Dim body As HtmlGenericControl'1
' body = Master.FindControl("body")'1
' body.Attributes.Add("class", "store")'1
' End Sub
'End Class '1

The 2nd chunk of code is for the paypal side of things:
Imports System.Net
Imports System.IO
Imports System.Text
Public Class store_thankyou
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here


Dim tx, PDTvalidateQuery, token As String
Dim strResponse As HttpWebResponse
Dim temp As String
Dim PDTArray() As String
Dim iParts, sResults(0, 0), aParts(), sParts(), sKey, sValue As String
Dim i As Integer
Dim firstname, lastName, itemName, mcGross, mcCurrency As String

'set this to token from PayPal account

token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

'set tx to value of tx passed in via Querystring from PayPal
tx = Request.QueryString("tx")

'set string = to the cmd value, tx and at that needs to be
'POSTed back to PayPal to validate the PDT
PDTvalidateQuery = "cmd=_notify-synch&tx=" & tx & _
"&at=" & token

'Now we need to POST this info back to PayPal for validation
'of the PDT

' Create the request back
Dim req As HttpWebRequest = CType(WebRequest.Create("https://www.sandbox.paypal.com/cgi-bin/webscr"), _
HttpWebRequest)

' Set values for the request back
req.Method = "POST" 'set method
'set content type
req.ContentType = "application/x-www-form-urlencoded"
'set length
req.ContentLength = PDTvalidateQuery.Length

' Write the request back to PayPal
Dim stOut As StreamWriter = New StreamWriter(req.GetRequestStream(), _
Encoding.ASCII)
stOut.Write(PDTvalidateQuery)
stOut.Close()


Try
strResponse = CType(req.GetResponse(), HttpWebResponse)

Catch ex As SystemException

'############################################
'ADD CODE HERE TO HANDLE AN EXCEPTION IF THE SCRIPT
'CANNOT GET THE RESPONSE FROM PAYPAL
'############################################


End Try


'Once we write the stream back to PayPal, we need to read the
'response.

Dim IPNResponseStream As Stream = strResponse.GetResponseStream
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
Dim readStream As New StreamReader(IPNResponseStream, encode)

'read the response into a String variable "temp"
temp = readStream.ReadToEnd


'Check to see if the 1st line of the response was "SUCCESS"
If Mid(temp, 1, 7) = "SUCCESS" Then

'if it is SUCCESS, the code below puts the
'response in a nice array
temp = Mid(temp, 9)
sParts = Split(temp, 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


'add more case statements here in order to access other returned variables

Select Case sKey
Case "first_name"
firstname = sValue
Case "last_name"
lastName = sValue
Case "item_name"
itemName = sValue
Case "mc_gross"
mcGross = sValue
Case "mc_currency"
mcCurrency = sValue
End Select

Next

'############################################
'This is where the script begins to output the
'receipt page.
'############################################

Response.Write("<h2><b>Thanks for your Order!!</b></h2><br><br>")

Response.Write("<li>Name: " & firstname & " " & lastName & "</li>")
Response.Write("<li>Description: " & itemName & "</li>")
Response.Write("<li>Amount: " & mcCurrency & " " & mcGross & "</li>")
Response.Write("<hr>")


'debug
OutputEntirePDTString(temp)


Else
' IF PDT response is "FAIL" - investigate
Response.Write("Error - PDT FAIL")
End If

'close opened streams
readStream.Close()
strResponse.Close()

End Sub

Private Function OutputEntirePDTString(ByVal myPDTString As String) As String

Dim tempString() As String = Split(myPDTString, vbLf)
Dim x As Integer

For x = 0 To tempString.GetUpperBound(0)

Response.Write(tempString(x) & "<br>")

Next

End Function

End Class

How can I get the two pieces of code to work together?
AnswerRe: VB.NET Codefiles Pin
Chetan Patel10-Sep-07 20:31
Chetan Patel10-Sep-07 20:31 
QuestionRe: VB.NET Codefiles Pin
newbie1234567891011-Sep-07 5:47
newbie1234567891011-Sep-07 5:47 
AnswerRe: VB.NET Codefiles Pin
Chetan Patel11-Sep-07 23:10
Chetan Patel11-Sep-07 23:10 
GeneralRe: VB.NET Codefiles Pin
newbie1234567891012-Sep-07 3:19
newbie1234567891012-Sep-07 3:19 
QuestionGo Sub is gone how do I do it now? [modified] Pin
frankiebaby210-Sep-07 12:29
frankiebaby210-Sep-07 12:29 
AnswerRe: Go Sub is gone how do I do it now? Pin
Christian Graus10-Sep-07 13:15
protectorChristian Graus10-Sep-07 13:15 
GeneralRe: Go Sub is gone how do I do it now? [modified] Pin
frankiebaby210-Sep-07 13:55
frankiebaby210-Sep-07 13:55 
GeneralRe: Go Sub is gone how do I do it now? Pin
Christian Graus10-Sep-07 14:35
protectorChristian Graus10-Sep-07 14:35 
GeneralRe: Go Sub is gone how do I do it now? Pin
frankiebaby210-Sep-07 14:54
frankiebaby210-Sep-07 14:54 
GeneralRe: Go Sub is gone how do I do it now? Pin
Christian Graus10-Sep-07 14:57
protectorChristian Graus10-Sep-07 14:57 
GeneralRe: Go Sub is gone how do I do it now? Pin
frankiebaby210-Sep-07 15:10
frankiebaby210-Sep-07 15:10 
GeneralRe: Go Sub is gone how do I do it now? Pin
Christian Graus10-Sep-07 15:19
protectorChristian Graus10-Sep-07 15:19 
Questionregarding insertion of records Pin
joeashk10-Sep-07 10:34
joeashk10-Sep-07 10:34 
AnswerRe: regarding insertion of records Pin
Christian Graus10-Sep-07 10:53
protectorChristian Graus10-Sep-07 10:53 
Questionregarding insertion of records Pin
edwin_manic10-Sep-07 10:19
edwin_manic10-Sep-07 10:19 
AnswerRe: regarding insertion of records Pin
Colin Angus Mackay10-Sep-07 11:18
Colin Angus Mackay10-Sep-07 11:18 
QuestionDistorted text? Pin
jensenx10-Sep-07 9:19
jensenx10-Sep-07 9:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.