here's how it works:
1: someone makes an order/subscription through your site's account,
2: paypal send the details to a page on your server which will handle the results,
3: your page must get the querystring names & values and send them straight back to paypal, so paypal can evaluate the values to see if they really came from paypal to beging with,and that they were not altered,
4: paypal then sends back a response, if response = validated then You.DoYourThing else response = "invalid" then You.DoYourOtherThing
my problem is that i don't think i'm actually getting all the querystring names and values with my script and sending them back to paypal sucsessfully. So THAT'S why i'm here, to see if you guys can tell me if my script looks like that's what it's supposed to be doing, recieving querystring info, and sending it straight back in the same format.
i am very new to all programming, so i BARELY understood what i did so far, so i wouldn't doubt that it's wrong, but i can't see where, and paypal doesn't give many
vb.net examples, most are php, cold fusion, c#(which is what i based MY script off of (the C# example)), and perl.
they gave a
vb.net example, but i don't really understand how to use it, because i'm always working with aspx pages,a nd i THINK it's a service module example, actually, you tell me, here it is:
Code:
ASP.Net/VB
Imports System.Net
Imports System.IO
Imports System.Text
Public Class IPNHandler
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
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
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
Dim strFormValues As String = Request.Form.ToString()
Dim strNewValue, strResponse
' Create the request back
Dim req As HttpWebRequest = CType(WebRequest.Create("https://www.paypal.com/cgi-bin/webscr"), _
HttpWebRequest)
' Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
strNewValue = strFormValues + "&cmd=_notify-validate"
req.ContentLength = strNewValue.Length
' Write the request back IPN strings
Dim stOut As StreamWriter = New StreamWriter(req.GetRequestStream(), _
Encoding.ASCII)
stOut.Write(strNewValue)
stOut.Close()
and here's the C# i based MINE off of:
Code:
ASP.Net/C#
/// <summary>
/// Verifies the IPN message from PayPal
/// </summary>
/// <remarks>
/// Add code under Create the IpnTransaction to process your IPN
/// </remarks>
public class IpnHandler : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string strFormValues = Request.Form.ToString();
string strNewValue;
string strResponse;
// Create the request back
HttpWebRequest req = (HttpWebRequest) WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");
// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
strNewValue = strFormValues + "&cmd=_notify-validate";
req.ContentLength = strNewValue.Length;
// Write the request back IPN strings
StreamWriter stOut = new StreamWriter (req.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(strNewValue);
stOut.Close();
// Do the request to PayPal and get the response
StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
strResponse = stIn.ReadToEnd();
stIn.Close();
// Confirm whether the IPN was VERIFIED or INVALID. If INVALID, just ignore the IPN
if (strResponse == "VERIFIED")
{
// Create the IpnTransaction
}
}
}
ANY help at all is apreciated, even if you could just tell me if those two example were supposed to be .asmx files, but i'd be grateful as well if someone could tell me wht is wrong with my script. by the way, i AM getting a final response from paypal, but it's "invalid".
here's MY script:
<%@ Import namespace="System.NET" %>
<%@ Import namespace="System.data" %>
<%@ Import namespace="System.IO" %>
<%@ Import namespace="System.data.OLEDB" %>
<SCRIPT RUNAT=SERVER LANGUAGE="
VB">
Sub Page_Load(Sender As Object, E As EventArgs)
DIM SUBSCRIPTIONVALUES AS STRING = REQUEST.FORM.TOSTRING()
DIM REQ AS HTTPWEBREQUEST = CType(WebRequest.Create("https://www.sandbox.paypal.com/cgi-bin/webscr"), HttpWebRequest)
DIM CHECKSUBSCRIPTION AS STRING = SUBSCRIPTIONVALUES & "&cmd=_notify-validate"
REQ.METHOD = "POST"
REQ.CONTENTTYPE = "APPLICATION/X-WWW-FORM-URLENCODED"
REQ.CONTENTLENGTH = CHECKSUBSCRIPTION.LENGTH
DIM SENDVERIFY AS STREAMWRITER = NEW STREAMWRITER(REQ.GETREQUESTSTREAM(),SYSTEM.TEXT.EN CODING.ASCII)
SENDVERIFY.WRITE(CHECKSUBSCRIPTION)
SENDVERIFY.CLOSE()
DIM RETURNINFO AS STREAMREADER = NEW STREAMREADER(REQ.GETRESPONSE().GETRESPONSESTREAM() )
DIM VERIFYRESPONSE AS STRING = RETURNINFO.READTOEND()
RETURNINFO.CLOSE()
Response.Write(VERIFYRESPONSE & "<BR>" & SUBSCRIPTIONVALUES & "<br>" & REQUEST.QUERYSTRING("at") & REQUEST.QUERYSTRING("reciever_email") & REQUEST.QUERYSTRING("tx") & "<Br>" )
END SUB
</SCRIPT>
thanks: ALEX GRIM
---------------------------
A Black sheep moves easy in the darkness.
[email protected]
WWW.GRIMMUSIC.COM